Submission #15520

#TimeUsernameProblemLanguageResultExecution timeMemory
15520xhae쿼터너리 컴퓨터 (kriii3_Z)C++14
31 / 126
4000 ms1720 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...