QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#312718#5146. SkillsNCl3WA 207ms228084kbC++173.4kb2024-01-24 11:03:082024-01-24 11:03:08

Judging History

你现在查看的是最新测评结果

  • [2024-01-24 11:03:08]
  • 评测
  • 测评结果:WA
  • 用时:207ms
  • 内存:228084kb
  • [2024-01-24 11:03:08]
  • 提交

answer

#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define vi vector<int>
using namespace std;
typedef pair<int, int> pii;
constexpr int N=210;
constexpr int inf = 1e18;
struct A
{
    int a;
    bool operator<(const A &t) const
    {
        return a < t.a;
    }
};
// priority_queue<pii, vector<pii>, greater<pii>> heap;
// cout << setprecision(n)
void solve()
{
    int n;
    cin>>n;
    // f[n][150][150][150]
    vector<array<int,3>> a(n+1);
    for(int i=1;i<=n;i++)
        for(int j=0;j<3;j++)
            cin >> a[i][j];
        
    vector f(2,vector(N+1,vector(N+1,vector(N+1,0ll))));
    for(int i=0;i<n;i++){
        //0
        int nxt=i&1^1,cur=i&1;
        for(int j=0;j<N;j++)
            for(int k=0;k<N;k++){
                int t=0;
                int tj = j + (j != 0), tk = k + (k != 0);
                if(tj<N&&tk<N){
                    // for (int l = 0; l < N; l++)
                    //     t = max(t, f[cur][l][j][k]);
                        f[nxt][1][tj][tk] = max(f[nxt][1][tj][tk],f[cur][N][j][k]+a[i+1][0] - j - k);
                        f[nxt][N][tj][tk] = max(f[nxt][N][tj][tk] ,f[nxt][1][tj][tk]);
                        f[nxt][1][N][tk] = max(f[nxt][1][N][tk], f[nxt][1][tj][tk]);
                        f[nxt][1][tj][N] = max(f[nxt][1][tj][N], f[nxt][1][tj][tk]);
                }
            
            }

        //1
        for(int j=0;j<N;j++)
            for(int k=0;k<N;k++){
                int t=0;
                int tj = j + (j != 0), tk = k + (k != 0);
                if (tj < N && tk < N)
                {
                    // for (int l = 0; l < N; l++)
                    //     t = max(t, f[cur][j][l][k]);
                        f[nxt][tj][1][tk] = max(f[nxt][tj][1][tk], f[cur][j][N][k]+a[i+1][1] - j - k);
                        f[nxt][N][1][tk] = max(f[nxt][N][1][tk], f[nxt][tj][1][tk]);
                        f[nxt][tj][N][tk] = max(f[nxt][tj][N][tk], f[nxt][tj][1][tk]);
                        f[nxt][tj][1][N] = max(f[nxt][tj][1][N], f[nxt][tj][1][tk]);
                }
            }

        //2
        for (int j = 0; j < N; j++)
            for (int k = 0; k < N; k++)
            {
                int t = 0;
                int tj = j + (j != 0), tk = k + (k != 0);
                if (tj < N && tk < N)
                {
                    // for (int l = 0; l < N; l++)
                    //     t = max(t, f[cur][j][k][l]);
                        f[nxt][tj][tk][1] = max(f[nxt][tj][tk][1], f[cur][j][k][N]+a[i+1][2] - j - k);
                        f[nxt][N][tk][1] = max(f[nxt][1][N][tk], f[nxt][tj][tk][1]);
                        f[nxt][tj][N][1] = max(f[nxt][tj][N][1], f[nxt][tj][tk][1]);
                        f[nxt][tj][tk][N] = max(f[nxt][tj][tk][N], f[nxt][tj][tk][1]);
                }
            }
    }

    int ans=0;
    for (int j = 0; j < N; j++)
        for (int k = 0; k < N; k++)
            ans=max({ans,(f[n&1][1][j][k]),(f[n&1][j][1][k]),(f[n&1][j][k][1])});
            
    // cout<<f[2][0][1][2]<<' '<<f[1][0][1][0]<<' '<<f[1][0][0][1]<<endl;
    cout << ans << endl;
}
signed main()
{
    // freopen("data3.in", "r", stdin);
    // freopen("data3.out", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    cin>>t;
    while (t--)
    {
        solve();
    }

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 82ms
memory: 228084kb

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: 207ms
memory: 227896kb

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:

1478314

result:

wrong answer 1st numbers differ - expected: '1505431', found: '1478314'