Submission #66482

# Submission time Handle Problem Language Result Execution time Memory
66482 2018-08-10T20:02:02 Z hamzqq9 Ili (COI17_ili) C++14
100 / 100
565 ms 2584 KB
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define umax(x,y) x=max(x,y)
#define umin(x,y) x=min(x,y)
#define ll long long
#define ii pair<int,int>
#define iii pair<ii,int>
#define sz(x) (x.size())
#define orta ((bas+son)>>1)
#define all(x) x.begin(),x.end()
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define pw(x) (1<<(x))
#define inf 1000000000
#define MOD 1000000007
#define N 20005
#define MAX 10000006
#define LOG 20
using namespace std;
 
struct cur {

	int val[N];

} now[2];

ii go[N];
int n,m;
char s[N],a[55];
 
int get_num(int bas,int son) {
 
	int res=0;
 
	for(int i=bas;i<=son;i++) {
 
		int dig=a[i]-'0';
 
		res=res*10+dig;
 
	}
 
	return res;
 
}
 
int parse() {
 
	int len=strlen(a+1);
 
	int add=(a[1]=='x'?0:n);
 
	return add+get_num(2,len);
 
}
 
bool check() {

	for(int i=n+m;i>=n+1;i--) {

		if(now[1].val[i]==0) {

			if(now[1].val[go[i].st]==1 || now[1].val[go[i].nd]==1) return false;

			now[1].val[go[i].st]=0; 
			now[1].val[go[i].nd]=0;

		}

	}

	for(int i=n+1;i<=n+m;i++) {

		if(now[1].val[go[i].st]==0 && now[1].val[go[i].nd]==0) {

			if(now[1].val[i]==1) return false;

			now[1].val[i]=0;

		}

	}

	return true;

}

int main() {
 
//	freopen("input.txt","r",stdin);
 
	scanf("%d %d",&n,&m);
 
	scanf("%s",s+1);
 
	for(int i=1;i<=m;i++) {
 
		scanf("%s",a+1);
 
		int node1=parse();
 
		scanf("%s",a+1);
 
		int node2=parse();
 
		go[n+i]={node1,node2};
 
	}
 	
	for(int i=1;i<=n;i++) {

		now[0].val[i]=2;

	}

	for(int i=n+1;i<=n+m;i++) {

		if(s[i-n]=='?') now[0].val[i]=2;
		else now[0].val[i]=s[i-n]-'0';

	}

 	for(int i=n+m;i>=n+1;i--) {

 		if(now[0].val[i]==0) {

 			now[0].val[go[i].st]=0;
			now[0].val[go[i].nd]=0;

 		}

 	}

 	for(int i=n+1;i<=n+m;i++) {

 		if(now[0].val[go[i].st]==0 && now[0].val[go[i].nd]==0) {

 			now[0].val[i]=0;

 		}

 	}

 	for(int i=n+1;i<=n+m;i++) {

 		if(now[0].val[i]==2) {

 			for(int j=1;j<=n+m;j++) now[1].val[j]=now[0].val[j];

 			now[1].val[i]=0;

 			if(!check()) {

 				now[0].val[i]=1;

 			}

 		}

 	}

 	for(int i=n+1;i<=n+m;i++) {

 		if(now[0].val[i]==2) printf("?");
 		else printf("%c",'0'+now[0].val[i]);

 	}
 
}

Compilation message

ili.cpp: In function 'int main()':
ili.cpp:95:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~~
ili.cpp:97:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",s+1);
  ~~~~~^~~~~~~~~~
ili.cpp:101:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",a+1);
   ~~~~~^~~~~~~~~~
ili.cpp:105:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",a+1);
   ~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 3 ms 568 KB Output is correct
11 Correct 3 ms 568 KB Output is correct
12 Correct 4 ms 568 KB Output is correct
13 Correct 3 ms 568 KB Output is correct
14 Correct 3 ms 568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 248 KB Output is correct
2 Correct 2 ms 484 KB Output is correct
3 Correct 3 ms 484 KB Output is correct
4 Correct 2 ms 484 KB Output is correct
5 Correct 2 ms 536 KB Output is correct
6 Correct 2 ms 540 KB Output is correct
7 Correct 2 ms 564 KB Output is correct
8 Correct 2 ms 564 KB Output is correct
9 Correct 3 ms 568 KB Output is correct
10 Correct 3 ms 568 KB Output is correct
11 Correct 3 ms 568 KB Output is correct
12 Correct 4 ms 568 KB Output is correct
13 Correct 3 ms 568 KB Output is correct
14 Correct 3 ms 568 KB Output is correct
15 Correct 42 ms 588 KB Output is correct
16 Correct 243 ms 732 KB Output is correct
17 Correct 222 ms 732 KB Output is correct
18 Correct 360 ms 876 KB Output is correct
19 Correct 188 ms 984 KB Output is correct
20 Correct 565 ms 1124 KB Output is correct
21 Correct 460 ms 1260 KB Output is correct
22 Correct 82 ms 1260 KB Output is correct
23 Correct 89 ms 1492 KB Output is correct
24 Correct 85 ms 1536 KB Output is correct
25 Correct 143 ms 1660 KB Output is correct
26 Correct 163 ms 1928 KB Output is correct
27 Correct 177 ms 2092 KB Output is correct
28 Correct 132 ms 2092 KB Output is correct
29 Correct 150 ms 2292 KB Output is correct
30 Correct 145 ms 2336 KB Output is correct
31 Correct 216 ms 2412 KB Output is correct
32 Correct 223 ms 2584 KB Output is correct