# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
232871 |
2020-05-18T12:55:13 Z |
shayan_p |
Ili (COI17_ili) |
C++14 |
|
1199 ms |
13944 KB |
// Never let them see you bleed...
#include<bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1e4 + 10, mod = 1e9 + 7, inf = 1e9 + 10;
bitset<maxn> bs[maxn], zr, tmp, dp;
vector<int> to1[maxn], to2[maxn];
int toInt(string s){
stringstream ss;
ss << s;
int x;
ss >> x;
return x;
}
void inp(int i){
string s;
cin >> s;
int id = toInt(s.substr(1))-1;
if(s[0] == 'c')
bs[i] = bs[i] | bs[id], to1[i].PB(id);
else
bs[i][id] = 1, to2[i].PB(id);
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie();
int n, m;
cin >> n >> m;
string s;
cin >> s;
for(int i = 0; i < m; i++){
inp(i), inp(i);
}
for(int i = 0; i < m; i++){
if(s[i] == '0')
zr|= bs[i];
}
for(int i = 0; i < m; i++){
tmp = zr & bs[i];
if(tmp == bs[i])
s[i] = '0';
bs[i] = bs[i] ^ tmp;
}
for(int i = 0; i < m; i++){
if(s[i] == '?'){
tmp = zr | bs[i];
dp = 0;
bool bad = 0;
for(int j = 0; j < m; j++){
for(int x : to1[j])
dp[j]= dp[j] || dp[x];
for(int x : to2[j])
dp[j]= dp[j] || !tmp[x];
bad|= (s[j] == '1' && dp[j] == 0);
}
if(bad)
s[i] = '1';
}
}
return cout << s << endl, 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
768 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
896 KB |
Output is correct |
6 |
Correct |
5 ms |
896 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
768 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
896 KB |
Output is correct |
6 |
Correct |
5 ms |
896 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
8 ms |
1408 KB |
Output is correct |
9 |
Correct |
7 ms |
1280 KB |
Output is correct |
10 |
Correct |
8 ms |
1408 KB |
Output is correct |
11 |
Correct |
8 ms |
1408 KB |
Output is correct |
12 |
Correct |
7 ms |
1408 KB |
Output is correct |
13 |
Correct |
7 ms |
1408 KB |
Output is correct |
14 |
Correct |
9 ms |
1408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
768 KB |
Output is correct |
2 |
Correct |
5 ms |
768 KB |
Output is correct |
3 |
Correct |
5 ms |
896 KB |
Output is correct |
4 |
Correct |
5 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
896 KB |
Output is correct |
6 |
Correct |
5 ms |
896 KB |
Output is correct |
7 |
Correct |
5 ms |
896 KB |
Output is correct |
8 |
Correct |
8 ms |
1408 KB |
Output is correct |
9 |
Correct |
7 ms |
1280 KB |
Output is correct |
10 |
Correct |
8 ms |
1408 KB |
Output is correct |
11 |
Correct |
8 ms |
1408 KB |
Output is correct |
12 |
Correct |
7 ms |
1408 KB |
Output is correct |
13 |
Correct |
7 ms |
1408 KB |
Output is correct |
14 |
Correct |
9 ms |
1408 KB |
Output is correct |
15 |
Correct |
327 ms |
8576 KB |
Output is correct |
16 |
Correct |
631 ms |
9976 KB |
Output is correct |
17 |
Correct |
641 ms |
11640 KB |
Output is correct |
18 |
Correct |
1180 ms |
13688 KB |
Output is correct |
19 |
Correct |
525 ms |
10104 KB |
Output is correct |
20 |
Correct |
1199 ms |
13688 KB |
Output is correct |
21 |
Correct |
1157 ms |
13688 KB |
Output is correct |
22 |
Correct |
336 ms |
12920 KB |
Output is correct |
23 |
Correct |
375 ms |
13432 KB |
Output is correct |
24 |
Correct |
378 ms |
13432 KB |
Output is correct |
25 |
Correct |
379 ms |
13560 KB |
Output is correct |
26 |
Correct |
363 ms |
13312 KB |
Output is correct |
27 |
Correct |
358 ms |
13432 KB |
Output is correct |
28 |
Correct |
330 ms |
13052 KB |
Output is correct |
29 |
Correct |
338 ms |
13176 KB |
Output is correct |
30 |
Correct |
346 ms |
13304 KB |
Output is correct |
31 |
Correct |
439 ms |
13824 KB |
Output is correct |
32 |
Correct |
470 ms |
13944 KB |
Output is correct |