이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "abc.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define pii pair<int, int>
#define ff first
#define ss second
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
// Alice
int // returns la
alice(
/* in */ const int n,
/* in */ const char names[][5],
/* in */ const unsigned short numbers[],
/* out */ bool outputs_alice[]
) {
ll num = numbers[0];
int l = 0;
for(int k=0; k<=10; k++){
for(int i=0; i<16; i++){
outputs_alice[l] = bool((num & (1 << i)));
l++;
}
num += num;
num %= (1 << 16);
}
return l;
}
// Bob
int // returns lb
bob(
/* in */ const int m,
/* in */ const char senders[][5],
/* in */ const char recipients[][5],
/* out */ bool outputs_bob[]
) {
int l = 0;
for(int i=0; i<16; i++){
outputs_bob[l] = bool((m & (1 << i)));
l++;
}
return l;
}
vector<int> ro;
vector<pii> rp;
int add(int l, int cad, int a, int b){
ro.pb(OP_XOR);
ro.pb(OP_AND);
rp.pb({cad, a});
rp.pb({cad, a});
ro.pb(OP_AND);
rp.pb({b, l+1});
ro.pb(OP_XOR);
rp.pb({b, l+1});
ro.pb(OP_OR);
rp.pb({l+3, l+2});
return l + 5;
}
int sum(int l, int a, int b){
ro.pb(OP_ZERO);
rp.pb({0, 0});
vector<int> res;
l++;
for(int i=0; i<16; i++){
l = add(l, l, a + i, b + i);
res.pb(l - 1);
}
for(int i=0; i<16; i++){
ro.pb(OP_X1);
rp.pb({0, res[i]});
l++;
}
return l;
}
int mult(int l, int a, int b){
for(int i=0; i<16; i++){
ro.pb(OP_ZERO);
rp.pb({0, 0});
l++;
}
int ls = l-15;
for(int k=0; k<16; k++){
int s = l + 1;
for(int i=0; i<16; i++){
ro.pb(OP_AND);
rp.pb({a + i, b + k});
l++;
}
l = sum(l, s, ls);
ls = l - 15;
if(k < 15){
l = sum(l, a, a);
a = l - 15;
}
}
return l;
}
// 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 l = la + lb - 1;
ro.clear();
rp.clear();
l = mult(l, 0, la);
int ls = l - 15;
for(int i=0; i<la + lb; i++){
operations[i] = 0;
operands[i][0] = -1;
operands[i][1] = -1;
}
for(int i=la + lb; i<=l; i++){
operations[i] = ro[i - la - lb];
operands[i][0] = rp[i - la - lb].ff;
operands[i][1] = rp[i - la - lb].ss;
}
for(int i=0; i<16; i++){
outputs_circuit[0][i] = ls + i;
}
return l + 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |