Submission #2402829


Source Code Expand

#include <stdio.h>
#include <stdlib.h>

int *pro(int N, int *p, int *q){
	int i;
	int *ans = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		ans[i] = q[p[i]];
	}
	return ans;
}

int *power(int N, int *p, int K){
	if(K == 1){
		return p;
	}
	else if(K % 2 == 0){
		return power(N, pro(N, p, p), K / 2);
	}
	else{
		return pro(N, p, power(N, p, K - 1));
	}
}

int main(){
	int N, M, D, A, i, tmp;
	scanf("%d%d%d", &N, &M, &D);
	int *p = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		p[i] = i;
	}
	for(i = 0; i < M; i++){
		scanf("%d", &A);
		tmp = p[A - 1];
		p[A - 1] = p[A];
		p[A] = tmp;
	}
	p = power(N, p, D);
	int *ans = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		ans[p[i]] = i + 1;
	}
	for(i = 0; i < N; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}

Submission Info

Submission Time
Task D - 阿弥陀
User abc050
Language C (GCC 5.4.1)
Score 100
Code Size 842 Byte
Status AC
Exec Time 39 ms
Memory 20352 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:27:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &N, &M, &D);
  ^
./Main.c:33:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &A);
   ^

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 10 / 10 20 / 20 20 / 20 50 / 50
Status
AC × 9
AC × 18
AC × 18
AC × 29
Set Name Test Cases
Subtask1 sample_1.txt, 01_i.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt
Subtask2 sample_1.txt, sample_2.txt, sample_3.txt, 02_i.txt, 02_p.txt, 02_random01.txt, 02_random02.txt, 02_random03.txt, 02_random04.txt, 02_random05.txt, 02_random06.txt, 02_random07.txt, 02_random08.txt, 02_rp01.txt, 02_rp02.txt, 02_rp03.txt, 02_rp04.txt, 02_rp05.txt
Subtask3 sample_1.txt, sample_2.txt, 03_i.txt, 03_random01.txt, 03_random02.txt, 03_random03.txt, 03_random04.txt, 03_random05.txt, 03_random06.txt, 03_random07.txt, 03_random08.txt, 03_random09.txt, 03_random10.txt, 03_random11.txt, 03_random12.txt, 03_random13.txt, 03_random14.txt, 03_random15.txt
Subtask4 sample_1.txt, sample_2.txt, sample_3.txt, 04_i.txt, 04_p1.txt, 04_p2.txt, 04_random01.txt, 04_random02.txt, 04_random03.txt, 04_random04.txt, 04_random05.txt, 04_random06.txt, 04_random07.txt, 04_random08.txt, 04_random09.txt, 04_random10.txt, 04_random11.txt, 04_random12.txt, 04_random13.txt, 04_rp01.txt, 04_rp02.txt, 04_rp03.txt, 04_rp04.txt, 04_rp05.txt, 04_rp06.txt, 04_rp07.txt, 04_rp08.txt, 04_rp09.txt, 04_rp10.txt
Case Name Status Exec Time Memory
01_i.txt AC 30 ms 1536 KB
01_random01.txt AC 1 ms 128 KB
01_random02.txt AC 1 ms 128 KB
01_random03.txt AC 1 ms 128 KB
01_random04.txt AC 2 ms 256 KB
01_random05.txt AC 12 ms 1536 KB
01_random06.txt AC 25 ms 1536 KB
01_random07.txt AC 30 ms 1536 KB
02_i.txt AC 1 ms 256 KB
02_p.txt AC 1 ms 256 KB
02_random01.txt AC 1 ms 128 KB
02_random02.txt AC 1 ms 128 KB
02_random03.txt AC 1 ms 256 KB
02_random04.txt AC 1 ms 256 KB
02_random05.txt AC 2 ms 256 KB
02_random06.txt AC 9 ms 128 KB
02_random07.txt AC 18 ms 256 KB
02_random08.txt AC 18 ms 256 KB
02_rp01.txt AC 1 ms 256 KB
02_rp02.txt AC 1 ms 256 KB
02_rp03.txt AC 1 ms 256 KB
02_rp04.txt AC 1 ms 256 KB
02_rp05.txt AC 1 ms 256 KB
03_i.txt AC 1 ms 128 KB
03_random01.txt AC 2 ms 128 KB
03_random02.txt AC 16 ms 128 KB
03_random03.txt AC 13 ms 128 KB
03_random04.txt AC 13 ms 128 KB
03_random05.txt AC 3 ms 128 KB
03_random06.txt AC 3 ms 128 KB
03_random07.txt AC 4 ms 128 KB
03_random08.txt AC 1 ms 128 KB
03_random09.txt AC 5 ms 128 KB
03_random10.txt AC 9 ms 128 KB
03_random11.txt AC 15 ms 128 KB
03_random12.txt AC 15 ms 128 KB
03_random13.txt AC 12 ms 128 KB
03_random14.txt AC 10 ms 128 KB
03_random15.txt AC 4 ms 128 KB
04_i.txt AC 39 ms 17536 KB
04_p1.txt AC 28 ms 17920 KB
04_p2.txt AC 23 ms 14976 KB
04_random01.txt AC 21 ms 9344 KB
04_random02.txt AC 14 ms 9728 KB
04_random03.txt AC 12 ms 2048 KB
04_random04.txt AC 20 ms 1664 KB
04_random05.txt AC 18 ms 2688 KB
04_random06.txt AC 20 ms 11136 KB
04_random07.txt AC 26 ms 6272 KB
04_random08.txt AC 22 ms 4992 KB
04_random09.txt AC 23 ms 2944 KB
04_random10.txt AC 17 ms 11520 KB
04_random11.txt AC 38 ms 16384 KB
04_random12.txt AC 39 ms 17536 KB
04_random13.txt AC 37 ms 14848 KB
04_rp01.txt AC 28 ms 18432 KB
04_rp02.txt AC 28 ms 17152 KB
04_rp03.txt AC 28 ms 17152 KB
04_rp04.txt AC 27 ms 16384 KB
04_rp05.txt AC 28 ms 16384 KB
04_rp06.txt AC 29 ms 18432 KB
04_rp07.txt AC 30 ms 16768 KB
04_rp08.txt AC 29 ms 18432 KB
04_rp09.txt AC 28 ms 17536 KB
04_rp10.txt AC 30 ms 20352 KB
sample_1.txt AC 1 ms 128 KB
sample_2.txt AC 1 ms 128 KB
sample_3.txt AC 1 ms 128 KB