Submission #232861

# Submission time Handle Problem Language Result Execution time Memory
232861 2020-05-18T12:10:32 Z shayan_p Ili (COI17_ili) C++14
49 / 100
4000 ms 13196 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;
vector<int> to[maxn];

int toInt(string s){
    stringstream ss;
    ss << s;
    int x;
    ss >> x;
    return x;
}
void inp(int i){
    string s;
    cin >> s;
    if(s[0] == 'c')
	bs[i] = bs[i] | bs[toInt(s.substr(1))-1], to[toInt(s.substr(1))-1].PB(i);
    else
	bs[i][toInt(s.substr(1))-1] = 1;
}

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++){
	bool bad = 0;
	if(s[i] == '?'){
	    for(int j = m-1; j >= 0; j--){
		bad|= (s[j] == '1' && (bs[i] & bs[j]) == bs[j]);
		if(bad)
		    break;
	    }
	    if(bad)
		s[i] = '!';
	}	
	if(s[i] == '1' || s[i] == '!')
	    for(int j : to[i]){
		if(s[j] == '?')
		    s[j] = '!';
	    }
    }
    for(int i = 0; i < m; i++){
	if(s[i] == '!')
	    s[i] = '1';
    }
    return cout << s << endl, 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 6 ms 640 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 6 ms 640 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 7 ms 1024 KB Output is correct
10 Correct 8 ms 1152 KB Output is correct
11 Correct 10 ms 1152 KB Output is correct
12 Correct 8 ms 1152 KB Output is correct
13 Correct 9 ms 1152 KB Output is correct
14 Correct 9 ms 1152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 640 KB Output is correct
2 Correct 5 ms 640 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 6 ms 640 KB Output is correct
5 Correct 5 ms 640 KB Output is correct
6 Correct 5 ms 640 KB Output is correct
7 Correct 5 ms 640 KB Output is correct
8 Correct 9 ms 1152 KB Output is correct
9 Correct 7 ms 1024 KB Output is correct
10 Correct 8 ms 1152 KB Output is correct
11 Correct 10 ms 1152 KB Output is correct
12 Correct 8 ms 1152 KB Output is correct
13 Correct 9 ms 1152 KB Output is correct
14 Correct 9 ms 1152 KB Output is correct
15 Correct 113 ms 8192 KB Output is correct
16 Correct 364 ms 9464 KB Output is correct
17 Correct 248 ms 11384 KB Output is correct
18 Correct 1328 ms 13124 KB Output is correct
19 Correct 587 ms 9464 KB Output is correct
20 Correct 1503 ms 13056 KB Output is correct
21 Correct 3388 ms 13196 KB Output is correct
22 Correct 2696 ms 12792 KB Output is correct
23 Correct 3071 ms 13196 KB Output is correct
24 Correct 2724 ms 13180 KB Output is correct
25 Execution timed out 4086 ms 12800 KB Time limit exceeded
26 Halted 0 ms 0 KB -