#include <bits/stdc++.h>
#include "gift.h"
using namespace std;
int construct(int n, int r, vector <int> a, vector <int> b, vector <int> x){
vector <int> maxR(n, 0), cnt(n, 0);
for(int i = 0; i < r; i++){
if (x[i] == 2)
continue;
maxR[a[i]] = max(maxR[a[i]], b[i]);
}
for(int i = 0; i < n; i++){
maxR[i] = max(maxR[i], i);
if (i > 0)
maxR[i] = max(maxR[i], maxR[i - 1]);
if (maxR[i] == i){
cnt[i]++;
}
if (i > 0)
cnt[i] += cnt[i - 1];
}
for(int i = 0; i < r; i++){
if (x[i] == 1)
continue;
if (a[i] == b[i])
return 0;
int tmp = cnt[b[i] - 1];
if (a[i] > 0)
tmp -= cnt[a[i] - 1];
if (tmp < 1)
return 0;
}
string res;
res.push_back('B');
for(int i = 1; i < n; i++)
res.push_back((cnt[i - 1] & 1)? 'R' : 'B');
craft(res);
return 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
640 KB |
Output is correct |
5 |
Correct |
193 ms |
17072 KB |
Output is correct |
6 |
Correct |
191 ms |
17056 KB |
Output is correct |
7 |
Correct |
201 ms |
17072 KB |
Output is correct |
8 |
Correct |
201 ms |
17076 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
640 KB |
Output is correct |
4 |
Correct |
204 ms |
17200 KB |
Output is correct |
5 |
Correct |
196 ms |
17072 KB |
Output is correct |
6 |
Correct |
191 ms |
15992 KB |
Output is correct |
7 |
Correct |
191 ms |
15992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
0 ms |
256 KB |
Output is correct |
6 |
Correct |
1 ms |
256 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
256 KB |
Output is correct |
9 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
1 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
640 KB |
Output is correct |
5 |
Correct |
193 ms |
17072 KB |
Output is correct |
6 |
Correct |
191 ms |
17056 KB |
Output is correct |
7 |
Correct |
201 ms |
17072 KB |
Output is correct |
8 |
Correct |
201 ms |
17076 KB |
Output is correct |
9 |
Correct |
1 ms |
256 KB |
Output is correct |
10 |
Correct |
0 ms |
256 KB |
Output is correct |
11 |
Correct |
4 ms |
640 KB |
Output is correct |
12 |
Correct |
204 ms |
17200 KB |
Output is correct |
13 |
Correct |
196 ms |
17072 KB |
Output is correct |
14 |
Correct |
191 ms |
15992 KB |
Output is correct |
15 |
Correct |
191 ms |
15992 KB |
Output is correct |
16 |
Correct |
1 ms |
256 KB |
Output is correct |
17 |
Correct |
0 ms |
256 KB |
Output is correct |
18 |
Correct |
1 ms |
256 KB |
Output is correct |
19 |
Correct |
0 ms |
256 KB |
Output is correct |
20 |
Correct |
0 ms |
256 KB |
Output is correct |
21 |
Correct |
1 ms |
256 KB |
Output is correct |
22 |
Correct |
0 ms |
256 KB |
Output is correct |
23 |
Correct |
1 ms |
256 KB |
Output is correct |
24 |
Correct |
0 ms |
256 KB |
Output is correct |
25 |
Correct |
1 ms |
256 KB |
Output is correct |
26 |
Correct |
1 ms |
256 KB |
Output is correct |
27 |
Correct |
1 ms |
256 KB |
Output is correct |
28 |
Correct |
0 ms |
256 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
13 ms |
5308 KB |
Output is correct |
36 |
Correct |
14 ms |
5436 KB |
Output is correct |
37 |
Correct |
20 ms |
5820 KB |
Output is correct |
38 |
Correct |
207 ms |
17076 KB |
Output is correct |
39 |
Correct |
193 ms |
15976 KB |
Output is correct |
40 |
Correct |
204 ms |
17072 KB |
Output is correct |
41 |
Correct |
204 ms |
17072 KB |
Output is correct |
42 |
Correct |
212 ms |
17072 KB |
Output is correct |