# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1056405 |
2024-08-13T09:17:25 Z |
aykhn |
Catfish Farm (IOI22_fish) |
C++17 |
|
126 ms |
19960 KB |
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
const int MXN = 3e2 + 5;
long long dp[2][MXN][MXN], val[MXN][MXN];
long long up[MXN][MXN], lft[MXN][MXN], rig[MXN][MXN], in[MXN][MXN];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
{
for (int i = 0; i < M; i++) val[X[i] + 1][Y[i] + 1] += 1LL * W[i];
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
up[i][j] = val[i][j + 1];
lft[i][j] = lft[i][j - 1] + val[i - 1][j];
rig[i][j] = rig[i][j - 1] + val[i + 1][j];
in[i][j] = in[i][j - 1] + val[i][j];
}
}
for (int _ = 0; _ < 2; _++)
for (int j = 1; j <= N; j++) dp[_][1][j] = lft[1][j] + rig[1][j];
for (int j = 1; j <= N; j++)
{
dp[0][2][j] = dp[1][2][j] = lft[2][j] + rig[2][j];
for (int k = 1; k <= N; k++)
{
if (k < j)
{
long long res = (dp[0][1][k] - rig[1][k]) + ((lft[2][j] - in[1][k]) + rig[2][j]);
dp[1][2][j] = max(dp[1][2][j], res);
}
else if (k >= j)
{
long long res = dp[1][1][k] - in[2][j] + rig[2][j];
dp[1][2][j] = max(dp[1][2][j], res);
}
}
dp[1][2][j] = max(dp[1][2][j], dp[0][2][j]);
}
for (int i = 3; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
dp[0][i][j] = dp[1][i][j] = lft[i][j] + rig[i][j];
for (int k = 1; k <= N; k++)
{
if (k < j)
{
long long res = (dp[0][i - 1][k] - rig[i - 1][k]) + ((lft[i][j] - in[i - 1][k]) + rig[i][j]);
dp[1][i][j] = max(dp[1][i][j], res);
}
else if (k >= j)
{
long long res = dp[1][i - 1][k] - in[i][j] + rig[i][j];
dp[1][i][j] = max(dp[1][i][j], res);
}
}
for (int k = 1; k <= N; k++)
{
long long res = dp[1][i - 2][k] + lft[i][j] + rig[i][j];
if (k <= j) res -= rig[i - 2][k];
else res -= lft[i][j];
dp[0][i][j] = max(dp[0][i][j], res);
}
dp[1][i][j] = max(dp[1][i][j], dp[0][i][j]);
}
}
long long ans = 0;
for (int i = 1; i <= N; i++)
{
for (int j = 1; j <= N; j++)
{
ans = max(ans, dp[1][i][j]);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
126 ms |
13140 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
4440 KB |
Output is correct |
2 |
Runtime error |
104 ms |
19960 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
87 ms |
9300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
4444 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
87 ms |
9300 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
126 ms |
13140 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |