QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#294627#4830. Transfer of Dutyucup-team1055#0 686ms73376kbC++201.9kb2023-12-30 15:05:072023-12-30 15:05:08

Judging History

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

  • [2023-12-30 15:05:08]
  • 评测
  • 测评结果:0
  • 用时:686ms
  • 内存:73376kb
  • [2023-12-30 15:05:07]
  • 提交

answer

#include <bits/stdc++.h>

#define rep(i, s, n) for (int i = int(s); i < int(n); i++)
#define rrep(i, s, n) for (int i = int(n) - 1; i >= int(s); i--)
#define all(v) (v).begin(), (v).end()

using ll = long long;
using ull = unsigned long long;
using ld = long double;

template <class T> bool chmin(T &a, T b) {
    if (a <= b) return false;
    a = b;
    return true;
}

template <class T> bool chmax(T &a, T b) {
    if (a >= b) return false;
    a = b;
    return true;
}

struct random_number_generator {
    random_number_generator(int seed = -1) {
        if (seed < 0) seed = rnd();
        mt.seed(seed);
    }

    void set_seed(int seed) {
        mt.seed(seed);
    }

    template <class T> T get(T a, T b) {
        std::uniform_int_distribution<T> dist(a, b - 1);
        return dist(mt);
    }

  private:
    std::mt19937_64 mt;
    std::random_device rnd;
};

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::string s;
    std::cin >> s;
    const int max = 1'000'000;
    std::vector<ull> xs(max, 0);
    ull seed;
    ull now = 0;
    if (s == "start") {
        seed = std::random_device()();
    } else {
        assert(s == "resume");
        std::cin >> now >> seed;
    }
    random_number_generator rng(seed);
    std::map<ull, int> map;
    map[0] = -1;
    rep(i, 0, max) {
        if (map.contains(xs[i])) {
            xs[i] = rng.get<ull>(0, std::numeric_limits<ull>::max());
        }
        map[xs[i]] = i;
    }
    int n;
    std::cin >> n;
    rep(i, 0, n) {
        int p;
        std::cin >> p;
        p--;
        now ^= xs[p];
        if(map.contains(now)) {
            std::cout << map[now] + 1 << '\n';
        }
        else if(now == 0) {
            std::cout << "0\n";
        }
        else {
            std::cout << "-1\n";
        }
    }
    if(s == "start") {
        std::cout << now << " " << seed << '\n';
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 686ms
memory: 73368kb

input:

start
5
10
14
10
12
10

output:

10
-1
14
-1
-1
13055252766390202823 1774147400

input:

resume
13055252766390202823 1774147400
6
14
277
12
10
277
12

output:

-1
-1
-1
277
0
12

result:

ok 

Test #2:

score: 0
Wrong Answer
time: 654ms
memory: 73376kb

input:

start
1
1

output:

1
10666354965568341104 2324973465

input:

resume
10666354965568341104 2324973465
1
1

output:

-1

result:

wrong answer