Submission #814810

#TimeUsernameProblemLanguageResultExecution timeMemory
814810HanksburgerAlice, Bob, and Circuit (APIO23_abc)C++17
28 / 100
357 ms480608 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<n; i++)
        for (int j=0; j<16; j++)
            outputs_alice[i*16+j]=numbers[i]&(1<<j);
    return n*16;
}
int bob(const int m, const char senders[][5], const char recipients[][5], bool outputs_bob[])
{
    for (int i=0; i<676; i++)
        outputs_bob[i]=0;
    for (int i=0; i<m; i++)
        outputs_bob[(recipients[i][0]-'a')*26+senders[i][0]-'a']=1;
    return 676;
}
int circuit(const int la, const int lb, int operations[], int operands[][2], int outputs_circuit[][16])
{
    int ind[16], ind2[16], n=la/16, cur=la+676, carry;
    for (int u=0; u<n; u++)
    {
        for (int i=0; i<16; i++)
        {
            operands[cur][0]=0;
            operands[cur][1]=0;
            operations[cur]=OP_ZERO;
            ind[i]=cur;
            cur++;
        }
        for (int v=0; v<n; v++)
        {
            int num=n*16+u*26+v;
            for (int i=0; i<16; i++)
            {
                operands[cur][0]=v*16+i;
                operands[cur][1]=num;
                operations[cur]=OP_AND;
                ind2[i]=cur;
                cur++;
            }
            operands[cur][0]=ind[0];
            operands[cur][1]=ind2[0];
            operations[cur]=OP_XOR;

            operands[cur+1][0]=ind[0];
            operands[cur+1][1]=ind2[0];
            operations[cur+1]=OP_AND;

            ind[0]=cur;
            carry=cur+1;
            cur+=2;

            for (int j=1; j<16; j++)
            {
                operands[cur][0]=ind[j];
                operands[cur][1]=ind2[j];
                operations[cur]=OP_XOR;

                operands[cur+1][0]=cur;
                operands[cur+1][1]=carry;
                operations[cur+1]=OP_XOR;

                operands[cur+2][0]=ind[j];
                operands[cur+2][1]=ind2[j];
                operations[cur+2]=OP_AND;

                operands[cur+3][0]=ind[j];
                operands[cur+3][1]=carry;
                operations[cur+3]=OP_AND;

                operands[cur+4][0]=ind2[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[u][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...