답안 #15458

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15458 2015-07-12T08:02:17 Z myungwoo 쿼터너리 컴퓨터 (kriii3_Z) C++14
31 / 126
4000 ms 1728 KB
#include <bits/stdc++.h>
using namespace std;

int N, M;
int F[18], A[18], B[18], ans[18];

struct Z{
	int t, x, y, z;
} Q[401];

void dfs(int n)
{
	if (n == N){
		for (int i=0;i<N;i++) B[i] = A[i];
		for (int i=1;i<=M;i++){
			if (Q[i].t == 0){
				B[Q[i].x] = (B[Q[i].y] + B[Q[i].z]) & 3;
			}else if (Q[i].t == 1){
				B[Q[i].x] = (B[Q[i].y] ^ B[Q[i].z]);
			}else if (Q[i].t == 2){
				B[Q[i].x] = (B[Q[i].y] + Q[i].z) & 3;
			}else{
				B[Q[i].x] = (B[Q[i].y] ^ Q[i].z);
			}
		}
		for (int i=0;i<N;i++) ans[i] = (ans[i] + B[i]) & 3;
		return;
	}
	for (int i=0;i<4;i++) if (i != F[n]){
		A[n] = i;
		dfs(n+1);
	}
}

int main()
{
	scanf("%d%d", &N, &M);
	for (int i=0;i<N;i++) scanf("%d", F+i);
	for (int i=1;i<=M;i++) scanf("%d%d%d%d", &Q[i].t, &Q[i].x, &Q[i].y, &Q[i].z);
	dfs(0);
	for (int i=0;i<N;i++) printf("%d ", ans[i]); puts("");
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct
5 Correct 0 ms 1728 KB Output is correct
6 Correct 0 ms 1728 KB Output is correct
7 Correct 0 ms 1728 KB Output is correct
8 Correct 0 ms 1728 KB Output is correct
9 Correct 0 ms 1728 KB Output is correct
10 Correct 0 ms 1728 KB Output is correct
11 Correct 0 ms 1728 KB Output is correct
12 Correct 1 ms 1728 KB Output is correct
13 Correct 1 ms 1728 KB Output is correct
14 Correct 1 ms 1728 KB Output is correct
15 Correct 59 ms 1728 KB Output is correct
16 Correct 59 ms 1728 KB Output is correct
17 Correct 510 ms 1728 KB Output is correct
18 Correct 520 ms 1728 KB Output is correct
19 Correct 511 ms 1728 KB Output is correct
20 Correct 910 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2694 ms 1728 KB Output is correct
2 Execution timed out 4000 ms 1724 KB Program timed out
3 Halted 0 ms 0 KB -