CSES - NOI 2019 - Results
Submission details
Task:Distance Code
Sender:Knut Salomonsson
Submission time:2019-03-06 15:08:33 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.08 s1, 2, 3details
#20.07 s1, 2, 3details
#30.07 s1, 2, 3details
#40.08 s1, 2, 3details
#50.07 s1, 2, 3details
#60.07 s1, 2, 3details
#70.07 s1, 2, 3details
#80.07 s1, 2, 3details
#90.07 s1, 2, 3details
#100.07 s1, 2, 3details
#110.07 s1, 2, 3details
#120.07 s2, 3details
#130.07 s2, 3details
#140.08 s2, 3details
#150.07 s2, 3details
#160.09 s3details
#170.10 s3details
#180.09 s3details
#190.10 s3details
#200.07 s1, 2, 3details

Compiler report

input/code.cpp: In function 'vi dp(int, std::vector<bool>, std::vector<std::vector<int> >, int)':
input/code.cpp:70:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
             if(arr2[0] != -1)
             ^~
input/code.cpp:72:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
                 return arr2;
                 ^~~~~~
input/code.cpp:76:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

Code

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define rep(i, a, b) for(int i = a;i<b;i++)
#define iter(it, obj) for(auto it = obj.begin();it != obj.end();it++)

vector<char> evs;
vi thieves;
int n, m, k;

vi dp(int i, vector<bool> free, vector<vi > pris, int out){
    char c = evs[i];
    int t = thieves[i];

    if(c == 'C'){
        if(out == 0)
            return {-1};
        if(i == m-1){
            return {1};
        }
        free[t] = false;
        out--;
        pris[0].push_back(t);
        vi arr1 = dp(i+1,free, pris, out);
        if(arr1[0] != -1){
            arr1.insert(arr1.begin(),1);
            return arr1;
        }
        pris[0].pop_back(); pris[1].push_back(t);
        vi arr2 = dp(i+1, free, pris, out);
        if(arr2[0] != -1){
            arr2.insert(arr2.begin(),2);
            return arr2;
        }
        return {-1};
    }

    if(c == 'O'){
        if(pris[0].size() == 0 && pris[1].size() == 0)
        return {-1};
        if(i == m-1){
            if(pris[0].size()>0)
                return {1};
            else return {2};
        }
        if(pris[0].size() > 0){
            int send = out;
            iter(it, pris[0]){
                free[*it] = true;
                send++;
            }
            vector<vi > cop = pris;
            cop[0].clear();
            vi arr1 = dp(i+1, free, cop, send);
            if(arr1[0] != -1){
                arr1.insert(arr1.begin(), 1);
                return arr1;
            }
        }
        if(pris[1].size()>0){
            int send = out;
            iter(it, pris[1]){
                free[*it] = true;
                send++;
            }
            vector<vi > cop = pris;
            cop[1].clear();
            vi arr2 = dp(i+1, free, cop, send);
            if(arr2[0] != -1)
                arr2.insert(arr2.begin(), 2);
                return arr2;
        }

    }
}

int main(){
    cin >> n >>k >> m;
    thieves.resize(m); evs.resize(m);

    rep(i,0, m){
        cin >> evs[i] >> thieves[i];
        thieves[i]--;
    }
    vector<bool> tmp1 = vector<bool>(n, true);
    vector<vi > tmp2 = vector<vi >(2, vi());

    vi arr = dp(0, tmp1, tmp2, n);
    if(arr[0] == -1){
        cout << "Impossible"<<endl;
        return 0;
    }
    iter(it, arr){
        cout << *it<<endl;
    }
}

Test details

Test 1

Group: 1, 2, 3

Verdict:

input
1
2
2 1

correct output
(empty)

user output
2077791872
5338
0
0
0
...
Truncated

Test 2

Group: 1, 2, 3

Verdict:

input
1
3
3 1
2 1

correct output
(empty)

user output
1439245952
5220
0
0
0
...
Truncated

Test 3

Group: 1, 2, 3

Verdict:

input
1
4
3 2
2 1
4 1

correct output
(empty)

user output
-389302656
5266
0
0
0
...
Truncated

Test 4

Group: 1, 2, 3

Verdict:

input
1
4
2 3
3 4
1 3

correct output
(empty)

user output
1397307008
5356
0
0
0
...
Truncated

Test 5

Group: 1, 2, 3

Verdict:

input
1
5
3 5
4 1
1 3
...

correct output
(empty)

user output
-2029468032
5336
0
0
0
...
Truncated

Test 6

Group: 1, 2, 3

Verdict:

input
1
5
3 2
3 4
5 1
...

correct output
(empty)

user output
215938688
5280
0
0
0
...
Truncated

Test 7

Group: 1, 2, 3

Verdict:

input
1
5
4 3
1 4
4 2
...

correct output
(empty)

user output
-451082624
5357
0
0
0
...
Truncated

Test 8

Group: 1, 2, 3

Verdict:

input
1
10
9 3
8 9
2 9
...

correct output
(empty)

user output
-1635989888
5444
0
0
0
...
Truncated

Test 9

Group: 1, 2, 3

Verdict:

input
1
10
9 2
5 8
7 1
...

correct output
(empty)

user output
-23292288
5309
0
0
0
...
Truncated

Test 10

Group: 1, 2, 3

Verdict:

input
1
10
10 4
9 1
4 7
...

correct output
(empty)

user output
2025531008
5335
0
0
0
...
Truncated

Test 11

Group: 1, 2, 3

Verdict:

input
1
10
2 6
4 3
3 5
...

correct output
(empty)

user output
2083722880
5327
0
0
0
...
Truncated

Test 12

Group: 2, 3

Verdict:

input
1
500
10 6
6 255
6 428
...

correct output
(empty)

user output
2015884928
5226
0
0
0
...
Truncated

Test 13

Group: 2, 3

Verdict:

input
1
500
152 466
451 313
158 479
...

correct output
(empty)

user output
-1184057728
5242
0
0
0
...
Truncated

Test 14

Group: 2, 3

Verdict:

input
1
500
109 440
330 190
443 161
...

correct output
(empty)

user output
-1697597824
5216
0
0
0
...
Truncated

Test 15

Group: 2, 3

Verdict:

input
1
500
144 373
257 233
341 318
...

correct output
(empty)

user output
-406129024
5272
0
0
0
...
Truncated

Test 16

Group: 3

Verdict:

input
1
100000
54983 75172
93807 75172
44082 75172
...

correct output
(empty)

user output
-491415936
5399
0
0
0
...
Truncated

Test 17

Group: 3

Verdict:

input
1
100000
88863 19059
86423 76688
98536 95984
...

correct output
(empty)

user output
1729619584
5440
0
0
0
...
Truncated

Test 18

Group: 3

Verdict:

input
1
100000
59979 6389
19097 24999
27846 82330
...

correct output
(empty)

user output
1141499520
5265
0
0
0
...
Truncated

Test 19

Group: 3

Verdict:

input
1
100000
58761 66001
25102 51081
98625 67861
...

correct output
(empty)

user output
-369502592
5245
0
0
0
...
Truncated

Test 20

Group: 1, 2, 3

Verdict:

input
1
6
2 1
3 2
4 2
...

correct output
(empty)

user output
50189952
5253
0
0
0
...
Truncated