Submission #637091

# Submission time Handle Problem Language Result Execution time Memory
637091 2022-08-31T13:17:09 Z Fidan Digital Circuit (IOI22_circuit) C++17
0 / 100
3000 ms 2097152 KB
#include <bits/stdc++.h>
#include "circuit.h"
using namespace std;
typedef int ll;
const ll mod=1000002022;
ll n, m;
vector<ll> p, a;
vector<vector<ll>> v;
vector<ll> k;
vector<ll> s;
vector<ll> pw((2e5)+10);
void init(int N, int M, vector<int> P, vector<int> A){
	n=N;
	m=M;
	for(ll i=0; i<n+m; i++){
		p.push_back(P[i]);
		a.push_back(A[i]);
	}
	v.resize(n+m);
	for(ll i=1; i<n+m; i++){
		v[p[i]].push_back(i);
	}
	k.resize(n+m);
	s.resize(n+m);
	pw[0]=1;
	for(ll i=1; i<(2e5)+10; i++){
		pw[i]=(pw[i-1]*2)%mod;
	}
}
void solve(int x){
	k[x]=0;
	if(x>=n){
		k[x]=a[x-n];
		s[x]=0;
		return;
	}
	solve(v[x][0]);
	solve(v[x][1]);
	k[x]=((k[v[x][0]]*pw[s[v[x][1]]])%mod+(k[v[x][1]]*pw[s[v[x][0]]])%mod)%mod;
	s[x]=s[v[x][0]]+s[v[x][1]]+1;
	return;
}
int count_ways(int l, int r){
	for(ll i=l-n; i<=r-n; i++){
		a[i]=1-a[i];
	}
	solve(0);
	return k[0];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 976 KB Output is correct
2 Runtime error 2083 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 976 KB Output is correct
2 Incorrect 2 ms 1104 KB 1st lines differ - on the 1st token, expected: '52130940', found: '-222605210'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 976 KB Output is correct
2 Runtime error 2083 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3017 ms 5440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3017 ms 5440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 976 KB Output is correct
2 Incorrect 2 ms 1104 KB 1st lines differ - on the 1st token, expected: '52130940', found: '-222605210'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 976 KB Output is correct
2 Runtime error 2083 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 976 KB Output is correct
2 Runtime error 2083 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -