답안 #637091

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637091 2022-08-31T13:17:09 Z Fidan 디지털 회로 (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];
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3017 ms 5440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3017 ms 5440 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -