# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
697351 | 2023-02-09T12:09:51 Z | FEDIKUS | Digital Circuit (IOI22_circuit) | C++17 | 16 ms | 7556 KB |
#include "circuit.h" #include<bits/stdc++.h> #include <vector> using namespace std; typedef long long ll; const int maxn=2e5+10; const int mod=1e9+2022; int n,m; vector<int> g[maxn]; vector<int> p,a; int add(int a,int b){ return (a+b)%mod; } int mul(int a,int b){ return ll(a)*ll(b)%mod; } int bruk[maxn]; int power[maxn]; void dfs(int node){ bruk[node]=1; if(node<n) bruk[node]=mul(bruk[node],g[node].size()); for(int i:g[node]){ dfs(i); bruk[node]=mul(bruk[node],bruk[i]); } } void dfs2(int node,int tren){ if(node>=n){ power[node-n]=tren; return; } vector<int> pref(g[node].size()); vector<int> suf(g[node].size()); for(int i=0;i<(int)g[node].size();i++){ if(i==0) pref[i]=bruk[g[node][i]]; else pref[i]=mul(pref[i-1],bruk[g[node][i]]); } for(int i=(int)g[node].size()-1;i>=0;i--){ if(i==(int)g[node].size()-1) suf[i]=bruk[g[node][i]]; else suf[i]=mul(suf[i+1],bruk[g[node][i]]); } for(int i=0;i<(int)g[node].size();i++){ int ntren=tren; if(i>0) ntren=mul(ntren,pref[i-1]); if(i<(int)g[node].size()-1) ntren=mul(ntren,suf[i+1]); dfs2(g[node][i],ntren); } } void init(int N,int M, vector<int> P, vector<int> A) { n=N; m=M; p=P; a=A; for(int i=1;i<n+m;i++) g[p[i]].push_back(i); dfs(0); dfs2(0,1); for(int i=0;i<m;i++) cout<<power[i]<<" "; cout<<"\n"; for(int i=0;i<n+m;i++) cout<<bruk[i]<<" "; cout<<"\n"; } int count_ways(int L, int R) { L-=n; R-=n; for(int i=L;i<=R;i++) a[i]=!a[i]; int ret=0; for(int i=0;i<m;i++) if(a[i]) ret=add(ret,power[i]); return ret; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4944 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4944 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4944 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 16 ms | 7556 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 16 ms | 7556 KB | Execution killed with signal 13 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4944 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4944 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4944 KB | Possible tampering with the output or unexpected termination of the program |
2 | Halted | 0 ms | 0 KB | - |