Submission #15441

# Submission time Handle Problem Language Result Execution time Memory
15441 2015-07-12T07:41:36 Z progressive 쿼터너리 컴퓨터 (kriii3_Z) C++14
31 / 126
4000 ms 1092 KB
#include<cstdio>
int S[20];
int ban[20];
int mem[20];
int ans[20];
int w[500],x[500],y[500],z[500];
int xorarr[4][4]=
{
{0,1,2,3},
{1,0,3,2},
{2,3,0,1},
{3,2,1,0}
};
void addv(int x,int y,int z)
{
	mem[x]=(mem[y]+mem[z])%4;
}
void addc(int x,int y,int z)
{
	mem[x]=(mem[y]+z)%4;
}
void xorv(int x,int y,int z)
{
	mem[x]=xorarr[mem[y]][mem[z]];
}
void xorc(int x,int y,int z)
{
	mem[x]=xorarr[mem[y]][z];
}
void run(int a,int b,int c,int d)
{
	if(a==0) addv(b,c,d);
	if(a==1) xorv(b,c,d);
	if(a==2) addc(b,c,d);
	if(a==3) xorc(b,c,d);
}
int main()
{
	int N,M;
	scanf("%d%d",&N,&M);
	for(int i=0;i<N;i++) scanf("%d",ban+i);
	for(int i=0;i<M;i++)
		scanf("%d%d%d%d",w+i,x+i,y+i,z+i);
	int calc=1;
	for(int i=0;i<N;i++) calc*=3;
	for(int i=0;i<calc;i++)
	{
		{
			int x=i;
			for(int j=0;j<N;j++)
			{
				mem[j]=x%3;
				x/=3;
				if(mem[j]>=ban[j]) mem[j]++;
			}
		}
		for(int j=0;j<M;j++)
			run(w[j],x[j],y[j],z[j]);
		for(int j=0;j<N;j++)
			ans[j]=(ans[j]+mem[j])%4;
	}
	for(int i=0;i<N;i++)
		printf("%d ",ans[i]);
	
}
# 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 2 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 2 ms 1092 KB Output is correct
15 Correct 120 ms 1092 KB Output is correct
16 Correct 123 ms 1092 KB Output is correct
17 Correct 1088 ms 1092 KB Output is correct
18 Correct 1244 ms 1092 KB Output is correct
19 Correct 1083 ms 1092 KB Output is correct
20 Correct 1025 ms 1092 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3086 ms 1092 KB Output is correct
2 Execution timed out 4000 ms 1088 KB Program timed out
3 Halted 0 ms 0 KB -