Submission #785223

# Submission time Handle Problem Language Result Execution time Memory
785223 2023-07-17T07:20:00 Z 박상훈(#10022) Ili (COI17_ili) C++17
100 / 100
145 ms 12752 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
bitset<10010> dp[10010], zero;
char s[10010];
pair<int, int> adj[10010];
int n, m, val[20020];

int simulate(const bitset<10010> &msk){
	for (int i=1;i<=n;i++) val[i] = ((!msk[i]) & zero[i]);
	for (int i=1;i<=m;i++){
		val[i+n] = val[adj[i].first] | val[adj[i].second];
		// printf("%d -> %d / %d %d / %d %d\n", i, val[i+n], adj[i].first, adj[i].second, val[adj[i].first], val[adj[i].second]);
		if (val[i+n]==0 && s[i]=='1') return 0;
	}

	return 1;
}

int main(){
	scanf("%d %d", &n, &m);

	scanf("%s", s+1);

	for (int i=1;i<=m;i++){
		char op1, op2;
		int x1, x2;
		scanf(" %c%d %c%d", &op1, &x1, &op2, &x2);

		if (op1=='c') x1 += n;
		if (op2=='c') x2 += n;

		adj[i] = {x1, x2};

		if (x1 > n) dp[i] |= dp[x1-n];
		else dp[i].set(x1);

		if (x2 > n) dp[i] |= dp[x2-n];
		else dp[i].set(x2);

		if (s[i]=='0') zero |= dp[i];
	}

	zero = ~zero;
	for (int i=1;i<=m;i++) if (s[i]=='?'){
		dp[i] &= zero;
		if (dp[i].count()==0) s[i] = '0';
		else if (!simulate(dp[i])) s[i] = '1';
	}

	printf("%s\n", s+1);
}

Compilation message

ili.cpp: In function 'int main()':
ili.cpp:22:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |  scanf("%d %d", &n, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~
ili.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  scanf("%s", s+1);
      |  ~~~~~^~~~~~~~~~~
ili.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |   scanf(" %c%d %c%d", &op1, &x1, &op2, &x2);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 0 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 852 KB Output is correct
9 Correct 1 ms 724 KB Output is correct
10 Correct 1 ms 852 KB Output is correct
11 Correct 1 ms 852 KB Output is correct
12 Correct 1 ms 852 KB Output is correct
13 Correct 1 ms 852 KB Output is correct
14 Correct 1 ms 852 KB Output is correct
15 Correct 10 ms 7764 KB Output is correct
16 Correct 39 ms 9044 KB Output is correct
17 Correct 34 ms 10724 KB Output is correct
18 Correct 99 ms 12600 KB Output is correct
19 Correct 39 ms 9120 KB Output is correct
20 Correct 103 ms 12568 KB Output is correct
21 Correct 145 ms 12752 KB Output is correct
22 Correct 56 ms 12164 KB Output is correct
23 Correct 61 ms 12644 KB Output is correct
24 Correct 58 ms 12624 KB Output is correct
25 Correct 97 ms 12588 KB Output is correct
26 Correct 90 ms 12372 KB Output is correct
27 Correct 81 ms 12488 KB Output is correct
28 Correct 76 ms 12172 KB Output is correct
29 Correct 77 ms 12304 KB Output is correct
30 Correct 79 ms 12380 KB Output is correct
31 Correct 66 ms 12720 KB Output is correct
32 Correct 74 ms 12712 KB Output is correct