This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |