Submission #370198

# Submission time Handle Problem Language Result Execution time Memory
370198 2021-02-23T14:55:16 Z soroush Ili (COI17_ili) C++14
49 / 100
4000 ms 12652 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 1e4 + 10;

#define pb push_back
#define migmig ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define ms(x , y) memset(x , y , sizeof x)
#define dokme(x) cout << x, exit(0);

int n , m;
string s;

char c[maxn][2];
int a[maxn][2];
vector < int > ans[2];

bitset < maxn > x[maxn] , zero;

bool chk(int pos){
	for(int i : ans[1])if(s[i] == '1') //n na! m.
		if((x[i] ^ (x[pos] & x[i])).count() == 0)return(0);
	return(1);
}

int32_t main(){
	migmig;
	cin >> n >> m >> s;
	s = "6" + s;
	for(int i = 1 ; i <= m ; i ++){
		for(int j = 0 ; j < 2 ; j ++){
			cin >> c[i][j] >> a[i][j] , a[i][j] += ((c[i][j] == 'c') ? n : 0);
			if(a[i][j] <= n)x[i][a[i][j]] = 1;
			else
				for(int v = x[a[i][j] - n]._Find_first() ; v < maxn ; v = x[a[i][j] - n]._Find_next(v))
					x[i][v] = 1;
		}
		if(s[i] == '0')ans[0].pb(i);
		if(s[i] == '1')ans[1].pb(i);
	}
	for(int i : ans[0])
		zero |= x[i];
	for(int i = 1 ; i <= m ; i ++){
		x[i] ^= (zero & x[i]);
		if(x[i].count() == 0 and s[i] == '?')
			s[i] = '0';
	}
	for(int i = 1 ; i <= m ; i ++)if(s[i] == '?'){
		if(!chk(i))	
			s[i] = '1';
	}
	for(int i = 1 ; i <= m ; i ++)
		cout << s[i];
	return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 17 ms 1004 KB Output is correct
9 Correct 6 ms 876 KB Output is correct
10 Correct 11 ms 876 KB Output is correct
11 Correct 12 ms 1004 KB Output is correct
12 Correct 8 ms 876 KB Output is correct
13 Correct 9 ms 1004 KB Output is correct
14 Correct 11 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 17 ms 1004 KB Output is correct
9 Correct 6 ms 876 KB Output is correct
10 Correct 11 ms 876 KB Output is correct
11 Correct 12 ms 1004 KB Output is correct
12 Correct 8 ms 876 KB Output is correct
13 Correct 9 ms 1004 KB Output is correct
14 Correct 11 ms 1004 KB Output is correct
15 Correct 323 ms 7916 KB Output is correct
16 Correct 1357 ms 9196 KB Output is correct
17 Correct 1027 ms 10988 KB Output is correct
18 Execution timed out 4050 ms 12652 KB Time limit exceeded
19 Halted 0 ms 0 KB -