QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770542 | #147. Floppy | snpmrnhlol | 0 | 52ms | 11080kb | C++17 | 3.2kb | 2024-11-21 22:17:22 | 2024-11-21 22:17:22 |
Judging History
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);
for(int i = 0;i < n;i++){
cout<<v[i]<<' ';
}
cout<<'\n';
///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;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 3892kb
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:
0 0 0 4 0 3 0 1 6 0 0 5 0 0 3 0 0 4 21 0 0 0 0 0 0 0 0 0 0 0 0 2 4 0 1 6 0 7 0 3 0 0 2 8 0 0 0 0 0 0 2 1 4 0 1 3 2 0 1 5 2 1 6 9 0 2 0 3 0 10 0 0 0 2 0 1 3 0 1 6 0 0 0 2 1 5 0 0 1 4 3 0 0 2 7 0 0 0 0 2 1 5 6 11 0 0 1 4 0 0 0 1 2 3 0 20 0 0 0 0 4 0 2 0 3 2 0 1 16 0 15 0 0 0 4 0 3 2 1 5 3 2 0 13 0 0 0...
result:
wrong answer wrong answer on query #1 (a = 109, b = 205): read 0 but expected 115
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 12ms
memory: 5420kb
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:
0 0 0 0 0 0 1 16 0 0 0 0 0 2 1 3 0 0 2 4 1 11 0 0 0 1 2 3 0 2 0 10 0 0 0 0 0 0 0 0 1 6 1 7 0 0 0 2 1 3 4 3 0 0 1 2 1 5 0 1 8 0 0 0 2 5 4 3 0 2 1 9 0 0 0 0 1 2 8 0 0 0 7 0 0 0 2 0 3 5 0 0 0 2 1 6 0 0 0 1 3 0 1 2 4 1 15 0 14 0 0 2 0 12 0 0 0 10 0 0 0 0 0 0 1 5 0 1 4 3 0 1 6 0 7 0 3 0 1 8 0 0 5 0 0 2 0...
result:
wrong answer wrong answer on query #1 (a = 2131, b = 6955): read 0 but expected 6131
Subtask #3:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 52ms
memory: 11080kb
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:
0 0 0 0 0 0 0 0 0 0 0 0 1 9 0 0 0 7 0 6 0 0 3 0 1 5 0 0 1 4 0 0 1 2 8 1 11 0 0 0 2 15 0 0 0 0 0 3 2 1 4 0 1 7 0 6 0 0 2 0 1 4 0 0 2 0 5 12 0 0 6 0 4 0 0 0 5 0 8 0 7 0 0 0 1 2 6 5 4 0 0 0 11 0 10 0 0 0 0 0 0 0 1 3 0 1 4 0 1 5 0 0 2 0 6 0 0 0 0 0 4 5 0 2 0 7 0 2 0 6 0 0 5 4 3 0 2 1 9 0 13 0 0 0 5 0 0 ...
result:
wrong answer wrong answer on query #1 (a = 9100, b = 12589): read 0 but expected 11215