QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#781675#6692. Building CompanyxixuRE 2ms8304kbC++111.9kb2024-11-25 16:52:572024-11-25 16:53:19

Judging History

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

  • [2024-11-25 16:53:19]
  • 评测
  • 测评结果:RE
  • 用时:2ms
  • 内存:8304kb
  • [2024-11-25 16:52:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fup(a, b, c, d) for(int a = (b); a <= (c); a += (d))
#define fdo(a, b, c, d) for(int a = (b); a >= (c); a -= (d))
typedef long long ll;
typedef pair<int , int> PII;
typedef map<int , int> MII;
const int inf = 0x3f3f3f3f, N = 2e5 + 10, M = 4e5 + 10, mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int g, n;

int yq[N];
map<int , priority_queue<PII, vector<PII>, greater<PII>>> he;
vector<PII> v[N];
queue<int> q;
vector<PII> ch;
map<int , int> mp;

void add(int op, int nu)
{
    int &va = mp[op];
    va += nu;
    priority_queue<PII, vector<PII>, greater<PII>> &pq = he[op];

    while(!pq.empty()) {
        PII p = pq.top();
        if(p.first > va) break ;
        pq.pop();
        if((-- yq[op]) == 0) q.push(p.second);
    }
}

void solve()
{
    cin >> g;

    fup(i, 1, g, 1) {
        int a, b;
        cin >> a >> b;
        ch.push_back({a,b});
    }

    cin >> n;

    fup(i, 1, n, 1) {
        int m, k;
        cin >> m;
        yq[i] = m;
        fup(j, 1, m, 1) {
            int a, b;
            cin >> a >> b;
            he[a].push({b, i});
        }

        cin >> k;
        fup(j, 1, k, 1) {
            int c, d;
            cin >> c >> d;
            v[i].push_back({c, d});
        }
    }

    fup(i, 1, n, 1) {
        if(!yq[i]) {
            q.push(i);
        }
    }

    for(auto x : ch) {
        int op, nu;
        op = x.first, nu = x.second;
        add(op, nu);
    }

    int ans = 0;
    while(!q.empty()) {
        int id = q.front();
        q.pop();
        ans ++;

        for(auto x : v[id]) add(x.first, x.second);
    }

    cout << ans << '\n';
}

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int _ = 1;
    // cin >> _;
    while(_ --)
    {
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 8304kb

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
Runtime Error

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:


result: