CSES - Aalto Competitive Programming 2024 - wk12 - Mon - Results
Submission details
Task:Practice Sessions
Sender:aalto2024m_001
Submission time:2024-11-25 17:33:30 +0200
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails
#40.00 sdetails
#5ACCEPTED0.00 sdetails
#6ACCEPTED0.00 sdetails
#70.00 sdetails
#80.00 sdetails
#90.00 sdetails
#100.00 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#140.01 sdetails
#150.01 sdetails
#160.01 sdetails
#170.31 sdetails
#180.26 sdetails
#190.23 sdetails
#200.31 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i=a;i<(b);++i)
#define all(x) begin(x),end(x)
#define sz(x) int((x).size())
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;

const int M = 1e9+7;

int R[5001][5001][2];

int main() {
  int n, k;
  cin >> n >> k;
  if (n == k) {
    cout << "1\n";
    return 0;
  }
  rep(n0,1,n+1) {
    rep(k0,1,n0) {
      const int n1 = n0 - k0;
      R[n0][k0][0] = (R[n0][k0-1][0] + R[n1][min(n1,k0-1)][1]) % M;
      R[n0][k0][1] = (R[n0][k0-1][1] + R[n1][n1][0] - R[n1][k0][0] + M) % M;
    }
    R[n0][n0][0] = (R[n0][n0-1][0]+1) % M;
    R[n0][n0][1] = (R[n0][n0-1][1]+1) % M;
  }
  cout << (ll(R[n][k][0]) - R[n][k-1][0] + R[n][k][1] - R[n][k-1][1] + M*2) % M << '\n';
}

Test details

Test 1

Verdict: ACCEPTED

input
6 2

correct output
4

user output
4

Test 2

Verdict: ACCEPTED

input
3 3

correct output
1

user output
1

Test 3

Verdict: ACCEPTED

input
2 1

correct output
0

user output
0

Test 4

Verdict:

input
3 2

correct output
1

user output
2

Test 5

Verdict: ACCEPTED

input
5 2

correct output
2

user output
2

Test 6

Verdict: ACCEPTED

input
7 3

correct output
3

user output
3

Test 7

Verdict:

input
10 1

correct output
23

user output
27

Test 8

Verdict:

input
30 10

correct output
3798

user output
4664

Test 9

Verdict:

input
28 3

correct output
44442

user output
54474

Test 10

Verdict:

input
29 4

correct output
43031

user output
52768

Test 11

Verdict:

input
333 2

correct output
420856463

user output
945477076

Test 12

Verdict:

input
357 1

correct output
21271311

user output
5632819

Test 13

Verdict:

input
500 9

correct output
665929071

user output
405343674

Test 14

Verdict:

input
500 17

correct output
493880105

user output
319103645

Test 15

Verdict:

input
500 49

correct output
43728321

user output
165091094

Test 16

Verdict:

input
499 19

correct output
128412292

user output
135702533

Test 17

Verdict:

input
5000 100

correct output
686974306

user output
795202922

Test 18

Verdict:

input
4589 1

correct output
67768215

user output
292001971

Test 19

Verdict:

input
4321 987

correct output
890135419

user output
216592201

Test 20

Verdict:

input
4987 222

correct output
626500635

user output
905911596