# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
417888 | 2021-06-04T13:07:20 Z | 반딧불(#7603) | Long puzzle (innopolis2021_final_D) | C++17 | 456 ms | 427776 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MOD = 1000000007; int n, l; int DP[302][302][602][2]; int DPo[2][302][302]; int arr[302]; int a[302], b[302]; ll ans; int main(){ scanf("%d %d", &n, &l); for(int i=1; i<=n; i++){ string tStr; cin >> arr[i] >> tStr; a[i] = (tStr[0] == 'n' ? 0 : tStr[0] == 'i' ? 1 : -1); cin >> tStr; b[i] = (tStr[0] == 'n' ? 0 : tStr[0] == 'o' ? 1 : -1); if(!a[i] && !b[i] && arr[i] == l) ans++; } DP[0][0][300][0] = 1; for(int i=1; i<=n; i++){ for(int j=0; j<=l; j++) for(int k=0; k<=600; k++){ DP[i][j][k][0] = DP[i-1][j][k][0]; DP[i][j][k][1] = DP[i-1][j][k][1]; } if(!a[i] || !b[i]){ continue; } int weight = (a[i] - b[i]) / 2; for(int j=0; j+arr[i]<=l; j++){ for(int k=1; k<=600; k++){ DP[i][j+arr[i]][k+weight][1] += DP[i-1][j][k][1]; DP[i][j+arr[i]][k+weight][1] %= MOD; DP[i][j+arr[i]][k+weight][!!weight] += DP[i-1][j][k][0]; DP[i][j+arr[i]][k+weight][!!weight] %= MOD; } } } DPo[0][0][0] = DPo[1][0][0] = 1; for(int i=1; i<=n; i++){ for(int j=0; j<=l; j++) DPo[0][i][j] = DPo[0][i-1][j], DPo[1][i][j] = DPo[1][i-1][j]; if(a[i] == -1 && b[i] == -1){ for(int j=0; j+arr[i]<=l; j++){ DPo[0][i][j+arr[i]] += DPo[0][i-1][j]; DPo[0][i][j+arr[i]] %= MOD; } } if(a[i] == 1 && b[i] == 1){ for(int j=0; j+arr[i]<=l; j++){ DPo[1][i][j+arr[i]] += DPo[1][i-1][j]; DPo[1][i][j+arr[i]] %= MOD; } } } for(int i=1; i<=n; i++){ if(a[i] || !b[i]) continue; for(int j=1; j<=n; j++){ if(!a[j] || b[j] || arr[i]+arr[j]>l) continue; int weight = (b[i] - a[j]) / 2; ans += DP[n][l-arr[i]-arr[j]][300+weight][1]; ans %= MOD; if(b[i] == -1 && a[j] == -1){ ans += DPo[0][n][l-arr[i]-arr[j]]; ans %= MOD; } if(b[i] == 1 && a[j] == 1){ ans += DPo[1][n][l-arr[i]-arr[j]]; ans %= MOD; } } } printf("%lld", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 28748 KB | Output is correct |
2 | Correct | 26 ms | 28788 KB | Output is correct |
3 | Correct | 30 ms | 28780 KB | Output is correct |
4 | Correct | 24 ms | 28688 KB | Output is correct |
5 | Correct | 1 ms | 716 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
8 | Correct | 24 ms | 28700 KB | Output is correct |
9 | Correct | 24 ms | 28748 KB | Output is correct |
10 | Correct | 21 ms | 28748 KB | Output is correct |
11 | Correct | 18 ms | 28756 KB | Output is correct |
12 | Correct | 2 ms | 2380 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 254 ms | 427716 KB | Output is correct |
2 | Correct | 253 ms | 427636 KB | Output is correct |
3 | Correct | 322 ms | 427724 KB | Output is correct |
4 | Correct | 393 ms | 427680 KB | Output is correct |
5 | Correct | 260 ms | 427680 KB | Output is correct |
6 | Correct | 12 ms | 18508 KB | Output is correct |
7 | Correct | 30 ms | 46780 KB | Output is correct |
8 | Correct | 48 ms | 74932 KB | Output is correct |
9 | Correct | 397 ms | 427688 KB | Output is correct |
10 | Correct | 419 ms | 427636 KB | Output is correct |
11 | Correct | 402 ms | 427624 KB | Output is correct |
12 | Correct | 427 ms | 427656 KB | Output is correct |
13 | Correct | 276 ms | 427696 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 12748 KB | Output is correct |
2 | Correct | 9 ms | 12664 KB | Output is correct |
3 | Correct | 13 ms | 12748 KB | Output is correct |
4 | Correct | 9 ms | 12708 KB | Output is correct |
5 | Correct | 1 ms | 1612 KB | Output is correct |
6 | Correct | 3 ms | 2380 KB | Output is correct |
7 | Correct | 3 ms | 3276 KB | Output is correct |
8 | Correct | 15 ms | 12684 KB | Output is correct |
9 | Correct | 12 ms | 12724 KB | Output is correct |
10 | Correct | 11 ms | 12748 KB | Output is correct |
11 | Correct | 11 ms | 12660 KB | Output is correct |
12 | Correct | 10 ms | 12748 KB | Output is correct |
13 | Correct | 9 ms | 12664 KB | Output is correct |
14 | Correct | 13 ms | 12716 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 12748 KB | Output is correct |
2 | Correct | 9 ms | 12664 KB | Output is correct |
3 | Correct | 13 ms | 12748 KB | Output is correct |
4 | Correct | 9 ms | 12708 KB | Output is correct |
5 | Correct | 1 ms | 1612 KB | Output is correct |
6 | Correct | 3 ms | 2380 KB | Output is correct |
7 | Correct | 3 ms | 3276 KB | Output is correct |
8 | Correct | 15 ms | 12684 KB | Output is correct |
9 | Correct | 12 ms | 12724 KB | Output is correct |
10 | Correct | 11 ms | 12748 KB | Output is correct |
11 | Correct | 11 ms | 12660 KB | Output is correct |
12 | Correct | 10 ms | 12748 KB | Output is correct |
13 | Correct | 9 ms | 12664 KB | Output is correct |
14 | Correct | 13 ms | 12716 KB | Output is correct |
15 | Correct | 38 ms | 48640 KB | Output is correct |
16 | Correct | 33 ms | 48664 KB | Output is correct |
17 | Correct | 49 ms | 48668 KB | Output is correct |
18 | Correct | 40 ms | 48612 KB | Output is correct |
19 | Correct | 4 ms | 4428 KB | Output is correct |
20 | Correct | 5 ms | 7244 KB | Output is correct |
21 | Correct | 9 ms | 11108 KB | Output is correct |
22 | Correct | 47 ms | 48708 KB | Output is correct |
23 | Correct | 51 ms | 48608 KB | Output is correct |
24 | Correct | 46 ms | 48612 KB | Output is correct |
25 | Correct | 46 ms | 48596 KB | Output is correct |
26 | Correct | 44 ms | 48712 KB | Output is correct |
27 | Correct | 42 ms | 48708 KB | Output is correct |
28 | Correct | 37 ms | 48596 KB | Output is correct |
29 | Correct | 37 ms | 48616 KB | Output is correct |
30 | Correct | 50 ms | 48676 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 28748 KB | Output is correct |
2 | Correct | 26 ms | 28788 KB | Output is correct |
3 | Correct | 30 ms | 28780 KB | Output is correct |
4 | Correct | 24 ms | 28688 KB | Output is correct |
5 | Correct | 1 ms | 716 KB | Output is correct |
6 | Correct | 1 ms | 844 KB | Output is correct |
7 | Correct | 1 ms | 972 KB | Output is correct |
8 | Correct | 24 ms | 28700 KB | Output is correct |
9 | Correct | 24 ms | 28748 KB | Output is correct |
10 | Correct | 21 ms | 28748 KB | Output is correct |
11 | Correct | 18 ms | 28756 KB | Output is correct |
12 | Correct | 2 ms | 2380 KB | Output is correct |
13 | Correct | 254 ms | 427716 KB | Output is correct |
14 | Correct | 253 ms | 427636 KB | Output is correct |
15 | Correct | 322 ms | 427724 KB | Output is correct |
16 | Correct | 393 ms | 427680 KB | Output is correct |
17 | Correct | 260 ms | 427680 KB | Output is correct |
18 | Correct | 12 ms | 18508 KB | Output is correct |
19 | Correct | 30 ms | 46780 KB | Output is correct |
20 | Correct | 48 ms | 74932 KB | Output is correct |
21 | Correct | 397 ms | 427688 KB | Output is correct |
22 | Correct | 419 ms | 427636 KB | Output is correct |
23 | Correct | 402 ms | 427624 KB | Output is correct |
24 | Correct | 427 ms | 427656 KB | Output is correct |
25 | Correct | 276 ms | 427696 KB | Output is correct |
26 | Correct | 8 ms | 12748 KB | Output is correct |
27 | Correct | 9 ms | 12664 KB | Output is correct |
28 | Correct | 13 ms | 12748 KB | Output is correct |
29 | Correct | 9 ms | 12708 KB | Output is correct |
30 | Correct | 1 ms | 1612 KB | Output is correct |
31 | Correct | 3 ms | 2380 KB | Output is correct |
32 | Correct | 3 ms | 3276 KB | Output is correct |
33 | Correct | 15 ms | 12684 KB | Output is correct |
34 | Correct | 12 ms | 12724 KB | Output is correct |
35 | Correct | 11 ms | 12748 KB | Output is correct |
36 | Correct | 11 ms | 12660 KB | Output is correct |
37 | Correct | 10 ms | 12748 KB | Output is correct |
38 | Correct | 9 ms | 12664 KB | Output is correct |
39 | Correct | 13 ms | 12716 KB | Output is correct |
40 | Correct | 38 ms | 48640 KB | Output is correct |
41 | Correct | 33 ms | 48664 KB | Output is correct |
42 | Correct | 49 ms | 48668 KB | Output is correct |
43 | Correct | 40 ms | 48612 KB | Output is correct |
44 | Correct | 4 ms | 4428 KB | Output is correct |
45 | Correct | 5 ms | 7244 KB | Output is correct |
46 | Correct | 9 ms | 11108 KB | Output is correct |
47 | Correct | 47 ms | 48708 KB | Output is correct |
48 | Correct | 51 ms | 48608 KB | Output is correct |
49 | Correct | 46 ms | 48612 KB | Output is correct |
50 | Correct | 46 ms | 48596 KB | Output is correct |
51 | Correct | 44 ms | 48712 KB | Output is correct |
52 | Correct | 42 ms | 48708 KB | Output is correct |
53 | Correct | 37 ms | 48596 KB | Output is correct |
54 | Correct | 37 ms | 48616 KB | Output is correct |
55 | Correct | 50 ms | 48676 KB | Output is correct |
56 | Correct | 1 ms | 588 KB | Output is correct |
57 | Correct | 1 ms | 416 KB | Output is correct |
58 | Correct | 278 ms | 427716 KB | Output is correct |
59 | Correct | 290 ms | 427696 KB | Output is correct |
60 | Correct | 428 ms | 427608 KB | Output is correct |
61 | Correct | 290 ms | 427716 KB | Output is correct |
62 | Correct | 22 ms | 29860 KB | Output is correct |
63 | Correct | 54 ms | 55192 KB | Output is correct |
64 | Correct | 67 ms | 89028 KB | Output is correct |
65 | Correct | 456 ms | 427624 KB | Output is correct |
66 | Correct | 413 ms | 427700 KB | Output is correct |
67 | Correct | 438 ms | 427640 KB | Output is correct |
68 | Correct | 434 ms | 427652 KB | Output is correct |
69 | Correct | 423 ms | 427656 KB | Output is correct |
70 | Correct | 387 ms | 427684 KB | Output is correct |
71 | Correct | 343 ms | 427776 KB | Output is correct |
72 | Correct | 316 ms | 427644 KB | Output is correct |
73 | Correct | 456 ms | 427676 KB | Output is correct |