QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630860#9345. Artful Paintingscrimsonsunset#WA 0ms3600kbC++202.3kb2024-10-11 20:42:172024-10-11 20:42:17

Judging History

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

  • [2024-10-11 20:42:17]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-10-11 20:42:17]
  • 提交

answer

#include <bits/stdc++.h>
#include <bits/extc++.h>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

mt19937  rnd(1337);

void solve() {
    int n, m1, m2;
    cin >> n >> m1 >> m2;
    vector<int> p(m1 + m2);
    vector<vector<bool>> ch(m1 + m2, vector<bool>(n, false));
    for (int i = 0, l, r, k; i < m1; ++i) {
        cin >> l >> r >> k;
        --l, --r;
        p[i] = k;
        for (int j = l; j <= r; ++j)
            ch[i][j] = 1;
    }
    for (int i = 0, l, r, k; i < m2; ++i) {
        cin >> l >> r >> k;
        --l, --r;
        p[i + m1] = k;
        for (int j = 0; j < n; ++j)
            if (j < l || j > r)
                ch[i + m1][j] = 1;
    }
    vector<int> ord(n);
    iota(all(ord), 0);
    shuffle(all(ord), rnd);
    vector<int> rev(n);
    for (int i = 0; i < n; ++i)
        rev[ord[i]] = i;
    vector<int> cnt(n, 0);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < m1 + m2; ++j)
            if (p[j] != 0)
                cnt[i] += ch[j][i];
    int ans = 0;
    set<pair<int, int>> val;
    for (int i = 0; i < n; ++i)
        val.insert({cnt[i], ord[i]});
    set<int> l;
    for (int i = 0; i < m1 + m2; ++i)
        if (p[i] != 0)
            l.insert(i);
    while (l.size()) {
        ++ans;
        auto v = rev[prev(val.end())->second];
        val.erase(prev(val.end()));
        cout << v << endl;
        for (int j = 0; j < m1 + m2; ++j)
            if (ch[j][v]) {
                --p[j];
                if (p[j] == 0) {
                    l.erase(j);
                    for (int q = 0; q < n; ++q)
                        if (ch[j][q]) {
                            auto it = val.find({cnt[q], ord[q]});
                            if (it != val.end()) {
                                val.erase(it);
                                --cnt[q];
                                val.insert({cnt[q], ord[q]});
                            }
                        }
                }
            }
    }
    cout << ans << '\n';
}

signed main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--)
        solve();
}

详细

Test #1:

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

input:

1
3 1 1
1 2 1
2 2 1

output:

0
1

result:

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