QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#418520#6692. Building CompanyOneWan#WA 2ms5960kbC++231.8kb2024-05-23 14:20:262024-05-23 14:20:26

Judging History

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

  • [2024-05-23 14:20:26]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5960kb
  • [2024-05-23 14:20:26]
  • 提交

answer

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

using i64 = long long;

int __OneWan_2024 = [](){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	return 0;
}();

map<int, i64> cnt;
map<int, vector<array<int, 2>>> mp;
int flag[100005];
int m[100005];
int k[100005];
vector<array<int, 2>> v[100005];
int main() {
    int g;
    cin >> g;
    for (int i = 1; i <= g; i++) {
        int x, y;
        cin >> x >> y;
        cnt[x] += y;
    }
    int n;
    cin >> n;
    for (int i = 1 ; i <= n ; i++) {
        cin >> m[i];
        flag[i] = 0;
        for (int j = 0 ; j < m[i] ; j++) {
            int x, y;
            cin >> x >> y;
            if (cnt.count(x) && cnt[x] >= y) {
                flag[i]++;
            } else {
                mp[x].push_back({y, i});
            }
        }
        cin >> k[i];
        for (int j = 0 ; j < k[i] ; j++) {
            int x, y;
            cin >> x >> y;
            v[i].push_back({x, y});
        }
    }
    for (auto &[_, vec] : mp) {
        sort(rbegin(vec), rbegin(vec));
    }
    queue<int> que;
    for (int i = 1 ; i <= n ; i++) {
        if (flag[i] == m[i]) {
            que.push(i);
        }
    }
    while (!que.empty()) {
        int x = que.front();
        que.pop();
        for (auto &[x, y] : v[x]) {
            i64 z = cnt[x] += y;
            auto &vec = mp[x];
            while (!vec.empty() && vec.back()[0] <= z) {
                int gs = vec.back()[1];
                flag[gs]++;
                if (flag[gs] == m[gs]) {
                    que.push(gs);
                }
                vec.pop_back();
            }
        }
    }
    int ans = 0;
    for (int i = 1 ; i <= n ; i++) {
        if (flag[i] == m[i]) {
            ans++;
        }
    }
    cout << ans << "\n";
	return 0;
}

详细

Test #1:

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

input:

2 2 1 1 2
5
1 3 1
0
2 1 1 2 1
2 3 2 2 1
3 1 5 2 3 3 4
1 2 5
3 2 1 1 1 3 4
1 1 3
0
1 3 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 5860kb

input:

3 610031727 590328742 816793299 18485566 654221125 47823436
10
3 610031727 224714165 816793299 491951703 654221125 593479446
1 610031727 538596643
1 610031727 551036304
3 816793299 262985484 610031727 52580932 654221125 424397787
1 654221125 889197190
3 654221125 126924193 610031727 963399336 816793...

output:

10

result:

ok 1 number(s): "10"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3612kb

input:

10 720543365 814021419 777649737 273919247 339754140 472967790 545693058 298289557 949226024 176807538 267294560 819212220 337794335 504610276 137418995 614590802 632556957 783062334 587607535 115519693
100
5 949226024 327424834 777649737 117746775 137418995 152960310 720543365 423301366 267294560 4...

output:

100

result:

ok 1 number(s): "100"

Test #4:

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

input:

33 598906111 952747266 214206082 308472115 773699301 71970369 334282917 266176016 861160505 745480638 397625705 130382274 75028923 106125916 739923352 754152044 493886549 212094717 352869179 727757279 697376464 343501623 916521518 80952344 90959088 722016125 286878647 329186592 770901193 30277256 92...

output:

2

result:

wrong answer 1st numbers differ - expected: '100', found: '2'