Submission #417722

# Submission time Handle Problem Language Result Execution time Memory
417722 2021-06-04T08:06:51 Z 송준혁(#7519) Long puzzle (innopolis2021_final_D) C++17
80 / 100
3000 ms 76748 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], 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]++;
			else D[0][0][l][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) for (int k=A[i].fi; k<=L; k++) for (int l=0; l<i; l++) D[i][j][k][A[i].se] = (D[i][j][k][A[i].se] + D[l][j][k-A[i].fi][0])%MOD; 
		if (j) for (int k=B[j].fi; k<=L; k++) for (int l=0; l<j; l++) D[i][j][k][B[j].se] = (D[i][j][k][B[j].se] + D[i][l][k-B[j].fi][1])%MOD; 
	}
	for (pii t : E) for (int i=0; i<=X; i++) for (int j=0; j<=Y; j++){
		ans = (ans + D[i][j][L-t.fi][t.se])%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 460 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 2 ms 844 KB Output is correct
4 Correct 1 ms 460 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 588 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 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 3 ms 588 KB Output is correct
2 Correct 4 ms 768 KB Output is correct
3 Correct 16 ms 968 KB Output is correct
4 Correct 65 ms 1772 KB Output is correct
5 Correct 4 ms 716 KB Output is correct
6 Correct 1 ms 588 KB Output is correct
7 Correct 1 ms 588 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 76 ms 1784 KB Output is correct
10 Correct 63 ms 1684 KB Output is correct
11 Correct 61 ms 1760 KB Output is correct
12 Correct 63 ms 1688 KB Output is correct
13 Correct 11 ms 844 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 2 ms 1356 KB Output is correct
3 Correct 6 ms 3320 KB Output is correct
4 Correct 1 ms 1100 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 6 ms 2816 KB Output is correct
9 Correct 5 ms 2636 KB Output is correct
10 Correct 4 ms 2380 KB Output is correct
11 Correct 5 ms 2124 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 5 ms 3020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 588 KB Output is correct
2 Correct 2 ms 1356 KB Output is correct
3 Correct 6 ms 3320 KB Output is correct
4 Correct 1 ms 1100 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 6 ms 2816 KB Output is correct
9 Correct 5 ms 2636 KB Output is correct
10 Correct 4 ms 2380 KB Output is correct
11 Correct 5 ms 2124 KB Output is correct
12 Correct 2 ms 1484 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 5 ms 3020 KB Output is correct
15 Correct 5 ms 2636 KB Output is correct
16 Correct 6 ms 2892 KB Output is correct
17 Correct 84 ms 13180 KB Output is correct
18 Correct 6 ms 3004 KB Output is correct
19 Correct 3 ms 2636 KB Output is correct
20 Correct 2 ms 1612 KB Output is correct
21 Correct 4 ms 3020 KB Output is correct
22 Correct 66 ms 12212 KB Output is correct
23 Correct 55 ms 11752 KB Output is correct
24 Correct 49 ms 11360 KB Output is correct
25 Correct 49 ms 10820 KB Output is correct
26 Correct 43 ms 9916 KB Output is correct
27 Correct 29 ms 8268 KB Output is correct
28 Correct 15 ms 5248 KB Output is correct
29 Correct 2 ms 1484 KB Output is correct
30 Correct 78 ms 12836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 588 KB Output is correct
3 Correct 2 ms 844 KB Output is correct
4 Correct 1 ms 460 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 588 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 3 ms 588 KB Output is correct
14 Correct 4 ms 768 KB Output is correct
15 Correct 16 ms 968 KB Output is correct
16 Correct 65 ms 1772 KB Output is correct
17 Correct 4 ms 716 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 2 ms 716 KB Output is correct
21 Correct 76 ms 1784 KB Output is correct
22 Correct 63 ms 1684 KB Output is correct
23 Correct 61 ms 1760 KB Output is correct
24 Correct 63 ms 1688 KB Output is correct
25 Correct 11 ms 844 KB Output is correct
26 Correct 1 ms 588 KB Output is correct
27 Correct 2 ms 1356 KB Output is correct
28 Correct 6 ms 3320 KB Output is correct
29 Correct 1 ms 1100 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 6 ms 2816 KB Output is correct
34 Correct 5 ms 2636 KB Output is correct
35 Correct 4 ms 2380 KB Output is correct
36 Correct 5 ms 2124 KB Output is correct
37 Correct 2 ms 1484 KB Output is correct
38 Correct 1 ms 588 KB Output is correct
39 Correct 5 ms 3020 KB Output is correct
40 Correct 5 ms 2636 KB Output is correct
41 Correct 6 ms 2892 KB Output is correct
42 Correct 84 ms 13180 KB Output is correct
43 Correct 6 ms 3004 KB Output is correct
44 Correct 3 ms 2636 KB Output is correct
45 Correct 2 ms 1612 KB Output is correct
46 Correct 4 ms 3020 KB Output is correct
47 Correct 66 ms 12212 KB Output is correct
48 Correct 55 ms 11752 KB Output is correct
49 Correct 49 ms 11360 KB Output is correct
50 Correct 49 ms 10820 KB Output is correct
51 Correct 43 ms 9916 KB Output is correct
52 Correct 29 ms 8268 KB Output is correct
53 Correct 15 ms 5248 KB Output is correct
54 Correct 2 ms 1484 KB Output is correct
55 Correct 78 ms 12836 KB Output is correct
56 Correct 0 ms 204 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 352 ms 26752 KB Output is correct
59 Correct 352 ms 26316 KB Output is correct
60 Execution timed out 3045 ms 76748 KB Time limit exceeded
61 Halted 0 ms 0 KB -