Submission #814750

#TimeUsernameProblemLanguageResultExecution timeMemory
814750HanksburgerAlice, Bob, and Circuit (APIO23_abc)C++17
12 / 100
119 ms12388 KiB
#include "abc.h" #include <bits/stdc++.h> using namespace std; 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 int alice(const int n, const char names[][5], const unsigned short numbers[], bool outputs_alice[]) { for (int i=0; i<16; i++) outputs_alice[i]=numbers[0]&(1<<i); return 16; } int bob(const int m, const char senders[][5], const char recipients[][5], bool outputs_bob[]) { for (int i=0; i<m; i++) outputs_bob[i]=0; return m; } int ind[16]; int circuit(const int la, const int lb, int operations[], int operands[][2], int outputs_circuit[][16]) { if (!lb) { for (int i=0; i<16; i++) { operands[i+16][0]=0; operands[i+16][1]=0; operations[i+16]=OP_ZERO; outputs_circuit[0][i]=i+16; } return 32; } for (int i=0; i<16; i++) ind[i]=i; int cur=lb+16, carry; for (int i=1; i<lb; i++) { operands[cur][0]=0; operands[cur][1]=ind[0]; operations[cur]=OP_XOR; operands[cur+1][0]=0; operands[cur+1][1]=ind[0]; operations[cur+1]=OP_AND; ind[0]=cur; carry=cur+1; cur+=2; for (int j=1; j<16; j++) { operands[cur][0]=j; operands[cur][1]=ind[j]; operations[cur]=OP_XOR; operands[cur+1][0]=cur; operands[cur+1][1]=carry; operations[cur+1]=OP_XOR; operands[cur+2][0]=j; operands[cur+2][1]=ind[j]; operations[cur+2]=OP_AND; operands[cur+3][0]=j; operands[cur+3][1]=carry; operations[cur+3]=OP_AND; operands[cur+4][0]=ind[j]; operands[cur+4][1]=carry; operations[cur+4]=OP_AND; operands[cur+5][0]=cur+2; operands[cur+5][1]=cur+3; operations[cur+5]=OP_OR; operands[cur+6][0]=cur+5; operands[cur+6][1]=cur+4; operations[cur+6]=OP_OR; ind[j]=cur+1; carry=cur+6; cur+=7; } } for (int i=0; i<16; i++) outputs_circuit[0][i]=ind[i]; return cur; }
#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...