답안 #126647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126647 2019-07-08T08:36:55 Z fizzydavid 우주 해적 (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]);
                           ~~~~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 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
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2064 ms 25208 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -