QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417120#6692. Building CompanyXiaoretaWWA 0ms3496kbC++202.4kb2024-05-22 14:45:322024-05-22 14:45:32

Judging History

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

  • [2024-05-22 14:45:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3496kb
  • [2024-05-22 14:45:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define rep(i, l, r) for (int i = l; i < r; ++i)
#define per(i, r, l) for (int i = r-1; i >= l; --i)
typedef long long ll;
typedef pair<int, int> PI;
template<typename T> bool setmax(T &a, T b) { return (a < b ? a = b, 1 : 0); }
template<typename T> bool setmin(T &a, T b) { return (a > b ? a = b, 1 : 0); }

#define print(a) cerr << "[ "; for (auto it : a) cerr << it << ", "; cerr << "]\n";

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int g; cin >> g;
    map<int, int> has;
    for (int i = 0; i < g; i++) {
        int t, u; cin >> t >> u;
        has[t] = u;
    }
    int n; cin >> n;
    map<int, int> need;
    map<int, multiset<PI>> todo;
    vector<vector<PI>> bonus(n);
    vector<int> vis(n);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int m; cin >> m;
        for (int j = 0; j < m; j++) {
            int a, b; cin >> a >> b;
            if (has[a] >= b) continue;
            ++need[i];
            todo[a].insert(mp(b, i));
        }
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int c, d; cin >> c >> d;
            bonus[i].push_back(mp(c, d));
        }
        if (!need[i]) {
            // finish
            auto get = [&](auto get, int x) -> void {
                ++ans;
                vector<int> finish;
                for (auto [c, d] : bonus[x]) {
                    has[c] += d;
                    int cnt = 0;
                    for (auto [more, id] : todo[c]) {
                        if (more > has[c]) break;
                        ++cnt;
                        --need[id];
                        if (!need[id] && !vis[id]) {
                            // get(get, id);
                            finish.push_back(id);
                            vis[id] = 1;
                        }
                    }
                    while (cnt--) todo[c].erase(todo[c].begin());
                    // cerr << "??? " << x << ' ';
                    // print(finish);
                }
                for (int id : finish) get(get, id);
            };
            vis[i] = 1;
            get(get, i);
        }
    }

    cout << ans << '\n';

    return 0;
}

详细

Test #1:

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

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: -100
Wrong Answer
time: 0ms
memory: 3496kb

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:

8

result:

wrong answer 1st numbers differ - expected: '10', found: '8'