답안 #15520

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15520 2015-07-12T08:46:59 Z xhae 쿼터너리 컴퓨터 (kriii3_Z) C++14
31 / 126
4000 ms 1720 KB
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;

int main()
{
  int N, M;
  cin >> N >> M;

  vector<int> f(N);
  for (int i=0; i<N; i++) cin >> f[i];

  vector<int> cmd(M), x(M), y(M), z(M);
  for (int i=0; i<M; i++)
    cin >> cmd[i] >> x[i] >> y[i] >> z[i];

  vector<int> t(N);
  for (int bit=0; bit<(1<<(2*N)); bit ++) {
    int ok = 1;
    for (int i=0; i<N; i++)
      if (((bit>>(2*i))&3) == f[i]) {
        ok = 0;
        break;
      }
    if (!ok) continue;

    vector<int> reg(N);
    for (int i=0; i<N; i++)
      reg[i] = (bit>>(2*i))&3;

    for (int i=0; i<M; i++) {
      if (cmd[i] == 0) reg[x[i]] = (reg[y[i]] + reg[z[i]]) & 3;
      else if (cmd[i] == 1) reg[x[i]] = reg[y[i]] ^ reg[z[i]];
      else if (cmd[i] == 2) reg[x[i]] = (reg[y[i]] + z[i]) & 3;
      else reg[x[i]] = reg[y[i]] ^ z[i];
    }

    for (int i=0; i<N; i++) t[i] = (t[i] + reg[i]) & 3;
  }

  for (int i=0; i<N; i++) cout << t[i] << " ";
  cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1720 KB Output is correct
2 Correct 0 ms 1720 KB Output is correct
3 Correct 0 ms 1720 KB Output is correct
4 Correct 0 ms 1720 KB Output is correct
5 Correct 0 ms 1720 KB Output is correct
6 Correct 0 ms 1720 KB Output is correct
7 Correct 0 ms 1720 KB Output is correct
8 Correct 0 ms 1720 KB Output is correct
9 Correct 0 ms 1720 KB Output is correct
10 Correct 0 ms 1720 KB Output is correct
11 Correct 0 ms 1720 KB Output is correct
12 Correct 0 ms 1720 KB Output is correct
13 Correct 0 ms 1720 KB Output is correct
14 Correct 0 ms 1720 KB Output is correct
15 Correct 65 ms 1720 KB Output is correct
16 Correct 66 ms 1720 KB Output is correct
17 Correct 676 ms 1720 KB Output is correct
18 Correct 674 ms 1720 KB Output is correct
19 Correct 638 ms 1720 KB Output is correct
20 Correct 660 ms 1720 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2049 ms 1720 KB Output is correct
2 Execution timed out 4000 ms 1716 KB Program timed out
3 Halted 0 ms 0 KB -