QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#626693#7905. Ticket to RideMiniLongWA 2ms3976kbC++173.4kb2024-10-10 11:43:512024-10-10 11:43:56

Judging History

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

  • [2024-10-10 11:43:56]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3976kb
  • [2024-10-10 11:43:51]
  • 提交

answer

#include <bits/stdc++.h>
#define _rep(i, x, y) for(int i = x; i <= y; ++i)
#define _req(i, x, y) for(int i = x; i >= y; --i)
#define _rev(i, u) for(int i = head[u]; i; i = e[i].nxt)
#define pb push_back
#define fi first
#define se second
#define mst(f, i) memset(f, i, sizeof f)
using namespace std;
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
typedef long long ll;
typedef pair<int, int> PII;
namespace fastio{
    #ifdef ONLINE_JUDGE
    char ibuf[1 << 20],*p1 = ibuf, *p2 = ibuf;
    #define get() p1 == p2 && (p2 = (p1 = ibuf) + fread(ibuf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++
    #else
    #define get() getchar()
    #endif
    template<typename T> inline void read(T &t){
        T x = 0, f = 1;
        char c = getchar();
        while(!isdigit(c)){
            if(c == '-') f = -f;
            c = getchar();
        }
        while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
        t = x * f;
    }
    template<typename T, typename ... Args> inline void read(T &t, Args&... args){
        read(t);
        read(args...);
    }
    template<typename T> void write(T t){
        if(t < 0) putchar('-'), t = -t;
        if(t >= 10) write(t / 10);
        putchar(t % 10 + '0');
    }
    template<typename T, typename ... Args> void write(T t, Args... args){
        write(t), putchar(' '), write(args...);
    }
    template<typename T> void writeln(T t){
        write(t);
        puts("");
    }
    template<typename T> void writes(T t){
        write(t), putchar(' ');
    }
    #undef get
};
using namespace fastio;
#define multitest() int T; read(T); _rep(tCase, 1, T)
namespace Calculation{
    const ll mod = 998244353;
    ll ksm(ll p, ll h){ll base = p % mod, res = 1; while(h){if(h & 1ll) res = res * base % mod; base = base * base % mod, h >>= 1ll;} return res;}
    void dec(ll &x, ll y){x = ((x - y) % mod + mod) % mod;}
    void add(ll &x, ll y){x = (x + y) % mod;}
    void mul(ll &x, ll y){x = x * y % mod;}
    ll sub(ll x, ll y){return ((x - y) % mod + mod) % mod;}
    ll pls(ll x, ll y){return ((x + y) % mod + mod) % mod;}
    ll mult(ll x, ll y){return x * y % mod;}
}
using namespace Calculation;
const int N = 1e4 + 5, M = 5005;
const ll inf = 0x3f3f3f3f3f3f3f3f;
ll n, m;
vector<PII> v[N];
ll w[M][M];
ll g[N][2], f[N][2], ans[N];
int main(){
    multitest(){
        read(n, m);
        _rep(i, 1, m){
            ll l, r, w; read(l, r, w);
            v[r].pb({l, w});
        }
        _rep(i, 0, n) _rep(j, 0, n) w[i][j] = -inf;
        w[0][0] = 0;
        _rep(t, 0, n){//t = i - j
            int c = t & 1;
            _rep(i, t, n){
                int j = i - t;
                g[i][c] = max(g[i - 1][c ^ 1], f[i - 1][c ^ 1]);
                w[t][i] = max(w[t][i], g[i][t]);
                for(auto &[l, val] : v[i]){
                    _rep(k, 0, l) w[t][k] += val;
                }
                _rep(k, 0, i - 1) f[i][c] = max(f[i][c], w[t][k]);
            }
            ans[n - t] = max(ans[n - t], max(g[n][c], f[n][c]));
            _rep(i, 0, n) f[i][c ^ 1] = g[i][c ^ 1] = 0;
        }
        _rep(i, 1, n) writes(ans[i]); puts("");
        _rep(i, 0, n){
            ans[i] = 0;
            _rep(j, 0, 1) f[i][j] = g[i][j] = 0;
            _rep(j, 0, n) w[i][j] = 0;
            v[i].clear();
        }
    }    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3952kb

input:

2
4 3
0 2 3
3 4 2
0 3 1
3 1
1 3 100

output:

2 3 5 6 
0 100 100 

result:

ok 2 lines

Test #2:

score: -100
Wrong Answer
time: 2ms
memory: 3976kb

input:

1000
2 9
0 2 396628655
1 2 268792718
0 2 16843338
1 2 717268783
0 1 693319712
0 1 856168102
1 2 407246545
1 2 527268921
0 1 536134606
6 2
2 5 451394766
0 5 695984050
9 7
0 6 73936815
2 9 505041862
4 5 223718927
5 7 179262261
3 5 449258178
0 5 493128
0 3 994723920
6 6
3 5 433389755
2 4 773727734
4 5 ...

output:

2085622420 4419671380 
0 0 451394766 451394766 1147378816 1147378816 
223718927 672977105 994723920 1218442847 1668194153 1742130968 1921393229 1921393229 2426435091 
127680943 773727734 1334798432 2227456393 2675644351 2675644351 
976357580 1353785907 2103791342 2347908675 3241574409 3936588085 418...

result:

wrong answer 5th lines differ - expected: '976357580 1594205360 210379134...241574409 3936588085 4180705418', found: '976357580 1353785907 210379134...41574409 3936588085 4180705418 '