Submission #66563

# Submission time Handle Problem Language Result Execution time Memory
66563 2018-08-11T12:30:37 Z ekrem Ili (COI17_ili) C++
0 / 100
7 ms 4216 KB
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define N 1000005
using namespace std;

typedef pair < int , int > ii;

int n, m, c, b, a[N], aa[N];
char x, y;
ii g[N];
char s[N];

void hazirla(){
	for(int i = n + m; i > n; i--){
		if(a[i] == 0 and a[g[i].st] <= 0 and a[g[i].nd] <= 0){
			a[g[i].st] = 0;
			a[g[i].nd] = 0;
		}
		// if(a[i] == 1 and a[g[i].st] == 0 and abs(a[g[i].nd]) > 0)
		// 	a[g[i].nd] = 1;
		// if(a[i] == 1 and a[g[i].nd] == 0 and abs(a[g[i].st]) > 0)
		// 	a[g[i].st] = 1;
		if((a[g[i].st] == 1 or a[g[i].nd] == 1) and abs(a[i]) > 0)
			a[i] = 1;
		if(a[g[i].st] == 0 and a[g[i].nd] == 0 and a[i] <= 0)
			a[i] = 0;
	}
}

bool bak(){
	for(int i = n + 1; i <= n + m; i++){
		if(a[i] == 0 and (a[g[i].st] == 1 or a[g[i].nd] == 1) )
			return 0;
		if(a[i] == 1 and (a[g[i].st] == 0 and a[g[i].nd] == 0) )
			return 0;
	}
	return 1;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	scanf("%d %d %s",&n ,&m, s + 1);

	memset(a, -1, sizeof a);

	for(int i = n + 1; i <= n + m; i++){
		if(s[i - n] == '1')
			a[i] = 1;
		if(s[i - n] == '0')
			a[i] = 0;
	}

	hazirla();

	for(int i = 1; i <= m; i++){
		scanf(" %c%d %c %d",&x, &c, &y ,&b);
		if(x == 'c')
			c += n;
		if(y == 'c')
			b += n;
		g[i + n].st = c;
		g[i + n].nd = b;
	}


	for(int i = 1; i <= n + m; i++)
		aa[i] = a[i];

	for(int i = n + 1; i <= n + m; i++)
		if(a[i] == -1){
			a[i] = 0;
			hazirla();
			bool f = bak();
			// cout << i << " = " << f << " ye bakiliyo\n";
			for(int j = 1; j <= n + m; j++)a[j] = aa[j];
			if(!f){
				a[i] = 1;
				hazirla();
				for(int j = 1; j <= n + m; j++)aa[j] = a[j];
			}
		}
	for(int i = n + 1; i <= n + m; i++)
		if(a[i] >= 0)
			printf("%d",a[i]);
		else
			printf("?");
	return 0;
}

Compilation message

ili.cpp: In function 'int main()':
ili.cpp:47:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d %s",&n ,&m, s + 1);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ili.cpp:61:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf(" %c%d %c %d",&x, &c, &y ,&b);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4216 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 4216 KB Output isn't correct
2 Halted 0 ms 0 KB -