This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "abc.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
// 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
// Alice
int // returns la
alice(
    /*  in */ const int n,
    /*  in */ const char names[][5],
    /*  in */ const unsigned short numbers[],
    /* out */ bool outputs_alice[]
) {
    int ind=0;
    for(int i=0;i<n;i++){
        int val=0;
        int subind=0;
        while(names[i][subind]){
            val*=26;
            val+=names[i][subind]-'a';
            subind++;
        }
        for(int j=0;j<20;j++){
            outputs_alice[ind++]=(val>>j)&1;
        }
        for(int j=0;j<16;j++){
            outputs_alice[ind++]=(numbers[i]>>j)&1;
        }
    }
    return ind;
}
// Bob
int // returns lb
bob(
    /*  in */ const int m,
    /*  in */ const char senders[][5],
    /*  in */ const char recipients[][5],
    /* out */ bool outputs_bob[]
) {
    int ind=0;
    for(int i=0;i<m;i++){
        int val=0;
        int subind=0;
        while(senders[i][subind]){
            val*=26;
            val+=senders[i][subind]-'a';
            subind++;
        }
        for(int j=0;j<20;j++){
            outputs_bob[ind++]=(val>>j)&1;
        }
        val=0;
        subind=0;
        while(recipients[i][subind]){
            val*=26;
            val+=recipients[i][subind]-'a';
            subind++;
        }
        for(int j=0;j<20;j++){
            outputs_bob[ind++]=(val>>j)&1;
        }
    }
    return ind;
}
// 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]
) {
    const int n=la/36,m=lb/40;
    int nextindex=la+lb;
    auto pushgate=[&](int g1,int g2,int op) -> int {
        operations[nextindex]=op;
        operands[nextindex][0]=g1;
        operands[nextindex][1]=g2;
        return nextindex++;
    };
    auto sumgate=[&](vector<int>&x,vector<int>&y) -> vector<int> {
        vector<int>result;
        int past=-1;
        for(int i=0;i<16;i++){
            int cur=pushgate(x[i],y[i],OP_XOR);
            int nextt=pushgate(x[i],y[i],OP_AND);
            if(i){
                int nexttt=pushgate(cur,past,OP_AND);
                nextt=pushgate(nextt,nexttt,OP_OR);
                cur=pushgate(cur,past,OP_XOR);
            }
            result.pb(cur);
            past=nextt;
        }
        return result;
    };
    auto createzeronum = [&]() -> vector<int> {
        vector<int>result;
        for(int i=0;i<16;i++){
            result.pb(pushgate(0,0,OP_ZERO));
        }
        return result;
    };
    vector<int>allzeros=createzeronum();
    auto check = [&](vector<int>target, int g) -> vector<int> {
        vector<int>result;
        for(int i=0;i<16;i++){
            result.pb(pushgate(target[i],g,OP_AND));
        }
        return result;
    };
    auto compare=[&](vector<int>g1,vector<int>g2)->int {
        int result=pushgate(g1[0],g2[0],OP_XOR);
        for(int i=1;i<20;i++){
            int cur=pushgate(g1[i],g2[i],OP_XOR);
            result=pushgate(result,cur,OP_OR);
        }
        return pushgate(result,0,OP_NOT_X0);
    };
    auto orgate=[&](vector<int>g1,vector<int>g2)->vector<int> {
        vector<int>result;
        for(int i=0;i<16;i++){
            result.pb(pushgate(g1[i],g2[i],OP_OR));
        }
        return result;
    };
    vector<int>names[n],nums[n];
    for(int i=0;i<n;i++){
        int beg=i*36;
        for(int j=beg;j<beg+20;j++){
            names[i].pb(j);
        }
        for(int j=beg+20;j<beg+36;j++){
            nums[i].pb(j);
        }
    }
    vector<int>from[m],to[m];
    for(int i=0;i<m;i++){
        int beg=la+i*40;
        for(int j=beg;j<beg+20;j++){
            from[i].pb(j);
        }
        for(int j=beg+20;j<beg+40;j++){
            to[i].pb(j);
        }
    }
    vector<int>canget[m];
    for(int i=0;i<m;i++){
        canget[i]=allzeros;
        for(int j=0;j<n;j++){
            vector<int>toad=nums[j];
            int cmp=compare(from[i],names[j]);
            toad=check(toad,cmp);
            canget[i]=orgate(canget[i],toad);
        }
    }
    vector<vector<int>>ans;
    for(int i=0;i<n;i++){
        ans.pb(allzeros);
        for(int j=0;j<m;j++){
            vector<int>toad=canget[j];
            int cmp=compare(to[j],names[i]);
            toad=check(toad,cmp);
            ans.back()=sumgate(ans.back(),toad);
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<16;j++){
            outputs_circuit[i][j]=ans[i][j];
        }
    }
    return nextindex;
}
| # | 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... |