이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int N=3000;
int n;
ll k;
vector<int>graph(N+10);
vector<int>pairs(N+10);
int dfs(ll k, pair<int,int>pareja,int pos){
if(k<=0){
return pos;
}
if(pareja.first==pos){
return dfs(k-1,pareja,pareja.second);
}
return dfs(k-1,pareja, graph[pos]);
}
int main(){
cin >> n >> k;
for(int i=1;i<=n;i++){
int a; cin >> a;
graph[i]=a;
}
for(int x=1;x<=n;x++){
for(int y=1;y<=n;y++){
pairs[dfs(k,{x,y},1)]++;
}
}
for(int i=1;i<=n;i++){
cout<<pairs[i]<<endl;
}
}
# | 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... |