QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#22591 | #6156. 冰火战士 | ETK | 100 ✓ | 981ms | 71908kb | C++23 | 2.4kb | 2022-03-10 01:45:23 | 2024-07-05 05:38:13 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define pii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define ll long long
using namespace std;
inline ll read(){
ll x=0,f=1;char ch=getchar();
while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;
}
const int N=2e6+5;
struct node{int id,v;}b[N];
bool cmp(node a,node b){return a.v<b.v;}
int n,m,tot,op[N],t[N],x[N],y[N],c[N];
int t1[N],t2[N];
inline void add(int *t,int x,int v){
for(;x<=m;x+=x&-x)t[x]+=v;
}
inline int Q(int x){
int res=0;
for(;x;x-=x&-x)res+=t2[x];
return res;
}
int main(){
n=read();
rep(i,1,n){
op[i]=read();
if(op[i]==1){
t[i]=read(),x[i]=read(),y[i]=read();
b[++tot]={i,x[i]};
}else{
t[i]=read();
}
}
sort(b+1,b+tot+1,cmp);
rep(i,1,tot){//离散化
if(b[i].v!=b[i-1].v){
c[++m]=b[i].v;
}
x[b[i].id]=m;
}
rep(i,1,n){
//修改
if(op[i]==1){
if(t[i]==0)add(t1,x[i],y[i]);
else add(t2,1,y[i]),add(t2,x[i]+1,-y[i]);
}else{
int id=t[i];
if(t[id]==0)add(t1,x[id],-y[id]);
else add(t2,1,-y[id]),add(t2,x[id]+1,y[id]);
}
//查询
int now=0,sum1=0,sum2=0;
per(i,20,0){//冰系和更小的情况下,在树状数组上二分
if(now+(1<<i)>m)continue;
if(sum1+t1[now+(1<<i)]<sum2+t2[now+(1<<i)]){
now+=(1<<i);
sum1+=t1[now],sum2+=t2[now];
}
}
if(now==m){
if(sum1==0)puts("Peace");
else printf("%d %d\n",c[now],sum1<<1);
continue;
}
int sum=Q(now+1),p=0,psum=0;
per(i,20,0){//火系和更小时同样做二分
if(p+(1<<i)>m)continue;
if(psum+t2[p+(1<<i)]>=sum){
p+=(1<<i);
psum+=t2[p];
}
}
if(max(sum,sum1)<=0)puts("Peace");
else if(sum1>sum)printf("%d %d\n",c[now],sum1<<1);
else printf("%d %d\n",c[p],sum<<1);
}
return 0;
}
详细
Test #1:
score: 10
Accepted
time: 2ms
memory: 18068kb
input:
100 1 0 218 8134 2 1 1 0 322 4393 1 1 582 4233 1 0 426 4960 1 0 563 3003 1 1 71 7234 1 1 979 934 1 1 691 7228 1 1 723 1288 1 0 243 717 1 1 440 1860 1 1 128 76 1 0 230 4481 1 0 608 5824 2 3 1 0 107 6946 1 1 948 1161 1 1 108 5000 1 0 155 5615 2 15 1 1 927 6672 1 0 812 3669 1 1 95 7297 1 1 28 1482 2 6 ...
output:
Peace Peace Peace 582 8466 582 8466 582 8466 582 8466 582 10334 582 24712 582 24712 582 26146 582 26146 582 26146 440 29102 440 29102 582 26322 440 31086 440 33408 440 33408 440 33408 440 33408 440 45438 440 45438 440 45438 440 45438 440 45438 440 45438 440 46752 440 46752 440 46752 440 46752 440 46...
result:
ok 100 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 16056kb
input:
10000 1 1 617 3010 1 1 618 1611 1 1 618 8241 1 1 619 2442 1 1 620 7838 1 0 620 213 1 0 620 9615 1 1 620 5337 1 0 621 1309 1 0 622 1864 1 1 622 5158 1 1 622 348 1 0 622 3882 1 1 622 824 1 0 622 5246 1 1 622 761 1 1 623 2455 1 1 624 4419 1 1 624 8757 1 1 624 2328 1 1 625 9786 1 1 626 6994 1 1 626 2378...
output:
Peace Peace Peace Peace Peace 620 426 620 15676 620 19656 620 19656 620 19656 620 19656 620 19656 620 19656 620 19656 620 19656 620 19656 620 19656 622 27930 622 44258 622 44258 624 44258 624 44258 624 44258 624 44258 625 44258 626 45794 626 45794 626 45794 626 45794 628 45794 628 45794 628 45794 62...
result:
ok 10000 lines
Test #3:
score: 10
Accepted
time: 4ms
memory: 16132kb
input:
10000 1 1 867 9673 1 0 868 374 1 0 868 8754 1 0 868 5112 1 1 868 866 1 0 869 5341 1 0 870 6811 1 1 870 3136 1 1 870 1543 1 1 871 6525 1 1 871 1674 1 1 872 1838 1 1 873 7148 1 1 873 3262 1 1 873 1301 1 0 873 7434 1 1 874 5359 1 0 874 2808 1 0 874 2510 1 0 874 2152 1 1 875 5263 1 1 876 7616 1 0 876 85...
output:
Peace Peace Peace Peace 868 1732 868 1732 868 1732 868 8004 868 11090 868 24140 868 27488 870 29432 870 43728 870 50252 870 52784 870 52784 871 52784 871 52784 871 52784 871 52784 871 52784 873 59898 873 59898 873 64396 873 67652 873 67652 873 67652 874 82592 875 82592 876 99688 876 99688 876 99688 ...
result:
ok 10000 lines
Test #4:
score: 10
Accepted
time: 76ms
memory: 22572kb
input:
200000 1 0 68501 4107 1 0 114713 4264 1 0 79273 9390 1 0 59365 5025 1 1 154543 9706 1 1 195251 2745 1 1 105643 632 1 0 23703 8863 1 0 95321 2975 1 1 197593 2537 1 0 198906 3676 1 1 187265 2227 1 1 94557 9531 1 1 30342 3049 1 0 138225 2469 1 1 196601 8832 1 0 120056 743 1 0 10889 4446 1 0 3473 455 1 ...
output:
Peace Peace Peace Peace 154543 19412 154543 24902 105643 26166 105643 26166 105643 26166 105643 31240 105643 31240 105643 35694 94557 54756 94557 54756 94557 54756 94557 54770 94557 54770 94557 63662 94557 64572 94557 72420 94557 72420 94557 89468 94557 89468 81597 102226 81597 102226 81597 102226 8...
result:
ok 200000 lines
Test #5:
score: 10
Accepted
time: 68ms
memory: 24772kb
input:
200000 1 0 183981 1897 1 0 75105 2383 2 1 1 1 122913 2305 2 4 1 0 166063 5502 1 0 104001 4089 1 1 14 6405 1 0 115017 891 1 0 45734 9976 2 7 1 0 82385 570 1 1 33811 2907 1 0 118337 3336 1 0 80880 3103 1 0 49711 9838 1 0 70429 4710 1 1 95279 1936 1 0 135871 1761 1 0 187701 580 1 1 77073 5299 1 1 14062...
output:
Peace Peace Peace 122913 4610 Peace Peace Peace Peace Peace Peace Peace Peace Peace Peace Peace Peace Peace 95279 3872 95279 3872 95279 3872 77073 14470 77073 17256 77073 17256 77073 17256 77073 17256 77073 17256 77073 17256 77073 17256 77073 17256 54047 19952 54047 19952 54047 19952 58917 19952 540...
result:
ok 200000 lines
Test #6:
score: 10
Accepted
time: 73ms
memory: 24616kb
input:
200000 1 0 100908 5091 1 1 50240 5983 1 0 198465 1950 1 1 147925 610 1 1 107569 9345 1 0 126728 6141 1 1 157465 2742 1 0 14879 3002 2 1 1 0 174194 5987 1 0 156741 2887 1 1 159685 3784 1 0 172136 4317 1 0 170361 871 1 1 117603 1002 1 0 142251 1949 1 1 187581 9460 1 1 100500 523 1 0 167172 7820 1 0 71...
output:
Peace Peace Peace 147925 1220 107569 10182 107569 10182 107569 10182 107569 16186 147925 6704 147925 6704 147925 6704 147925 14272 147925 14272 147925 14272 147925 14272 147925 14272 157465 27958 157465 27958 157465 27958 157465 29166 157465 31972 157465 31972 157465 34430 157465 34430 157465 34430 ...
result:
ok 200000 lines
Test #7:
score: 10
Accepted
time: 913ms
memory: 61668kb
input:
2000000 1 0 1217091 107 1 0 1765937 30 2 1 2 2 1 0 758967 946 1 1 1726929 789 1 0 1866918 861 1 0 841825 869 1 0 1734601 47 1 1 877281 397 1 0 1619742 549 2 5 1 1 590165 542 1 0 332203 963 2 8 1 1 1526271 702 1 0 914523 449 1 0 1711581 229 1 1 1939244 63 1 1 645419 616 1 1 1526125 930 1 0 639503 193...
output:
Peace Peace Peace Peace Peace 1726929 1578 1726929 1578 1726929 1578 1726929 1578 877281 2372 877281 2372 877281 1738 877281 1738 877281 2372 877281 1926 1526271 1926 1526271 2824 1526271 2824 1526271 2824 1526271 2824 1526271 2824 1526125 3210 1526125 4968 1190423 5100 1190423 5100 1190423 5100 119...
result:
ok 2000000 lines
Test #8:
score: 10
Accepted
time: 890ms
memory: 66628kb
input:
2000000 1 0 1846771 368 1 1 1884221 616 1 0 1582901 883 1 1 890448 498 1 0 1169093 113 1 1 858334 764 1 0 317696 641 1 0 1152391 874 1 1 1548506 552 1 0 1716021 263 1 1 1206791 754 1 1 101157 555 1 1 1229682 332 1 1 5411 776 1 0 560553 469 1 0 503881 718 1 1 1454571 850 2 4 1 1 1255962 189 1 1 46296...
output:
Peace 1884221 736 1884221 1232 1884221 1232 1884221 1232 1884221 1232 890448 1282 890448 1282 1548506 2336 1548506 2336 1206791 3256 1206791 3256 1206791 3256 1206791 3256 1206791 4194 1206791 4508 1206791 5630 1206791 5630 1206791 5630 1206791 5630 1206791 5630 1206791 6202 1206791 6586 1206791 658...
result:
ok 2000000 lines
Test #9:
score: 10
Accepted
time: 863ms
memory: 65964kb
input:
2000000 1 0 933589 540 1 0 1332805 804 1 1 726913 60 1 0 582566 540 1 0 1541647 266 1 0 61185 227 1 0 44006 722 2 1 1 1 1100826 318 1 1 1583347 709 1 1 488319 941 2 10 1 0 1929473 528 2 13 1 1 1077416 855 1 0 1182411 885 1 0 1667425 768 1 1 1383821 403 1 0 187972 894 1 1 1583116 592 1 1 242066 187 2...
output:
Peace Peace Peace 726913 120 726913 120 726913 120 726913 120 726913 120 726913 756 726913 2174 726913 2174 488319 1898 488319 1898 488319 1898 726913 2466 726913 2466 726913 2466 1077416 2978 488319 3686 726913 4456 726913 4456 726913 4456 1077416 4766 1077416 4766 1077416 4766 726913 5090 726913 6...
result:
ok 2000000 lines
Test #10:
score: 10
Accepted
time: 981ms
memory: 71908kb
input:
2000000 1 0 267659481 924 1 1 211034569 948 1 1 760144421 564 1 1 657639999 860 1 0 180151690 350 2 4 1 1 99406176 793 2 3 1 1 81357121 972 1 0 260132781 642 1 0 7161061 191 1 1 245955169 633 1 1 387566565 485 1 1 72982881 592 1 1 141574651 711 1 1 88299089 143 1 0 355273696 723 1 1 19210825 454 1 0...
output:
Peace Peace 760144421 1128 657639999 1848 657639999 2548 760144421 1128 760144421 1128 211034569 700 211034569 700 211034569 700 211034569 1082 245955169 1082 245955169 1082 245955169 1082 245955169 1082 245955169 1082 245955169 1082 245955169 1082 211034569 3016 211034569 3942 211034569 3942 211034...
result:
ok 2000000 lines
Extra Test:
score: 0
Extra Test Passed