Submission #991522

#TimeUsernameProblemLanguageResultExecution timeMemory
991522Nika533September (APIO24_september)C++17
59 / 100
154 ms22364 KiB
#pragma GCC diagnostic warning "-std=c++11" #include <bits/stdc++.h> #define pb push_back #define f first #define s second #define MOD 1000000007 #define flush fflush(stdout) #define all(x) (x).begin(),(x).end() #define allr(x) (x).rbegin(), (x).rend() #define pii pair<int,int> using namespace std; const int N=1e5+5,M=15; int T,k,sz[N][M],p[N][M]; vector<int> g[N]; void make_set(int v, int t) { p[v][t]=v; sz[v][t]=1; } int find_set(int v, int t) { if (p[v][t]==v) return v; return p[v][t]=find_set(p[v][t],t); } void merge(int a, int b, int t) { a=find_set(a,t); b=find_set(b,t); if (a==b) return; if (sz[a][t]<sz[b][t]) swap(a,b); sz[a][t]+=sz[b][t]; p[b][t]=a; } void add_edges(int v, int t) { for (auto u:g[v]) if (p[u][t]>=0) merge(u,v,t); } int solve(int n, int m, vector<int> F,vector<vector<int>> S) { for (int i=0; i<n; i++) { for (int j=0; j<m; j++) p[i][j]=-1; g[i].clear(); } for (int i=1; i<n; i++) { g[i].pb(F[i]); g[F[i]].pb(i); } int ans=0; for (int i=0; i<m; i++) make_set(0,i); for (int i=n-2; i>=0; i--) { bool check=1; for (int j=0; j<m; j++) { int x=S[j][i]; make_set(x,j); add_edges(x,j); if (sz[find_set(x,j)][j]!=n-i) check=0; } if (check) ans++; } return ans; }

Compilation message (stderr)

september.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
#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...