結果

問題 No.801 エレベーター
ユーザー akakimidoriakakimidori
提出日時 2019-03-17 21:46:59
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 864 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 30,292 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-22 04:53:25
合計ジャッジ時間 3,897 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 0 ms
4,376 KB
testcase_02 AC 0 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 120 ms
4,376 KB
testcase_14 AC 120 ms
4,376 KB
testcase_15 AC 120 ms
4,380 KB
testcase_16 AC 120 ms
4,380 KB
testcase_17 AC 119 ms
4,380 KB
testcase_18 AC 120 ms
4,380 KB
testcase_19 AC 120 ms
4,376 KB
testcase_20 AC 120 ms
4,376 KB
testcase_21 AC 119 ms
4,376 KB
testcase_22 AC 120 ms
4,376 KB
testcase_23 AC 119 ms
4,376 KB
testcase_24 AC 119 ms
4,380 KB
testcase_25 AC 120 ms
4,380 KB
testcase_26 AC 120 ms
4,376 KB
testcase_27 AC 120 ms
4,376 KB
testcase_28 AC 128 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long int int64;

const int mod=1000000007;

void run(void){
  int n,m,k;
  scanf("%d%d%d",&n,&m,&k);
  int *l=(int *)calloc(m,sizeof(int));
  int *r=(int *)calloc(m,sizeof(int));
  int i;
  for(i=0;i<m;i++) scanf("%d%d",l+i,r+i);
  int *now=(int *)calloc(n+2,sizeof(int));
  for(i=1;i<=n+1;i++) now[i]=1;
  int *next=(int *)calloc(n+2,sizeof(int));
  while(k--){
    memset(next,0,sizeof(int)*(n+2));
    for(i=0;i<m;i++){
      int v=(now[r[i]]-now[l[i]-1]+mod)%mod;
      next[l[i]]=(next[l[i]]+v)%mod;
      next[r[i]+1]=(next[r[i]+1]+mod-v)%mod;
    }
    for(int iter=0;iter<2;iter++){
      for(i=1;i<=n+1;i++) next[i]=(next[i]+next[i-1])%mod;
    }
    int *swap=now;
    now=next;
    next=swap;
  }
  printf("%d\n",(now[n]-now[n-1]+mod)%mod);
}

int main(void){
  run();
  return 0;
}
0