Submission #172153


Source Code Expand

Copy
import java.util.*;
public class Main {
	public static double fact(int n){
		double x = 1;
		for(; n != 1; n--){
			x *= n;
		}
		return x;
	}
	
	public static double H(int n,int r){
		switch(r){
		case 0: 
			return 0;
		case 1:
			return n;
		default:
			return fact(n+r-1) / (fact(n-1) * fact(r));
		}
	}
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int first = sc.nextInt();
		double ans = 1;
		int count = 0;
		for(int i = 1;i < n; i++){
			int temp = sc.nextInt();
			if (temp != -1){
				ans *= H((temp - first + 1),count);
				count = 0;
				first = temp;
			}
			else
				count += 1;
		}
		
		System.out.println((int)(ans % 1000000007));
		}
	}

Submission Info

Submission Time
Task C - タコヤ木
User existy
Language Java (OpenJDK 1.7.0)
Score 0
Code Size 756 Byte
Status WA
Exec Time 16552 ms
Memory 27032 KB

Judge Result

Set Name Sample Subtask1 Subtask2 Subtask3
Score / Max Score 0 / 0 0 / 50 0 / 30 0 / 20
Status
AC × 2
TLE × 1
AC × 2
WA × 5
TLE × 7
AC × 3
WA × 9
TLE × 14
AC × 2
WA × 17
TLE × 17
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Subtask2 sample_01.txt, sample_02.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt
Subtask3 subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt, subtask2_01.txt, subtask2_02.txt, subtask2_03.txt, subtask2_04.txt, subtask2_05.txt, subtask2_06.txt, subtask2_07.txt, subtask2_08.txt, subtask2_09.txt, subtask2_10.txt, subtask2_11.txt, subtask2_12.txt, subtask3_01.txt, subtask3_02.txt, subtask3_03.txt, subtask3_04.txt, subtask3_05.txt, subtask3_06.txt, subtask3_07.txt, subtask3_08.txt, subtask3_09.txt, subtask3_10.txt, subtask3_11.txt, subtask3_12.txt
Case Name Status Exec Time Memory
sample_01.txt AC 512 ms 23116 KB
sample_02.txt AC 481 ms 23260 KB
sample_03.txt TLE 2758 ms 23612 KB
subtask1_01.txt WA 517 ms 23136 KB
subtask1_02.txt WA 492 ms 23136 KB
subtask1_03.txt WA 474 ms 23260 KB
subtask1_04.txt TLE 10199 ms 23604 KB
subtask1_05.txt TLE 10323 ms 23728 KB
subtask1_06.txt TLE 10255 ms 23608 KB
subtask1_07.txt WA 484 ms 23648 KB
subtask1_08.txt WA 480 ms 23524 KB
subtask1_09.txt TLE 10260 ms 23632 KB
subtask1_10.txt TLE 16509 ms 23800 KB
subtask1_11.txt TLE 10265 ms 23668 KB
subtask1_12.txt TLE 10359 ms 23604 KB
subtask2_01.txt WA 501 ms 23260 KB
subtask2_02.txt AC 500 ms 23136 KB
subtask2_03.txt WA 490 ms 23260 KB
subtask2_04.txt TLE 10374 ms 24008 KB
subtask2_05.txt TLE 10275 ms 23736 KB
subtask2_06.txt TLE 10261 ms 23604 KB
subtask2_07.txt WA 599 ms 25436 KB
subtask2_08.txt WA 622 ms 25876 KB
subtask2_09.txt TLE 10253 ms 23600 KB
subtask2_10.txt TLE 10352 ms 24444 KB
subtask2_11.txt TLE 16552 ms 24200 KB
subtask2_12.txt TLE 16495 ms 24152 KB
subtask3_01.txt WA 478 ms 23140 KB
subtask3_02.txt AC 479 ms 23260 KB
subtask3_03.txt WA 535 ms 23264 KB
subtask3_04.txt WA 976 ms 26020 KB
subtask3_05.txt WA 571 ms 23772 KB
subtask3_06.txt WA 902 ms 25756 KB
subtask3_07.txt TLE 5274 ms 26108 KB
subtask3_08.txt WA 597 ms 27032 KB
subtask3_09.txt TLE 10294 ms 23612 KB
subtask3_10.txt WA 842 ms 26320 KB
subtask3_11.txt TLE 2048 ms 24628 KB
subtask3_12.txt WA 730 ms 27004 KB