Submission #172501


Source Code Expand

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

int i,j,k;

long SUM(long bottom,long roof,long count);
long C(long n,long r);
long F(long n);

int main(){
  int n;
  long a[2000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%ld",&a[i]);
  }
  
  long bottom,roof;
  long count;
  long s;
  long ans=1;

  long f=0;
  for(i=0;i<n;i++){
    count++;

    if(f==0 && a[i]==-1){
      bottom=a[i-1];
      f=1;
      count=0;
    }
    if(f==1 && a[i]!=-1){
      roof=a[i];
      f=0;
      // printf("b:%ld,r:%ld,c:%ld\n",bottom,roof,count);
      s=SUM(bottom,roof,count);
      ans*=s;
    }
  }

  printf("%ld\n",ans%1000000007);
  return 0;
}

long SUM(long bottom,long roof,long count){
  return C(roof-bottom+count,count);
}

long C(long n,long r){
  if(r<=0)return 1;
  return F(n)/(F(r)*F(n-r));
}

long F(long n){
  long f=n;
  if(n <= 0)return 1;

  while(--n){
    f *= n;
  }
  return f;
}

Submission Info

Submission Time
Task C - タコヤ木
User Tanix
Language C (GCC 4.6.4)
Score 0
Code Size 958 Byte
Status WA
Exec Time 2030 ms
Memory 840 KB

Compile Error

./Main.c: In function ‘main’:
./Main.c:13:8: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
./Main.c:15:10: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]

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 × 12
WA × 1
RE × 1
AC × 17
WA × 4
RE × 5
AC × 18
WA × 4
TLE × 1
RE × 13
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 20 ms 788 KB
sample_02.txt AC 20 ms 796 KB
sample_03.txt TLE 2029 ms 800 KB
subtask1_01.txt AC 20 ms 788 KB
subtask1_02.txt AC 20 ms 792 KB
subtask1_03.txt AC 20 ms 740 KB
subtask1_04.txt AC 20 ms 796 KB
subtask1_05.txt AC 18 ms 784 KB
subtask1_06.txt AC 18 ms 792 KB
subtask1_07.txt RE 238 ms 788 KB
subtask1_08.txt AC 20 ms 796 KB
subtask1_09.txt AC 21 ms 796 KB
subtask1_10.txt AC 20 ms 792 KB
subtask1_11.txt AC 23 ms 788 KB
subtask1_12.txt WA 19 ms 776 KB
subtask2_01.txt AC 20 ms 720 KB
subtask2_02.txt RE 234 ms 788 KB
subtask2_03.txt RE 231 ms 784 KB
subtask2_04.txt AC 20 ms 796 KB
subtask2_05.txt AC 21 ms 796 KB
subtask2_06.txt WA 18 ms 784 KB
subtask2_07.txt RE 233 ms 788 KB
subtask2_08.txt AC 18 ms 792 KB
subtask2_09.txt AC 20 ms 840 KB
subtask2_10.txt RE 233 ms 668 KB
subtask2_11.txt WA 23 ms 792 KB
subtask2_12.txt WA 20 ms 744 KB
subtask3_01.txt AC 20 ms 788 KB
subtask3_02.txt RE 1411 ms 784 KB
subtask3_03.txt RE 283 ms 784 KB
subtask3_04.txt RE 235 ms 788 KB
subtask3_05.txt RE 239 ms 796 KB
subtask3_06.txt RE 242 ms 796 KB
subtask3_07.txt TLE 2030 ms 732 KB
subtask3_08.txt AC 22 ms 784 KB
subtask3_09.txt AC 18 ms 792 KB
subtask3_10.txt RE 252 ms 792 KB
subtask3_11.txt RE 263 ms 788 KB
subtask3_12.txt RE 238 ms 796 KB