답안 #126648

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
126648 2019-07-08T08:39:42 Z fjzzq2002 우주 해적 (JOI14_space_pirate) C++14
10 / 100
2000 ms 26568 KB
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
#include <assert.h>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,a[SZ]; ll k;
int go[64][SZ],cnt[SZ];
int cal()
{
	for(int i=1;i<=n;++i)
		go[0][i]=a[i];
	for(int i=1;i<64;++i)
		for(int j=1;j<=n;++j)
			go[i][j]=go[i-1][go[i-1][j]];
	int u=1;
	for(int i=61;i>=0;--i) if(k&(1LL<<i))
		u=go[i][u];
	return u;
}
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)
		{
			swap(a[i],j);
			++cnt[cal()];
			swap(a[i],j);
		}
	for(int i=1;i<=n;++i)
		printf("%d\n",cnt[i]);
}

Compilation message

space_pirate.cpp: In function 'int main()':
space_pirate.cpp:50: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:52:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",a+i);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 892 KB Output is correct
2 Correct 64 ms 888 KB Output is correct
3 Correct 64 ms 1016 KB Output is correct
4 Correct 64 ms 888 KB Output is correct
5 Correct 64 ms 888 KB Output is correct
6 Correct 65 ms 888 KB Output is correct
7 Correct 67 ms 892 KB Output is correct
8 Correct 66 ms 904 KB Output is correct
9 Correct 64 ms 888 KB Output is correct
10 Correct 65 ms 888 KB Output is correct
11 Correct 64 ms 908 KB Output is correct
12 Correct 67 ms 912 KB Output is correct
13 Correct 65 ms 908 KB Output is correct
14 Correct 66 ms 908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 892 KB Output is correct
2 Correct 64 ms 888 KB Output is correct
3 Correct 64 ms 1016 KB Output is correct
4 Correct 64 ms 888 KB Output is correct
5 Correct 64 ms 888 KB Output is correct
6 Correct 65 ms 888 KB Output is correct
7 Correct 67 ms 892 KB Output is correct
8 Correct 66 ms 904 KB Output is correct
9 Correct 64 ms 888 KB Output is correct
10 Correct 65 ms 888 KB Output is correct
11 Correct 64 ms 908 KB Output is correct
12 Correct 67 ms 912 KB Output is correct
13 Correct 65 ms 908 KB Output is correct
14 Correct 66 ms 908 KB Output is correct
15 Execution timed out 2047 ms 1528 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2021 ms 26568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 892 KB Output is correct
2 Correct 64 ms 888 KB Output is correct
3 Correct 64 ms 1016 KB Output is correct
4 Correct 64 ms 888 KB Output is correct
5 Correct 64 ms 888 KB Output is correct
6 Correct 65 ms 888 KB Output is correct
7 Correct 67 ms 892 KB Output is correct
8 Correct 66 ms 904 KB Output is correct
9 Correct 64 ms 888 KB Output is correct
10 Correct 65 ms 888 KB Output is correct
11 Correct 64 ms 908 KB Output is correct
12 Correct 67 ms 912 KB Output is correct
13 Correct 65 ms 908 KB Output is correct
14 Correct 66 ms 908 KB Output is correct
15 Execution timed out 2047 ms 1528 KB Time limit exceeded
16 Halted 0 ms 0 KB -