제출 #1204213

#제출 시각아이디문제언어결과실행 시간메모리
1204213ByeWorld9월 (APIO24_september)C++20
0 / 100
36 ms7492 KiB
#include "september.h" #include <bits/stdc++.h> // #pragma GCC optimize("O3", "unroll-loops") #define ll long long #define pb push_back #define fi first #define se second #define lf (id<<1) #define rg ((id<<1)|1) #define md ((l+r)>>1) #define ld long double using namespace std; typedef pair<ll,ll> pii; typedef pair<pii,ll> ipii; const ll MAXN = 3e5+10; const ll MOD = 1000000; const ll INF = 1e9+10; const ll SQRT = 6500; const ll BL = INF/SQRT+1; ll sum(auto a, auto b){ return (a+MOD+b)%MOD; } mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n, m; int par[MAXN]; vector<int> adj[MAXN]; int arr[7][MAXN]; bool done[MAXN]; set <int> tag; void dfs(int nw){ // cout << nw << " nw\n"; done[nw] = 1; tag.insert(nw); for(auto nx : adj[nw]){ if(nx == par[nw] || done[nx]) continue; dfs(nx); } } void RESET(){ tag.clear(); for(int i=0; i<=n; i++){ done[i] = 0; adj[i].clear(); } } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { n = N; m = M; for(int i=2; i<=n; i++){ par[i] = F[i-2]+1; adj[par[i]].pb(i); } for(int i=1; i<=m; i++){ for(int j=1; j<=n-1; j++){ arr[i][j] = S[i-1][j-1]+1; } } int tot = 0; for(int i=1; i<=n-1; ){ // cout << i << ' ' << arr[1][i] << " arr\n"; tot++; dfs(arr[1][i]); while(!tag.empty()){ tag.erase(arr[1][i]); i++; } } RESET(); return tot; }
#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...