Submission #110775

# Submission time Handle Problem Language Result Execution time Memory
110775 2019-05-12T08:09:55 Z autumn_eel Space Pirate (JOI14_space_pirate) C++14
10 / 100
61 ms 512 KB
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
typedef long long ll;

int a[200000];
int ans[200000];

int main(){
	int n;ll K;cin>>n>>K;
	if(n>100)abort();
	rep(i,n){
		scanf("%d",&a[i]);a[i]--;
	}
	rep(i,n){
		int p=a[i];
		rep(j,n){
			a[i]=j;
			int x=0,cnt=0;
			map<int,int>mp;
			mp[x]=0;
			int b=-1;
			while(cnt<K){
				x=a[x];
				cnt++;
				if(mp.count(x)){
					b=cnt-mp[x];
					break;
				}
				else mp[x]=cnt;
			}
			ll d=(K-cnt)%b;
			rep(k,d)x=a[x];
			ans[x]++;
		}
		a[i]=p;
	}
	rep(i,n){
		printf("%d\n",ans[i]);
	}
}

Compilation message

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&a[i]);a[i]--;
   ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 13 ms 440 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 61 ms 256 KB Output is correct
5 Correct 39 ms 412 KB Output is correct
6 Correct 33 ms 384 KB Output is correct
7 Correct 61 ms 376 KB Output is correct
8 Correct 49 ms 256 KB Output is correct
9 Correct 52 ms 256 KB Output is correct
10 Correct 41 ms 384 KB Output is correct
11 Correct 4 ms 356 KB Output is correct
12 Correct 45 ms 384 KB Output is correct
13 Correct 36 ms 372 KB Output is correct
14 Correct 31 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 13 ms 440 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 61 ms 256 KB Output is correct
5 Correct 39 ms 412 KB Output is correct
6 Correct 33 ms 384 KB Output is correct
7 Correct 61 ms 376 KB Output is correct
8 Correct 49 ms 256 KB Output is correct
9 Correct 52 ms 256 KB Output is correct
10 Correct 41 ms 384 KB Output is correct
11 Correct 4 ms 356 KB Output is correct
12 Correct 45 ms 384 KB Output is correct
13 Correct 36 ms 372 KB Output is correct
14 Correct 31 ms 384 KB Output is correct
15 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 256 KB Output is correct
2 Correct 13 ms 440 KB Output is correct
3 Correct 4 ms 512 KB Output is correct
4 Correct 61 ms 256 KB Output is correct
5 Correct 39 ms 412 KB Output is correct
6 Correct 33 ms 384 KB Output is correct
7 Correct 61 ms 376 KB Output is correct
8 Correct 49 ms 256 KB Output is correct
9 Correct 52 ms 256 KB Output is correct
10 Correct 41 ms 384 KB Output is correct
11 Correct 4 ms 356 KB Output is correct
12 Correct 45 ms 384 KB Output is correct
13 Correct 36 ms 372 KB Output is correct
14 Correct 31 ms 384 KB Output is correct
15 Runtime error 3 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Halted 0 ms 0 KB -