# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
209738 | | ruler | Ili (COI17_ili) | C++14 | | 793 ms | 12928 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// IOI 2021
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
////////////////////////////////////////////////////////////////////
const int N = 1e4 + 2;
char C[2][N];
int n, m, X[2][N];
bitset<N> M[N], B, Q, F;
string S;
bool Val(int i) {
F = 0, Q = M[i] ^ B;
for (int j = 0; j < m; j++) {
for (int k = 0; k < 2; k++)
F[j] = F[j] | (C[k][j] == 'x' ? Q[X[k][j]] : F[X[k][j]]);
if (S[j] == '1' && !F[j]) return false;
}
return true;
}
int main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
mt19937 Rnd(time(0));
cin >> n >> m >> S;
for (int i = 0; i < m; i++) {
for (int j = 0; j < 2; j++) {
cin >> C[j][i] >> X[j][i]; X[j][i]--;
if (C[j][i] == 'x') M[i].set(X[j][i]);
else M[i] |= M[X[j][i]];
}
if (S[i] == '0') B |= M[i];
}
B.flip();
for (int i = 0; i < m; i++) {
M[i] &= B;
if (M[i].count() == 0) S[i] = '0';
}
for (int i = 0; i < m; i++) {
if (S[i] == '?' && !Val(i)) S[i] = '1';
cout << S[i];
}
cout << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |