Submission #770564

#TimeUsernameProblemLanguageResultExecution timeMemory
770564Essa2006Space Pirate (JOI14_space_pirate)C++14
10 / 100
2076 ms2464 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' #define FF first #define SS second #define all(a) a.begin(), a.end() #define mod (ll)(1000000007) ll n, k; vector<int>A, Ans; void pre(){ A.clear(), Ans.clear(); A.resize(n+1), Ans.resize(n+1); } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>k; pre(); for(int i=1;i<=n;i++){ cin>>A[i]; } vector<int>B=A; for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ B[i]=j; vector<int>Vis(n+1); int time_=1, cur=1; while(true){ if(Vis[cur]){ int lim=(k-time_+1)%(time_-Vis[cur]); for(int f=0;f<=lim;f++){ if(f==lim) Ans[cur]++; cur=B[cur]; } break; } Vis[cur]=time_++; cur=B[cur]; } } B[i]=A[i]; } for(int i=1;i<=n;i++){ cout<<Ans[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...