이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define sz(a) (ll) a.size()
#define all(x) (x).begin(), (x).end()
vector<int> vist, nchild, pa;
set<int> call, tagged;
vector<vector<int>> child;
void pop(int nw){
if(nchild[nw]!=0 || nw==0) return;
tagged.erase(nw);
nchild[pa[nw]]--;
pop(pa[nw]);
}
int solve(int n, int m, std::vector<int> f, std::vector<std::vector<int>> s) {
int ans=0;
pa=f;
vist.assign(n, 0);
nchild.assign(n, 0);
call={}; tagged={};
child.assign(n, vector<int>(0));
for(int i=1; i<n; i++){
child[pa[i]].pb(i);
nchild[pa[i]]++;
}
for(int i=0; i<n-1; i++){
for(int j=0; j<m; j++){
vist[s[j][i]]++;
if(vist[s[j][i]]!=m){ call.insert(s[j][i]); continue; }
call.erase(s[j][i]);
if(nchild[s[j][i]]==0) pop(s[j][i]);
else tagged.insert(s[j][i]);
}
ans+=(tagged.empty() && call.empty());
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |