Submission #790012

#TimeUsernameProblemLanguageResultExecution timeMemory
790012AndreyDigital Circuit (IOI22_circuit)C++17
7 / 100
3093 ms18540 KiB
#include "circuit.h" #include<bits/stdc++.h> using namespace std; long long n,m; vector<long long> p2(300001); vector<long long> haha[300001]; vector<long long> st(300001); vector<long long> wow(300001); vector<long long> no(300001); const long long MOD = 1e9+2022; void dfs(long long a) { long long sb = 0; if(a < n) { sb = 1; } for(long long v: haha[a]) { dfs(v); sb+=st[v]; } st[a] = sb; } void dude(long long a) { if(!haha[a].empty()) { wow[haha[a][0]] = wow[a]+st[haha[a][1]]; wow[haha[a][1]] = wow[a]+st[haha[a][0]]; dude(haha[a][0]); dude(haha[a][1]); } } void init(int N, int M, vector<int> p, vector<int> a) { n = N; m = M; p2[0] = 1; for(long long i = 1; i < 300000; i++) { p2[i] = (p2[i-1]*2)%MOD; } for(long long i = 1; i < n+m; i++) { haha[p[i]].push_back(i); } dfs(0); dude(0); for(int i = 0; i < a.size(); i++) { no[i] = a[i]; } } int count_ways(int l, int r) { for(long long i = l-n; i <= r-n; i++) { if(no[i] == 1) { no[i] = 0; } else { no[i] = 1; } } long long sb = 0; for(long long i = 0; i < m; i++) { sb+=p2[wow[i+n]]*no[i]; sb%=MOD; } return sb; }

Compilation message (stderr)

circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:46:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i = 0; i < a.size(); i++) {
      |                    ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...