Submission #173070


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) % 1000000007;
				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 772 Byte
Status WA
Exec Time 16354 ms
Memory 27280 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 488 ms 23092 KB
sample_02.txt AC 472 ms 23216 KB
sample_03.txt TLE 2853 ms 23564 KB
subtask1_01.txt WA 454 ms 23220 KB
subtask1_02.txt WA 452 ms 23216 KB
subtask1_03.txt WA 449 ms 23220 KB
subtask1_04.txt TLE 11017 ms 23688 KB
subtask1_05.txt TLE 10982 ms 23684 KB
subtask1_06.txt TLE 10991 ms 23560 KB
subtask1_07.txt WA 464 ms 23728 KB
subtask1_08.txt WA 460 ms 23600 KB
subtask1_09.txt TLE 10976 ms 23604 KB
subtask1_10.txt TLE 16354 ms 24016 KB
subtask1_11.txt TLE 10989 ms 23696 KB
subtask1_12.txt TLE 11022 ms 23728 KB
subtask2_01.txt WA 446 ms 23088 KB
subtask2_02.txt AC 447 ms 23260 KB
subtask2_03.txt WA 529 ms 23220 KB
subtask2_04.txt TLE 11303 ms 24232 KB
subtask2_05.txt TLE 10996 ms 23692 KB
subtask2_06.txt TLE 11211 ms 23596 KB
subtask2_07.txt WA 631 ms 26256 KB
subtask2_08.txt WA 729 ms 26168 KB
subtask2_09.txt TLE 10995 ms 23608 KB
subtask2_10.txt TLE 11212 ms 24308 KB
subtask2_11.txt TLE 11209 ms 24172 KB
subtask2_12.txt TLE 16354 ms 24212 KB
subtask3_01.txt WA 451 ms 23088 KB
subtask3_02.txt AC 456 ms 23216 KB
subtask3_03.txt WA 542 ms 23348 KB
subtask3_04.txt WA 945 ms 26132 KB
subtask3_05.txt WA 545 ms 23604 KB
subtask3_06.txt WA 875 ms 25748 KB
subtask3_07.txt TLE 5518 ms 26104 KB
subtask3_08.txt WA 629 ms 26976 KB
subtask3_09.txt TLE 11031 ms 23592 KB
subtask3_10.txt WA 827 ms 26316 KB
subtask3_11.txt TLE 2045 ms 24584 KB
subtask3_12.txt WA 726 ms 27280 KB