QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#20812 | #147. Floppy | Qingyu | 100 ✓ | 60ms | 8520kb | C++20 | 1.8kb | 2022-02-19 00:32:40 | 2023-09-13 03:31:50 |
Judging History
floppy
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <vector>
#include "floppy.h"
using namespace std;
void read_array(int subtask_id, const vector<int>& v) {
int n = v.size();
string bits = "";
vector<int> st;
for (int i = 0; i < n; ++i) {
while (st.size() && v[i] >= v[st.back()]) {
st.pop_back();
bits.push_back('0');
}
st.push_back(i);
bits.push_back('1');
}
save_to_floppy(bits);
}
vector<int> get_v(int n, const string& bits) {
vector<int> ans(n);
int i = 0;
int l = bits.size();
vector<int> st = {-1};
for (int j = 0; j < l; ++j) {
if (bits[j] == '0') {
st.pop_back();
} else {
ans[i] = st.back();
st.push_back(i);
++i;
}
}
return ans;
}
vector<int> solve_queries(int subtask_id, int N, const string& bits, const vector<int>& a, const vector<int>& b) {
vector<int> v = get_v(N, bits);
//for (int i = 0; i < N; ++i)
//cout << v[i] << ' ';
//cout << endl;
vector<vector<int>> redg(N);
for (int i = 0; i < N; ++i) {
if (v[i] == -1)
continue;
redg[i].push_back(v[i]);
for (int j = 1; j - 1 < redg[redg[i][j - 1]].size(); ++j) {
redg[i].push_back(redg[redg[i][j - 1]][j - 1]);
}
}
int m = a.size();
vector<int> answers(m);
for (int i = 0; i < m; ++i) {
int l = a[i];
int v = b[i];
int j = 20;
while (j >= 0) {
if (j < redg[v].size() && l <= redg[v][j])
v = redg[v][j];
else
--j;
}
//cout << a[i] << ' ' << b[i] << ": " << v << endl;
answers[i] = v;
}
return answers;
}
详细
Subtask #1:
score: 7
Accepted
Test #1:
score: 7
Accepted
time: 2ms
memory: 3724kb
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:
986 10110111001000110101101101010011000011010110010110110001011010011011010110000110101110001011100111011000001111000011000111010011010001110110001101100011011100010110110011101011000000111100010101100110000110110011011001100110100001111010011101100000110111011110000011110100001101101010011110010100...
input:
1 496 986 10110111001000110101101101010011000011010110010110110001011010011011010110000110101110001011100111011000001111000011000111010011010001110110001101100011011100010110110011101011000000111100010101100110000110110011011001100110100001111010011101100000110111011110000011110100001101101010011110...
output:
115 18 115 305 115 18 305 373 115 305 115 373 115 115 305 365 373 461 305 305 18 115 429 201 305 305 115 39 67 18 115 115 305 305 115 373 115 352 67 305 115 373 115 453 18 67 18 305 373 115 115 429 373 252 115 125 115 201 115 491 115 305 115 18 305 305 287 305 115 305 18 201 115 373 370 305 305 201 ...
result:
ok good job! L = 986
Test #2:
score: 7
Accepted
time: 2ms
memory: 3740kb
input:
1 496 466 469 320 402 391 453 73 101 122 49 54 94 93 148 197 168 233 144 125 161 69 34 247 76 37 90 71 33 42 212 188 156 110 135 165 374 277 289 248 273 236 131 210 242 238 231 366 346 314 358 300 349 322 412 315 268 354 340 99 176 290 313 221 229 332 265 269 146 316 403 369 492 190 256 266 100 126 ...
output:
982 10110110011010110101100010110011100111000011100111010001111010010000110110111010011100000111001101100000111001110101011010011011001000011000001101011010101101001001101101000111100011001010110101000111000111110011000000111100011001101101010001110110110100100111100110001001110100001101010100011010...
input:
1 496 982 10110110011010110101100010110011100111000011100111010001111010010000110110111010011100000111001101100000111001110101011010011011001000011000001101011010101101001001101101000111100011001010110101000111000111110011000000111100011001101101010001110110110100100111100110001001110100001101010100...
output:
339 339 339 389 222 339 256 256 339 180 339 339 339 310 109 71 339 365 256 256 171 455 484 264 200 339 256 413 339 339 339 339 339 339 109 339 256 109 339 222 339 339 109 339 109 339 455 346 109 213 339 53 339 339 109 339 339 339 109 339 339 339 339 339 339 109 109 339 256 109 339 256 310 109 339 10...
result:
ok good job! L = 982
Test #3:
score: 7
Accepted
time: 2ms
memory: 3732kb
input:
1 496 487 495 488 494 486 493 490 492 485 491 483 489 484 482 480 481 479 478 477 475 476 473 474 472 470 471 466 469 468 465 467 464 462 463 458 461 459 460 457 456 455 454 453 451 452 449 450 448 447 444 446 445 442 443 441 434 440 438 439 437 435 436 433 431 432 429 430 424 428 423 427 426 422 42...
output:
666 10110110110110110111101111101101110110111011101101101111111011011110111011101101110111011011011011101111101101101101110110110111011110110110110111011011011101101110110110111101101111011101101101101101111101101101111011111011011101101101110111101111011101111011111011101111101111111011011011101101...
input:
1 496 666 10110110110110110111101111101101110110111011101101101111111011011110111011101101110111011011011011101111101101101101110110110111011110110110110111011011011101101110110110111101101111011101101101101101111101101101111011111011011101101101110111101111011101111011111011101111101111111011011011...
output:
157 202 218 223 145 242 85 315 70 15 230 197 261 162 175 175 25 112 225 98 68 319 290 147 247 167 353 360 167 3 22 315 432 353 5 418 313 151 129 58 54 206 151 18 125 227 112 92 73 98 27 91 153 318 400 16 121 234 174 78 244 68 372 242 48 11 5 221 129 194 395 33 263 102 91 172 391 125 112 240 266 349 ...
result:
ok good job! L = 666
Test #4:
score: 7
Accepted
time: 2ms
memory: 3748kb
input:
1 495 473 486 488 489 491 485 477 474 472 480 483 460 459 462 448 447 444 449 454 442 434 437 443 439 433 430 440 438 435 431 429 436 424 421 426 418 422 417 413 416 414 405 409 406 407 403 404 391 392 385 388 387 386 390 384 377 369 382 371 375 374 370 367 368 366 360 362 363 364 352 348 361 354 35...
output:
988 10101010111110001011100111100010111010011110001111100011100110111011101101101101101110001111001101111011101010111001111000110110110110101101011011101011100110011011100111100110011100101110101110011101101011110001111101011100110110011010101110110101111101100011111000111010010110101101101110011011...
input:
1 495 988 10101010111110001011100111100010111010011110001111100011100110111011101101101101101110001111001101111011101010111001111000110110110110101101011011101011100110011011100111100110011100101110101110011101101011110001111101011100110110011010101110110101111101100011111000111010010110101101101110...
output:
290 457 363 400 302 348 463 117 103 109 363 385 53 457 130 13 18 53 126 18 81 446 482 81 409 491 123 18 377 486 277 13 342 98 342 298 486 456 438 361 13 46 382 18 347 293 431 457 44 482 483 75 412 369 483 13 428 483 382 299 430 363 98 486 109 478 306 281 31 331 461 182 446 46 205 87 340 317 356 53 6...
result:
ok good job! L = 988
Test #5:
score: 7
Accepted
time: 2ms
memory: 3724kb
input:
1 498 379 228 234 288 275 306 283 287 302 280 196 162 261 251 312 255 204 405 289 220 265 269 342 148 231 338 296 394 161 267 340 116 218 226 305 186 282 240 391 337 351 366 401 321 333 454 362 396 406 329 380 443 190 292 301 273 358 377 402 398 418 414 450 475 348 354 419 285 291 279 216 262 349 32...
output:
991 11010110011010111100110000011100001110101001101011000110101101010110110000110101000110100011010110100110101100101011001100010011010110111010001100110001100111001101001101001110110101000111010101010100001110101101000110111010000111000111100101110110010011101001101001100000110101010110111000011110...
input:
1 498 991 11010110011010111100110000011100001110101001101011000110101101010110110000110101000110100011010110100110101100101011001100010011010110111010001100110001100111001101001101001110110101000111010101010100001110101101000110111010000111000111100101110110010011101001101001100000110101010110111000...
output:
417 63 362 63 456 372 102 372 63 237 372 289 63 63 372 289 63 102 63 63 63 372 63 63 78 289 162 102 162 289 289 63 372 102 372 63 115 102 372 372 372 138 162 372 372 372 289 372 118 289 372 280 162 63 372 102 372 289 289 372 372 372 362 417 63 372 474 289 63 78 372 268 237 417 372 417 351 63 417 237...
result:
ok good job! L = 991
Subtask #2:
score: 21
Accepted
Test #6:
score: 21
Accepted
time: 4ms
memory: 4352kb
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:
19989 101100110111000110101100011100011100110011011010001110010101010111000111100011001110110011100000110110000110101100111101110000000110110011001011010101110100110011011100010100110110011100110001110000000001101110100110101110010111001111001000011010011110010010011011101001010011000111010110001111...
input:
2 9998 19989 10110011011100011010110001110001110011001101101000111001010101011100011110001100111011001110000011011000011010110011110111000000011011001100101101010111010011001101110001010011011001110011000111000000000110111010011010111001011100111100100001101001111001001001101110100101001100011101011...
output:
6131 6131 359 6131 6131 6131 6131 359 6131 6131 2817 6131 359 6131 6131 5102 6131 1055 6131 7338 2817 6131 5760 5760 6131 6131 359 6131 6131 6664 6131 7884 6131 2817 7338 7338 8312 6131 6131 5102 6131 7338 6131 6131 6131 5760 6131 6131 6395 6131 6131 2817 6131 2118 8687 2471 6131 6131 6131 6131 7338...
result:
points 1.0 good job! L = 19989
Test #7:
score: 21
Accepted
time: 10ms
memory: 4348kb
input:
2 9999 731433813 672900155 -154266178 -142062752 810401507 609673796 544462551 633906986 571738102 936132990 790930862 713932885 583772218 618694605 415964624 125339983 752948390 446516496 494161410 870044586 267348103 415149513 140247028 139903914 573253228 -211705903 596809434 509194500 671221940 ...
output:
19985 111010001110011000111101110000110100011011100011001100111010001100110101100110110110100011001111010001101100011011000110101011001101110001110010010011001101100001101100111000110110011011100010110101000011000001101011011011000111001011101000010000011100111101110001101000001101011011100000111001...
input:
2 9999 19985 11101000111001100011110111000011010001101110001100110011101000110011010110011011011010001100111101000110110001101100011010101100110111000111001001001100110110000110110011100011011001101110001011010100001100000110101101101100011100101110100001000001110011110111000110100000110101101110000...
output:
4198 2380 6998 4198 4198 4198 6998 4198 4198 8541 4198 4198 4198 4198 4198 5400 4198 8286 3848 8849 4198 2037 5400 7980 2037 4198 4198 4198 4198 4198 4198 4198 7619 9045 4198 5400 4198 4198 4198 4198 2037 4198 4198 6998 4198 4198 4198 4198 4198 4198 8849 8849 7619 4198 4198 4198 4198 4198 4198 4198 ...
result:
points 1.0 good job! L = 19985
Test #8:
score: 21
Accepted
time: 6ms
memory: 4464kb
input:
2 9997 999646439 999877567 999615045 999572458 999465340 998602736 998754430 998562475 998183998 998108258 997864409 997668387 997816125 997387979 997110884 996840136 996816135 996727915 996673898 996724983 996388637 996660759 996075504 996307507 996029274 994026101 995863929 995531258 994972765 994...
output:
13389 101111101111110111111101101101110111111111110110110110111011110111111101111011101101110110111101111101111011011011110110111101101110111011011101110110111101101101110111101101101101101101110111011011110110111101101101111101111011011011110111101101110110110110110110110110111101110111101101101111...
input:
2 9997 13389 10111110111111011111110110110111011111111111011011011011101111011111110111101110110111011011110111110111101101101111011011110110111011101101110111011011110110110111011110110110110110110111011101101111011011110110110111110111101101101111011110110111011011011011011011011011110111011110110...
output:
1088 1215 5472 1158 7944 1502 3135 3011 3625 7853 396 2376 2480 2718 3625 2224 66 645 2239 4329 2871 2002 349 4713 963 1081 1075 302 384 3422 345 3651 2980 2891 1884 3288 1711 128 1812 8221 4866 980 1683 3879 1471 4534 1183 5748 5420 4153 311 4251 9426 2070 1185 2363 212 4405 3576 6882 6758 1175 312...
result:
points 1.0 good job! L = 13389
Test #9:
score: 21
Accepted
time: 12ms
memory: 4648kb
input:
2 9997 998075413 999768563 996994821 995848879 992447573 993627169 993755793 993838328 990880244 992269976 991969312 992511252 990615969 990854518 989858767 989576734 990174788 990535036 988582131 988861974 988343926 988904854 988679289 987728654 988224499 988144927 987476186 986075661 984274493 983...
output:
19990 101111010101101100110111001011011001110111111000110101100111001101100111001011101001110011101010111011001101110101100110101110011111010011010101111101001111100111011001101110110011101011100110011011001110100111010110101011010101101110110111010101011011010101101011101011100101110100110101011101...
input:
2 9997 19990 10111101010110110011011100101101100111011111100011010110011100110110011100101110100111001110101011101100110111010110011010111001111101001101010111110100111110011101100110111011001110101110011001101100111010011101011010101101010110111011011101010101101101010110101110101110010111010011010...
output:
2180 455 485 911 9955 7271 6982 9890 737 2764 9364 1214 639 1960 414 8137 7579 7130 308 8277 1409 8801 9229 1705 333 9851 2686 7725 7995 9118 3287 9917 7353 1790 26 8313 6210 7875 2347 7552 3061 2690 30 9917 3008 9054 9725 9755 6626 9214 7276 3464 9615 8305 8076 2328 599 3845 1453 9722 9074 6986 675...
result:
points 1.0 good job! L = 19990
Test #10:
score: 21
Accepted
time: 10ms
memory: 4236kb
input:
2 9996 858247159 442798730 530600104 557785258 -353636825 -522042815 -470118868 -915939541 -785438325 -68695070 108509921 10169473 -237573210 730447976 -260998254 -253035962 158696722 -91003900 600314055 292558809 168182086 279048883 463103031 504100858 320637761 399185676 413728072 629957268 280982...
output:
19986 110101110110100010111000011010110011101001011010100011010011100100001101111001100110100111001010101000001101011011000011101010110011010001101110011011000011110001101000001101110101100001111000110101010101110001100010011101110010011000011011001011110001100011101011011010100001110100101011010100...
input:
2 9996 19986 11010111011010001011100001101011001110100101101010001101001110010000110111100110011010011100101010100000110101101100001110101011001101000110111001101100001111000110100000110111010110000111100011010101010111000110001001110111001001100001101100101111000110001110101101101010000111010010101...
output:
4729 7373 2242 2242 338 940 4729 4729 8569 940 7373 7373 9560 7373 482 940 2242 7373 940 4729 3470 7373 7373 7373 6705 7373 7373 1199 4729 4783 2242 7373 7373 4729 940 940 6705 2242 4729 940 7373 7373 940 7373 7373 7373 7373 940 6705 2242 4729 2242 6705 7373 2242 4729 6705 7373 7373 940 2242 2242 73...
result:
points 1.0 good job! L = 19986
Subtask #3:
score: 72
Accepted
Test #11:
score: 72
Accepted
time: 42ms
memory: 6592kb
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:
79980 110010101101011011011100100111001011100110010000011100001011010110010011111000011011000110111011000110110100100110000111101010100110100011011011001100111101010100000011011100111001001110010011010110100011010101011001101101000011101001101011110111000000001011010000011011011010011101001000110111...
input:
3 39995 79980 1100101011010110110111001001110010111001100100000111000010110101100100111110000110110001101110110001101101001001100001111010101001101000110110110011001111010101000000110111001110010011100100110101101000110101010110011011010000111010011010111101110000000010110100000110110110100111010010...
output:
11215 3597 17919 17919 16794 7409 7409 17919 17919 17919 17919 17919 37333 16794 38000 37333 17919 8605 16794 17919 27076 17919 17919 17919 17240 12582 27076 17919 17919 37333 17919 11215 17919 17919 17919 17919 17919 17919 7409 17919 17919 17919 584 32471 3597 32471 28370 17919 3597 17919 39520 373...
result:
points 1.0 good job! L = 79980
Test #12:
score: 72
Accepted
time: 36ms
memory: 6616kb
input:
3 39999 867402172 685901466 686671636 711501842 903386066 833531940 941869841 155613808 75348538 621222078 361531803 494133420 183601186 469266981 615102900 778500747 967242098 906173922 878275917 950695497 896291806 891834174 648534298 781268592 646594891 772566083 814129180 955538985 702320755 372...
output:
79988 110101001100111001101101001001001110011110110100100001110011100011101100011100001001110011101001100000111010011011011001010100111001110010011001101000111001100000111100010110110011101101000010101101110000011100110110110000011011100110110101110001110011011001100110000000101110100110110101100010...
input:
3 39999 79988 1101010011001110011011010010010011100111101101001000011100111000111011000111000010011100111010011000001110100110110110010101001110011100100110011010001110011000001111000101101100111011010000101011011100000111001101101100000110111001101101011100011100110110011001100000001011101001101101...
output:
26342 9725 33006 26342 4221 26342 26342 26342 22096 25742 4221 26342 26342 19941 31716 26342 37017 31716 16513 2293 26342 26342 16513 26342 31716 26342 31716 22096 31716 16513 16513 16513 7246 26342 16513 26342 29199 34715 26342 16513 16513 14546 13032 27508 16513 26342 26342 16513 4221 37017 26342 ...
result:
points 1.0 good job! L = 79988
Test #13:
score: 72
Accepted
time: 60ms
memory: 8520kb
input:
3 39999 999942157 999920759 999874133 999902533 999819991 999831518 999785254 999798240 999745461 999681177 999690072 999678043 999529806 999656013 999367471 999501765 999498631 999326775 999353567 999256847 999285607 999067567 999153844 998988618 999045678 999017050 998767814 999006932 998853649 99...
output:
53269 111011011011101110110111011011011011101101111011011101111011011011011011101101111011110111011110111111011011011011101111011011111101111101111011101111011110111011101101111101111111111101101110111011011011101110110110110111011011011011101101101101111101111011011101101101101110110110110111011011...
input:
3 39999 53269 1110110110111011101101110110110110111011011110110111011110110110110110111011011110111101110111101111110110110110111011110110111111011111011110111011110111101110111011011111011111111111011011101110110110111011101101101101110110110110111011011011011111011110110111011011011011101101101101...
output:
9331 28322 15895 17633 4819 9380 18962 8175 12943 3121 33276 24495 23835 281 11609 2119 4296 18907 4734 9864 8595 9301 6423 7540 4409 11341 9722 745 6216 17596 30576 665 11330 1559 11285 5885 2545 10467 14703 9655 1345 9539 15122 3417 13491 8325 19130 5510 9130 13001 19577 1949 2991 5417 26009 10114...
result:
points 1.0 good job! L = 53269
Test #14:
score: 72
Accepted
time: 38ms
memory: 8432kb
input:
3 39997 999741536 998563309 999117238 999051426 999931575 998790342 998708277 999435518 998494006 999770772 999520752 999601843 999178766 999104397 998691983 999251186 998976540 998475511 999227922 999247583 998586910 998896453 998949171 998600846 998732343 997177247 997226941 998040189 997452681 99...
output:
79991 110110001110011001101111000111001011010110110101100111011001110111100011011001101010110110111000110110011011011011001011011010110101101101001111001110010111001011100110101101011011111000111001011110001110011001101110011011011111000111001111001101101101010110101110011100111100010111011101011011...
input:
3 39997 79991 1101100011100110011011110001110010110101101101011001110110011101111000110110011010101101101110001101100110110110110010110110101101011011010011110011100101110010111001101011010110111110001110010111100011100110011011100110110111110001110011110011011011010101101011100111001111000101110111...
output:
34621 36735 470 4891 26861 1224 17021 470 39536 33354 26470 36052 13047 7404 30035 1034 10900 5242 388 28048 10799 38942 11853 36483 960 10252 4438 38142 31605 32014 1804 27448 37085 325 7647 30672 34077 1269 3362 6651 1664 37092 36001 29837 3561 8043 28822 4190 428 25451 6063 31562 19212 5494 5784 ...
result:
points 1.0 good job! L = 79991
Test #15:
score: 72
Accepted
time: 34ms
memory: 6512kb
input:
3 39999 446703557 267282645 373717810 575565010 -137808037 -196908944 -205843339 -67672074 -63391808 -145086107 -30135820 -560752712 -433832675 -416669373 203113652 -426744750 113728661 -149585326 789868391 13250158 60761658 -329610624 -203413073 -30407976 459063756 587074990 164973770 338401060 389...
output:
79987 110100111100010110011010100110110000110110101001011010101100011001111001110110101101100110100000001101101011000011011001100111010011001110110001110110000011110001111100000111001111000011101100110000110111000011010101011101010100000000111001101100000110110101011010001111011000010011101100011000...
input:
3 39999 79987 1101001111000101100110101001101100001101101010010110101011000110011110011101101011011001101000000011011010110000110110011001110100110011101100011101100000111100011111000001110011110000111011001100001101110000110101010111010101000000001110011011000001101101010110100011110110000100111011...
output:
13881 24249 13197 24249 26661 13197 10910 13197 13881 22746 13197 13197 13197 13197 26661 13881 33135 20387 24249 13197 5140 13197 13197 13881 14955 2564 34509 13197 26661 34509 20387 6034 13197 13197 37006 13197 13197 34509 26661 24249 13197 34509 34509 34509 34509 2564 37006 13197 13197 20387 1319...
result:
points 1.0 good job! L = 79987