제출 #1078122

#제출 시각아이디문제언어결과실행 시간메모리
1078122pccDigital Circuit (IOI22_circuit)C++17
46 / 100
3034 ms12880 KiB
#include "circuit.h" #include <vector> #include <bits/stdc++.h> #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,popcnt,sse4") using namespace std; #define ll long long #define pll pair<ll,ll> #define fs first #define sc second const int mxn = 2e5+10; const ll mod = 1000002022; vector<int> tree[mxn]; int par[mxn]; int N,M; ll dp[mxn]; ll sz[mxn]; ll arr[mxn]; ll mad(ll a,ll b){ a += b; return a>=mod?a-mod:a; } ll mub(ll a,ll b){ return mad(a,mod-b); } ll pw(ll a,ll b){ ll re = 1; while(b){ if(b&1)re = re*a%mod; b>>=1; a = a*a%mod; } return re; } void dfs(int now){ dp[now] = sz[now] = 1; for(auto nxt:tree[now]){ dfs(nxt); sz[now] = sz[nxt]*sz[now]%mod; } if(tree[now].size())sz[now] = sz[now]*tree[now].size()%mod; return; } void dfs1(int now){ ll sum = 0; vector<ll> suf; for(auto nxt:tree[now]){ suf.push_back(sz[nxt]); } suf.push_back(1); for(int i = (int)suf.size()-2;i>=0;i--)suf[i] = suf[i+1]*suf[i]%mod; ll pref = 1; for(int i = 0;i<tree[now].size();i++){ int nxt = tree[now][i]; ll ts = pref*suf[i+1]%mod; dp[nxt] = dp[now]*ts%mod; dfs1(nxt); pref = pref*sz[nxt]%mod; } return; } void init(int N1, int M1, std::vector<int> P, std::vector<int> A) { N = N1,M = M1; for(int i = 1;i<N+M;i++){ par[i] = P[i]; tree[par[i]].push_back(i); } for(int i = 0;i<M;i++){ arr[i+N] = A[i]; } dfs(0); dfs1(0); cerr<<"SZ: "; for(int i = 0;i<N+M;i++)cerr<<sz[i]<<' ';cerr<<endl; cerr<<"DP: "; for(int i = 0;i<N+M;i++)cerr<<dp[i]<<' ';cerr<<endl; /* */ //for(int i = 0;i<N+M;i++)cerr<<dp[i][0]<<','<<dp[i][1]<<' ';cerr<<endl; } int count_ways(int L, int R) { for(int i = L;i<=R;i++){ arr[i] ^= 1; } //cerr<<"NOW: ";for(int i = N;i<N+M;i++)cerr<<arr[i]<<' ';cerr<<endl; ll ans = 0; for(int i = N;i<N+M;i++)ans = mad(ans,dp[i]*arr[i]%mod); return ans; //dfs(0); //cerr<<"NOW: "; //for(int i = N;i<N+M;i++)cerr<<(dp[i][0]?0:1);cerr<<endl; }

컴파일 시 표준 에러 (stderr) 메시지

circuit.cpp: In function 'void dfs1(int)':
circuit.cpp:61:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |  for(int i = 0;i<tree[now].size();i++){
      |                ~^~~~~~~~~~~~~~~~~
circuit.cpp:53:5: warning: unused variable 'sum' [-Wunused-variable]
   53 |  ll sum = 0;
      |     ^~~
circuit.cpp: In function 'void init(int, int, std::vector<int>, std::vector<int>)':
circuit.cpp:83:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   83 |  for(int i = 0;i<N+M;i++)cerr<<sz[i]<<' ';cerr<<endl;
      |  ^~~
circuit.cpp:83:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   83 |  for(int i = 0;i<N+M;i++)cerr<<sz[i]<<' ';cerr<<endl;
      |                                           ^~~~
circuit.cpp:85:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   85 |  for(int i = 0;i<N+M;i++)cerr<<dp[i]<<' ';cerr<<endl;
      |  ^~~
circuit.cpp:85:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   85 |  for(int i = 0;i<N+M;i++)cerr<<dp[i]<<' ';cerr<<endl;
      |                                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...