Submission #480265

# Submission time Handle Problem Language Result Execution time Memory
480265 2021-10-15T12:12:27 Z BERNARB01 Ili (COI17_ili) C++17
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  string v;
  cin >> v;
  vector<vector<int>> g(n + m);
  for (int i = 0; i < m; i++) {
    for (int itr = 0; itr < 2; itr++) {
      char c;
      int from;
      cin >> c >> from;
      --from;
      if (c == 'x') {
        from += m;
      }
      g[from].push_back(i);
    }
  }
  vector<vector<int>> sols;
  for (int i = 0; i < (1 << n); i++) {
    vector<int> que(n);
    vector<int> a(n + m, 0);
    vector<int> inDeg(n + m, 2);
    for (int j = 0; j < n; j++) {
      que[j] = j + m;
      a[j + m] = !!(i & (1 << j));
      inDeg[j + m] = 0;
    }
    for (int b = 0; b < (int) que.size(); b++) {
      int f = que[b];
      for (int u : g[f]) {
        inDeg[u] -= 1;
        a[u] |= a[f];
        if (inDeg[u] == 0) {
          que.push_back(u);
        }
      }
    }
    bool can = true;
    for (int j = 0; j < n; j++) {
      if (v[j] == '?') {
        continue;
      }
      if ((v[j] - '0') != a[j]) {
        can = false;
        break;
      }
    }
    if (can) {
      sols.emplace_back(a);
    }
  }
  vector<set<int>> se(m);
  for (const auto& a : sols) {
    for (int i = 0; i < m; i++) {
      se[i].insert(a[i]);
    }
  }
  for (int i = 0; i < m; i++) {
    if (se[i].size() == 1) {
      cout << *se[i].begin();
    } else {
      cout << '?';
    }
  }
  cout << '\n';
  return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -