QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#571383#9345. Artful Paintingsucup-team004#WA 20ms3676kbC++201.7kb2024-09-17 22:28:212024-09-17 22:28:21

Judging History

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

  • [2024-09-17 22:28:21]
  • 评测
  • 测评结果:WA
  • 用时:20ms
  • 内存:3676kb
  • [2024-09-17 22:28:21]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;

bool chmin(i64 &a, i64 b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    int N, M1, M2;
    std::cin >> N >> M1 >> M2;
    
    std::vector<int> L(M1 + M2), R(M1 + M2), K(M1 + M2);
    for (int i = 0; i < M1 + M2; i++) {
        std::cin >> L[i] >> R[i] >> K[i];
        L[i]--;
    }
    
    int lo = 0, hi = N;
    while (lo < hi) {
        int x = (lo + hi) / 2;
        
        std::vector<i64> f(N + 1);
        int lst = -1;
        for (int t = 0; t <= N; t++) {
            for (int i = 0; i < M1 + M2; i++) {
                if (i < M1) {
                    if (chmin(f[L[i]], f[R[i]] - K[i])) {
                        lst = t;
                    }
                } else {
                    if (chmin(f[R[i]], f[L[i]] + x - K[i])) {
                        lst = t;
                    }
                }
            }
            for (int i = N - 1; i >= 0; i--) {
                if (chmin(f[i], f[i + 1])) {
                    lst = t;
                }
            }
            if (chmin(f[N], f[0] + x)) {
                lst = t;
            }
            if (chmin(f[0], f[N] - x)) {
                lst = t;
            }
        }
        if (lst == N) {
            lo = x + 1;
        } else {
            hi = x;
        }
    }
    
    std::cout << lo << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int T;
    std::cin >> T;
    
    while (T--) {
        solve();
    }
    
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3492kb

input:

1
3 1 1
1 2 1
2 2 1

output:

1

result:

ok single line: '1'

Test #2:

score: -100
Wrong Answer
time: 20ms
memory: 3676kb

input:

1
1000 500 500
479 860 170
73 939 25
363 772 30
185 584 89
326 482 10
784 949 23
384 740 114
233 693 45
167 724 211
217 436 95
46 701 153
138 585 67
321 388 11
114 890 194
407 854 74
438 845 117
9 718 259
393 576 35
182 707 257
451 766 136
150 382 31
468 785 40
202 490 46
326 815 59
272 441 77
123 8...

output:

490

result:

wrong answer 1st lines differ - expected: '492', found: '490'