Submission #751598

#TimeUsernameProblemLanguageResultExecution timeMemory
751598boyliguanhanAlice, Bob, and Circuit (APIO23_abc)C++17
Compilation error
0 ms0 KiB
#include "abc.h" #include<bits/stdc++.h> using namespace std; // you may find the definitions useful const int ZERO = 0; // f(ZERO, x0, x1) = 0 const int NOR = 1; // f(NOR, x0, x1) = !(x0 || x1) const int GREATER = 2; // f(GREATER, x0, x1) = (x0 > x1) const int NOT_X1 = 3; // f(NOT_X1, x0, x1) = !x1 const int LESS = 4; // f(LESS, x0, x1) = (x0 < x1) const int NOT_X0 = 5; // f(NOT_X0, x0, x1) = !x0 const int XOR = 6; // f(XOR, x0, x1) = (x0 ^ x1) const int NAND = 7; // f(NAND, x0, x1) = !(x0 && x1) const int AND = 8; // f(AND, x0, x1) = (x0 && x1) const int EQUAL = 9; // f(EQUAL, x0, x1) = (x0 == x1) const int X0 = 10; // f(X0, x0, x1) = x0 const int GEQ = 11; // f(GEQ, x0, x1) = (x0 >= x1) const int X1 = 12; // f(X1, x0, x1) = x1 const int LEQ = 13; // f(LEQ, x0, x1) = (x0 <= x1) const int OR = 14; // f(OR, x0, x1) = (x0 || x1) const int ONE = 15; // f(ONE, x0, x1) = 1 #define circ(a,b,c) op1[l] = a, op2[l][0] = b, op2[l][1] = c, l++; int alices, bobs; vector<vector<pair<char, int>>> al; vector<vector<pair<char,char>>> bo; // Alice int // returns la alice( /* in */ const int n, /* in */ const char names[][5], /* in */ const unsigned short numbers[], /* out */ bool outputs_alice[] ) { for(int j = 0; j < 26; j++) for(int i = 0; i < 16; i++) outputs_alice[j*16+i] = (bool)(numbers[j]&1<<i); map<char[5], int> mp; for(int i = 0; i < n; i++) mp[names[i]]; int x = 0; for(auto &i: mp) i.second = x++; int l = 16*26; for(int i = 0; i < n; i++) { for(int j = 0; j < 5; j++) outputs_alice[l++] = mp[names[i]]&1<<j; } 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[] ) { map<char[5], int> mp; for(int i = 0; i < m; i++) mp[senders[i]], mp[recipients[i]]; int x = 0; for(auto &i: mp) i.second = x++; int out[26][26]{}; for(int i = 0; i < m; i++) out[mp[recipients[i]]][mp[senders[i]]] = 1; for(int i = 0; i < 676; i++) outputs_bob[i] = out[i/26][i%26]; return 676; } void xxx(){} // for debug purposes only (like a conditional breakpoint) void shift(int src, int &l, int op1[], int op2[][2]){ op1[l] = ZERO, op2[l][0] = 1, op2[l][1] = 2; l++; for(int i = 0; i < 15; i++) circ(X0, src+i,0); } int add(int a, int b, int &l, int shifts, int op1[], int op2[][2]) { if(!shifts) return a; int pos1 = l, pos2 = l+16; for(int i = 0; i < 16; i++) circ(XOR, a+i, b+i); if(l>=241) xxx(); for(int i = 0; i < 16; i++) circ(AND, a+i, b+i); if(l>=241) xxx(); pos2 = l; shift(pos2-16, l, op1, op2); if(l>=241) xxx(); return add(pos1, pos2, l, shifts-1, op1, op2); } // Circuit int // returns l circuit( /* in */ const int la, /* in */ const int lb, /* out */ int op1[], /* out */ int op2[][2], /* out */ int outputs_circuit[][16] ) { int l = la+lb, pl = l; vector<int> results; for(int i = 0; i < 26; i++) { for(int j = 0; j < 26; j++) for(int k = 0; k < 16; k++) circ(AND, la+i*26+j, j*16+k); int res = pl; for(int j = 1; j < 26; j++) res = add(res, pl+j*16, l, 16, op1, op2); for(int j = 0; j < 16; j++) outputs_circuit[i][j] = res+j; pl=l; } return l; }

Compilation message (stderr)

In file included from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from abc.cpp:2:
/usr/include/c++/10/tuple: In instantiation of 'std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>) [with _Args1 = {const char (&)[5]}; long unsigned int ..._Indexes1 = {0}; _Args2 = {}; long unsigned int ..._Indexes2 = {}; _T1 = const char [5]; _T2 = int]':
/usr/include/c++/10/tuple:1678:63:   required from 'std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>) [with _Args1 = {const char (&)[5]}; _Args2 = {}; _T1 = const char [5]; _T2 = int]'
/usr/include/c++/10/ext/new_allocator.h:150:4:   required from 'void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<const char [5], int>; _Args = {const std::piecewise_construct_t&, std::tuple<const char (&)[5]>, std::tuple<>}; _Tp = std::_Rb_tree_node<std::pair<const char [5], int> >]'
/usr/include/c++/10/bits/alloc_traits.h:512:17:   required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<const char [5], int>; _Args = {const std::piecewise_construct_t&, std::tuple<const char (&)[5]>, std::tuple<>}; _Tp = std::_Rb_tree_node<std::pair<const char [5], int> >; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::_Rb_tree_node<std::pair<const char [5], int> > >]'
/usr/include/c++/10/bits/stl_tree.h:618:32:   required from 'void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const char (&)[5]>, std::tuple<>}; _Key = char [5]; _Val = std::pair<const char [5], int>; _KeyOfValue = std::_Select1st<std::pair<const char [5], int> >; _Compare = std::less<char [5]>; _Alloc = std::allocator<std::pair<const char [5], int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const char [5], int> >*]'
/usr/include/c++/10/bits/stl_tree.h:635:21:   required from 'std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const char (&)[5]>, std::tuple<>}; _Key = char [5]; _Val = std::pair<const char [5], int>; _KeyOfValue = std::_Select1st<std::pair<const char [5], int> >; _Compare = std::less<char [5]>; _Alloc = std::allocator<std::pair<const char [5], int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const char [5], int> >*]'
/usr/include/c++/10/bits/stl_tree.h:2461:33:   required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const char (&)[5]>, std::tuple<>}; _Key = char [5]; _Val = std::pair<const char [5], int>; _KeyOfValue = std::_Select1st<std::pair<const char [5], int> >; _Compare = std::less<char [5]>; _Alloc = std::allocator<std::pair<const char [5], int> >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree<char [5], std::pair<const char [5], int>, std::_Select1st<std::pair<const char [5], int> >, std::less<char [5]>, std::allocator<std::pair<const char [5], int> > >::iterator; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree<char [5], std::pair<const char [5], int>, std::_Select1st<std::pair<const char [5], int> >, std::less<char [5]>, std::allocator<std::pair<const char [5], int> > >::const_iterator]'
/usr/include/c++/10/bits/stl_map.h:501:37:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = char [5]; _Tp = int; _Compare = std::less<char [5]>; _Alloc = std::allocator<std::pair<const char [5], int> >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = int; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = char [5]]'
abc.cpp:38:20:   required from here
/usr/include/c++/10/tuple:1689:70: error: array used as initializer
 1689 |         second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
      |                                                                      ^