#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
int pl[4][4]={0,1,2,3,1,2,3,0,2,3,0,1,3,0,1,2},xo[4][4]={0,1,2,3,1,0,3,2,2,3,0,1,3,2,1,0};
int a,b,i,j,U,p,q,v[19],x[444],y[444],z[444],ch[444],T,fl[19],ss[19];
main()
{
scanf("%d%d",&a,&b);
for(i=0;i<a;i++)
{
scanf("%d",&fl[i]);
}
for(i=0;i<b;i++)
{
scanf("%d%d%d%d",&ch[i],&x[i],&y[i],&z[i]);
}
T=1;
for(i=0;i<a;i++)T*=3;
for(i=0;i<T;i++)
{
U=i;
for(j=0;j<a;j++)
{
p=U%3-1;
q=0;
if(fl[j]==q)q++;
for(;p>=0;p--)
{
q++;
if(fl[j]==q)q++;
}
v[j]=q;
U/=3;
}
for(j=0;j<b;j++)
{
if(ch[j]==0)v[x[j]]=pl[v[y[j]]][v[z[j]]];
else if(ch[j]==1)v[x[j]]=xo[v[y[j]]][v[z[j]]];
else if(ch[j]==2)v[x[j]]=pl[v[y[j]]][z[j]];
else v[x[j]]=xo[v[y[j]]][z[j]];
}
for(j=0;j<a;j++)ss[j]+=v[j];
}
for(i=0;i<a;i++)printf("%d ",ss[i]%4);
}
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
1092 KB |
Output is correct |
15 |
Correct |
76 ms |
1092 KB |
Output is correct |
16 |
Correct |
75 ms |
1092 KB |
Output is correct |
17 |
Correct |
661 ms |
1092 KB |
Output is correct |
18 |
Correct |
643 ms |
1092 KB |
Output is correct |
19 |
Correct |
684 ms |
1092 KB |
Output is correct |
20 |
Correct |
682 ms |
1092 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2020 ms |
1092 KB |
Output is correct |
2 |
Execution timed out |
4000 ms |
1088 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |