# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1070149 | Unforgettablepl | 디지털 회로 (IOI22_circuit) | C++17 | 3043 ms | 2904 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "circuit.h"
#include <bits/stdc++.h>
using namespace std;
const long long modulo = 1e9+2022;
namespace {
int N,M;
vector<vector<int>> adj;
vector<int> A;
}
void init(int N,int M,vector<int> P,vector<int> A){
::N = N;
::M = M;
::A = move(A);
adj = vector<vector<int>>(N);
for(int i=1;i<N+M;i++)adj[P[i]].emplace_back(i);
}
int count_ways(int L,int R){
for(int i=L;i<=R;i++)A[i-N]^=1;
function<pair<long long,long long>(int)> dfs = [&](int x)->pair<long long,long long>{
if(x>=N) {
return {A[x-N],1};
}
long long tot_ways = adj[x].size();
vector<long long> DP(adj[x].size()+1);
DP[0]=1;
for(int&i:adj[x]) {
auto temp = dfs(i);
tot_ways*=temp.second;
tot_ways%=modulo;
long long bad_ways = (temp.second-temp.first+modulo)%modulo;
for(int j=adj[x].size();j>=0;j--) {
DP[j]*=bad_ways;
DP[j]%=modulo;
if(j)DP[j]+=temp.first*DP[j-1];
DP[j]%=modulo;
}
}
long long ans = 0;
for(long long i=1;i<=adj[x].size();i++) {
ans+=DP[i]*i;
ans%=modulo;
}
return {ans,tot_ways};
};
return dfs(0).first;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |