제출 #920274

#제출 시각아이디문제언어결과실행 시간메모리
920274Pring앨리스, 밥, 서킷 (APIO23_abc)C++17
12 / 100
111 ms10012 KiB
#include <bits/stdc++.h> #include "abc.h" using namespace std; #define fs first #define sc second #define mp make_pair #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++) typedef pair<int, int> pii; // you may find the definitions useful const int OP_ZERO = 0; // f(OP_ZERO, x0, x1) = 0 const int OP_NOR = 1; // f(OP_NOR, x0, x1) = !(x0 || x1) const int OP_GREATER = 2; // f(OP_GREATER, x0, x1) = (x0 > x1) const int OP_NOT_X1 = 3; // f(OP_NOT_X1, x0, x1) = !x1 const int OP_LESS = 4; // f(OP_LESS, x0, x1) = (x0 < x1) const int OP_NOT_X0 = 5; // f(OP_NOT_X0, x0, x1) = !x0 const int OP_XOR = 6; // f(OP_XOR, x0, x1) = (x0 ^ x1) const int OP_NAND = 7; // f(OP_NAND, x0, x1) = !(x0 && x1) const int OP_AND = 8; // f(OP_AND, x0, x1) = (x0 && x1) const int OP_EQUAL = 9; // f(OP_EQUAL, x0, x1) = (x0 == x1) const int OP_X0 = 10; // f(OP_X0, x0, x1) = x0 const int OP_GEQ = 11; // f(OP_GEQ, x0, x1) = (x0 >= x1) const int OP_X1 = 12; // f(OP_X1, x0, x1) = x1 const int OP_LEQ = 13; // f(OP_LEQ, x0, x1) = (x0 <= x1) const int OP_OR = 14; // f(OP_OR, x0, x1) = (x0 || x1) const int OP_ONE = 15; // f(OP_ONE, x0, x1) = 1 const int LEN = 16; // Alice int // returns la alice( /* in */ const int n, /* in */ const char names[][5], /* in */ const unsigned short numbers[], /* out */ bool outputs_alice[] ) { FOR(i, 0, LEN) outputs_alice[i] = ((numbers[0] >> i) & 1); return LEN; } // Bob int // returns lb bob( /* in */ const int m, /* in */ const char senders[][5], /* in */ const char recipients[][5], /* out */ bool outputs_bob[] ) { // outputs_bob[0] = (m > 0); FOR(i, 0, LEN) outputs_bob[i] = ((m >> i) & 1); return LEN; } // Circuit int // returns l circuit( /* in */ const int la, /* in */ const int lb, /* out */ int operations[], /* out */ int operands[][2], /* out */ int outputs_circuit[][16] ) { int cnt = la + lb; auto add_op = [&](int input_a, int input_b, int op) { operations[cnt] = op; operands[cnt][0] = input_a, operands[cnt][1] = input_b; return cnt++; }; auto add_ops = [&](int inputs_a, int inputs_b, int op) { int pos = cnt; FOR(i, 0, LEN) { add_op(inputs_a + i, inputs_b + i, op); } return pos; }; int zero = add_ops(0, 0, OP_ZERO); auto LEFT = [&](int inputs, int p) { int pos = cnt; FOR(i, 0, LEN) { if (i < p) add_op(0, 0, OP_ZERO); else add_op(inputs + i - p, 0, OP_X0); } return pos; }; auto LEFT_ADV = [&](int inputs, int p, int b, int op) { int pos = cnt; FOR(i, 0, LEN) { if (i < p) add_op(0, 0, OP_ZERO); else add_op(inputs + i - p, b, op); } return pos; }; auto adder = [&](int inputs_a, int inputs_b) { int c = zero, c1, c2, g1; vector<int> vc, vg; FOR(i, 0, LEN) { int a = inputs_a + i, b = inputs_b + i; c1 = add_op(a, b, OP_AND); g1 = add_op(a, b, OP_XOR); c2 = add_op(c, g1, OP_AND); vc.push_back(c); vg.push_back(g1); c = add_op(c1, c2, OP_OR); } int pos = cnt; FOR(i, 0, LEN) { add_op(vg[i], vc[i], OP_XOR); } return pos; }; int a = 0, b = LEN; int now = zero; FOR(i, 0, LEN) { now = adder(now, LEFT_ADV(a, i, b + i, OP_AND)); } FOR(i, 0, LEN) outputs_circuit[0][i] = now + i; return cnt; }

컴파일 시 표준 에러 (stderr) 메시지

abc.cpp: In function 'int alice(int, const char (*)[5], const short unsigned int*, bool*)':
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:39:5: note: in expansion of macro 'FOR'
   39 |     FOR(i, 0, LEN) outputs_alice[i] = ((numbers[0] >> i) & 1);
      |     ^~~
abc.cpp: In function 'int bob(int, const char (*)[5], const char (*)[5], bool*)':
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:54:5: note: in expansion of macro 'FOR'
   54 |     FOR(i, 0, LEN) outputs_bob[i] = ((m >> i) & 1);
      |     ^~~
abc.cpp: In lambda function:
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:79:9: note: in expansion of macro 'FOR'
   79 |         FOR(i, 0, LEN) {
      |         ^~~
abc.cpp: In lambda function:
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:89:9: note: in expansion of macro 'FOR'
   89 |         FOR(i, 0, LEN) {
      |         ^~~
abc.cpp: In lambda function:
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:98:9: note: in expansion of macro 'FOR'
   98 |         FOR(i, 0, LEN) {
      |         ^~~
abc.cpp: In lambda function:
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:108:9: note: in expansion of macro 'FOR'
  108 |         FOR(i, 0, LEN) {
      |         ^~~
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:118:9: note: in expansion of macro 'FOR'
  118 |         FOR(i, 0, LEN) {
      |         ^~~
abc.cpp: In function 'int circuit(int, int, int*, int (*)[2], int (*)[16])':
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:128:5: note: in expansion of macro 'FOR'
  128 |     FOR(i, 0, LEN) {
      |     ^~~
abc.cpp:8:38: warning: unused variable 'Z' [-Wunused-variable]
    8 | #define FOR(i, j, k) for (int i = j, Z = k; i < k; i++)
      |                                      ^
abc.cpp:131:5: note: in expansion of macro 'FOR'
  131 |     FOR(i, 0, LEN) outputs_circuit[0][i] = now + i;
      |     ^~~
abc.cpp:87:10: warning: variable 'LEFT' set but not used [-Wunused-but-set-variable]
   87 |     auto LEFT = [&](int inputs, int p) {
      |          ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...