Submission #234725

#TimeUsernameProblemLanguageResultExecution timeMemory
234725ArshiaDadrasIli (COI17_ili)C++17
0 / 100
5 ms768 KiB
/* In the name of Allah */ #include<bits/stdc++.h> using namespace std; const int N = 2e4 + 5; vector<int> adj[N]; bool mark[N]; int n, m; char c[N]; int read() { int u; char x, y; scanf("%c%d%c", &x, &u, &y); if (x ^ 'x') u += n; return --u; } bool check(int root) { c[root] = '0'; mark[root] = true; for (int u = n + m - 1; u >= n; u--) { if (mark[u]) for (auto v: adj[u]) if (c[v] == '?') { mark[v] = true; c[v] = '0'; } bool one = false; for (auto v: adj[u]) one |= c[v] != '0'; if (c[u] != '?' && c[u] - '0' != one) return false; } return true; } void read_input() { cin >> n >> m; for (int i = 0; i < m; i++) cin >> c[n + i]; for (int i = 0; i < m; i++) { int u = read(), v = read(); adj[n + i].push_back(u); adj[n + i].push_back(v); } } void solve() { for (int u = 0; u < n; u++) c[u] = '?'; for (int u = n + m - 1; u >= n; u--) if (c[u] == '0') for (auto v: adj[u]) c[v] = '0'; for (int u = 0; u < n + m; u++) { if (c[u] == '?' && !check(u)) { mark[u] = false; c[u] = '1'; } for (int v = 0; v < n + m; v++) if (mark[v]) { mark[v] = false; c[v] = '?'; } } for (int i = 0; i < m; i++) cout << c[n + i]; } int main() { ios:: sync_with_stdio(0), cin.tie(0), cout.tie(0); read_input(), solve(); return 0; }

Compilation message (stderr)

ili.cpp: In function 'int read()':
ili.cpp:14:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%c%d%c", &x, &u, &y);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...