답안 #15368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15368 2015-07-12T06:50:40 Z skeksk91 쿼터너리 컴퓨터 (kriii3_Z) C++
31 / 126
4000 ms 1092 KB
#include <stdio.h>
#include <stack>
#include <string.h>
#include <string>
#include <vector>
#include <queue>
#include <limits.h>
#include <algorithm>
#define ll long long
int n, m, v[20], f[20], page[20], inst[500], ret[500], a[500], b[500], u[500];
int plus[4][4] ={{0,1,2,3},{1,2,3,0},{2,3,0,1},{3,0,1,2}};
int xor2[4][4] = {{0,1,2,3},{1,0,3,2},{2,3,0,1},{3,2,1,0}};

void func(int here){
	if(here==n){
		//for(int i = 0 ; i < n; i++){
		//	printf("%d ", v[i]);
		//}
		//printf("\n");
		for(int i = 0; i < n; i++){
			u[i] = v[i];
		}
		for(int i = 0; i < m; i++){
			if(inst[i]==0){
				u[ret[i]] = plus[u[a[i]]][u[b[i]]];
			}
			else if(inst[i]==1){
				u[ret[i]] = xor2[u[a[i]]][u[b[i]]];
			}
			else if(inst[i]==2){
				u[ret[i]] = plus[u[a[i]]][b[i]];
			}
			else{
				u[ret[i]] = xor2[u[a[i]]][b[i]];
			}
		}
		for(int i = 0; i < n; i++){
			page[i] += u[i];
		}
		return;
	}
	for(int i = 0; i < 4; i++){
		if(f[here] != i){
			v[here] = i;
			func(here+1);
		}
	}
}
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", &inst[i], &ret[i], &a[i], &b[i]);
	}
	func(0);
	for(int i = 0; i < n; i++){
		printf("%d ",page[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 1 ms 1092 KB Output is correct
13 Correct 0 ms 1092 KB Output is correct
14 Correct 0 ms 1092 KB Output is correct
15 Correct 63 ms 1092 KB Output is correct
16 Correct 65 ms 1092 KB Output is correct
17 Correct 561 ms 1092 KB Output is correct
18 Correct 526 ms 1092 KB Output is correct
19 Correct 560 ms 1092 KB Output is correct
20 Correct 545 ms 1092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1637 ms 1092 KB Output is correct
2 Execution timed out 4000 ms 1088 KB Program timed out
3 Halted 0 ms 0 KB -