Submission #126647

#TimeUsernameProblemLanguageResultExecution timeMemory
126647fizzydavidSpace Pirate (JOI14_space_pirate)C++14
10 / 100
2064 ms25208 KiB
//by yjz #include<bits/stdc++.h> #define FF first #define SS second #define MP make_pair #define PB push_back typedef long long ll; using namespace std; const int maxn = 100111; int n, a[maxn]; ll K; int go[60][maxn]; int ans[maxn]; int calc() { for (int i=1; i<60; i++) for (int j=1; j<=n; j++) go[i][j] = go[i-1][go[i-1][j]]; int x = 1; for (int i=0; i<60; i++) if ((K>>i)&1) x = go[i][x]; return x; } int main() { scanf("%d%lld", &n, &K); for (int i=1; i<=n; i++) scanf("%d", &a[i]); for (int i=1; i<=n; i++) { for (int j=1; j<=n; j++) { for (int k=1; k<=n; k++) { go[0][k] = k==i?j:a[k]; } ans[calc()]++; } } for (int i=1; i<=n; i++) printf("%d\n", ans[i]); return 0; }

Compilation message (stderr)

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%lld", &n, &K);
  ~~~~~^~~~~~~~~~~~~~~~~~
space_pirate.cpp:24:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1; i<=n; i++) scanf("%d", &a[i]);
                           ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...