Submission #26301

# Submission time Handle Problem Language Result Execution time Memory
26301 2017-06-29T06:04:16 Z 김현수(#1102) Ili (COI17_ili) C++11
0 / 100
0 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]] == '1') 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, B;
		scanf("\n%c%d %c%d",&A,&in[i][0],&B,&in[i][1]);
		if(A == 'c') in[i][0] += n;
		if(B == '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:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("\n%c%d %c%d",&A,&in[i][0],&B,&in[i][1]);
                                                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2216 KB Output isn't correct
2 Halted 0 ms 0 KB -