QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#312298 | #5146. Skills | qzhfx | WA | 33ms | 4392kb | C++23 | 1.7kb | 2024-01-23 19:30:04 | 2024-01-23 19:30:05 |
Judging History
answer
#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
#define endl '\n'
#define INF 0x3f3f3f3f3f3f3f3f
#define inf 0x3f3f3f3f
#define lowbit(x) ((x)&(-x))
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 1e3 + 7;
const int mod = 998244353;
int f[2][3][180][180];
int a[N][3];
void solve(){
int n;
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i][0] >> a[i][1] >> a[i][2];
}
memset(f,0,sizeof f);
int now = 0;
for(int i=0;i<n;i++){
for(int x = 0;x < 3; x++) {
for (int j = 0; j < 180&&j<=i; j++) {
for (int k = 0; k < 180&&k<=i; k++) {
int pj = j ? j + 1 : 0, pk = k ? k + 1 : 0;
if(pj<180&&pk<180)f[now][x][j][k] = max(f[now][x][pj][pk],f[now^1][x][j][k] - pj - pk + a[i + 1][x]);
if(pk<180)f[now][(x + 1) % 3][pk][1] = max(f[now][(x + 1) % 3][pk][1],f[now ^ 1][x][j][k] - 1 - pk + a[i + 1][(x + 1) % 3]);
if(pj<180)f[now][(x + 2) % 3][1][pj] = max(f[now][(x + 2) % 3][1][pj],f[now ^ 1][x][j][k] - 1 - pj + a[i + 1][(x + 2) % 3]);
}
}
}
now ^= 1;
}
int ans = 0;
for(int x = 0; x < 3; x ++){
for(int j = 0;j< 180;j ++){
for(int k = 0;k < 180;k ++){
ans = max(ans,f[now ^ 1][x][j][k]);
}
}
}
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#ifdef qzhfx
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
int t;
t = 1;
cin >> t;
while(t--){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 4376kb
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: -100
Wrong Answer
time: 33ms
memory: 4392kb
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:
1101197
result:
wrong answer 1st numbers differ - expected: '1505431', found: '1101197'