제출 #993523

#제출 시각아이디문제언어결과실행 시간메모리
993523AMel0n9월 (APIO24_september)C++17
0 / 100
1 ms348 KiB
#include "september.h" #include <bits/stdc++.h> using namespace std; #define endl '\n' #define rep(a) for(int i=0;i<a;++i) #define ll long long #define vi vector<int> //#define S[j][i] S[0][i] // two pointers? int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) { vi CHILDREN(N); vector<bool> LEAVES(N); for(int i=1; i<N; ++i) { CHILDREN[P[i]]++; } rep(N){ if (CHILDREN[i]==0) LEAVES[i] = true; } int res =INT_MAX; for (int j =0; j < M; ++j) { int tempres = 0; int BCNTR = 0; vi C = CHILDREN; vector<bool> L=LEAVES; vector<bool> B(N,false); rep(N-1) { if (L[S[j][i]]) { C[P[S[j][i]]]--; //cout << "IS LEAF "<<S[j][i] << endl; if (C[P[S[j][i]]] == 0 && B[P[S[j][i]]]== true) { B[P[S[j][i]]] = false; BCNTR--; //cout << "RMV BRANCH " << P[S[j][i]] << endl; } else if (C[P[S[j][i]]]==0 && B[P[S[j][i]]]==false) { L[P[S[j][i]]] = true; //cout << "ADD LEAF " << P[S[j][i]]<< endl; } } else { B[S[j][i]] = true; BCNTR++; //cout << "ADD BRANCH " << S[j][i]<<endl; } if(BCNTR==0) { tempres++; //cout << "RES++" << endl; } } res = min(tempres, res); } return res; }
#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...