# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
232278 | pedy4000 | Ili (COI17_ili) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <algorithm>
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
const int N = 1e4 + 8;
int n, m;
string s;
int type[N * 2];
bool can[N * 2][2];
bool mark[N * 2];
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m >> s;
for (int i = 0; i < m; i++)
type[i] = (s[i] == '?'? 2: s[i] - '0');
for (int i = m; i < m + n; i++)
type[i] = 2;
for (int i = 0; i < m; i++)
for (int j = 0; j < 2; j++) {
char c;
int ind;
cin >> c >> ind;
ind--;
if (c == 'x')
ind += m;
in[i].push_back(ind);
out[ind].push_back(i);
}
for (int mask = 0; mask < (1 << n); mask++) {
for (int i = m; i < m + n; i++)
mark[i] = (mask >> (i - m)) & 1;
for (int i = 0; i < m; i++)
mark[i] = mark[in[i][0]] | mark[in[i][1]];
bool ok = true;
for (int i = 0; i < m + n; i++)
if (type[i] < 2 && type[i] != mark[i])
ok = false;
if (ok)
for (int i = 0; i < m; i++)
can[i][mark[i]] = true;
}
for (int i = 0; i < m; i++) {
if (can[i][0] && !can[i][1])
cout << '0';
if (!can[i][0] && can[i][1])
cout << '1';
if (can[i][0] && can[i][1])
cout << '?';
}
return 0;
}