QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#119297#6669. MapaLinshey#0 0ms0kbC++143.4kb2023-07-05 09:57:532024-05-31 19:05:14

Judging History

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

  • [2024-05-31 19:05:14]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-05 09:57:53]
  • 提交

answer


#include <bits/stdc++.h>

using namespace std; const int N = 128, M = 20000;

unsigned k[N], v[N];

unsigned seed;

inline unsigned rnd(unsigned x) { return (unsigned long long)k[x] * seed % 998244353 ^ seed ^ k[x]; }

char s[M]; int t;

inline void print_(unsigned x, int pr)
{
    int l = x ? 31 - __builtin_clz(x) : -1;
    for (int i = pr; i <= l; i++) s[t++] = '1'; s[t++] = '0';
    for (int i = max(pr - 1, l); i >= 0; i--) s[t++] = (x >> i & 1) + '0';
}

inline unsigned read_(int pr)
{
    int l = pr; unsigned res = 0;
    while (s[t++] == '1') l++;
    while (l--) res = res << 1 | (s[t++] - '0');
    return res;
}

inline void Print(unsigned x)
{
    for (int i = 29; i >= 0; i--) s[t++] = (x >> i & 1) + '0';
}

inline unsigned Read()
{
    int l = 30; unsigned res = 0;
    while (l--) res = res << 1 | (s[t++] - '0');
    return res;
}

unsigned pos[N];
int mp[8];

mt19937 rng(23333);

void Solve0(vector<int> ss)
{
    int n = ss.size();
    if (n <= 8)
    {
        int x = 0, y;
        do
        {
            y = 0, seed = rng(), x++;
            memset(mp, 0, sizeof(int) * 8);
            for (int z : ss) if (mp[rnd(z) % (n * 13) / 13]++) { y = 1; break; }
        }
        while (y != 0);
        print_(x, 8);
        // cerr << "?" << seed << endl;
    // cerr << "Solve0: " << n << ' ' << x << endl;
        for (int z : ss) pos[z] += (rnd(z) % (n * 13) / 13);
    }
    else
    {
        int tar = n >> 1;
        int x = 0, y;
        do
        {
            y = 0, seed = rng(), x++;
            for (int z : ss) y += (rnd(z) % 19260818 < 9630409);
        }
        while (y != tar);
        print_(x, __builtin_ctz(n) >> 1);
        // cerr << "!" << seed << endl;
    // cerr << "Solve0: " << n << ' ' << x << endl;
        vector<int> s0, s1;
        for (int z : ss) if (rnd(z) % 19260818 < 9630409) pos[z] += n - tar, s0.push_back(z); else s1.push_back(z);
        Solve0(s0), Solve0(s1);
    }
}

void Solve1(vector<int> ss, int n)
{
    if (n <= 8)
    {
        int x = read_(8); while (x--) seed = rng();
        // cerr << "?" << seed << endl;
        for (int z : ss) pos[z] += (rnd(z) % (n * 13) / 13);
    }
    else
    {
        int tar = n >> 1;
        int x = read_(__builtin_ctz(n) >> 1); while (x--) seed = rng();
        // cerr << "!" << seed << endl;
        vector<int> s0, s1;
        for (int z : ss) if (rnd(z) % 19260818 < 9630409) pos[z] += n - tar, s0.push_back(z); else s1.push_back(z);
        Solve1(s0, tar), Solve1(s1, n - tar);
    }
}

unsigned table[N];

int main()
{
    // freopen("tmp2.log", "w", stderr);
    int OP; cin >> OP;
    if (OP == 1)
    {
        int n; scanf("%d", &n);
        for (int i = 0; i < n; i++) scanf("%u%u", k + i, v + i);
        vector<int> ss;
        for (int i = 0; i < n; i++) ss.push_back(i);
        Solve0(ss);
        for (int i = 0; i < n; i++) table[pos[i]] = v[i];
        for (int i = 0; i < n; i++) Print(table[i]);
        // cerr << "t: " << t << endl;
        printf("%s\n", s);
    }
    else
    {
        int n, q, K;
        scanf("%d%d%d", &n, &q, &K);
        scanf("%s", s);
        for (int i = 0; i < q; i++) scanf("%u", k + i);
        vector<int> ss;
        for (int i = 0; i < q; i++) ss.push_back(i);
        Solve1(ss, n);
        for (int i = 0; i < n; i++) table[i] = Read();
        for (int i = 0; i < q; i++) printf("%u\n", table[pos[i]]);
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

1
100
495528311 963488152
269613430 443544124
700489871 792354118
151890319 506569919
180452297 13229948
684464994 543841485
978085128 903812192
238355172 441140842
28061035 783291471
530823766 718942732
936853023 439421263
201361623 226633955
304644844 778868118
864860135 461524170
88300500 6959354...

output:

111101011011110100111101111011001011001000110111101000010000001110001110111011000000101000000010111011000111101100110111111111011011111010001000000010001100010101000010011000100110110101011000000100101010111011101101100111000010100000110010000101111100100000111001110001000010011001100000000111100110...

input:

Invalid Output on Phase 1

output:


result: