Submission #417739

# Submission time Handle Problem Language Result Execution time Memory
417739 2021-06-04T08:23:33 Z 송준혁(#7519) Long puzzle (innopolis2021_final_D) C++17
100 / 100
205 ms 233700 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define lb lower_bound
#define MOD 1000000007
#define INF (1ll<<62)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

int N, X, Y, L;
pii A[330], B[330];
vector<pii> E;
LL D[330][330][330][2][2], ans;

int main(){
	char a[10], b[10];
	scanf("%d %d", &N, &L);
	for (int i=1; i<=N; i++){
		int l;
		scanf("%d %s %s", &l, a, b);
		if (a[0] == 'n'){
			if (b[0] == 'n') ans += (l==L);
			else if (b[0] == 'i') D[0][0][l][0][0]++, D[0][0][l][0][1]++;
			else D[0][0][l][1][0]++, D[0][0][l][1][1]++;
		}
		else if (b[0] == 'n') E.pb(pii(l, a[0] == 'i'));
		else{
			if (a[0] == 'o') A[++X] = pii(l, b[0]=='o');
			else B[++Y] = pii(l, b[0]=='o');
		}
	}
	sort(A+1, A+X+1, [&](pii a, pii b){return a.se < b.se;});
	sort(B+1, B+Y+1, [&](pii a, pii b){return a.se > b.se;});
	for (int i=0; i<=X; i++) for (int j=0; j<=Y; j++) {
		if (!i && !j) continue;
		for (int k=1; k<=L; k++){
			LL t[2]={0,0};
			if (i && k > A[i].fi) t[A[i].se] += D[i-1][j][k-A[i].fi][0][1];
			if (j && k > B[j].fi) t[B[j].se] += D[i][j-1][k-B[j].fi][1][0];
			if (j) D[i][j][k][0][0] = (D[i][j-1][k][0][0] + t[0]) % MOD;
			else D[i][j][k][0][0] = t[0] % MOD;
			if (i) D[i][j][k][0][1] = (D[i-1][j][k][0][1] + t[0]) % MOD;
			else D[i][j][k][0][1] = t[0] % MOD;
			if (j) D[i][j][k][1][0] = (D[i][j-1][k][1][0] + t[1]) % MOD;
			else D[i][j][k][1][0] = t[1] % MOD;	
			if (i) D[i][j][k][1][1] = (D[i-1][j][k][1][1] + t[1]) % MOD;
			else D[i][j][k][1][1] = t[1] % MOD;	
		}
	}
	for (pii t : E) for (int i=0; i<=X; i++){
		ans = (ans + D[i][Y][L-t.fi][t.se][0])%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}
/*
8 4
1 none in
1 in in
1 in out
1 out out
1 out in
1 int none
1 out none
1 out none
*/

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d %d", &N, &L);
      |  ~~~~~^~~~~~~~~~~~~~~~~
Main.cpp:22:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |   scanf("%d %s %s", &l, a, b);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 844 KB Output is correct
3 Correct 2 ms 1356 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1100 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 2 ms 1868 KB Output is correct
4 Correct 3 ms 3276 KB Output is correct
5 Correct 1 ms 1100 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 1 ms 716 KB Output is correct
9 Correct 4 ms 3276 KB Output is correct
10 Correct 3 ms 3276 KB Output is correct
11 Correct 3 ms 3240 KB Output is correct
12 Correct 3 ms 3148 KB Output is correct
13 Correct 1 ms 1484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 3 ms 3788 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 844 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 2 ms 3148 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 2764 KB Output is correct
11 Correct 2 ms 2508 KB Output is correct
12 Correct 1 ms 1740 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 3 ms 3404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 716 KB Output is correct
2 Correct 1 ms 1612 KB Output is correct
3 Correct 3 ms 3788 KB Output is correct
4 Correct 1 ms 1356 KB Output is correct
5 Correct 1 ms 844 KB Output is correct
6 Correct 1 ms 716 KB Output is correct
7 Correct 1 ms 972 KB Output is correct
8 Correct 2 ms 3148 KB Output is correct
9 Correct 2 ms 3020 KB Output is correct
10 Correct 2 ms 2764 KB Output is correct
11 Correct 2 ms 2508 KB Output is correct
12 Correct 1 ms 1740 KB Output is correct
13 Correct 1 ms 716 KB Output is correct
14 Correct 3 ms 3404 KB Output is correct
15 Correct 3 ms 3532 KB Output is correct
16 Correct 3 ms 3916 KB Output is correct
17 Correct 14 ms 18004 KB Output is correct
18 Correct 3 ms 4044 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 1 ms 1612 KB Output is correct
21 Correct 2 ms 3148 KB Output is correct
22 Correct 12 ms 16716 KB Output is correct
23 Correct 11 ms 16044 KB Output is correct
24 Correct 11 ms 15432 KB Output is correct
25 Correct 10 ms 14740 KB Output is correct
26 Correct 9 ms 13468 KB Output is correct
27 Correct 8 ms 11212 KB Output is correct
28 Correct 5 ms 7116 KB Output is correct
29 Correct 2 ms 1868 KB Output is correct
30 Correct 12 ms 17484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 1 ms 844 KB Output is correct
3 Correct 2 ms 1356 KB Output is correct
4 Correct 1 ms 716 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 844 KB Output is correct
9 Correct 1 ms 844 KB Output is correct
10 Correct 1 ms 588 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 1100 KB Output is correct
14 Correct 1 ms 1100 KB Output is correct
15 Correct 2 ms 1868 KB Output is correct
16 Correct 3 ms 3276 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 716 KB Output is correct
21 Correct 4 ms 3276 KB Output is correct
22 Correct 3 ms 3276 KB Output is correct
23 Correct 3 ms 3240 KB Output is correct
24 Correct 3 ms 3148 KB Output is correct
25 Correct 1 ms 1484 KB Output is correct
26 Correct 1 ms 716 KB Output is correct
27 Correct 1 ms 1612 KB Output is correct
28 Correct 3 ms 3788 KB Output is correct
29 Correct 1 ms 1356 KB Output is correct
30 Correct 1 ms 844 KB Output is correct
31 Correct 1 ms 716 KB Output is correct
32 Correct 1 ms 972 KB Output is correct
33 Correct 2 ms 3148 KB Output is correct
34 Correct 2 ms 3020 KB Output is correct
35 Correct 2 ms 2764 KB Output is correct
36 Correct 2 ms 2508 KB Output is correct
37 Correct 1 ms 1740 KB Output is correct
38 Correct 1 ms 716 KB Output is correct
39 Correct 3 ms 3404 KB Output is correct
40 Correct 3 ms 3532 KB Output is correct
41 Correct 3 ms 3916 KB Output is correct
42 Correct 14 ms 18004 KB Output is correct
43 Correct 3 ms 4044 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 1 ms 1612 KB Output is correct
46 Correct 2 ms 3148 KB Output is correct
47 Correct 12 ms 16716 KB Output is correct
48 Correct 11 ms 16044 KB Output is correct
49 Correct 11 ms 15432 KB Output is correct
50 Correct 10 ms 14740 KB Output is correct
51 Correct 9 ms 13468 KB Output is correct
52 Correct 8 ms 11212 KB Output is correct
53 Correct 5 ms 7116 KB Output is correct
54 Correct 2 ms 1868 KB Output is correct
55 Correct 12 ms 17484 KB Output is correct
56 Correct 0 ms 204 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 45 ms 53352 KB Output is correct
59 Correct 43 ms 52772 KB Output is correct
60 Correct 205 ms 233700 KB Output is correct
61 Correct 45 ms 55620 KB Output is correct
62 Correct 13 ms 23236 KB Output is correct
63 Correct 17 ms 27564 KB Output is correct
64 Correct 18 ms 28236 KB Output is correct
65 Correct 194 ms 224688 KB Output is correct
66 Correct 200 ms 224504 KB Output is correct
67 Correct 189 ms 220368 KB Output is correct
68 Correct 194 ms 217676 KB Output is correct
69 Correct 179 ms 206240 KB Output is correct
70 Correct 135 ms 152320 KB Output is correct
71 Correct 73 ms 86464 KB Output is correct
72 Correct 18 ms 20556 KB Output is correct
73 Correct 195 ms 228968 KB Output is correct