Submission #145335

#TimeUsernameProblemLanguageResultExecution timeMemory
145335SamAndIli (COI17_ili)C++17
100 / 100
1092 ms12828 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair const int N = 10004; int n, m; bitset<N> a[N]; pair<pair<char, int>, pair<char, int> > g[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; g[i] = m_p(m_p(s1, x1), m_p(s2, x2)); } 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) { bitset<N> z = (a[i] | x0); for (int j = 1; j <= m; ++j) { bool z1 = false, z2 = false; if (g[j].first.first == 'x') { if (z[g[j].first.second] == 1) z1 = true; } else { if (anss[g[j].first.second] == '0') z1 = true; } if (g[j].second.first == 'x') { if (z[g[j].second.second] == 1) z2 = true; } else { if (anss[g[j].second.second] == '0') z2 = true; } if (z1 && z2) anss[j] = '0'; else anss[j] = ans[j]; if (ans[j] == '1' && anss[j] == '0') { ans[i] = '1'; break; } } } 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...