QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#770545#147. Floppysnpmrnhlol0 34ms10952kbC++173.1kb2024-11-21 22:18:182024-11-21 22:18:18

Judging History

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

  • [2024-11-21 22:18:18]
  • 评测
  • 测评结果:0
  • 用时:34ms
  • 内存:10952kb
  • [2024-11-21 22:18:18]
  • 提交

floppy

#include <bits/stdc++.h>
#include "floppy.h"
using namespace std;
void read_array(int subtask_id, const std::vector<int> &v) {
    std::string bits = "";
    int n = (int)v.size();
    /// i dont know what the fuck am i fucking doing
    vector <vector<int>> rmq;
    rmq.assign(n, vector<int>(16, 0));
    for(int i = 0;i < 16;i++){
        for(int j = 0;j < n - (1<<i) + 1;j++){
            if(i == 0){
                rmq[j][i] = j;
            }else{
                rmq[j][i] = ((v[rmq[j][i - 1]] < v[rmq[j + (1<<(i - 1))][i - 1]])?rmq[j + (1<<(i - 1))][i - 1]:rmq[j][i - 1]);
            }
        }
    }
    auto query = [&](int l, int r) -> int{
        int nr = 31 - __builtin_clz(r - l + 1);
        int x = rmq[l][nr];
        int y = rmq[r - (1<<nr) + 1][nr];
        if(v[x] < v[y])return y;
        else return x;
    };
    auto ballcutter = [&](auto self, int l, int r) -> void{
        ///retain if has left child or right child
        ///thats it
        ///im losing my mind
        int id = query(l, r);
        if(l <= id - 1){
            bits+='1';
        }else bits+='0';
        if(id + 1 <= r){
            bits+='1';
        }else bits+='0';
        if(l <= id - 1)self(self, l, id - 1);
        if(id + 1 <= r)self(self, id + 1, r);
    };
    ballcutter(ballcutter, 0, n - 1);
    save_to_floppy(bits);
}

