Submission #997036

#TimeUsernameProblemLanguageResultExecution timeMemory
997036huutuanSeptember (APIO24_september)C++17
0 / 100
1 ms4700 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]; return ans; }
#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...