Submission #720378

#TimeUsernameProblemLanguageResultExecution timeMemory
720378ismayilDigital Circuit (IOI22_circuit)C++17
Compilation error
0 ms0 KiB
#include "circuit.h" #include <bits/stdc++.h> #define ll long long #define endl '\n' using namespace std; const int MAX = 3e3; const int MOD = 1000002022; ll dp[2][MAX]; vector<ll> adj[MAX]; ll n, m; void init(int N, int M, vector<int> P, vector<int> A) { n = N, m = M; memset(dp, 0, sizeof(dp)); for(int i = 0; i < N + M; i++){ if(P[i] == -1) continue; adj[P[i]].push_back(i); } for(int i = 0; i < M; i++){ dp[A[i]][i + n] = 1; } } void dfs(int u){ if(u >= n) return; ll l = -1, r = -1; for(auto v : adj[u]){ dfs(v); if(l == -1) l = v; else r = v; } if(l == -1 || r == -1) return; dp[0][u] = (dp[0][l] * dp[1][r] % MOD + dp[1][l] * dp[0][r] % MOD + 2 * dp[0][l] * dp[0][r] % MOD) % MOD; dp[1][u] = (dp[0][l] * dp[1][r] % MOD + dp[1][l] * dp[0][r] % MOD + 2 * dp[1][l] * dp[1][r] % MOD) % MOD; } int count_ways(int L, int R) { for(int i = L; i <= R; i++){ dp[0][i] = 1 - dp[0][i]; dp[1][i] = 1 - dp[1][i]; } dfs(0); return dp[1][0]; } int main(){ init(3, 4, {-1, 0, 1, 0, 1, 2, 2}, {0, 1, 1, 0}); cout<< count_ways(3, 6) << endl << flush; }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccCIJBlr.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccyGghGr.o:circuit.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status