답안 #680908

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
680908 2023-01-12T02:50:47 Z AngusWong 디지털 회로 (IOI22_circuit) C++17
7 / 100
3000 ms 8136 KB
#include "circuit.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
using namespace std;

const ll mod=1000002022LL;
const ll N=2e5+9;
ll n, m, p[N], a[N];
pll dp[N];
vector<ll> v[N];

void init(int N, int M, vector<int> P, vector<int> A) {
	n=N, m=M;
	for (int i=0; i<n+m; i++) p[i]=P[i];
	for (int i=0; i<m; i++) a[i+n]=A[i];
	for (int i=1; i<n+m; i++) v[p[i]].push_back(i);
}

void dfs(ll x){
	if (x>=n){
		if (a[x]) dp[x]={1, 0};
		else dp[x]={0, 1};
		return;
	}
	for (ll i: v[x]) dfs(i);
	dp[x].f=(dp[v[x][0]].f*dp[v[x][1]].s%mod+dp[v[x][0]].s*dp[v[x][1]].f%mod+dp[v[x][0]].f*dp[v[x][1]].f*2%mod)%mod;
	dp[x].s=(dp[v[x][0]].f*dp[v[x][1]].s%mod+dp[v[x][0]].s*dp[v[x][1]].f%mod+dp[v[x][0]].s*dp[v[x][1]].s*2%mod)%mod;
}

int count_ways(int L, int R) {
	for (int i=L; i<=R; i++) a[i]^=1;
	dfs(0);
	return dp[0].f;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Incorrect 2 ms 4944 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 3 ms 5072 KB Output is correct
4 Correct 3 ms 5072 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5072 KB Output is correct
8 Correct 3 ms 5012 KB Output is correct
9 Correct 3 ms 5072 KB Output is correct
10 Correct 3 ms 5072 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Incorrect 2 ms 4944 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3097 ms 8136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 3097 ms 8136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Correct 2 ms 4944 KB Output is correct
3 Correct 3 ms 5072 KB Output is correct
4 Correct 3 ms 5072 KB Output is correct
5 Correct 3 ms 5072 KB Output is correct
6 Correct 3 ms 5072 KB Output is correct
7 Correct 3 ms 5072 KB Output is correct
8 Correct 3 ms 5012 KB Output is correct
9 Correct 3 ms 5072 KB Output is correct
10 Correct 3 ms 5072 KB Output is correct
11 Correct 3 ms 5072 KB Output is correct
12 Correct 3 ms 5072 KB Output is correct
13 Execution timed out 3097 ms 8136 KB Time limit exceeded
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Incorrect 2 ms 4944 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4944 KB Output is correct
2 Incorrect 2 ms 4944 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
3 Halted 0 ms 0 KB -