# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
144691 |
2019-08-17T14:12:22 Z |
Milki |
Ili (COI17_ili) |
C++14 |
|
1766 ms |
988 KB |
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
#define sz(x) ((int) x.size())
#define pb(x) push_back(x)
#define TRACE(x) cerr << #x << " = " << x << endl
typedef long long ll;
typedef pair<int, int> point;
const int MAXN = 2e4 + 5;
int n, m, lt[MAXN], rt[MAXN], val[MAXN], tmp_val[MAXN];
string s;
bool go(){
REP(i, n + m)
tmp_val[i] = val[i];
for(int i = n + m - 1; i >= n; --i)
if(tmp_val[i] == 0){
if(tmp_val[ lt[i] ] == 1) return false;
if(tmp_val[ rt[i] ] == 1) return false;
tmp_val[ lt[i] ] = tmp_val[ rt[i] ] = 0;
}
REP(i, n){
if(tmp_val[i] == -1)
tmp_val[i] = 1;
}
FOR(i, n, n + m){
if(tmp_val[i] == -1){
if(tmp_val[lt[i]] == 0 && tmp_val[rt[i]] == 0)
tmp_val[i] = 0;
else
tmp_val[i] = 1;
}
else if(tmp_val[i] == 1 && tmp_val[lt[i]] == 0 && tmp_val[rt[i]] == 0)
return false;
}
return true;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
memset(val, -1, sizeof(val));
cin >> n >> m;
cin >> s;
REP(i, m){
char c1, c2;
int a, b;
cin >> c1 >> a >> c2 >> b;
a --; b --;
if(c1 == 'x')
lt[i + n] = a;
else
lt[i + n] = a + n;
if(c2 == 'x')
rt[i + n] = b;
else
rt[i + n] = b + n;
}
FOR(i, n, n + m)
if(s[i - n] != '?')
val[i] = s[i - n] - '0';
FOR(i, n, n + m){
if(val[i] != -1){
cout << char('0' + val[i]);
continue;
}
val[i] = 1;
bool ret1 = go();
val[i] = 0;
bool ret2 = go();
if(ret1 && ret2){
val[i] = -1;
cout << '?';
}
else{
val[i] = ret1;
cout << char('0' + ret1);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
504 KB |
Output is correct |
11 |
Correct |
4 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
504 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
504 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
4 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
376 KB |
Output is correct |
10 |
Correct |
4 ms |
504 KB |
Output is correct |
11 |
Correct |
4 ms |
504 KB |
Output is correct |
12 |
Correct |
3 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
376 KB |
Output is correct |
14 |
Correct |
4 ms |
504 KB |
Output is correct |
15 |
Correct |
302 ms |
632 KB |
Output is correct |
16 |
Correct |
821 ms |
760 KB |
Output is correct |
17 |
Correct |
911 ms |
728 KB |
Output is correct |
18 |
Correct |
1066 ms |
764 KB |
Output is correct |
19 |
Correct |
848 ms |
664 KB |
Output is correct |
20 |
Correct |
1766 ms |
776 KB |
Output is correct |
21 |
Correct |
1527 ms |
900 KB |
Output is correct |
22 |
Correct |
274 ms |
760 KB |
Output is correct |
23 |
Correct |
269 ms |
760 KB |
Output is correct |
24 |
Correct |
261 ms |
764 KB |
Output is correct |
25 |
Correct |
344 ms |
760 KB |
Output is correct |
26 |
Correct |
330 ms |
760 KB |
Output is correct |
27 |
Correct |
334 ms |
900 KB |
Output is correct |
28 |
Correct |
306 ms |
760 KB |
Output is correct |
29 |
Correct |
318 ms |
764 KB |
Output is correct |
30 |
Correct |
410 ms |
888 KB |
Output is correct |
31 |
Correct |
323 ms |
760 KB |
Output is correct |
32 |
Correct |
371 ms |
988 KB |
Output is correct |