Submission #15283

#TimeUsernameProblemLanguageResultExecution timeMemory
15283gs14004쿼터너리 컴퓨터 (kriii3_Z)C++14
31 / 126
4000 ms1088 KiB
#include <cstdio> int arr[18]; int cnt[18]; int n, m; int op[405], x[405], y[405], z[450]; int f[18]; void backtrack(int pos){ if(pos == n){ int arr2[18]; for(int i=0; i<n; i++){ arr2[i] = arr[i]; } for(int i=0; i<m; i++){ if(op[i] == 0){ arr2[x[i]] = arr2[y[i]] + arr2[z[i]]; } if(op[i] == 1){ arr2[x[i]] = arr2[y[i]] ^ arr2[z[i]]; } if(op[i] == 2){ arr2[x[i]] = arr2[y[i]] + z[i]; } if(op[i] == 3){ arr2[x[i]] = arr2[y[i]] ^ z[i]; } arr2[x[i]] &= 3; } for(int i=0; i<n; i++){ cnt[i] += arr2[i]; cnt[i] %= 4; } return; } for(int i=0; i<4; i++){ if(i == f[pos]) continue; arr[pos] = i; backtrack(pos+1); arr[pos] = 0; } } int main(){ scanf("%d %d",&n,&m); for(int i=0; i<n; i++){ scanf("%d",&f[i]); } for(int i=0; i<m; i++){ scanf("%d %d %d %d",&op[i],&x[i],&y[i],&z[i]); } backtrack(0); for(int i=0; i<n; i++){ printf("%d ",cnt[i]); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...