QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#630760#9345. Artful Paintingscrimsonsunset#WA 61ms4060kbC++202.0kb2024-10-11 20:17:592024-10-11 20:17:59

Judging History

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

  • [2024-10-11 20:17:59]
  • 评测
  • 测评结果:WA
  • 用时:61ms
  • 内存:4060kb
  • [2024-10-11 20:17:59]
  • 提交

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()

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> 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], 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 = prev(val.end())->second;
        val.erase(prev(val.end()));
        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], q});
                            if (it != val.end()) {
                                val.erase(it);
                                --cnt[q];
                                val.insert({cnt[q], q});
                            }
                        }
                }
            }
    }
    cout << ans << '\n';
}

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

詳細信息

Test #1:

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

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: 61ms
memory: 4060kb

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:

506

result:

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