QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#403946#5188. 鬼街james1BadCreeperWA 0ms4012kbC++142.7kb2024-05-02 22:41:022024-05-02 22:41:02

Judging History

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

  • [2024-05-02 22:41:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4012kb
  • [2024-05-02 22:41:02]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define COLOR(s) ("\x1b[" s "m")

int main() {
  int N, Q;
  for (; ~scanf("%d%d", &N, &Q); ) {
    vector<vector<int>> pss(N + 1);
    for (int p = 2; p <= N; ++p) if (!pss[p].size()) {
      for (int n = p; n <= N; n += p) pss[n].push_back(p);
    }
    
    vector<Int> damage(N, 0);
    using Entry = pair<Int, int>;
    vector<set<Entry>> ss(N);
    vector<int> xs(Q + 1, 0);
    vector<Int> ys(Q + 1, 0);
    vector<int> done(Q + 1, 0);
    
    vector<int> que;
    auto update = [&](int u) -> void {
      const auto &ps = pss[xs[u]];
      const int psLen = ps.size();
      Int hp = ys[u];
      for (const int p : ps) {
        hp -= damage[p];
      }
      if (hp <= 0) {
        done[u] = 1;
        que.push_back(u);
      } else {
        for (int i = 0; i < psLen; ++i) {
          ss[ps[i]].insert(make_pair(damage[ps[i]] + (hp - 1 + i) / psLen, u));
        }
      }
    };
    
    Int lastans = 0;
    int id = 0;
    for (int q = 0; q < Q; ++q) {
      int O, X;
      Int Y;
      scanf("%d%d%lld", &O, &X, &Y);
      Y ^= lastans;
// cerr<<COLOR("33")<<O<<" "<<X<<" "<<Y<<COLOR()<<endl;
      if (O == 0) {
        for (const int p : pss[X]) {
          damage[p] += Y;
        }
        for (const int p : pss[X]) {
          for (; ss[p].size() && (*ss[p].begin()).first < damage[p]; ) {
            const int u = (*ss[p].begin()).second; ss[p].erase(ss[p].begin()); 
            update(u); 
          }
        }
        vector<int> ans;
        ans.swap(que);
        sort(ans.begin(), ans.end());
        printf("%d", (int)ans.size());
        for (const int u : ans) {
          printf(" %d", u);
        }
        puts("");
        lastans = ans.size();
      } else if (O == 1) {
        const int u = ++id;
        xs[u] = X;
        ys[u] = Y;
        for (const int p : pss[X]) {
          ys[u] += damage[p];
        }
        update(u);
      } else {
        assert(false);
      }
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

20 9
1 10 2
0 5 0
0 6 1
0 7 1
0 15 1
1 12 3
0 8 0
1 5 0
0 8 2

output:

0
0
0
1 1
1 1
1 2

result:

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