제출 #145303

#제출 시각아이디문제언어결과실행 시간메모리
145303SamAndIli (COI17_ili)C++17
49 / 100
4053 ms7804 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...