# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
209738 |
2020-03-15T12:57:18 Z |
ruler |
Ili (COI17_ili) |
C++14 |
|
793 ms |
12928 KB |
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
////////////////////////////////////////////////////////////////////
const int N = 1e4 + 2;
char C[2][N];
int n, m, X[2][N];
bitset<N> M[N], B, Q, F;
string S;
bool Val(int i) {
F = 0, Q = M[i] ^ B;
for (int j = 0; j < m; j++) {
for (int k = 0; k < 2; k++)
F[j] = F[j] | (C[k][j] == 'x' ? Q[X[k][j]] : F[X[k][j]]);
if (S[j] == '1' && !F[j]) return false;
}
return true;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
mt19937 Rnd(time(0));
cin >> n >> m >> S;
for (int i = 0; i < m; i++) {
for (int j = 0; j < 2; j++) {
cin >> C[j][i] >> X[j][i]; X[j][i]--;
if (C[j][i] == 'x') M[i].set(X[j][i]);
else M[i] |= M[X[j][i]];
}
if (S[i] == '0') B |= M[i];
}
B.flip();
for (int i = 0; i < m; i++) {
M[i] &= B;
if (M[i].count() == 0) S[i] = '0';
}
for (int i = 0; i < m; i++) {
if (S[i] == '?' && !Val(i)) S[i] = '1';
cout << S[i];
}
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
888 KB |
Output is correct |
9 |
Correct |
6 ms |
760 KB |
Output is correct |
10 |
Correct |
6 ms |
888 KB |
Output is correct |
11 |
Correct |
11 ms |
1016 KB |
Output is correct |
12 |
Correct |
6 ms |
888 KB |
Output is correct |
13 |
Correct |
6 ms |
888 KB |
Output is correct |
14 |
Correct |
7 ms |
1016 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
5 ms |
376 KB |
Output is correct |
4 |
Correct |
5 ms |
376 KB |
Output is correct |
5 |
Correct |
5 ms |
376 KB |
Output is correct |
6 |
Correct |
6 ms |
376 KB |
Output is correct |
7 |
Correct |
5 ms |
376 KB |
Output is correct |
8 |
Correct |
6 ms |
888 KB |
Output is correct |
9 |
Correct |
6 ms |
760 KB |
Output is correct |
10 |
Correct |
6 ms |
888 KB |
Output is correct |
11 |
Correct |
11 ms |
1016 KB |
Output is correct |
12 |
Correct |
6 ms |
888 KB |
Output is correct |
13 |
Correct |
6 ms |
888 KB |
Output is correct |
14 |
Correct |
7 ms |
1016 KB |
Output is correct |
15 |
Correct |
32 ms |
7912 KB |
Output is correct |
16 |
Correct |
274 ms |
9220 KB |
Output is correct |
17 |
Correct |
136 ms |
11000 KB |
Output is correct |
18 |
Correct |
637 ms |
12920 KB |
Output is correct |
19 |
Correct |
190 ms |
9208 KB |
Output is correct |
20 |
Correct |
657 ms |
12688 KB |
Output is correct |
21 |
Correct |
793 ms |
12920 KB |
Output is correct |
22 |
Correct |
187 ms |
12340 KB |
Output is correct |
23 |
Correct |
194 ms |
12792 KB |
Output is correct |
24 |
Correct |
172 ms |
12792 KB |
Output is correct |
25 |
Correct |
410 ms |
12776 KB |
Output is correct |
26 |
Correct |
398 ms |
12540 KB |
Output is correct |
27 |
Correct |
398 ms |
12664 KB |
Output is correct |
28 |
Correct |
366 ms |
12280 KB |
Output is correct |
29 |
Correct |
376 ms |
12408 KB |
Output is correct |
30 |
Correct |
389 ms |
12536 KB |
Output is correct |
31 |
Correct |
454 ms |
12916 KB |
Output is correct |
32 |
Correct |
488 ms |
12928 KB |
Output is correct |