# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1046701 |
2024-08-06T20:45:45 Z |
Trent |
Catfish Farm (IOI22_fish) |
C++17 |
|
957 ms |
2097152 KB |
#include "fish.h"
#include "bits/stdc++.h";
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct pii{int a, b;};
ll INF = 1e16;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
int MH = Y[0] + 1;
for(int i : Y) MH = max(MH, i + 1);
vvll wp(N, vll(MH));
vvll wpsa(N, vll(MH));
forR(i, M) wp[X[i]][Y[i]] = W[i];
forR(x, N) {
wpsa[x][0] = wp[x][0];
REP(y, 1, MH) wpsa[x][y] = wpsa[x][y-1] + wp[x][y];
}
vector<set<int>> sCare(N);
forR(i, M) {
if(X[i] > 0) sCare[X[i]-1].insert(Y[i] + 1);
if(X[i] + 1 < N) sCare[X[i] + 1].insert(Y[i] + 1);
if(X[i] > 1) sCare[X[i]-2].insert(Y[i] + 1);
if(X[i] + 2 < N) sCare[X[i] + 2].insert(Y[i] + 1);
sCare[X[i]].insert(Y[i]+1);
}
forR(i, N) sCare[i].insert(0);
vector<vi> care(N);
forR(i, N) for(int j : sCare[i]) care[i].push_back(j);
vvll I(N, vll(MH+1)), D(N, vll(MH+1)), E(N, vll(MH+1));
// h = HEIGHT, not the index of last element!
forR(i, N) {
ll besIE = -INF, besII = -INF;
if(i > 0) {
for(int k : care[i-1]) besIE = max(besIE, E[i-1][k] - (k > 0 ? wpsa[i-1][k-1] : 0));
}
for(int h : care[i]){
if(h > 0) {
if(i == 0) I[i][h] = 0;
else {
I[i][h] = max(I[i][h], besIE + wpsa[i-1][h-1]);
besII = max(besII, I[i-1][h]- (h > 0 ? wpsa[i-1][h-1] : 0));
I[i][h] = max(I[i][h], besII + wpsa[i-1][h-1]);
}
}
}
ll besD = -INF;
for(int h = MH; h > 0; --h) {
if(i == 0) D[i][h] = 0;
else {
if(h + 1 <= MH) {
besD = max(besD, max(I[i-1][h+1], D[i-1][h+1]) + wpsa[i][h]);
}
D[i][h] = max(D[i][h], besD - (h > 0 ? wpsa[i][h-1] : 0));
}
}
ll besE = -INF;
if(i > 0) {
forR(y, MH+1) besE = max(besE, E[i-1][y]);
}
forR(h, MH+1) {
if(i == 0) E[i][h] = 0;
else {
ll tot = max(I[i-1][h], D[i-1][h]) + (h > 0 ? wpsa[i][h-1] : 0);
// forR(y, h) tot += wp[i][y];
E[i][h] = max(E[i][h], max(tot, besE));
}
}
}
ll mx = 0;
REP(h, 1, MH+1) mx = max(mx, max(I[N-1][h], D[N-1][h]));
forR(h, MH+1) mx = max(mx, E[N-1][h]);
return mx;
}
Compilation message
fish.cpp:2:25: warning: extra tokens at end of #include directive
2 | #include "bits/stdc++.h";
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
660 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
675 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
42576 KB |
Output is correct |
2 |
Correct |
37 ms |
42588 KB |
Output is correct |
3 |
Correct |
45 ms |
43356 KB |
Output is correct |
4 |
Correct |
47 ms |
46424 KB |
Output is correct |
5 |
Correct |
66 ms |
51156 KB |
Output is correct |
6 |
Correct |
58 ms |
50512 KB |
Output is correct |
7 |
Correct |
63 ms |
51276 KB |
Output is correct |
8 |
Correct |
60 ms |
51028 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
1 ms |
872 KB |
Output is correct |
17 |
Correct |
29 ms |
9416 KB |
Output is correct |
18 |
Correct |
27 ms |
8540 KB |
Output is correct |
19 |
Correct |
27 ms |
9052 KB |
Output is correct |
20 |
Correct |
26 ms |
8284 KB |
Output is correct |
21 |
Correct |
27 ms |
6364 KB |
Output is correct |
22 |
Correct |
52 ms |
12368 KB |
Output is correct |
23 |
Correct |
9 ms |
6232 KB |
Output is correct |
24 |
Correct |
23 ms |
9308 KB |
Output is correct |
25 |
Correct |
2 ms |
964 KB |
Output is correct |
26 |
Correct |
7 ms |
5724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
856 KB |
Output is correct |
12 |
Correct |
1 ms |
604 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
3932 KB |
Output is correct |
16 |
Correct |
1 ms |
872 KB |
Output is correct |
17 |
Correct |
29 ms |
9416 KB |
Output is correct |
18 |
Correct |
27 ms |
8540 KB |
Output is correct |
19 |
Correct |
27 ms |
9052 KB |
Output is correct |
20 |
Correct |
26 ms |
8284 KB |
Output is correct |
21 |
Correct |
27 ms |
6364 KB |
Output is correct |
22 |
Correct |
52 ms |
12368 KB |
Output is correct |
23 |
Correct |
9 ms |
6232 KB |
Output is correct |
24 |
Correct |
23 ms |
9308 KB |
Output is correct |
25 |
Correct |
2 ms |
964 KB |
Output is correct |
26 |
Correct |
7 ms |
5724 KB |
Output is correct |
27 |
Correct |
164 ms |
354388 KB |
Output is correct |
28 |
Correct |
193 ms |
45452 KB |
Output is correct |
29 |
Correct |
563 ms |
398420 KB |
Output is correct |
30 |
Correct |
826 ms |
434516 KB |
Output is correct |
31 |
Correct |
809 ms |
432976 KB |
Output is correct |
32 |
Correct |
227 ms |
39504 KB |
Output is correct |
33 |
Correct |
892 ms |
437076 KB |
Output is correct |
34 |
Correct |
957 ms |
437096 KB |
Output is correct |
35 |
Correct |
127 ms |
41048 KB |
Output is correct |
36 |
Correct |
868 ms |
417208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
42576 KB |
Output is correct |
2 |
Correct |
37 ms |
42588 KB |
Output is correct |
3 |
Correct |
45 ms |
43356 KB |
Output is correct |
4 |
Correct |
47 ms |
46424 KB |
Output is correct |
5 |
Correct |
66 ms |
51156 KB |
Output is correct |
6 |
Correct |
58 ms |
50512 KB |
Output is correct |
7 |
Correct |
63 ms |
51276 KB |
Output is correct |
8 |
Correct |
60 ms |
51028 KB |
Output is correct |
9 |
Runtime error |
772 ms |
2097152 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
660 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |