Submission #997038

#TimeUsernameProblemLanguageResultExecution timeMemory
997038huutuanSeptember (APIO24_september)C++17
100 / 100
145 ms15164 KiB
#include "september.h" #include <vector> #include <bits/stdc++.h> using namespace std; const int N=1e5+10; bool is_equal[N], check[N], ss[N], vis[N]; int par[N], cnt[N]; int a[5][N], n, m; vector<int> g[N]; int solve(int N_, int M, vector<int> F, vector<vector<int>> S) { n=N_, m=M; for (int i=0; i<m; ++i) for (int j=1; j<n; ++j) a[i][j]=S[i][j-1]+1; for (int i=1; i<=n; ++i) par[i]=F[i-1]+1, g[par[i]].push_back(i); int sum=0; for (int i=1; i<n; ++i){ int u=a[0][i]; if (vis[par[u]]) --sum, ss[u]=0; for (int v:g[u]){ if (!vis[v]) ss[v]=1, ++sum; } vis[u]=1; check[i]=!sum; is_equal[i]=1; } for (int j=1; j<m; ++j){ sum=0; for (int i=1; i<n; ++i){ if (a[0][i]!=a[j][i]){ sum-=!!cnt[a[0][i]]; sum-=!!cnt[a[j][i]]; ++cnt[a[0][i]]; --cnt[a[j][i]]; sum+=!!cnt[a[0][i]]; sum+=!!cnt[a[j][i]]; } is_equal[i]&=!sum; } } int ans=0; for (int i=1; i<n; ++i) ans+=check[i] && is_equal[i]; for (int i=0; i<=n; ++i){ g[i].clear(); ss[i]=vis[i]=cnt[i]=0; } return ans; }

Compilation message (stderr)

september.cpp: In function 'int solve(int, int, std::vector<int>, std::vector<std::vector<int> >)':
september.cpp:47:26: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   47 |       ss[i]=vis[i]=cnt[i]=0;
      |                    ~~~~~~^~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...