QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#571554#9353. Interesting Permutationreal_sigma_team#WA 0ms3544kbC++171.9kb2024-09-18 00:29:392024-09-18 00:29:40

Judging History

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

  • [2024-09-18 00:29:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3544kb
  • [2024-09-18 00:29:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int tests;
    cin >> tests;
    while (tests--) {
        int n;
        cin >> n;
        int m1, m2;
        cin >> m1 >> m2;
        vector<tuple<int, int, int>> q1(m1), q2(m2);
        for (auto& [l, r, x] : q1) {
            cin >> l >> r >> x;
            --l;
        }
        for (auto& [l, r, x] : q2) {
            cin >> r >> l >> x;
            --r;
        }
        int L = 0, R = n;
        while (L != R) {
            int M = (L + R) / 2;
            vector<int> dist(n + 1, -1e9);
            dist[0] = 0;
            bool upd = false;
            for (int iter = 0; iter <= n + 1; ++iter) {
                upd = false;
                for (int i = 0; i < n; ++i) {
                    if (dist[i + 1] < dist[i]) {
                        dist[i + 1] = dist[i];
                        upd = true;
                    }
                }
                for (int i = 0; i < n; ++i) {
                    if (dist[i] < dist[i + 1] - 1) {
                        dist[i] = dist[i + 1] - 1;
                        upd = true;
                    }
                }
                for (auto [l, r, x] : q1) {
                    if (dist[r] < dist[l] + x) {
                        dist[r] = dist[l] + x;
                        upd = true;
                    }
                }
                for (auto [l, r, x] : q2) {
                    x -= M;
                    if (dist[r] < dist[l] + x) {
                        dist[r] = dist[l] + x;
                        upd = true;
                    }
                }
            }
            if (dist[n] > M || upd) {
                L = M + 1;
            } else {
                R = M;
            }
        }
        cout << R << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3544kb

input:

3
3
0 2 2
3
0 1 2
3
0 2 3

output:

3
0
0

result:

wrong answer 1st lines differ - expected: '2', found: '3'