Submission #15405

# Submission time Handle Problem Language Result Execution time Memory
15405 2015-07-12T07:14:04 Z tonyjjw 쿼터너리 컴퓨터 (kriii3_Z) C++
31 / 126
4000 ms 1092 KB
#include<stdio.h>
int n,m;
int b[20];
int cmd[420][4];
int ans[420];
int c[20];
int d[20];
void f(int x){
	if(x==n){
		int i;
		for(i=0;i<n;i++){
			d[i]=c[i];
		}
		for(i=0;i<m;i++){
			if(cmd[i][0]==0){
				d[cmd[i][1]]=(d[cmd[i][2]]+d[cmd[i][3]])%4;
			}
			if(cmd[i][0]==1){
				d[cmd[i][1]]=d[cmd[i][2]]^d[cmd[i][3]];
			}
			if(cmd[i][0]==2){
				d[cmd[i][1]]=(d[cmd[i][2]]+cmd[i][3])%4;
			}
			if(cmd[i][0]==3){
				d[cmd[i][1]]=d[cmd[i][2]]^cmd[i][3];
			}
		}
		for(i=0;i<n;i++){
			ans[i]+=d[i];
			ans[i]%=4;
		}
	}
	else{
		for(c[x]=0;c[x]<4;c[x]++){
			if(c[x]==b[x])continue;
			f(x+1);
		}
	}
}
int main(){
	int i,j;
	scanf("%d%d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%d",&b[i]);
	}
	for(i=0;i<m;i++){
		scanf("%d%d%d%d",&cmd[i][0],&cmd[i][1],&cmd[i][2],&cmd[i][3]);
	}
	f(0);
	for(i=0;i<n;i++){
		printf("%d ",ans[i]%4);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1092 KB Output is correct
2 Correct 0 ms 1092 KB Output is correct
3 Correct 0 ms 1092 KB Output is correct
4 Correct 0 ms 1092 KB Output is correct
5 Correct 0 ms 1092 KB Output is correct
6 Correct 0 ms 1092 KB Output is correct
7 Correct 0 ms 1092 KB Output is correct
8 Correct 0 ms 1092 KB Output is correct
9 Correct 0 ms 1092 KB Output is correct
10 Correct 0 ms 1092 KB Output is correct
11 Correct 0 ms 1092 KB Output is correct
12 Correct 0 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 0 ms 1092 KB Output is correct
15 Correct 62 ms 1092 KB Output is correct
16 Correct 68 ms 1092 KB Output is correct
17 Correct 568 ms 1092 KB Output is correct
18 Correct 606 ms 1092 KB Output is correct
19 Correct 563 ms 1092 KB Output is correct
20 Correct 517 ms 1092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1583 ms 1092 KB Output is correct
2 Execution timed out 4000 ms 1088 KB Program timed out
3 Halted 0 ms 0 KB -