QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#251182 | #3042. Hilbert's Hotel | S00021 | WA | 70ms | 29880kb | C++14 | 1.9kb | 2023-11-14 12:36:52 | 2023-11-14 12:36:53 |
Judging History
answer
#include<bits/stdc++.h>
#define N 200005
#define int long long
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define MP make_pair
#define M 1000000007
#define ls (rt<<1)
#define rs (rt<<1|1)
using namespace std;
int Q; multiset<int>st;
struct SGT{
int tag1[N<<3],tag2[N<<3];
void build(int rt,int l,int r){
tag1[rt]=1,tag2[rt]=0; if(l==r) return;
int md=(l+r)>>1; build(ls,l,md),build(rs,md+1,r);
}void upd(int rt,int d0,int d1){
(tag1[rt]*=d0)%=M,(tag2[rt]*=d0)%=M,(tag2[rt]+=d1)%=M;
}void pd(int rt){
upd(ls,tag1[rt],tag2[rt]);
upd(rs,tag1[rt],tag2[rt]); tag1[rt]=1,tag2[rt]=0;
}void modf(int rt,int l,int r,int L,int R,int d0,int d1){ if(L>R) return;
if(L<=l&&r<=R){upd(rt,d0,d1); return;} int md=(l+r)>>1; pd(rt);
if(L<=md) modf(ls,l,md,L,R,d0,d1); if(R>md) modf(rs,md+1,r,L,R,d0,d1);
}int ask(int rt,int l,int r,int x,int t){
if(l==r) return (t*tag1[rt]%M+tag2[rt])%M; int md=(l+r)>>1; pd(rt);
if(x<=md) return ask(ls,l,md,x,t); else return ask(rs,md+1,r,x,t);}
}T; int n,l0[N],l1[N],sum[N],cn,id[N];
signed main(){
scanf("%lld",&n),T.build(1,0,n);
for(int i=1;i<=n;i++){
int op,x,k; scanf("%lld",&op);
l0[i]=l0[i-1],l1[i]=l1[i-1],sum[i]=sum[i-1];
if(op==1){ id[i]=(++cn);
scanf("%lld",&k); if(k){
T.modf(1,0,n,0,cn-1,1,k);
T.modf(1,0,n,cn,cn,1,0),l1[i]=i;
}else{
T.modf(1,0,n,0,cn-1,2,0);
T.modf(1,0,n,cn,cn,2,1),l0[i]=i; } sum[i]+=k;
}if(op==2) scanf("%lld%lld",&x,&k),printf("%lld\n",T.ask(1,0,n,x,k-1));
if(op==3){ scanf("%lld",&x);
int po=i; while(1){
if(po<=0){puts("0"); break;}
if(x==0){printf("%lld\n",id[l1[po]]); break;}
if(sum[po]-sum[l0[po]]>x){
int t=lower_bound(sum+l0[po]+1,sum+po+1,sum[po]-x)-sum;
printf("%lld\n",id[t]); break;
}else{ x-=(sum[po]-sum[l0[po]]);
if(x&1){printf("%lld\n",id[l0[po]]); break;} x>>=1,po=l0[po]-1;
}}
}
}return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 7968kb
input:
10 3 0 1 3 2 1 2 1 0 3 10 2 2 5 1 5 1 0 3 5 2 3 3
output:
0 1 0 9 4 4
result:
ok 6 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 7988kb
input:
16 2 0 8 2 0 4 3 7 3 5 2 0 8 3 6 1 0 3 8 2 0 2 1 2 2 2 1 2 2 1 1 6 1 1 3 4 2 3 2
output:
7 3 0 0 7 0 0 2 0 0 3 2
result:
ok 12 lines
Test #3:
score: 0
Accepted
time: 1ms
memory: 7984kb
input:
11 2 0 8 3 9 1 5 2 0 10 2 0 5 1 0 3 9 2 2 7 2 2 3 3 0 1 0
output:
7 0 14 9 2 13 5 1
result:
ok 8 lines
Test #4:
score: 0
Accepted
time: 0ms
memory: 7976kb
input:
20 1 0 3 1 2 0 4 2 0 7 1 0 3 8 1 0 2 3 7 3 4 2 3 4 3 1 3 8 1 0 2 4 5 1 9 3 2 3 3 3 2 1 7 1 0
output:
1 6 12 0 13 1 7 3 0 9 5 5 5
result:
ok 13 lines
Test #5:
score: 0
Accepted
time: 0ms
memory: 8052kb
input:
11 1 0 2 0 4 2 0 9 1 1 1 9 1 4 2 0 8 2 4 3 2 1 3 1 2 2 3 6
output:
6 16 28 2 19 11
result:
ok 6 lines
Test #6:
score: 0
Accepted
time: 0ms
memory: 7868kb
input:
20 2 0 9 2 0 9 1 0 3 6 1 9 2 0 10 2 1 10 3 7 3 5 1 0 2 1 1 2 1 5 1 7 2 3 3 2 2 2 1 8 1 4 1 0 1 0 2 5 2
output:
8 8 0 27 28 2 2 20 36 12 9 20
result:
ok 12 lines
Test #7:
score: 0
Accepted
time: 1ms
memory: 7900kb
input:
15 2 0 4 3 4 1 0 2 1 7 3 10 1 0 1 0 2 1 1 2 1 2 2 2 5 1 0 2 2 10 1 0 2 1 6 1 0
output:
3 0 13 0 4 12 18 76 176
result:
ok 9 lines
Test #8:
score: 0
Accepted
time: 1ms
memory: 7972kb
input:
13 1 2 1 2 3 3 2 0 6 3 8 2 0 3 2 2 2 3 8 2 1 2 1 4 1 0 1 4 1 0
output:
1 9 0 6 1 0 3
result:
ok 7 lines
Test #9:
score: 0
Accepted
time: 0ms
memory: 7964kb
input:
11 3 4 2 0 9 3 9 1 0 3 5 1 0 2 0 8 2 0 9 2 2 3 3 6 2 0 9
output:
0 8 0 1 28 32 5 1 32
result:
ok 9 lines
Test #10:
score: 0
Accepted
time: 1ms
memory: 7908kb
input:
13 3 6 1 0 1 7 3 4 3 1 2 0 8 1 9 1 9 1 5 3 10 3 10 2 4 6 2 3 9
output:
0 2 2 21 4 4 10 22
result:
ok 8 lines
Test #11:
score: 0
Accepted
time: 0ms
memory: 8064kb
input:
17 3 10 3 0 2 0 7 3 3 2 0 9 1 0 2 0 7 2 0 10 2 0 6 2 1 4 1 0 1 0 3 7 2 1 2 3 3 1 9 3 5
output:
0 0 6 0 8 12 18 10 7 3 12 3 4
result:
ok 13 lines
Test #12:
score: 0
Accepted
time: 0ms
memory: 7904kb
input:
18 1 0 3 3 1 4 2 2 3 2 2 4 2 2 2 2 0 10 3 3 3 1 3 9 1 0 1 1 1 9 3 4 1 9 2 4 1 3 0 3 6
output:
1 2 3 1 22 2 2 1 5 18 6 6
result:
ok 12 lines
Test #13:
score: 0
Accepted
time: 0ms
memory: 8024kb
input:
990 3 613 3 983 3 529 2 0 4 2 0 8 3 352 3 136 2 0 1 2 0 6 3 144 3 936 1 7 3 102 2 0 3 2 0 4 1 0 2 0 10 3 381 3 200 2 2 4 1 6 3 251 1 9 2 4 5 1 3 2 3 6 2 1 4 3 65 2 2 6 2 2 4 3 934 2 3 6 2 3 3 2 2 10 2 1 2 2 5 3 3 618 3 996 3 335 3 268 2 3 6 1 5 1 5 2 4 7 1 6 1 5 3 347 3 646 1 3 1 6 2 8 1 3 845 1 7 3...
output:
0 0 0 3 7 0 0 0 5 0 0 0 9 10 32 2 0 7 2 4 17 24 2 29 25 0 17 14 37 20 2 0 0 2 0 17 19 0 2 14 2 2 2 17 3 109 4 195 30 28 54 24 24 24 8 0 3 368 24 17 24 1561 39 1369 24 28 875 103 28 219 20 74 234 28 26 28 28 379 742 28 56 26 1064 28 28 28 35 1288 426 18 28 1642 2 117 1049 819 44 19 26 44 28 24 3370 4...
result:
ok 652 lines
Test #14:
score: 0
Accepted
time: 1ms
memory: 10128kb
input:
942 1 0 3 671 3 788 1 4 3 146 2 0 9 2 2 3 3 130 3 343 3 783 1 10 3 36 1 9 2 1 7 1 0 3 85 2 4 3 2 5 3 2 5 9 1 0 2 0 9 3 913 2 1 8 2 2 4 3 164 1 6 2 5 7 1 6 3 628 1 3 2 1 6 1 7 1 0 3 545 3 319 3 551 3 672 3 464 3 680 3 670 2 11 3 2 6 7 2 4 8 3 535 1 9 3 394 2 9 2 1 0 2 7 6 1 10 1 0 2 1 2 1 0 2 2 4 2 3...
output:
1 0 0 20 2 0 1 1 0 36 5 4 5 17 156 6 152 88 0 32 1 151 11 11 11 5 5 5 6 5 70 100 11 11 25 102 1064 1872 1040 2774 220 19 669 413 27 19 20 4413 19 19 16 33 19 22 696 15 1403 19 19 130 28 197 1877 19 19 19 360 31 33 35 16 35 1703 855 423 35 2180 38 3 162 162 14182 4774 40 130406 40 3174 13 40 40 40 38...
result:
ok 607 lines
Test #15:
score: 0
Accepted
time: 0ms
memory: 8028kb
input:
904 3 946 3 64 3 559 3 380 1 4 1 0 3 555 1 7 1 9 3 319 2 4 3 1 2 1 0 3 104 1 2 1 4 1 9 2 3 5 2 9 9 2 7 2 2 7 2 1 7 1 1 2 1 1 3 180 3 687 1 2 2 11 1 3 785 1 10 1 5 2 1 4 3 758 3 275 3 182 2 12 2 2 6 4 2 14 5 3 718 3 356 1 4 2 5 2 1 1 2 13 3 2 16 1 1 5 1 6 2 6 1 3 573 2 14 1 1 3 2 19 2 3 211 2 8 4 3 2...
output:
0 0 0 0 2 2 2 0 45 8 14 14 59 6 0 2 0 88 2 6 2 16 47 4 2 0 46 12 0 57 6 16 1 0 56 14 85 87 27 2 58 39 6 6 2 22 6 89 6 1 0 42 280 29 618 30 2 487 1183 25 8 134 30 22 1070 30 30 22 30 255 29 30 820 22 313 1481 20 43 43 40 4252 39 30 43 6498 1218 43 46 15316 3476 2772 26 70 43 836 46 40 43 46 14164 39 ...
result:
ok 609 lines
Test #16:
score: 0
Accepted
time: 1ms
memory: 8004kb
input:
935 1 4 2 0 2 1 3 2 1 3 3 61 2 2 3 1 5 1 3 2 0 9 2 1 1 2 4 2 2 2 3 2 1 3 3 430 1 2 3 517 1 8 1 7 1 0 1 2 2 3 1 3 744 2 0 7 3 413 2 5 1 1 0 2 6 8 1 6 3 61 3 718 1 0 3 387 2 9 1 2 11 5 3 987 2 9 2 3 723 2 0 5 3 362 2 2 1 3 887 3 311 1 1 1 4 1 7 3 279 3 374 1 2 3 787 3 374 3 803 3 212 1 10 1 1 1 2 1 0 ...
output:
5 5 0 2 23 11 1 10 13 0 0 42 0 78 8 32 60 10 0 12 12 8 12 16 12 308 10 220 12 12 12 10 12 8 12 10 166 98 654 206 20 286 8 10 7 102 74 24 24 20 587 94 24 1137 24 13 1 24 34 6 31 35 17 24 8 24 137 31 38 31 23 93 121 31 31 38 24 2247 24 24 39 7 31 1929 161 71 22 227 185 177 101 57 12 931 31 31 31 26 46...
result:
ok 613 lines
Test #17:
score: 0
Accepted
time: 1ms
memory: 7992kb
input:
999 3 86 3 146 3 588 3 62 3 143 3 85 2 0 5 2 0 4 3 678 1 9 3 500 1 2 1 0 3 835 1 8 1 3 1 10 2 2 1 1 5 3 154 1 8 2 6 6 3 463 3 782 2 4 3 1 7 3 995 2 7 4 1 3 3 546 1 0 1 0 2 9 3 2 0 5 3 356 3 361 2 1 5 3 948 2 6 9 2 9 1 1 8 3 445 2 2 1 1 8 3 41 2 9 2 2 13 1 3 98 2 0 4 3 184 3 44 1 6 3 413 3 602 1 7 2 ...
output:
0 0 0 0 0 0 4 3 0 0 3 21 0 18 3 0 28 0 18 0 20 296 3 12 224 3 124 12 12 184 12 32 8 11 304 4 9 12 3 161 18 0 22 25 12 1 244 11 39 232 12 33 0 6 682 11 482 14 12 21 273 83 17 17 21 21 12 15 21 12 5 170 860 36 36 21 64 37 2744 156 26 21 264 32 36 2872 36 36 37 16 37 2 2198 37 21 317 369 37 41 21 21 30...
result:
ok 656 lines
Test #18:
score: 0
Accepted
time: 1ms
memory: 8000kb
input:
951 3 497 2 0 10 2 0 9 3 250 1 6 3 887 1 1 2 0 8 2 1 4 3 711 2 2 1 3 194 3 314 2 0 3 2 1 6 2 2 1 1 8 3 355 1 6 3 650 2 0 1 1 9 2 3 7 1 10 3 775 2 1 5 3 463 3 476 2 1 6 2 2 1 1 8 3 797 2 6 9 2 1 4 2 3 5 1 3 1 0 1 6 3 783 2 1 5 3 908 1 0 1 3 1 1 2 11 5 2 13 1 2 10 5 1 5 1 4 1 7 1 1 2 0 4 1 0 1 7 3 465...
output:
0 9 8 0 0 14 4 0 0 0 0 9 6 0 0 0 21 21 0 38 0 0 39 33 0 16 45 37 9 104 0 13 0 12 249 1 18 18 560 60 44 11 643 18 70 302 9 22 11 539 923 1115 155 7 29 1501 1565 205 9 29 29 163 347 29 22 102 17 1074 85 29 29 633 25 777 1 634 18 39 29 410 1522 47 489 39 362 1582 47 2256 47 750 39 62 39 34 2265 59 358 ...
result:
ok 611 lines
Test #19:
score: 0
Accepted
time: 1ms
memory: 8004kb
input:
913 3 715 2 0 5 3 302 1 2 2 0 1 2 1 2 1 3 1 6 2 1 2 1 1 2 1 1 2 2 1 3 14 3 729 2 2 2 2 2 3 2 1 1 3 732 3 516 1 9 1 7 2 6 1 2 3 5 3 255 3 303 3 27 3 747 2 1 1 1 3 1 7 2 0 4 3 2 2 6 2 3 178 1 9 1 0 1 7 1 3 1 1 1 7 3 364 1 0 2 0 8 3 513 1 9 1 4 3 902 1 4 2 13 1 3 801 2 2 1 3 329 1 10 3 958 3 320 3 984 ...
output:
0 4 0 2 1 10 10 7 0 0 8 9 10 0 0 0 21 0 0 1 0 26 41 8 11 0 0 252 15 15 31 0 221 0 15 15 15 43 15 0 83 9 15 23 23 23 23 824 239 15 79 95 925 40 915 936 23 850 56 19 21 37 37 21 54 37 2197 13 597 209 37 103 195 23 23 140 35 668 500 1708 91 14 196 2550 37 686 53 39 31 489 53 349 401 23 285 470 46 56 91...
result:
ok 602 lines
Test #20:
score: 0
Accepted
time: 1ms
memory: 8100kb
input:
977 3 637 3 620 3 388 1 0 2 0 7 2 1 1 3 989 3 446 1 0 3 987 3 20 1 6 3 241 1 7 1 6 1 2 2 3 4 3 400 2 5 2 1 6 1 9 3 758 3 657 2 0 10 3 772 3 601 2 5 1 2 7 3 3 327 3 51 2 2 3 3 314 3 609 1 3 1 8 2 7 3 1 0 1 0 3 782 3 667 3 953 3 292 1 4 1 5 1 8 1 4 3 431 1 3 1 10 3 464 1 7 1 7 1 0 1 4 1 5 2 3 5 3 713 ...
output:
0 0 0 12 1 1 0 2 0 2 18 2 3 1 2 72 0 2 17 11 2 2 41 1 2 22 11 12 12 1 11 11 465 2 11 11 1348 26 31 448 4754 31 31 1493 853 269 1365 28 28 31 31 719 3168 31 21 258 10 986 98 4724 21 2744 31 717 3973 28 649 31 31 31 1028 47 78 31 205 42 28 26 81 77 51 211 3551 1439 26 8 51 127 6 51 51 51 51 187 28 51 ...
result:
ok 626 lines
Test #21:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
940 1 6 3 869 1 3 3 579 2 0 4 2 1 5 3 443 3 460 1 4 3 715 3 42 2 0 5 1 5 2 0 2 1 7 3 260 1 9 2 3 3 3 502 1 8 3 420 1 4 3 676 3 54 1 0 1 6 2 2 3 2 6 8 2 4 4 3 192 3 470 2 1 6 3 663 2 6 6 2 2 1 2 8 1 3 205 3 193 3 840 1 3 2 0 1 3 616 2 0 4 1 0 3 3 2 8 2 3 440 2 7 4 3 320 3 683 2 5 7 1 3 1 10 2 5 6 3 8...
output:
0 0 12 7 0 0 0 0 17 19 0 23 0 0 0 0 84 44 68 0 0 96 9 40 80 6 9 9 0 101 9 107 12 22 9 46 9 12 126 135 12 58 14 15 15 12 61 54 18 18 18 18 18 17 18 44 17 19 18 18 28 12 17 17 18 9 17 273 18 18 388 18 47 18 17 18 8 15 90 159 18 34 139 53 18 15 34 161 34 100 76 74 2708 18 857 34 34 35 34 417 7 2593 34 ...
result:
ok 644 lines
Test #22:
score: 0
Accepted
time: 1ms
memory: 8000kb
input:
988 2 0 1 3 374 1 0 3 649 2 1 2 1 2 2 0 8 3 543 3 318 1 7 3 228 2 0 5 3 114 2 2 2 3 661 2 0 3 2 1 1 2 3 5 3 275 2 0 8 2 3 7 2 0 10 3 384 3 250 2 0 8 2 3 7 2 2 1 1 0 1 9 1 2 3 536 1 0 1 6 3 777 1 10 2 3 7 2 9 6 3 85 2 1 8 1 10 1 0 2 10 5 1 6 3 155 1 8 3 467 2 3 7 1 7 3 908 2 14 4 1 1 3 176 2 12 4 2 2...
output:
0 0 1 3 16 1 0 1 17 1 8 0 13 10 4 0 23 6 27 1 1 23 6 7 4 7 62 5 7 134 8 11 11 158 11 3 7 19 174 5 158 11 1 28 212 184 7 99 603 27 27 161 28 16 367 36 750 78 13 17 1086 36 1262 28 518 1566 28 30 28 1892 27 36 1288 28 28 2028 25 68 48 1384 28 36 216 36 54 1426 34 36 226 738 0 19 13 28 32 1088 15 234 3...
result:
ok 687 lines
Test #23:
score: -100
Wrong Answer
time: 70ms
memory: 29880kb
input:
285800 1 589 2 1 115 2 1 226 2 1 514 2 1 456 3 629709122 1 619 2 2 192 3 459147753 1 38 2 2 576 2 3 8 3 201981823 3 524189144 2 3 32 1 56 2 4 20 3 214735859 1 890 2 5 636 3 478695264 3 460825804 2 5 103 3 952035202 2 0 286 1 525 1 288 1 957 2 0 618 3 735607495 2 1 93 2 1 286 1 985 2 9 663 1 683 2 2 ...
output:
114 225 513 455 0 191 0 613 7 0 0 31 19 0 635 0 0 102 0 2477 4579 0 3465 3658 662 5004 5531 0 0 0 6085 6160 6201 2926 0 0 0 4574 2946 0 17 12920 16648 11235 17 0 7809 17 17 0 13273 0 17 17 0 0 10365 1695 0 0 0 40360 0 50264 26 26 46388 279 51921 26 35101 0 17 26 3285 26 39483 26 17 26 2946 1358 26 1...
result:
wrong answer 133858th lines differ - expected: '989124573', found: '835864823'