CSES - NOI 2019 - Results
Submission details
Task:Distance Code
Sender:Knut Salomonsson
Submission time:2019-03-06 15:09:38 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#10.06 s1, 2, 3details
#20.07 s1, 2, 3details
#30.07 s1, 2, 3details
#40.06 s1, 2, 3details
#50.07 s1, 2, 3details
#60.07 s1, 2, 3details
#70.07 s1, 2, 3details
#80.06 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.07 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:77: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
1113814656
5327
0
0
0
...
Truncated

Test 2

Group: 1, 2, 3

Verdict:

input
1
3
3 1
2 1

correct output
(empty)

user output
-1825786240
5263
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
-1705142656
5353
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
420820608
5225
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
-273713536
5230
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
-1392990592
5438
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
-727198080
5396
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
-1396103552
5433
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
906946176
5278
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
-2100971904
5232
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
1468933760
5355
0
0
0
...
Truncated

Test 12

Group: 2, 3

Verdict:

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

correct output
(empty)

user output
-1408469376
5311
0
0
0
...
Truncated

Test 13

Group: 2, 3

Verdict:

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

correct output
(empty)

user output
1618769536
5235
0
0
0
...
Truncated

Test 14

Group: 2, 3

Verdict:

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

correct output
(empty)

user output
-1676028288
5307
0
0
0
...
Truncated

Test 15

Group: 2, 3

Verdict:

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

correct output
(empty)

user output
-624740736
5292
0
0
0
...
Truncated

Test 16

Group: 3

Verdict:

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

correct output
(empty)

user output
991651456
5318
0
0
0
...
Truncated

Test 17

Group: 3

Verdict:

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

correct output
(empty)

user output
-1627945344
5253
0
0
0
...
Truncated

Test 18

Group: 3

Verdict:

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

correct output
(empty)

user output
1494894208
5433
0
0
0
...
Truncated

Test 19

Group: 3

Verdict:

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

correct output
(empty)

user output
1398847104
5335
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
-1622157696
5219
0
0
0
...
Truncated