Submission #1359223
Source Code Expand
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1000*1000*1000+7; int N, K; vector<vector<ll> > dp[2]; vector<ll> po; int main() { scanf("%d %d", &N, &K); dp[0] = dp[1] = vector<vector<ll> >(K + 1, vector<ll>(N + 1, 0)); po.resize(2002); po[0] = 1; for(int i = 1; i < 2002; i++) { po[i] = po[i - 1] * 2 % mod; } for(int i = 1; i <= K; i++) { for(int j = 1; j <= N; j++) { int rem = (N - j) - (K - i); if(rem < 0) continue; if(i == 1) { dp[0][i][j] = rem + j - 2 < 0? 1 : po[rem + j - 2]; dp[1][i][j] = dp[0][i][j]; if(j) { dp[1][i][j] += dp[1][i][j - 1]; dp[1][i][j] %= mod; } continue; } dp[0][i][j] = dp[1][i - 1][j - 1]; if(rem) dp[0][i][j] += dp[0][i - 1][j]; dp[1][i][j] = dp[0][i][j]; if(j) { dp[1][i][j] += dp[1][i][j - 1]; dp[1][i][j] %= mod; } } } printf("%lld", dp[0][K][N]); }
Submission Info
Submission Time | |
---|---|
Task | F - Solitaire |
User | choikiwon |
Language | C++14 (GCC 5.4.1) |
Score | 1200 |
Code Size | 1199 Byte |
Status | AC |
Exec Time | 47 ms |
Memory | 62976 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:12:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %d", &N, &K); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1200 / 1200 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt |
All | 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_example_01.txt | AC | 1 ms | 256 KB |
00_example_02.txt | AC | 1 ms | 256 KB |
00_example_03.txt | AC | 26 ms | 31616 KB |
01.txt | AC | 1 ms | 256 KB |
02.txt | AC | 12 ms | 14208 KB |
03.txt | AC | 1 ms | 256 KB |
04.txt | AC | 2 ms | 640 KB |
05.txt | AC | 1 ms | 256 KB |
06.txt | AC | 1 ms | 256 KB |
07.txt | AC | 1 ms | 256 KB |
08.txt | AC | 1 ms | 256 KB |
09.txt | AC | 39 ms | 50048 KB |
10.txt | AC | 1 ms | 256 KB |
11.txt | AC | 1 ms | 256 KB |
12.txt | AC | 40 ms | 52224 KB |
13.txt | AC | 1 ms | 384 KB |
14.txt | AC | 18 ms | 20992 KB |
15.txt | AC | 4 ms | 4352 KB |
16.txt | AC | 19 ms | 21760 KB |
17.txt | AC | 15 ms | 17408 KB |
18.txt | AC | 31 ms | 38656 KB |
19.txt | AC | 28 ms | 33920 KB |
20.txt | AC | 13 ms | 14848 KB |
21.txt | AC | 1 ms | 256 KB |
22.txt | AC | 47 ms | 62976 KB |
23.txt | AC | 1 ms | 384 KB |