답안 #824313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824313 2023-08-14T01:31:33 Z vjudge1 디지털 회로 (IOI22_circuit) C++17
2 / 100
9 ms 2000 KB
#include "circuit.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> adj[1010];
int state[1010], n, m;
void init(int N, int M, vector<int> P, vector<int> A) {
  n=N;
  m=M;
  for(int i = 0; i < M; i++)
    state[i+N] = A[i];
  for(int i = 1; i < n+m; i++)
    adj[P[i]].push_back(i);
}
pair<long long, long long> dfs(int N) {
  if(N>=n) {
    return {!state[N], state[N]};
  }
  long long dp[1+adj[N].size()]{}, c = adj[N].size();
  dp[0] = 1;
  for(auto i: adj[N]) {
    int a, b;
    tie(a,b)=dfs(i);
    for(int  j= c+1; --j;)
      dp[j] = (a*dp[j]+b*dp[j-1])%1000002022;
    dp[0] = dp[0]*a%1000002022;
  }
  long long ans1=0, ans2=0;
  for(int i = 0; i <= c; i++)
    ans1+=(c-i)*dp[i], ans2+=i*dp[i];
  return {ans1%1000002022, ans2%1000002022};
}
int count_ways(int L, int R) {
  for(int i = L; i <= R; i++) {
    state[i]^=1;
  }
  return dfs(0).second;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 8 ms 336 KB Output is correct
6 Correct 8 ms 336 KB Output is correct
7 Correct 8 ms 336 KB Output is correct
8 Correct 9 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Runtime error 1 ms 464 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 8 ms 336 KB Output is correct
6 Correct 8 ms 336 KB Output is correct
7 Correct 8 ms 336 KB Output is correct
8 Correct 9 ms 336 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Runtime error 1 ms 464 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 2000 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 2000 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 0 ms 336 KB Output is correct
3 Runtime error 1 ms 464 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 8 ms 336 KB Output is correct
6 Correct 8 ms 336 KB Output is correct
7 Correct 8 ms 336 KB Output is correct
8 Correct 9 ms 336 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Runtime error 1 ms 464 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 8 ms 336 KB Output is correct
4 Correct 9 ms 336 KB Output is correct
5 Correct 8 ms 336 KB Output is correct
6 Correct 8 ms 336 KB Output is correct
7 Correct 8 ms 336 KB Output is correct
8 Correct 9 ms 336 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 336 KB Output is correct
11 Runtime error 1 ms 464 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -