#include <bits/stdc++.h>
using namespace std;
const int N = 10004;
int n, m;
bitset<N> a[N];
char anss[N], ans[N];
bitset<N> x0;
int main()
{
cin >> n >> m;
cin >> anss;
for (int i = 1; i <= m; ++i)
ans[i] = anss[i - 1];
for (int i = 1; i <= m; ++i)
{
char s1, s2;
int x1, x2;
cin >> s1 >> x1 >> s2 >> x2;
if (s1 == 'c')
a[i] = a[x1];
else
a[i][x1] = 1;
if (s2 == 'c')
a[i] = (a[i] | a[x2]);
else
a[i][x2] = 1;
}
for (int i = 1; i <= m; ++i)
{
if (ans[i] == '0')
{
x0 = (x0 | a[i]);
}
}
for (int i = 1; i <= m; ++i)
{
if ((a[i] & x0) == a[i])
ans[i] = '0';
}
for (int i = 1; i <= m; ++i)
{
for (int j = 1; j <= m; ++j)
{
if (ans[j] == '1' && ((a[i] | x0) & a[j]) == a[j])
ans[i] = '1';
}
}
for (int i = 1; i <= m; ++i)
cout << ans[i];
cout << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
38 ms |
884 KB |
Output is correct |
9 |
Correct |
9 ms |
760 KB |
Output is correct |
10 |
Correct |
28 ms |
888 KB |
Output is correct |
11 |
Correct |
28 ms |
888 KB |
Output is correct |
12 |
Correct |
31 ms |
888 KB |
Output is correct |
13 |
Correct |
39 ms |
1016 KB |
Output is correct |
14 |
Correct |
36 ms |
888 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 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 |
380 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
38 ms |
884 KB |
Output is correct |
9 |
Correct |
9 ms |
760 KB |
Output is correct |
10 |
Correct |
28 ms |
888 KB |
Output is correct |
11 |
Correct |
28 ms |
888 KB |
Output is correct |
12 |
Correct |
31 ms |
888 KB |
Output is correct |
13 |
Correct |
39 ms |
1016 KB |
Output is correct |
14 |
Correct |
36 ms |
888 KB |
Output is correct |
15 |
Execution timed out |
4085 ms |
7800 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |