Submission #1063454

#TimeUsernameProblemLanguageResultExecution timeMemory
1063454vjudge1Space Pirate (JOI14_space_pirate)C++17
0 / 100
2039 ms1116 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...