Submission #785796

#TimeUsernameProblemLanguageResultExecution timeMemory
785796AndreyDigital Circuit (IOI22_circuit)C++17
Compilation error
0 ms0 KiB
#include "circuit.h" #include<bits/stdc++.h> using namespace std; vector<int> haha[300001]; vector<long long> wut[300001]; vector<long long> bruh(300001); vector<long long> dp(300001); vector<long long> prod(300001); const long long MOD = 1e9+2022; long long n,m; void dfs(long long a, long long t) { long long br = 0,pr = 1,sb = 0,yeah = 0; for(long long i = 0; i < wut[a].size(); i++) { if(bruh[wut[a][i]]) { br++; } yeah++; } for(v: haha[a]) { if(v != t) { dfs(v,a); sb = (sb*prod[v]+dp[v]*pr)%MOD; pr*=prod[v]; pr%=MOD; yeah++; } } prod[a] = (pr*yeah)%MOD; dp[a] = (sb+br*pr)%MOD; } void init(int N, int M, vector<int> p, vector<int> a) { n = N; m = M; for(long long i = n; i < n+m; i++) { bruh[i] = a[i-n]; } for(long long i = 1; i < n; i++) { haha[i].push_back(p[i]); haha[p[i]].push_back(i); } for(long long i = n; i < n+m; i++) { wut[p[i]].push_back(i); } } int count_ways(int l, int r) { for(long long i = l; i <= r; i++) { if(bruh[i]) { bruh[i] = 0; } else { bruh[i] = 1; } } dfs(0,-1); return dp[0]; }

Compilation message (stderr)

circuit.cpp: In function 'void dfs(long long int, long long int)':
circuit.cpp:15:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(long long i = 0; i < wut[a].size(); i++) {
      |                          ~~^~~~~~~~~~~~~~~
circuit.cpp:21:10: error: found ':' in nested-name-specifier, expected '::'
   21 |     for(v: haha[a]) {
      |          ^
      |          ::
circuit.cpp:21:9: error: 'v' has not been declared
   21 |     for(v: haha[a]) {
      |         ^
circuit.cpp:30:13: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   30 |     prod[a] = (pr*yeah)%MOD;
circuit.cpp:31:27: error: expected ')' before ';' token
   31 |     dp[a] = (sb+br*pr)%MOD;
      |                           ^
      |                           )
circuit.cpp:21:8: note: to match this '('
   21 |     for(v: haha[a]) {
      |        ^