# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790010 | Andrey | Digital Circuit (IOI22_circuit) | C++17 | 3056 ms | 18412 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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; i <= r; 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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |