Submission #1056220

#TimeUsernameProblemLanguageResultExecution timeMemory
1056220Soysauce앨리스, 밥, 서킷 (APIO23_abc)C++17
Compilation error
0 ms0 KiB
#include <iostream>
#include <unordered_map>
#include <vector>
#include <cstring>

const int MOD = 65536;

int alice(const int n, const char names[][5], const unsigned short numbers[], bool outputs_alice[]) {
    // Simple encoding: We will use a naive approach for the binary string from Alice
    for (int i = 0; i < n; ++i) {
        // Output the least significant bits of the favorite numbers
        outputs_alice[i] = (numbers[i] & 1); // Just an example: taking the LSB of each number
    }
    return n; // Return the length of the binary string
}

int bob(const int m, const char senders[][5], const char recipients[][5], bool outputs_bob[]) {
    // Simple encoding: Use a simple approach for encoding sender-recipient pairs
    for (int i = 0; i < m; ++i) {
        // Example: encode if the first letter of sender and recipient are the same
        outputs_bob[i] = (senders[i][0] == recipients[i][0]);
    }
    return m; // Return the length of the binary string
}

int circuit(const int la, const int lb, int operations[], int operands[][2], int outputs_circuit[][16]) {
    // Simple circuit: We'll perform a couple of operations
    int gate_count = la + lb;

    // Perform an AND operation between the first bit from Alice and the first bit from Bob
    operations[gate_count] = 8; // AND operation
    operands[gate_count][0] = 0; // First bit from Alice
    operands[gate_count][1] = la; // First bit from Bob
    gate_count++;

    // Perform an OR operation between the result and the second bit from Alice
    operations[gate_count] = 14; // OR operation
    operands[gate_count][0] = 0; // First bit from Alice
    operands[gate_count][1] = gate_count - 1; // Previous gate
    gate_count++;

    // Output the result to the outputs_circuit
    for (int i = 0; i < la; ++i) {
        for (int j = 0; j < 16; ++j) {
            outputs_circuit[i][j] = operands[gate_count - 1][j % 2];
        }
    }

    return gate_count; // Return the number of gates used
}

// Sample usage
int main() {
    // Sample data
    int n = 3;
    const char names[3][5] = {"alic", "bob", "circ"};
    unsigned short numbers[3] = {10000, 20000, 30000};
    bool outputs_alice[10] = {0};

    int m = 5;
    const char senders[5][5] = {"alic", "bob", "bob", "circ", "circ"};
    const char recipients[5][5] = {"circ", "circ", "alic", "circ", "circ"};
    bool outputs_bob[10] = {0};

    int operations[100] = {0};
    int operands[100][2] = {0};
    int outputs_circuit[3][16] = {0};

    // Call the functions
    int la = alice(n, names, numbers, outputs_alice);
    int lb = bob(m, senders, recipients, outputs_bob);
    int gate_count = circuit(la, lb, operations, operands, outputs_circuit);

    // Output the results
    std::cout << "Alice's output: ";
    for (int i = 0; i < la; ++i) {
        std::cout << outputs_alice[i];
    }
    std::cout << std::endl;

    std::cout << "Bob's output: ";
    for (int i = 0; i < lb; ++i) {
        std::cout << outputs_bob[i];
    }
    std::cout << std::endl;

    std::cout << "Circuit's output: " << std::endl;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 16; ++j) {
            std::cout << outputs_circuit[i][j];
        }
        std::cout << std::endl;
    }

    return 0;
}

Compilation message (stderr)

abc.cpp: In function 'int main()':
abc.cpp:72:9: warning: unused variable 'gate_count' [-Wunused-variable]
   72 |     int gate_count = circuit(la, lb, operations, operands, outputs_circuit);
      |         ^~~~~~~~~~
/usr/bin/ld: /tmp/ccFwr2S8.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJ30oI9.o:abc.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status