Submission #214422


Source Code Expand

Copy
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int d = sc.nextInt();
		int[] a = new int[m];
		for(int i=0;i<m;i++) {
			a[i] = sc.nextInt()-1;
		}
		int[] f = new int[n];
		for(int i=0;i<n;i++) {
			f[i] = i;
		}
		for(int i=m-1;i>=0;i--) {
			int temp = f[a[i]];
			f[a[i]] = f[a[i]+1];
			f[a[i]+1] = temp;
		}
		//System.out.println(Arrays.toString(f));
		int[] ans = new int[n];
		boolean[] used = new boolean[n];
		int[] t = new int[n];
		Arrays.fill(t, -1);
		for(int i=0;i<n;i++) {
			if (used[i]) {
				continue;
			}
			ArrayList<Integer> path = new ArrayList<>();
			int now = i;
			int start = -1;
			int cycle = -1;
			for(int time=0;time<n;time++) {
				if (t[now] != -1) {
					cycle = time-t[now];
					start = time-cycle;
					break;
				}else{
					path.add(now);
					used[now] = true;
					t[now] = time;
				}
				now = f[now];
			}
			//System.out.println(path);
			for(int j=0;j<path.size();j++) {
				if (j + d >= path.size()) {
					ans[path.get(j)] = path.get((j+d-start)%cycle+start);
				}else{
					ans[path.get(j)] = path.get(j+d);
				}
			}
		}
		for(int i=0;i<n;i++) {
			System.out.println(ans[i]+1);
		}
	}

}

Submission Info

Submission Time
Task D - 阿弥陀
User piroz95
Language Java (OpenJDK 1.7.0)
Score 50
Code Size 1394 Byte
Status RE
Exec Time 2174 ms
Memory 41444 KB

Judge Result

Set Name Subtask1 Subtask2 Subtask3 Subtask4
Score / Max Score 0 / 10 0 / 20 0 / 20 50 / 50
Status
AC × 8
RE × 1
AC × 17
RE × 1
AC × 13
RE × 5
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 2118 ms 40804 KB
01_random01.txt AC 527 ms 23348 KB
01_random02.txt RE 446 ms 23388 KB
01_random03.txt AC 452 ms 23344 KB
01_random04.txt AC 802 ms 35980 KB
01_random05.txt AC 1900 ms 40184 KB
01_random06.txt AC 2057 ms 39396 KB
01_random07.txt AC 2120 ms 40156 KB
02_i.txt AC 627 ms 25844 KB
02_p.txt AC 564 ms 24628 KB
02_random01.txt AC 456 ms 23216 KB
02_random02.txt RE 466 ms 23348 KB
02_random03.txt AC 614 ms 28400 KB
02_random04.txt AC 494 ms 23596 KB
02_random05.txt AC 744 ms 38204 KB
02_random06.txt AC 882 ms 37472 KB
02_random07.txt AC 982 ms 37640 KB
02_random08.txt AC 955 ms 38612 KB
02_rp01.txt AC 570 ms 24756 KB
02_rp02.txt AC 570 ms 24752 KB
02_rp03.txt AC 549 ms 24752 KB
02_rp04.txt AC 543 ms 24748 KB
02_rp05.txt AC 550 ms 24748 KB
03_i.txt AC 446 ms 23216 KB
03_random01.txt AC 697 ms 34284 KB
03_random02.txt RE 913 ms 37608 KB
03_random03.txt AC 858 ms 38268 KB
03_random04.txt RE 874 ms 37620 KB
03_random05.txt AC 755 ms 36744 KB
03_random06.txt RE 718 ms 36844 KB
03_random07.txt RE 757 ms 37092 KB
03_random08.txt AC 556 ms 26348 KB
03_random09.txt AC 758 ms 37136 KB
03_random10.txt AC 828 ms 37860 KB
03_random11.txt AC 871 ms 37920 KB
03_random12.txt AC 884 ms 38212 KB
03_random13.txt AC 845 ms 38128 KB
03_random14.txt AC 813 ms 37608 KB
03_random15.txt RE 761 ms 37816 KB
04_i.txt AC 2114 ms 41164 KB
04_p1.txt AC 1997 ms 40484 KB
04_p2.txt AC 1797 ms 39304 KB
04_random01.txt AC 1600 ms 38772 KB
04_random02.txt AC 1469 ms 37228 KB
04_random03.txt AC 1130 ms 38280 KB
04_random04.txt AC 1212 ms 39064 KB
04_random05.txt AC 1268 ms 38328 KB
04_random06.txt AC 1672 ms 38900 KB
04_random07.txt AC 1501 ms 38724 KB
04_random08.txt AC 1409 ms 38468 KB
04_random09.txt AC 1331 ms 38776 KB
04_random10.txt AC 1622 ms 38788 KB
04_random11.txt AC 2159 ms 40804 KB
04_random12.txt AC 2174 ms 41152 KB
04_random13.txt AC 2133 ms 41444 KB
04_rp01.txt AC 2102 ms 39900 KB
04_rp02.txt AC 2009 ms 40604 KB
04_rp03.txt AC 1997 ms 39304 KB
04_rp04.txt AC 2015 ms 39816 KB
04_rp05.txt AC 2007 ms 40428 KB
04_rp06.txt AC 1995 ms 39856 KB
04_rp07.txt AC 1995 ms 39884 KB
04_rp08.txt AC 2023 ms 40572 KB
04_rp09.txt AC 2015 ms 40104 KB
04_rp10.txt AC 1996 ms 39192 KB
sample_1.txt AC 466 ms 23220 KB
sample_2.txt AC 470 ms 23212 KB
sample_3.txt AC 470 ms 23216 KB