QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296001#4830. Transfer of Dutyhos_lyric0 85ms26504kbC++142.4kb2024-01-01 21:36:482024-01-01 21:36:48

Judging History

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

  • [2024-01-01 21:36:48]
  • 评测
  • 测评结果:0
  • 用时:85ms
  • 内存:26504kb
  • [2024-01-01 21:36:48]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

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")


#include <chrono>

#ifdef LOCAL
mt19937_64 rng(58);
#else
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#endif

////////////////////////////////////////////////////////////////////////////////


using U = unsigned long long;

constexpr int N = 1'000'010;

int main() {
  vector<U> rs(N);
  vector<pair<U, int>> ps(N);
  for (int u = 0; u < N; ++u) {
    rs[u] = rng();
    ps[u] = make_pair(rs[u], u);
  }
  sort(ps.begin(), ps.end());
  
  char typ[110];
  for (; ~scanf("%s", typ); ) {
    unsigned long long now = 0;
    if (!strcmp(typ, "resume")) {
      scanf("%llu", &now);
    }
    
    int Q;
    scanf("%d", &Q);
    for (; Q--; ) {
      int u;
      scanf("%d", &u);
      now ^= rs[u];
      
      if (!now) {
        puts("0");
      } else {
        auto it = lower_bound(ps.begin(), ps.end(), make_pair(now, -1));
        if (it != ps.end() && it->first == now) {
          printf("%d\n", it->second);
        } else {
          puts("-1");
        }
      }
    }
    
    if (!strcmp(typ, "start")) {
      printf("%llu\n", now);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 85ms
memory: 26504kb

input:

start
5
10
14
10
12
10

output:

10
-1
14
-1
-1
7177045345169533133

input:

resume
7177045345169533133
6
14
277
12
10
277
12

output:

-1
-1
-1
-1
-1
-1

result:

wrong answer