# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
786148 | 2023-07-18T04:56:08 Z | 박상훈(#10027) | NoM (RMI21_nom) | C++17 | 1 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; bitset<10010> dp[10010], zero; char s[10010]; pair<int, int> adj[10010]; int n, m, val[20020]; int simulate(const bitset<10010> &msk){ for (int i=1;i<=n;i++) val[i] = ((!msk[i]) & zero[i]); for (int i=1;i<=m;i++){ val[i+n] = val[adj[i].first] | val[adj[i].second]; // printf("%d -> %d / %d %d / %d %d\n", i, val[i+n], adj[i].first, adj[i].second, val[adj[i].first], val[adj[i].second]); if (val[i+n]==0 && s[i]=='1') return 0; } return 1; } int main(){ scanf("%d %d", &n, &m); scanf("%s", s+1); for (int i=1;i<=m;i++){ char op1, op2; int x1, x2; scanf(" %c%d %c%d", &op1, &x1, &op2, &x2); if (op1=='c') x1 += n; if (op2=='c') x2 += n; adj[i] = {x1, x2}; if (x1 > n) dp[i] |= dp[x1-n]; else dp[i].set(x1); if (x2 > n) dp[i] |= dp[x2-n]; else dp[i].set(x2); if (s[i]=='0') zero |= dp[i]; } zero = ~zero; for (int i=1;i<=m;i++) if (s[i]=='?'){ dp[i] &= zero; if (dp[i].count()==0) s[i] = '0'; else if (!simulate(dp[i])) s[i] = '1'; } printf("%s\n", s+1); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
2 | Halted | 0 ms | 0 KB | - |