#include <vector>
#include<bits/stdc++.h>
#include "circuit.h"
using namespace std;
#define vi vector<int>
#define vii vector<vi>
#define ll long long
#define vl vector<ll>
int n,m;
vii g;
vl ways;
vl wb;
int mod=1000002022;
void init(int N, int M, std::vector<int> P, std::vector<int> A) {
n=N;
m=M;
g.resize(N+M);
ways.resize(M+N);
wb.resize(M+N);
for(int i=1 ;i<N+M;i++){
g[P[i]].push_back(i);
}
for(int i=N;i<N+M;i++){
ways[i]=A[i-N];
wb[i]=!ways[i];
}
}
void dfs(int node){
if(g[node].size()==0)return;
dfs(g[node][0]);
dfs(g[node][1]);
ways[node]=2*ways[g[node][0]]*ways[g[node][1]]+ways[g[node][1]]*wb[g[node][0]]+ways[g[node][0]]*wb[g[node][1]];
wb[node]=2*wb[g[node][0]]*wb[g[node][1]]+ways[g[node][1]]*wb[g[node][0]]+ways[g[node][0]]*wb[g[node][1]];
ways[node]%=mod;
wb[node]%=mod;
}
int count_ways(int L, int R) {
for(int i=L;i<=R;i++){
ways[i]=!ways[i];
wb[i]=!wb[i];
}
dfs(0);
return ways[0];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Runtime error |
1200 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
0 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 |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 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 |
1200 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3067 ms |
4688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3067 ms |
4688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
336 KB |
Output is correct |
4 |
Correct |
0 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 |
336 KB |
Output is correct |
8 |
Correct |
1 ms |
336 KB |
Output is correct |
9 |
Correct |
1 ms |
336 KB |
Output is correct |
10 |
Correct |
1 ms |
336 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
13 |
Execution timed out |
3067 ms |
4688 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Runtime error |
1200 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 |
1200 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |