Submission #25819

# Submission time Handle Problem Language Result Execution time Memory
25819 2017-06-24T08:43:45 Z 김현수(#1080) Space Pirate (JOI14_space_pirate) C++11
10 / 100
3 ms 2020 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, a[105], ans[105], vis[105];

ll sim () {
	ll i = 1, j = k, cur = 1;
	if(j > n) {
		for(ll x=1;x<=n;x++) vis[x] = false;
		for(;!vis[i];i=a[i],cur++) vis[i] = cur;
		j -= vis[i] - 1;
		j %= (cur - vis[i]);
	}
	for(;j--;i=a[i]);
	return i;
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++) {
		for(int j=1;j<=n;j++) {
			int T = a[i];
			a[i] = j;
			ans[sim()]++;
			a[i] = T;
		}
	}
	for(int i=1;i<=n;i++) {
		printf("%lld\n",ans[i]);
	}
}

Compilation message

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:20:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld",&n,&k);
                         ^
space_pirate.cpp:21:43: 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("%lld",&a[i]);
                                           ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2020 KB Output is correct
2 Correct 0 ms 2020 KB Output is correct
3 Correct 0 ms 2020 KB Output is correct
4 Correct 3 ms 2020 KB Output is correct
5 Correct 3 ms 2020 KB Output is correct
6 Correct 0 ms 2020 KB Output is correct
7 Correct 3 ms 2020 KB Output is correct
8 Correct 0 ms 2020 KB Output is correct
9 Correct 0 ms 2020 KB Output is correct
10 Correct 0 ms 2020 KB Output is correct
11 Correct 0 ms 2020 KB Output is correct
12 Correct 0 ms 2020 KB Output is correct
13 Correct 0 ms 2020 KB Output is correct
14 Correct 0 ms 2020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed because of forbidden syscall futex (202)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 2020 KB Execution killed because of forbidden syscall futex (202)
2 Halted 0 ms 0 KB -