# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1081874 |
2024-08-30T12:24:50 Z |
juicy |
Ili (COI17_ili) |
C++17 |
|
487 ms |
13504 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
const int N = 10005;
int n, m;
int res[2 * N];
bool cant[N];
bitset<N> c[N];
vector<int> g[N];
void dfs(int u) {
res[u] = 0;
if (u <= m) {
for (int v : g[u]) {
if (res[v]) {
res[v] = 0;
dfs(v);
}
}
}
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
cin >> n >> m;
string s; cin >> s; s = '&' + s;
for (int i = 1; i <= m; ++i) {
for (int j = 0; j < 2; ++j) {
char c; int x; cin >> c >> x;
x += c == 'x' ? m : 0;
g[i].push_back(x);
}
}
memset(res, -1, sizeof(res));
for (int i = 1; i <= m; ++i) {
if (s[i] == '0') {
dfs(i);
} else if (s[i] == '1') {
res[i] = 1;
}
for (int v : g[i]) {
if (v <= m) {
c[i] |= c[v];
} else {
c[i].set(v - m);
}
}
}
for (int i = 1; i <= m; ++i) {
if (!res[g[i][0]] && !res[g[i][1]]) {
res[i] = 0;
}
}
for (int i = 1; i <= m; ++i) {
if (res[i] == -1) {
for (int j = 1; j <= m; ++j) {
if (res[j]) {
cant[j] = 1;
for (int v : g[j]) {
if (v <= m) {
cant[j] &= !res[v] || cant[v];
} else {
cant[j] &= !res[v] || c[i].test(v - m);
}
}
if (res[j] == 1 && cant[j]) {
res[i] = 1;
break;
}
}
}
}
}
for (int i = 1; i <= m; ++i) {
if (~res[i]) {
cout << res[i];
} else {
cout << "?";
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
2 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
2 ms |
1372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
860 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
604 KB |
Output is correct |
7 |
Correct |
1 ms |
604 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
2 ms |
1112 KB |
Output is correct |
10 |
Correct |
1 ms |
1116 KB |
Output is correct |
11 |
Correct |
2 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
1 ms |
1372 KB |
Output is correct |
14 |
Correct |
2 ms |
1372 KB |
Output is correct |
15 |
Correct |
9 ms |
8280 KB |
Output is correct |
16 |
Correct |
111 ms |
9728 KB |
Output is correct |
17 |
Correct |
56 ms |
11516 KB |
Output is correct |
18 |
Correct |
311 ms |
13380 KB |
Output is correct |
19 |
Correct |
53 ms |
9796 KB |
Output is correct |
20 |
Correct |
270 ms |
13144 KB |
Output is correct |
21 |
Correct |
487 ms |
13504 KB |
Output is correct |
22 |
Correct |
97 ms |
12904 KB |
Output is correct |
23 |
Correct |
90 ms |
13416 KB |
Output is correct |
24 |
Correct |
85 ms |
13192 KB |
Output is correct |
25 |
Correct |
373 ms |
13148 KB |
Output is correct |
26 |
Correct |
265 ms |
13148 KB |
Output is correct |
27 |
Correct |
253 ms |
13256 KB |
Output is correct |
28 |
Correct |
234 ms |
12916 KB |
Output is correct |
29 |
Correct |
288 ms |
12888 KB |
Output is correct |
30 |
Correct |
257 ms |
13200 KB |
Output is correct |
31 |
Correct |
252 ms |
13496 KB |
Output is correct |
32 |
Correct |
286 ms |
13400 KB |
Output is correct |