結果
| 問題 |
No.801 エレベーター
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-03-24 18:15:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 147 ms / 2,000 ms |
| コード長 | 1,304 bytes |
| コンパイル時間 | 508 ms |
| コンパイル使用メモリ | 84,184 KB |
| 実行使用メモリ | 38,912 KB |
| 最終ジャッジ日時 | 2024-10-03 04:07:34 |
| 合計ジャッジ時間 | 3,804 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
49 | scanf("%d%d%d", &n, &m, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:52:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
52 | scanf("%d%d", ls + i, rs + i), ls[i]--;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 801.cc: No.801 エレベーター - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 3000;
const int MAX_M = 3000;
const int MAX_K = 3000;
const int MOD = 1000000007;
/* typedef */
/* global variables */
int ls[MAX_M], rs[MAX_M];
int dp[MAX_K + 1][MAX_N + 1], dsums[MAX_N + 1];
/* subroutines */
inline void addmod(int &a, int b) { a = (a + b) % MOD; }
/* main */
int main() {
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < m; i++)
scanf("%d%d", ls + i, rs + i), ls[i]--;
dp[0][0] = 1;
for (int i = 0; i < k; i++) {
for (int j = 0; j < n; j++)
dsums[j + 1] = (dsums[j] + dp[i][j]) % MOD;
for (int j = 0; j < m; j++) {
int d = (dsums[rs[j]] + MOD - dsums[ls[j]]) % MOD;
addmod(dp[i + 1][ls[j]], d);
addmod(dp[i + 1][rs[j]], MOD - d);
}
for (int j = 0; j < n; j++)
addmod(dp[i + 1][j + 1], dp[i + 1][j]);
}
printf("%d\n", dp[k][n - 1]);
return 0;
}
tnakao0123