std::vector<int> solve_queries(int subtask_id, int n,
        const std::string &bits,
        const std::vector<int> &a, const std::vector<int> &b) {
    int m = a.size();
    vector<int> answers;
    vector <vector<int>> edge(n);
    vector <int> val(n);
    vector <int> v(n);
    vector <int> sub(n);
    int pt = 0;
    int cnt = 0;
    auto dfs = [&](auto self, int node, int st) -> void{
        int lc = -1, rc = -1;
        if(bits[pt] == '1'){
            edge[node].push_back(cnt);
            lc = cnt;
            cnt++;
        }
        if(bits[pt + 1] == '1'){
            edge[node].push_back(cnt);
            rc = cnt;
            cnt++;
        }
        pt+=2;
        sub[node] = 1;
        if(lc != -1){self(self, lc, st + 1);val[node] = max(val[node], val[lc] + 1);sub[node]+=sub[lc];st+=sub[lc];};
        if(rc != -1){self(self, rc, st + 1);val[node] = max(val[node], val[rc] + 1);sub[node]+=sub[rc];};
        v[st] = val[node];
    };
    cnt = 1;
    dfs(dfs, 0, 0);
    ///uhh idk what to do now
    vector <vector<int>> rmq;
    rmq.assign(n, vector<int>(16, 0));
    for(int i = 0;i < 16;i++){
        for(int j = 0;j < n - (1<<i) + 1;j++){
            if(i == 0){
                rmq[j][i] = j;
            }else{
                rmq[j][i] = ((v[rmq[j][i - 1]] < v[rmq[j + (1<<(i - 1))][i - 1]])?rmq[j + (1<<(i - 1))][i - 1]:rmq[j][i - 1]);
            }
        }
    }
    auto query = [&](int l, int r) -> int{
        int nr = 31 - __builtin_clz(r - l + 1);
        int x = rmq[l][nr];
        int y = rmq[r - (1<<nr) + 1][nr];
        if(v[x] < v[y])return y;
        else return x;
    };
    /// im fucking lazy
    for(int i = 0;i < m;i++){
        answers.push_back(query(a[i], b[i]));
    }
    return answers;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

input:

1 496
484
491
478
483
452
446
458
493
453
457
468
418
440
241
267
365
462
441
495
39
54
70
26
97
152
24
105
85
170
298
42
275
305
295
297
207
211
296
184
346
98
123
171
157
135
194
243
156
115
196
169
53
138
93
263
251
201
195
333
324
396
338
270
311
359
289
290
486
403
183
339
310
473
464
471
469
4...

output:

992
11111100110010010011100011110010100000111111111111111011101110000011000010001100111000001111111011100001001101000111000001010000110110001000111111011100001100001110110001001111000001111000001111101001010000001111000011111100000010001111111101110110000111000011001111110111000101000101100011111100...

input:

1 496
992
11111100110010010011100011110010100000111111111111111011101110000011000010001100111000001111111011100001001101000111000001010000110110001000111111011100001100001110110001001111000001111000001111101001010000001111000011111100000010001111111101110110000111000011001111110111000101000101100011...

output:

115
18
115
305
115
18
305
374
115
305
115
374
115
115
305
367
374
463
305
305
18
115
430
203
305
305
115
43
69
18
115
115
305
305
115
374
115
353
69
305
115
374
115
450
18
63
18
305
374
115
115
430
374
254
115
128
115
203
115
491
115
305
115
18
305
305
288
305
115
305
18
203
115
374
368
305
305
203
...

result:

wrong answer wrong answer on query #8 (a = 373, b = 441): read 374 but expected 373

Subtask #2:

score: 0
Wrong Answer

Test #6:

score: 0
Wrong Answer
time: 10ms
memory: 5400kb

input:

2 9998
941669562
945620824
923950848
951745929
487936934
545172907
544098433
249251812
620978276
575815248
584717207
588068187
353162497
679201670
592738155
438327774
762119945
576801563
408534366
592715009
525377786
603981493
-93758897
137509462
-38676966
-36724784
654920761
-595506762
-645387884
-...

output:

19996
111111111111000011111111110001001110000001001111110100001100100011111111101010100100010011111101010000011111000001001100001111100000010111000100111011110000001110100011111101100000101011000100111111000011010000010011001111011000111110001111111111100100110100011001001000100110010011110010100110...

input:

2 9998
19996
11111111111100001111111111000100111000000100111111010000110010001111111110101010010001001111110101000001111100000100110000111110000001011100010011101111000000111010001111110110000010101100010011111100001101000001001100111101100011111000111111111110010011010001100100100010011001001111001...

output:

6131
6131
361
6131
6131
6131
6131
361
6131
6131
2821
6131
361
6131
6131
5104
6131
1062
6131
7338
2821
6131
5761
5761
6131
6131
361
6131
6131
6665
6131
7888
6131
2821
7338
7338
8315
6131
6131
5104
6131
7338
6131
6131
6131
5761
6131
6131
6397
6131
6131
2821
6131
2124
8689
2476
6131
6131
6131
6131
7338...

result:

wrong answer wrong answer on query #3 (a = 185, b = 5711): read 361 but expected 359

Subtask #3:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 34ms
memory: 10952kb

input:

3 39995
922975946
766568552
929754744
983095922
988967630
879723897
928174186
951250463
831467029
836738151
464712826
467214506
167661408
156498284
426000721
530835328
-35115993
-86200136
327603078
448684869
192895652
125768327
402822176
196767853
409109378
985776352
976681898
967347754
989156210
99...

output:

79990
111111111111111110111010010011111000110011110010010011100100101101000001001011100000111111111101010100110000110011110111000010110010000011110111011010100010001100111111000000010110101000110011101111111111010010010010010011100010001111101010000011001000110110001110000101110001001000111111001111...

input:

3 39995
79990
1111111111111111101110100100111110001100111100100100111001001011010000010010111000001111111111010101001100001100111101110000101100100000111101110110101000100011001111110000000101101010001100111011111111110100100100100100111000100011111010100000110010001101100011100001011100010010001111...

output:

11219
3599
17920
17920
16796
7413
7413
17920
17920
17920
17920
17920
37334
16796
38001
37334
17920
8610
16796
17920
27078
17920
17920
17920
17244
12588
27078
17920
17920
37334
17920
11219
17920
17920
17920
17920
17920
17920
7413
17920
17920
17920
586
32473
3599
32473
28373
17920
3599
17920
39520
373...

result:

wrong answer wrong answer on query #1 (a = 9100, b = 12589): read 11219 but expected 11215