# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
545278 |
2022-04-04T06:54:24 Z |
tranxuanbach |
Ili (COI17_ili) |
C++17 |
|
639 ms |
436 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl '\n'
#define fi first
#define se second
#define For(i, l, r) for (auto i = l; i < r; i++)
#define ForE(i, l, r) for (auto i = l; i <= r; i++)
#define FordE(i, l, r) for (auto i = l; i >= r; i--)
#define Fora(v, a) for (auto v: a)
#define bend(a) a.begin(), a.end()
#define isz(a) ((signed)a.size())
using ll = long long;
using ld = long double;
using pii = pair <int, int>;
using vi = vector <int>;
using vpii = vector <pair <int, int>>;
using vvi = vector <vector <int>>;
const int N = 1e4 + 5;
int n, m;
char a[N];
int b[N][2];
bool val[2 * N];
char ans[N];
void dime(){
FordE(i, m + n, 1 + n){
if (val[i] == 0){
val[b[i - n][0]] = val[b[i - n][1]] = 0;
}
}
ForE(i, 1 + n, m + n){
val[i] = val[b[i - n][0]] | val[b[i - n][1]];
}
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
// freopen("KEK.inp", "r", stdin);
// freopen("KEK.out", "w", stdout);
cin >> n >> m;
ForE(i, 1, m){
cin >> a[i];
}
ForE(i, 1, m){
ForE(j, 0, 1){
char type; cin >> type; int u; cin >> u;
if (type == 'c'){
u += n;
}
b[i][j] = u;
}
}
ForE(i, 1, m){
ans[i] = '?';
}
ForE(i, 1, n + m){
val[i] = 1;
}
ForE(i, 1, m){
if (a[i] != '?'){
ans[i] = a[i];
if (ans[i] == '0'){
val[i + n] = 0;
}
}
}
dime();
ForE(i, 1 + n, m + n){
if (val[i] == 0){
ans[i - n] = '0';
}
}
ForE(i, 1, m){
if (ans[i] == '?'){
ForE(j, 1, n + m){
val[j] = 1;
}
ForE(j, 1, m){
if (j == i or ans[j] == '0'){
val[j + n] = 0;
}
}
dime();
bool ck = 1;
ForE(j, 1, m){
if (ans[j] != '?' and val[j + n] != ans[j] - '0'){
ck = 0;
break;
}
}
if (!ck){
ans[i] = '1';
}
}
}
ForE(i, 1, m){
cout << ans[i];
} cout << endl;
}
/*
==================================================+
INPUT: |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
OUTPUT: |
--------------------------------------------------|
--------------------------------------------------|
==================================================+
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
4 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
264 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
2 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
4 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
2 ms |
264 KB |
Output is correct |
15 |
Correct |
116 ms |
384 KB |
Output is correct |
16 |
Correct |
284 ms |
392 KB |
Output is correct |
17 |
Correct |
355 ms |
408 KB |
Output is correct |
18 |
Correct |
474 ms |
416 KB |
Output is correct |
19 |
Correct |
223 ms |
392 KB |
Output is correct |
20 |
Correct |
639 ms |
420 KB |
Output is correct |
21 |
Correct |
465 ms |
420 KB |
Output is correct |
22 |
Correct |
197 ms |
436 KB |
Output is correct |
23 |
Correct |
207 ms |
420 KB |
Output is correct |
24 |
Correct |
163 ms |
420 KB |
Output is correct |
25 |
Correct |
198 ms |
420 KB |
Output is correct |
26 |
Correct |
195 ms |
420 KB |
Output is correct |
27 |
Correct |
183 ms |
416 KB |
Output is correct |
28 |
Correct |
174 ms |
416 KB |
Output is correct |
29 |
Correct |
191 ms |
340 KB |
Output is correct |
30 |
Correct |
167 ms |
340 KB |
Output is correct |
31 |
Correct |
207 ms |
412 KB |
Output is correct |
32 |
Correct |
223 ms |
412 KB |
Output is correct |