Submission #781990

# Submission time Handle Problem Language Result Execution time Memory
781990 2023-07-13T14:36:04 Z t6twotwo Alice, Bob, and Circuit (APIO23_abc) C++17
36 / 100
267 ms 91268 KB
#include "abc.h"
#include <bits/stdc++.h>
using namespace std;

// 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

const int mod = 65536;

// Alice
int // returns la
alice(
    /*  in */ const int N,
    /*  in */ const char s[][5],
    /*  in */ const unsigned short v[],
    /* out */ bool ans[]
) {
    ans[0] = 0;
    ans[1] = 1;
    vector<int> a(26);
    for (int i = 0; i < 26; i++) {
        a[s[i][0] - 'a'] = v[i];
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 16; j++) {
            ans[i * 16 + j + 2] = a[i] >> j & 1;
        }
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 26; j++) {
            ans[418 + 26 * i + j] = s[i][0] - 'a' == j;
        }
    }
    return 1094;
}


// Bob
int // returns lb
bob(
    /*  in */ const int M,
    /*  in */ const char s[][5],
    /*  in */ const char t[][5],
    /* out */ bool ans[]
) {
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 26; j++) {
            ans[52 * i + j] = s[i][0] - 'a' == j;
        }
        for (int j = 0; j < 26; j++) {
            ans[52 * i + 26 + j] = t[i][0] - 'a' == j;
        }
    }
    return 52 * M;
}


// Circuit
int // returns l
circuit(
    /*  in */ const int n,
    /*  in */ const int m,
    /* out */ int A[],
    /* out */ int B[][2],
    /* out */ int ans[][16]
) {
    int N = 26;
    int M = m / 52;
    int T = n + m;
    vector v(26, vector<int>(16));
    for (int i = 0; i < M; i++) {
        vector<int> f(16);
        for (int j = 0; j < 16; j++) {
            vector<int> g(26);
            for (int k = 0; k < 26; k++) {
                g[k] = T;
                A[T] = 8;
                B[T][0] = 16 * k + j + 2;
                B[T][1] = 52 * i + k + n;
                T++;
            }
            A[T] = 14;
            B[T][0] = g[0];
            B[T][1] = g[1];
            T++;
            for (int k = 2; k < 26; k++) {
                A[T] = 14;
                B[T][0] = T - 1;
                B[T][1] = g[k];
                T++;
            }
            f[j] = T - 1;
        }
        for (int j = 0; j < 26; j++) {
            int c = 0;
            for (int k = 0; k < 16; k++) {
                A[T] = 8;
                B[T][0] = f[k];
                B[T][1] = 52 * i + 26 + j + n;
                T++;
                A[T] = 6;
                B[T][0] = T - 1;
                B[T][1] = v[j][k];
                T++;
                A[T] = 8;
                B[T][0] = T - 2;
                B[T][1] = v[j][k];
                T++;
                v[j][k] = T;
                A[T] = 6;
                B[T][0] = T - 2;
                B[T][1] = c;
                T++;
                A[T] = 8;
                B[T][0] = T - 3;
                B[T][1] = c;
                T++;
                A[T] = 14;
                B[T][0] = T - 1;
                B[T][1] = T - 3;
                c = T++;
            }
        }
    }
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 16; j++) {
            vector<int> g(26);
            for (int k = 0; k < 26; k++) {
                g[k] = T;
                A[T] = 8;
                B[T][0] = v[k][j];
                B[T][1] = 418 + 26 * i + k;
                T++;
            }
            A[T] = 14;
            B[T][0] = g[0];
            B[T][1] = g[1];
            T++;
            for (int k = 2; k < 26; k++) {
                A[T] = 14;
                B[T][0] = T - 1;
                B[T][1] = g[k];
                T++;
            }
            ans[i][j] = T - 1;
        }
    }
    return T;
}

Compilation message

abc.cpp: In function 'int circuit(int, int, int*, int (*)[2], int (*)[16])':
abc.cpp:82:9: warning: unused variable 'N' [-Wunused-variable]
   82 |     int N = 26;
      |         ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2172 KB Correct!
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2172 KB Correct!
2 Correct 4 ms 2180 KB Correct!
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2172 KB Correct!
2 Correct 4 ms 2180 KB Correct!
3 Correct 167 ms 86228 KB Correct!
4 Correct 175 ms 86444 KB Correct!
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3332 KB Correct!
2 Correct 104 ms 46228 KB Correct!
3 Correct 119 ms 59412 KB Correct!
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3332 KB Correct!
2 Correct 104 ms 46228 KB Correct!
3 Correct 119 ms 59412 KB Correct!
4 Incorrect 102 ms 46224 KB WA Your functions alice(), bob(), circuit() finished successfully, but the final output binary string is incorrect.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 3332 KB Correct!
2 Correct 104 ms 46228 KB Correct!
3 Correct 119 ms 59412 KB Correct!
4 Incorrect 102 ms 46224 KB WA Your functions alice(), bob(), circuit() finished successfully, but the final output binary string is incorrect.
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 267 ms 91268 KB WA Your functions alice(), bob(), circuit() finished successfully, but the final output binary string is incorrect.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 267 ms 91268 KB WA Your functions alice(), bob(), circuit() finished successfully, but the final output binary string is incorrect.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2172 KB Correct!
2 Correct 4 ms 2180 KB Correct!
3 Correct 167 ms 86228 KB Correct!
4 Correct 175 ms 86444 KB Correct!
5 Correct 7 ms 3332 KB Correct!
6 Correct 104 ms 46228 KB Correct!
7 Correct 119 ms 59412 KB Correct!
8 Incorrect 102 ms 46224 KB WA Your functions alice(), bob(), circuit() finished successfully, but the final output binary string is incorrect.
9 Halted 0 ms 0 KB -