답안 #637141

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
637141 2022-08-31T16:15:03 Z Fidan 디지털 회로 (IOI22_circuit) C++17
7 / 100
3000 ms 2097152 KB
#include <bits/stdc++.h>
#include "circuit.h"
using namespace std;
typedef long long 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(2010);
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<2010; 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 int(k[0]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 2203 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 2203 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 5716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3048 ms 5716 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 1 ms 464 KB Output is correct
9 Correct 1 ms 464 KB Output is correct
10 Correct 1 ms 464 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Execution timed out 3048 ms 5716 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 2203 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Runtime error 2203 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -