Submission #546665

#TimeUsernameProblemLanguageResultExecution timeMemory
546665cig32Vision Program (IOI19_vision)C++17
Compilation error
0 ms0 KiB
// \ begin end. #include "bits/stdc++.h" using namespace std; const int MAXN = 2e5 + 10; const int MOD = 998244353; //#define int long long #define ll __int128 mt19937_64 rng((int)std::chrono::steady_clock::now().time_since_epoch().count()); int rnd(int x, int y) { int u = uniform_int_distribution<int>(x, y)(rng); return u; } ll read() { // read int128 int x; cin >> x; return (ll)x; } long long bm(long long b, long long p) { if(p==0) return 1 % MOD; long long r = bm(b, p >> 1); if(p&1) return (((r*r) % MOD) * b) % MOD; return (r*r) % MOD; } long long inv(long long b) { return bm(b, MOD-2); } long long f[MAXN]; long long nCr(int n, int r) { long long ans = f[n]; ans *= inv(f[r]); ans %= MOD; ans *= inv(f[n-r]); ans %= MOD; return ans; } void precomp() { for(int i=0; i<MAXN; i++) f[i] = (i == 0 ? 1 % MOD : (f[i-1] * i) % MOD); } void construct_network(int H, int W, int K); int add_and(std::vector<int> Ns); int add_or(std::vector<int> Ns); int add_xor(std::vector<int> Ns); int add_not(int N); static const int MAX_INSTRUCTIONS = 10000; static const int MAX_INPUTS = 1000000; static const int _AND = 0; static const int _OR = 1; static const int _XOR = 2; static const int _NOT = 3; static inline bool increasing(int a, int b, int c) { return a <= b && b <= c; } [[noreturn]] static inline void error(string message) { printf("%s\n", message.c_str()); exit(0); } class InstructionNetwork { struct Instruction { int type; vector<int> input_indexes; inline Instruction(int _type, const vector<int>& _input_indexes): type(_type), input_indexes(_input_indexes) { } inline int apply(int a, int b) const { switch (type) { case _AND: return a & b; case _OR: return a | b; case _XOR: return a ^ b; default: return 0; } } inline int compute(const vector<int>& memory_cells) const { int r = memory_cells[input_indexes[0]]; if (type == _NOT) return 1 - r; for (int j = 1; j < (int)input_indexes.size(); j++) r = apply(r, memory_cells[input_indexes[j]]); return r; } }; int input_size; int total_inputs; vector<Instruction> instructions; public: inline void init(int _input_size) { this->input_size = _input_size; this->total_inputs = 0; this->instructions.clear(); } inline int add_instruction(int type, const vector<int>& input_indexes) { if (input_indexes.size() == 0) error("Instruction with no inputs"); if (instructions.size() + 1 > MAX_INSTRUCTIONS) error("Too many instructions"); if (total_inputs + input_indexes.size() > MAX_INPUTS) error("Too many inputs"); instructions.emplace_back(type, input_indexes); total_inputs += input_indexes.size(); int new_index = input_size + (int)instructions.size() - 1; for (int input_index : input_indexes) if (!increasing(0, input_index, new_index-1)) error("Invalid index"); return new_index; } inline int compute(vector<int> &memory_cells) const { for (auto &instruction : instructions) memory_cells.push_back(instruction.compute(memory_cells)); return memory_cells.back(); } }; static InstructionNetwork instructionNetwork; int add_and(vector<int> Ns) { return instructionNetwork.add_instruction(_AND, Ns); } int add_or(vector<int> Ns) { return instructionNetwork.add_instruction(_OR, Ns); } int add_xor(vector<int> Ns) { return instructionNetwork.add_instruction(_XOR, Ns); } int add_not(int N) { vector<int> Ns = {N}; return instructionNetwork.add_instruction(_NOT, Ns); } void construct_network(int H, int W, int K) { std::vector<int> Ns; for(int i=0; i<H; i++) { for(int j=0; j<W; j++) { if(i+j == K) Ns.push_back(i*W + j); } } add_or(Ns); }

Compilation message (stderr)

vision.cpp:1:1: warning: multi-line comment [-Wcomment]
    1 | // \
      | ^
/usr/bin/ld: /tmp/ccPPEYM2.o: in function `add_and(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x150): multiple definition of `add_and(std::vector<int, std::allocator<int> >)'; /tmp/ccOjC1N2.o:vision.cpp:(.text+0xa70): first defined here
/usr/bin/ld: /tmp/ccPPEYM2.o: in function `add_or(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x170): multiple definition of `add_or(std::vector<int, std::allocator<int> >)'; /tmp/ccOjC1N2.o:vision.cpp:(.text+0xa90): first defined here
/usr/bin/ld: /tmp/ccPPEYM2.o: in function `add_xor(std::vector<int, std::allocator<int> >)':
grader.cpp:(.text+0x190): multiple definition of `add_xor(std::vector<int, std::allocator<int> >)'; /tmp/ccOjC1N2.o:vision.cpp:(.text+0xab0): first defined here
/usr/bin/ld: /tmp/ccPPEYM2.o: in function `add_not(int)':
grader.cpp:(.text+0x1b0): multiple definition of `add_not(int)'; /tmp/ccOjC1N2.o:vision.cpp:(.text+0xad0): first defined here
collect2: error: ld returned 1 exit status