QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#245717 | #5146. Skills | yllcm | TL | 1202ms | 17960kb | C++14 | 2.7kb | 2023-11-10 10:27:55 | 2023-11-10 10:27:56 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define db double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
#define il inline
using namespace std;
inline int read() {
int x = 0; bool op = false;
char c = getchar();
while(!isdigit(c))op |= (c == '-'), c = getchar();
while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return op ? -x : x;
}
il bool chkmax(int &a, int b) {return (b > a ? a = b, true : false);}
const int N = 1e3 + 10;
const int INF = 1e9;
const int B = 200;
int n;
int a[N][3], f[2][3][N][N], val[N];
// int calc(int x) {return (x + 1) * x >> 1;}
void solve() {
n = read();
for(int i = 1; i <= n; i++) {
for(int j = 0; j < 3; j++) {
a[i][j] = read();
}
}
for(int j = 0; j < 3; j++) {
for(int x = 0; x <= n; x++) {
for(int y = 0; y <= n; y++) {
f[0][j][x][y] = -INF;
}
}
}
f[0][0][0][0] = 0;
int CNT = 0;
for(int i = 1; i <= n; i++) {
vector<int> st;
// printf("now:%d\n", i);
for(int j = 0; j < 3; j++) {
for(int x = 0; x <= i; x++) {
f[1][j][x][0] = f[0][j][x][0];
f[1][j][0][x] = f[0][j][0][x];
f[0][j][x][0] = f[0][j][0][x] = -INF;
}
for(int x = i; x; x--)for(int y = i; y; y--) {
if(i - x > B || i - y > B)break;
f[1][j][x][y] = f[0][j][x][y];
f[0][j][x][y] = -INF;
}
}
for(int j = 0; j < 3; j++) {
auto trans = [&](int x, int y) {
if(f[1][j][x][y] > -INF) {
CNT++;
chkmax(f[0][j][x][y], f[1][j][x][y]);
int c[3] = {x, y, i - 1};
rotate(c, c + 3 - (j + 1), c + 3);
for(int k = 0; k < 3; k++) {
int d[3] = {c[0], c[1], c[2]};
int v = a[i][k] - (!d[k] ? 0 : val[i - 1 - d[k]]);
d[k] = i; rotate(d, d + k, d + 3);
chkmax(f[0][k][d[1]][d[2]], f[1][j][x][y] + v);
}
}
return ;
};
for(int x = 0; x <= i; x++)trans(x, 0), trans(0, x);
for(int x = i; x; x--) {
for(int y = i; y; y--) {
if(i - x > B || i - y > B)break;
trans(x, y);
}
}
}
}
int ans = 0;
for(int i = 0; i <= n; i++) {
for(int j = 0; j <= n; j++) {
int v = 0;
if(i)v -= val[n - i];
if(j)v -= val[n - j];
chkmax(ans, max({f[0][0][i][j], f[0][1][i][j], f[0][2][i][j]}) + v);
}
}
// cerr << CNT << endl;
printf("%d\n", ans);
return ;
}
signed main() {
for(int i = 1; i < N; i++)val[i] = val[i - 1] + i;
int test = read();
while(test--)solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 11992kb
input:
2 3 1 1 10 1 10 1 10 1 1 5 1 2 3 6 5 4 7 8 9 12 11 10 13 14 15
output:
26 41
result:
ok 2 number(s): "26 41"
Test #2:
score: 0
Accepted
time: 205ms
memory: 14976kb
input:
1 200 6219 3608 2383 1139 2158 8611 6721 8216 8887 8736 6707 9755 7210 248 167 3849 276 8050 971 5062 1914 8290 1562 6017 8993 7990 3460 6323 6099 757 7652 4740 6117 6560 4206 180 3705 8906 5752 9619 8939 9696 793 6680 1777 384 3606 8772 9258 3906 709 4396 5083 6614 6057 4410 3132 8596 825 7437 6098...
output:
1505431
result:
ok 1 number(s): "1505431"
Test #3:
score: 0
Accepted
time: 212ms
memory: 14260kb
input:
1 200 7577 2771 7429 8435 7489 1440 1929 8819 818 7849 8462 8761 3344 5938 3673 9434 8897 6486 4668 636 8139 4777 3305 4238 4221 3326 639 3879 7469 1590 6370 9514 4307 6243 3301 8122 4967 184 9327 6142 1710 399 6814 9296 6270 5663 3564 5442 8315 1295 869 2635 7975 4837 9613 9439 4012 6660 1861 368 8...
output:
1497632
result:
ok 1 number(s): "1497632"
Test #4:
score: 0
Accepted
time: 530ms
memory: 15452kb
input:
1 300 0 10000 0 0 10000 0 0 10000 0 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 1000...
output:
2975228
result:
ok 1 number(s): "2975228"
Test #5:
score: 0
Accepted
time: 1202ms
memory: 17960kb
input:
1 500 10000 0 0 10000 0 0 10000 0 0 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10...
output:
4955301
result:
ok 1 number(s): "4955301"
Test #6:
score: 0
Accepted
time: 2ms
memory: 9852kb
input:
20 10 6219 3608 2383 1139 2158 8611 6721 8216 8887 8736 6707 9755 7210 248 167 3849 276 8050 971 5062 1914 8290 1562 6017 8993 7990 3460 0 0 0 10 7652 4740 6117 6560 4206 180 3705 8906 5752 9619 8939 9696 793 6680 1777 384 3606 8772 9258 3906 709 4396 5083 6614 6057 4410 3132 1 0 0 10 6098 4958 7691...
output:
71054 70167 68631 74395 65914 65051 62880 65098 62727 71034 64500 71945 54364 66298 74354 70243 65959 78873 58698 72175
result:
ok 20 numbers
Test #7:
score: 0
Accepted
time: 263ms
memory: 11364kb
input:
10 100 6477 7917 2869 3623 818 611 7204 100 8682 4362 969 2510 6908 984 5181 2260 1731 6628 4216 5142 96 2604 5754 1992 2495 6672 7175 2278 7381 2075 1083 8778 9329 7535 4274 7337 8259 7742 6826 2873 2891 7320 2082 1988 6680 3674 1820 6637 2634 2964 5548 9745 2848 1275 2120 8514 4029 4256 692 7567 1...
output:
754578 728471 732747 758719 749241 761073 730494 756306 758915 732583
result:
ok 10 numbers
Test #8:
score: -100
Time Limit Exceeded
input:
2 500 8487 2637 3423 692 627 5666 87 6242 9920 1603 3997 7168 3038 8194 4174 4170 4094 4270 8111 680 3974 7191 3780 9484 8222 3973 9422 3202 2613 6381 3555 8378 4605 9207 3035 9493 4615 6623 2865 370 5620 2590 1426 1407 2360 6168 1634 6195 7107 2847 9756 9348 2785 1270 1202 8847 7473 9872 4547 4904 ...