Submission #126647

# Submission time Handle Problem Language Result Execution time Memory
126647 2019-07-08T08:36:55 Z fizzydavid Space Pirate (JOI14_space_pirate) C++14
10 / 100
2000 ms 25208 KB
//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

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 time Memory Grader output
1 Correct 63 ms 632 KB Output is correct
2 Correct 61 ms 636 KB Output is correct
3 Correct 61 ms 760 KB Output is correct
4 Correct 61 ms 632 KB Output is correct
5 Correct 62 ms 632 KB Output is correct
6 Correct 62 ms 732 KB Output is correct
7 Correct 63 ms 632 KB Output is correct
8 Correct 63 ms 632 KB Output is correct
9 Correct 61 ms 616 KB Output is correct
10 Correct 61 ms 632 KB Output is correct
11 Correct 61 ms 632 KB Output is correct
12 Correct 62 ms 760 KB Output is correct
13 Correct 68 ms 632 KB Output is correct
14 Correct 61 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 632 KB Output is correct
2 Correct 61 ms 636 KB Output is correct
3 Correct 61 ms 760 KB Output is correct
4 Correct 61 ms 632 KB Output is correct
5 Correct 62 ms 632 KB Output is correct
6 Correct 62 ms 732 KB Output is correct
7 Correct 63 ms 632 KB Output is correct
8 Correct 63 ms 632 KB Output is correct
9 Correct 61 ms 616 KB Output is correct
10 Correct 61 ms 632 KB Output is correct
11 Correct 61 ms 632 KB Output is correct
12 Correct 62 ms 760 KB Output is correct
13 Correct 68 ms 632 KB Output is correct
14 Correct 61 ms 680 KB Output is correct
15 Execution timed out 2049 ms 1404 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2064 ms 25208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 63 ms 632 KB Output is correct
2 Correct 61 ms 636 KB Output is correct
3 Correct 61 ms 760 KB Output is correct
4 Correct 61 ms 632 KB Output is correct
5 Correct 62 ms 632 KB Output is correct
6 Correct 62 ms 732 KB Output is correct
7 Correct 63 ms 632 KB Output is correct
8 Correct 63 ms 632 KB Output is correct
9 Correct 61 ms 616 KB Output is correct
10 Correct 61 ms 632 KB Output is correct
11 Correct 61 ms 632 KB Output is correct
12 Correct 62 ms 760 KB Output is correct
13 Correct 68 ms 632 KB Output is correct
14 Correct 61 ms 680 KB Output is correct
15 Execution timed out 2049 ms 1404 KB Time limit exceeded
16 Halted 0 ms 0 KB -