답안 #52248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
52248 2018-06-25T06:09:19 Z 윤교준(#1348) 우주 해적 (JOI14_space_pirate) C++11
10 / 100
2000 ms 784 KB
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
using namespace std;
typedef long long ll;

const int MAXN = 3005;

vector<int> G[MAXN];

ll Ans[MAXN];
int A[MAXN];

int chk[MAXN];

int N; ll K;

int f() {
	fill(chk, chk+N+1, -1);

	vector<int> V;
	int cs = -1;

	for(int idx = 1, c = 0;; c++) {
		chk[idx] = c;
		V.pb(idx);

		idx = A[idx];
		if(0 <= chk[idx]) {
			cs = chk[idx];
			break;
		}
	}

	return V[(K-cs) % (sz(V)-cs) + cs];
}

int main() {
	scanf("%d%lld", &N, &K);
	for(int i = 1; i <= N; i++) scanf("%d", &A[i]);

	for(int a = 1; a <= N; a++) for(int b = 1; b <= N; b++) {
		int __backup = A[a]; A[a] = b;
		Ans[f()]++;
		A[a] = __backup;
	}

	for(int i = 1; i <= N; i++)
		printf("%lld\n", Ans[i]);
	return 0;
}

Compilation message

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:45: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:46:35: 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 6 ms 376 KB Output is correct
2 Correct 9 ms 524 KB Output is correct
3 Correct 4 ms 524 KB Output is correct
4 Correct 9 ms 596 KB Output is correct
5 Correct 8 ms 604 KB Output is correct
6 Correct 8 ms 604 KB Output is correct
7 Correct 10 ms 604 KB Output is correct
8 Correct 8 ms 784 KB Output is correct
9 Correct 9 ms 784 KB Output is correct
10 Correct 8 ms 784 KB Output is correct
11 Correct 4 ms 784 KB Output is correct
12 Correct 16 ms 784 KB Output is correct
13 Correct 9 ms 784 KB Output is correct
14 Correct 8 ms 784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 9 ms 524 KB Output is correct
3 Correct 4 ms 524 KB Output is correct
4 Correct 9 ms 596 KB Output is correct
5 Correct 8 ms 604 KB Output is correct
6 Correct 8 ms 604 KB Output is correct
7 Correct 10 ms 604 KB Output is correct
8 Correct 8 ms 784 KB Output is correct
9 Correct 9 ms 784 KB Output is correct
10 Correct 8 ms 784 KB Output is correct
11 Correct 4 ms 784 KB Output is correct
12 Correct 16 ms 784 KB Output is correct
13 Correct 9 ms 784 KB Output is correct
14 Correct 8 ms 784 KB Output is correct
15 Execution timed out 2063 ms 784 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 10 ms 784 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 9 ms 524 KB Output is correct
3 Correct 4 ms 524 KB Output is correct
4 Correct 9 ms 596 KB Output is correct
5 Correct 8 ms 604 KB Output is correct
6 Correct 8 ms 604 KB Output is correct
7 Correct 10 ms 604 KB Output is correct
8 Correct 8 ms 784 KB Output is correct
9 Correct 9 ms 784 KB Output is correct
10 Correct 8 ms 784 KB Output is correct
11 Correct 4 ms 784 KB Output is correct
12 Correct 16 ms 784 KB Output is correct
13 Correct 9 ms 784 KB Output is correct
14 Correct 8 ms 784 KB Output is correct
15 Execution timed out 2063 ms 784 KB Time limit exceeded
16 Halted 0 ms 0 KB -