QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#403841#8302. Incoming Asteroidsjames1BadCreeperWA 0ms24632kbC++141.8kb2024-05-02 19:34:332024-05-02 19:34:33

Judging History

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

  • [2024-05-02 19:34:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:24632kb
  • [2024-05-02 19:34:33]
  • 提交

answer

#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N = 3e5 + 5; 

int n, q, id; 
int a[N], arr[N]; 
set<pair<int, int>> st[N]; 
vector<pair<int, pair<int, int>>> loc[N]; 

int main(void) {
    ios::sync_with_stdio(0); 
    cin >> n >> q; 
    for (int lst = 0; q--; ) {
        int op; cin >> op;
        if (op == 1) {
            int y, k; cin >> y >> k; y ^= lst; arr[id++] = y; // 报警限制
            while (k--) {
                int v; cin >> v; v ^= lst; 
                st[v].emplace((y + 2) / 3 + a[v], id); 
                loc[id].push_back({v, {(y + 2) / 3 + a[v], a[v]}}); 
            }
        } else {
            int x, y; cin >> x >> y; x ^= lst; y ^= lst;
            int cnt = 0; a[x] += y; 

            vector<int> ans; 
            while (st[x].size()) {
                auto p = *st[x].begin();
                if (p.fi > a[x]) break; 

                int idx = p.se; // 检查这一条报警
                vector<int> vec; 
                for (auto nxt : loc[idx]) {
                    arr[idx] -= a[nxt.fi] - nxt.se.se; 
                    st[nxt.fi].erase({nxt.se.fi, idx}); 
                    vec.push_back(nxt.fi); 
                }
                if (arr[idx] <= 0) { ans.push_back(idx); continue; }

                loc[idx].clear(); 
                int v = (arr[idx] + 2) / 3; 
                for (int nxt : vec) {
                    st[nxt].emplace(v + a[nxt], idx); 
                    loc[idx].push_back({nxt, {v + a[nxt], a[nxt]}}); 
                }
            }

            lst = ans.size(); sort(ans.begin(), ans.end()); 
            cout << ans.size() << " "; 
            for (int i : ans) cout << i << " "; 
            cout << "\n"; 
        }
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 5
1 5 3 1 2 3
2 2 1
1 2 2 1 2
2 3 1
2 1 3

output:

0 
0 
2 1 2 

result:

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