Submission #611836

#TimeUsernameProblemLanguageResultExecution timeMemory
611836qwerasdfzxclSpace Pirate (JOI14_space_pirate)C++14
10 / 100
2072 ms2380 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int adj[100100], idx[100100]; ll ans[100100], t; void solve(int a, int b){ int org = adj[a]; adj[a] = b; vector<int> V = {0}; int i; ll cur = t, len = 0; for (i=1;;i=adj[i]){ if (idx[i]) {len = (int)V.size() - idx[i]; break;} V.push_back(i); idx[i] = (int)V.size()-1; --cur; } cur %= len; for (;cur;cur--){ i = adj[i]; } ans[i]++; for (auto &x:V) idx[x] = 0; adj[a] = org; } int main(){ int n; scanf("%d %lld", &n, &t); for (int i=1;i<=n;i++) scanf("%d", adj+i); for (int i=1;i<=n;i++){ for (int j=1;j<=n;j++) solve(i, j); } for (int i=1;i<=n;i++) printf("%lld\n", ans[i]); return 0; }

Compilation message (stderr)

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:36:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |     scanf("%d %lld", &n, &t);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
space_pirate.cpp:37:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |     for (int i=1;i<=n;i++) scanf("%d", adj+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...