#include #include #include #include #include using namespace std; int N, K, T; int B[1009], C[1009][1009]; vector> Answer; void Solve(int px, int py) { Answer.push_back(make_tuple("UPD", N, 1, -1)); Answer.push_back(make_tuple("XOR", N, py, N)); Answer.push_back(make_tuple("AND", N, px, N)); Answer.push_back(make_tuple("XOR", px, px, N)); Answer.push_back(make_tuple("XOR", py, py, N)); } int main() { // Step #1. Input cin >> N >> K >> T; for (int i = 1; i <= T; i++) { for (int j = 0; j < N; j++) cin >> C[i][j]; } assert(2 <= N && N <= 50); assert(1 <= K && K <= N); assert(1 <= T && T <= 100); for (int i = 1; i <= T; i++) { for (int j = 0; j < N; j++) { assert(C[i][j] == 0 || C[i][j] == 1); } } // Step #2. Solve for (int i = N - 2; i >= 0; i--) { for (int j = 0; j <= i; j++) { Solve(j, j + 1); } } Answer.push_back(make_tuple("UPD", N, 0, -1)); Answer.push_back(make_tuple("XOR", N, N - K, N)); // Step #3. Output The Answer cout << Answer.size() << endl; for (int i = 0; i < Answer.size(); i++) { if (get<0>(Answer[i]) == "UPD") cout << get<0>(Answer[i]) << " " << get<1>(Answer[i]) << " " << get<2>(Answer[i]) << endl; if (get<0>(Answer[i]) == "AND") cout << get<0>(Answer[i]) << " " << get<1>(Answer[i]) << " " << get<2>(Answer[i]) << " " << get<3>(Answer[i]) << endl; if (get<0>(Answer[i]) == "XOR") cout << get<0>(Answer[i]) << " " << get<1>(Answer[i]) << " " << get<2>(Answer[i]) << " " << get<3>(Answer[i]) << endl; } /*for (int i = 1; i <= T; i++) { for (int j = 0; j < N; j++) B[j] = C[i][j]; B[N] = 0; for (int j = 0; j < Answer.size(); j++) { if (get<0>(Answer[j]) == "UPD") B[get<1>(Answer[j])] = get<2>(Answer[j]); if (get<0>(Answer[j]) == "AND") B[get<1>(Answer[j])] = (B[get<2>(Answer[j])] & B[get<3>(Answer[j])]); if (get<0>(Answer[j]) == "XOR") B[get<1>(Answer[j])] = (B[get<2>(Answer[j])] ^ B[get<3>(Answer[j])]); } }*/ return 0; }