# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15283 |
2015-07-12T05:19:11 Z |
gs14004 |
쿼터너리 컴퓨터 (kriii3_Z) |
C++14 |
|
4000 ms |
1088 KB |
#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 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 |
Correct |
0 ms |
1088 KB |
Output is correct |
6 |
Correct |
0 ms |
1088 KB |
Output is correct |
7 |
Correct |
0 ms |
1088 KB |
Output is correct |
8 |
Correct |
0 ms |
1088 KB |
Output is correct |
9 |
Correct |
0 ms |
1088 KB |
Output is correct |
10 |
Correct |
0 ms |
1088 KB |
Output is correct |
11 |
Correct |
0 ms |
1088 KB |
Output is correct |
12 |
Correct |
1 ms |
1088 KB |
Output is correct |
13 |
Correct |
0 ms |
1088 KB |
Output is correct |
14 |
Correct |
0 ms |
1088 KB |
Output is correct |
15 |
Correct |
70 ms |
1088 KB |
Output is correct |
16 |
Correct |
67 ms |
1088 KB |
Output is correct |
17 |
Correct |
630 ms |
1088 KB |
Output is correct |
18 |
Correct |
644 ms |
1088 KB |
Output is correct |
19 |
Correct |
620 ms |
1088 KB |
Output is correct |
20 |
Correct |
629 ms |
1088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1839 ms |
1088 KB |
Output is correct |
2 |
Execution timed out |
4000 ms |
1084 KB |
Program timed out |
3 |
Halted |
0 ms |
0 KB |
- |