This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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] & (a[j] ^ (a[j] & x0))) == (a[j] ^ (a[j] & x0)))
ans[i] = '1';
}
}
for (int i = 1; i <= m; ++i)
cout << ans[i];
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |