Submission #15351

# Submission time Handle Problem Language Result Execution time Memory
15351 2015-07-12T06:30:59 Z gs13068 쿼터너리 컴퓨터 (kriii3_Z) C++
0 / 126
0 ms 1088 KB
#include<cstdio>

int a[22],n,m;

int d[22];
int t[22];
int r[22];

int w[444];
int x[444];
int y[444];
int z[444];

void dfs(int p)
{
    if(p==n)
    {
        int i;
        for(i=0;i<n;i++)t[i]=d[i];
        for(i=0;i<m;i++)
        {
            if(w[i]==0)t[x[i]]=t[y[i]]+t[z[i]];
            if(w[i]==1)t[x[i]]=t[y[i]]^t[z[i]];
            if(w[i]==2)t[x[i]]=t[y[i]]+z[i];
            if(w[i]==3)t[x[i]]=t[y[i]]^z[i];
        }
        for(i=0;i<n;i++)r[i]=(r[i]+t[i])%4;
        return;
    }
    for(d[p]=0;d[p]<4;d[p]++)if(d[p]!=a[p])dfs(p+1);
}

int main()
{
    int i;
    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++)scanf("%d",&a[i]);
    for(i=0;i<m;i++)scanf("%d%d%d%d",&w[i],&x[i],&y[i],&z[i]);
    dfs(0);
    for(i=0;i<n;i++)printf("%d ",r[i]);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1088 KB Output is correct
2 Correct 0 ms 1088 KB Output is correct
3 Correct 0 ms 1088 KB Output is correct
4 Correct 0 ms 1088 KB Output is correct
5 Incorrect 0 ms 1088 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB -