Submission #26328

# Submission time Handle Problem Language Result Execution time Memory
26328 2017-06-29T08:18:01 Z khsoo01 Ili (COI17_ili) C++11
100 / 100
1909 ms 2216 KB
#include<bits/stdc++.h>
using namespace std;
const int N = 20005;

int n, m, in[N][2];
char a[N], b[N];

bool pos () {
	for(int i=1;i<=n+m;i++) b[i] = a[i];
	for(int i=n+m;i>n;i--) {
		if(b[i] == '0') {
			for(auto &T : in[i]) {
				if(b[T] == '1') return false;
				if(b[T] == '?') b[T] = '0';
			}
		}
	}
	for(int i=1;i<=n;i++) {
		if(b[i] == '?') b[i] = '1';
	}
	for(int i=n+1;i<=n+m;i++) {
		if(b[i] == '?') {
			if(b[in[i][0]] == '0' && b[in[i][1]] == '0') b[i] = '0';
			else b[i] = '1';
		}
		else if(b[i] == '1' && b[in[i][0]] == '0' && b[in[i][1]] == '0') return false;
	}
	return true;
}

int main()
{
	scanf("%d%d%s",&n,&m,a+1);
	rotate(a+1, a+n+m+1, a+m+1);
	for(int i=1;i<=n;i++) a[i] = '?';
	for(int i=n+1;i<=n+m;i++) {
		char A[15], B[15];
		scanf("%s%s",A,B);
		for(int j=1;A[j];j++) {
			in[i][0] *= 10;
			in[i][0] += A[j] - '0';
		}
		for(int j=1;B[j];j++) {
			in[i][1] *= 10;
			in[i][1] += B[j] - '0';
		}
		if(A[0] == 'c') in[i][0] += n;
		if(B[0] == 'c') in[i][1] += n;
	}
	for(int i=n+1;i<=n+m;i++) {
		if(a[i] != '?') putchar(a[i]);
		else {
			bool b1, b2;
			a[i] = '1'; b1 = pos();
			a[i] = '0'; b2 = pos();
			if(b1 && b2) putchar('?');
			else putchar('0'+b1);
			a[i] = '?';
		}
	}
	puts("");
}

Compilation message

ili.cpp: In function 'int main()':
ili.cpp:33:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%s",&n,&m,a+1);
                           ^
ili.cpp:38:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s%s",A,B);
                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Correct 0 ms 2216 KB Output is correct
4 Correct 0 ms 2216 KB Output is correct
5 Correct 0 ms 2216 KB Output is correct
6 Correct 0 ms 2216 KB Output is correct
7 Correct 0 ms 2216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Correct 0 ms 2216 KB Output is correct
4 Correct 0 ms 2216 KB Output is correct
5 Correct 0 ms 2216 KB Output is correct
6 Correct 0 ms 2216 KB Output is correct
7 Correct 0 ms 2216 KB Output is correct
8 Correct 0 ms 2216 KB Output is correct
9 Correct 0 ms 2216 KB Output is correct
10 Correct 0 ms 2216 KB Output is correct
11 Correct 0 ms 2216 KB Output is correct
12 Correct 0 ms 2216 KB Output is correct
13 Correct 0 ms 2216 KB Output is correct
14 Correct 0 ms 2216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2216 KB Output is correct
2 Correct 0 ms 2216 KB Output is correct
3 Correct 0 ms 2216 KB Output is correct
4 Correct 0 ms 2216 KB Output is correct
5 Correct 0 ms 2216 KB Output is correct
6 Correct 0 ms 2216 KB Output is correct
7 Correct 0 ms 2216 KB Output is correct
8 Correct 0 ms 2216 KB Output is correct
9 Correct 0 ms 2216 KB Output is correct
10 Correct 0 ms 2216 KB Output is correct
11 Correct 0 ms 2216 KB Output is correct
12 Correct 0 ms 2216 KB Output is correct
13 Correct 0 ms 2216 KB Output is correct
14 Correct 0 ms 2216 KB Output is correct
15 Correct 366 ms 2216 KB Output is correct
16 Correct 876 ms 2216 KB Output is correct
17 Correct 1096 ms 2216 KB Output is correct
18 Correct 893 ms 2216 KB Output is correct
19 Correct 963 ms 2216 KB Output is correct
20 Correct 1909 ms 2216 KB Output is correct
21 Correct 1453 ms 2216 KB Output is correct
22 Correct 306 ms 2216 KB Output is correct
23 Correct 276 ms 2216 KB Output is correct
24 Correct 273 ms 2216 KB Output is correct
25 Correct 349 ms 2216 KB Output is correct
26 Correct 356 ms 2216 KB Output is correct
27 Correct 343 ms 2216 KB Output is correct
28 Correct 346 ms 2216 KB Output is correct
29 Correct 329 ms 2216 KB Output is correct
30 Correct 319 ms 2216 KB Output is correct
31 Correct 326 ms 2216 KB Output is correct
32 Correct 379 ms 2216 KB Output is correct