(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #984001

#TimeUsernameProblemLanguageResultExecution timeMemory
984001c2zi6Alice, Bob, and Circuit (APIO23_abc)C++17
12 / 100
112 ms15696 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "abc.h" // 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 void write(bool* arr, int i, int x) { rep(j, 16) { arr[16*i+2 + j] = bool(x & (1<<j)); } } int alice( /* in */ const int n, /* in */ const char names[][5], /* in */ const unsigned short numbers[], /* out */ bool outputs_alice[] ) { outputs_alice[0] = false; outputs_alice[1] = true; int cnt = 0; write(outputs_alice, 0, numbers[0]); cnt++; /* rep(i, 16*cnt + 2) cout << "GATE " << i << ": " << outputs_alice[i] << endl; */ return 16*cnt + 2; } int bob( /* in */ const int m, /* in */ const char senders[][5], /* in */ const char recipients[][5], /* out */ bool outputs_bob[] ) { return m; } int circuit( /* in */ const int la, /* in */ const int lb, /* out */ int operations[], /* out */ int operands[][2], /* out */ int outputs_circuit[][16] ) { int bits = 16; int n, m, gatecnt, null; auto read = [&](int ind, int from) { rep(i, bits) outputs_circuit[ind][i] = from++; }; auto fillzero = [&](int ind) { rep(i, bits) outputs_circuit[ind][i] = 0; }; auto onebitsum = [&](int a, int b, int c) { operations[gatecnt] = OP_XOR; operands[gatecnt][0] = a; operands[gatecnt][1] = b; int xor1 = gatecnt++; operations[gatecnt] = OP_AND; operands[gatecnt][0] = a; operands[gatecnt][1] = b; int and1 = gatecnt++; operations[gatecnt] = OP_XOR; operands[gatecnt][0] = xor1; operands[gatecnt][1] = c; int xor2 = gatecnt++; operations[gatecnt] = OP_AND; operands[gatecnt][0] = xor1; operands[gatecnt][1] = c; int and2 = gatecnt++; operations[gatecnt] = OP_OR; operands[gatecnt][0] = and1; operands[gatecnt][1] = and2; int or1 = gatecnt++; return mkp(xor2, or1); }; auto sumab = [&](int a, int b) { int prim[bits], sec[bits]; tie(prim[0], sec[0]) = onebitsum(a++, b++, 0); replr(i, 1, bits-1) { tie(prim[i], sec[i]) = onebitsum(a++, b++, sec[i-1]); } int ind = gatecnt; rep(i, bits) { operations[gatecnt] = OP_X0; operands[gatecnt][0] = prim[i]; operands[gatecnt][1] = 0; gatecnt++; } return ind; }; auto sumof = [&](VI a) { if (a.size() == 0) return null; if (a.size() == 1) return a[0]; int last = sumab(a[0], a[1]); replr(i, 2, a.size()-1) last = sumab(last, a[i]); return last; }; n = 1; m = lb; gatecnt = la + lb; null = gatecnt; rep(i, 16) { operations[gatecnt] = OP_ZERO; operands[gatecnt][0] = 0; operands[gatecnt][1] = 0; gatecnt++; } VI a; rep(i, m) a.pb(2); int ind = sumof(a); read(0, ind); return gatecnt; }

Compilation message (stderr)

abc.cpp: In function 'int circuit(int, int, int*, int (*)[2], int (*)[16])':
abc.cpp:93:6: warning: variable 'n' set but not used [-Wunused-but-set-variable]
   93 |  int n, m, gatecnt, null;
      |      ^
abc.cpp:97:7: warning: variable 'fillzero' set but not used [-Wunused-but-set-variable]
   97 |  auto fillzero = [&](int ind) {
      |       ^~~~~~~~
#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...