QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#76262 | #4253. Robot | lmeowdn | 10 | 620ms | 106988kb | C++14 | 3.8kb | 2023-02-08 18:29:19 | 2023-02-08 18:29:22 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#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 fi first
#define se second
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef unsigned long long ull;
typedef long double ld;
int read() {
int x=0,w=1; char c=getchar();
while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
return x*w;
}
const int N=6e5+9;
const ld eps=1e-5;
int n,m,a[N],t[N],mt,qt;
vi q,ans;
char c[N];
bool eq(ld a,ld b) {return b-eps<a&&a<b+eps;}
struct oper {int x,k;};
vector<oper> v[N];
struct node {
ld x,y;
node(int _x=0,int _y=0) {x=_x, y=_y;}
};
struct line {
ld k,b;
line(ld _k=0,ld _b=0) {k=_k, b=_b;}
line(ld _k,ld _x=0,ld _y=0) {k=_k, b=_y-_k*_x;}
line(node aa,node bb) {k=(aa.y-bb.y)/(aa.x-bb.x), b=aa.y-k*aa.x;}
ld f(ld x) {return k*x+b;}
};
struct polyline {
vector<node> p; int sz;
polyline() {p.clear(); sz=0;}
void push(node x) {p.eb(x), ++sz;}
void clear() {p.clear(); sz=0;}
vi query(vi t) {
vi ans(0); int pos=0; line cur(p[0],p[1]);
for(int x:t) {
while(pos<sz&&p[pos+1].x<x) pos++, cur=line(p[pos],p[pos+1]);
ld res=cur.f(x); ans.eb((int)(res+0.5));
}
return ans;
}
void print() {
cerr<<"POLYLINE: ";
for(node g:p) cerr<<"("<<g.x<<","<<g.y<<"), ";
cerr<<endl;
}
} s[N];
void get_add(ld x1,ld x2,ld l1,ld l2,ld r1,ld r2,polyline &res) {
//cerr<<" "<<x1<<" "<<x2<<" "<<l1<<" "<<l2<<" "<<r1<<" "<<r2<<endl;
if(l1<l2) swap(l1,l2), swap(r1,r2);
if(r1>=r2) res.push(node(x2,r1));
else {
ld x3=x1+(l1-l2)*(x2-x1)/(r2-r1+l1-l2);
ld y3=line(node(x1,l1),node(x2,r1)).f(x3);
res.push(node(x3,y3));
res.push(node(x2,r2));
}
}
polyline operator + (polyline a,polyline b) {
//cerr<<"ADD\n";
//cerr<<" ", a.print(), cerr<<" ", b.print();
int pa=1, pb=1, sa=a.sz, sb=b.sz;
polyline res; res.push(node(0,max(a.p[0].y,b.p[0].y)));
ld lst=0, lsta=a.p[0].y, lstb=b.p[0].y;
rep(i,3,sa+sb) {
if(pa<sa&&eq(a.p[pa].x,lst)) pa++;
else if(pb<sb&&eq(b.p[pb].x,lst)) pb++;
else {
ld cur=min(a.p[pa].x,b.p[pb].x);
ld cura=line(a.p[pa-1],a.p[pa]).f(cur);
ld curb=line(b.p[pb-1],b.p[pb]).f(cur);
get_add(lst,cur,lsta,lstb,cura,curb,res);
lst=cur, lsta=cura, lstb=curb;
if(a.p[pa].x<b.p[pb].x) pa++;
else pb++;
}
}
//res.print();
return res;
}
polyline solve(int l,int r) {
if(l==r) return s[l]; int mid=l+r>>1;
return solve(l,mid)+solve(mid+1,r);
}
void work() {
rep(i,1,n) {
s[i].clear();
s[i].push(node(0,a[i]));
int sz=v[i].size(); line cur; cur.k=0, cur.b=a[i];
rep(j,0,sz-1) {
node cn(v[i][j].x,cur.f(v[i][j].x));
s[i].push(cn);
cur=line(v[i][j].k,cn.x,cn.y);
}
}
polyline rp=solve(1,n);
vi res=rp.query(q);
rep(i,0,qt-1) ans[i]=max(ans[i],res[i]);
}
signed main() {
n=read(), m=read();
rep(i,1,n) a[i]=read();
rep(i,1,m) {
scanf("%lld%s",&t[i],c);
if(c[0]=='q') q.eb(t[i]), qt++;
else {
int k=read(), x=read();
v[k].eb((oper){t[i],x});
}
mt=max(mt,t[i]);
}
rep(i,1,n) v[i].eb((oper){mt,0});
ans.resize(q.size());
work();
rep(i,1,n) a[i]=-a[i];
rep(i,1,n) for(oper &p:v[i]) p.k=-p.k;
work();
rep(i,0,qt-1) printf("%lld\n",ans[i]);
return 0;
}
详细
Test #1:
score: 0
Wrong Answer
time: 17ms
memory: 39940kb
input:
1999 2000 199 8854 -9513 9848 8434 -6615 -6770 4057 -9730 686 1586 6806 -511 -6328 -2250 2785 -4083 -3961 -711 9606 -9391 1041 -2844 -4889 993 -6955 -1982 -5300 9053 -5275 3950 -7977 -3652 8624 -716 -2013 -5229 -3686 -4602 -5031 9777 3802 491 -1354 -26 -3366 5285 5805 -7098 2233 -5967 -1318 -4553 63...
output:
86972685 360437813 838138694 913546809 969490828 1039888005 1109819936 1176518021 1251178690 1310478588 1510656739 1541256250 1558188182 1650871444 1683896338 1758251927 1785953178 1924001830 1993300747 2050167655 2254083111 2698180404 2750013492 2975978602 3216808736 3276627292 3332456927 335270661...
result:
wrong answer 1st numbers differ - expected: '86968438', found: '86972685'
Test #2:
score: 0
Wrong Answer
time: 8ms
memory: 39832kb
input:
1999 2000 6817 4353 -8180 954 -2553 1768 4986 -889 7032 -450 1234 -7637 9636 380 3607 -2296 -4881 -9025 2375 -1561 -8807 -3103 4385 8883 -2887 -1185 1960 6711 3478 -1056 -1717 -534 -9885 -6301 6011 5965 -9833 -5181 5329 3688 -6837 9023 64 -8326 3021 -7193 -9218 -4699 2354 -4720 1621 7361 -5233 9211 ...
output:
9999 6881572 19292887 55029237 173059574 235141372 259235497 297362903 487381111 672375553 768858519 844208387 852253071 1019587808 1077357817 1147544186 1160798950 1226407369 1261081352 1340924569 1413768568 1576031955 1664681643 1707999613 1779008863 1838571072 1977895625 2055501021 2318335488 235...
result:
wrong answer 2nd numbers differ - expected: '6877566', found: '6881572'
Test #3:
score: 10
Accepted
time: 197ms
memory: 63124kb
input:
99659 99039 -39276177 -64464963 -70081363 -443045475 -655771408 -409419920 -285052520 -312069074 -936205590 -10621715 -908116392 -660740279 -953732094 -591542519 -194540162 -139991296 -705911340 -778931920 -474438963 -518208970 -59960466 -981034014 -514533441 -217486555 -711871023 -615144144 -631291...
output:
999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 999962473 ...
result:
ok 49673 numbers
Test #4:
score: 0
Wrong Answer
time: 376ms
memory: 84444kb
input:
99572 579859 -100705410 -669206879 -432488010 -384767624 -742351351 -839681487 -968882737 -976751481 57117493 -959321678 -819420190 -325014480 -636525861 -382469947 -876672604 -213012287 -209210199 -875230847 -920443172 -731589320 -946964322 -789362448 -872075805 -828546101 51836817 -913319025 -8404...
output:
999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999981953 999964257 999964257 999964257 999964257 999964257 999964257 999964257 999964257 999959652 999959652 999959652 999959652 999959652 999959652 999959652 ...
result:
wrong answer 32nd numbers differ - expected: '999930200', found: '999929795'
Test #5:
score: 0
Wrong Answer
time: 327ms
memory: 85372kb
input:
99320 577219 -525813544 -959369807 -718451747 -533082399 -787662356 -531754846 -650759294 -381852570 -979346470 -644489626 -425559804 -332888497 -203462089 -292970440 -958637976 -533593640 53499163 -331134986 -296264838 -806780896 -651958364 -547743072 -590243769 -75974484 -843772303 -367318307 -443...
output:
999992360 999992301 999992301 999992301 999992301 999992301 999992301 999992301 999992301 999992301 999991855 999987041 999984455 999983385 999980799 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 999978927 ...
result:
wrong answer 11th numbers differ - expected: '999991856', found: '999991855'
Test #6:
score: 0
Wrong Answer
time: 138ms
memory: 59876kb
input:
90498 99230 -33558917 30715649 81001133 -12438113 81315374 -70949846 -71212693 66569129 -16194103 -63049353 -79869090 97189792 61301532 53180861 -26423528 -30279746 32502058 7951680 -97121356 -5044511 -4113729 82719257 96311627 80260870 -29075735 -31473462 -27928703 81572824 -89715849 85470402 -5284...
output:
106294952 110163416 118535792 121674188 127268720 127704968 131859284 137162984 139716728 142361108 151520324 153761324 159719396 164628680 167492180 175844636 185014808 186302636 187034696 195742724 204533420 207048320 213505388 220715432 226279088 230415476 231647528 234046892 240457148 243998924 ...
result:
wrong answer 408th numbers differ - expected: '2078996209', found: '2078996456'
Test #7:
score: 0
Wrong Answer
time: 151ms
memory: 60932kb
input:
99124 99428 -29121705 73122072 14759978 -93785828 -52964748 50664810 -67789167 38732351 -57330970 48764999 -73647685 92261655 2267455 -21312555 -51092994 33675829 40607569 -85559394 -93024695 24124094 -45466947 -66665193 -99870070 -58435829 -56724651 -98854388 86610996 59912463 -27223092 85984568 94...
output:
106340510 113640698 116739890 122754640 124220766 127865950 128706392 135771234 142501746 142918910 150583550 157918850 162749170 171812008 180577442 182247096 185391794 194654232 201310892 209518444 210866742 213027412 213683098 222590248 225580256 231447498 239671018 249411498 250792730 251150014 ...
result:
wrong answer 1417th numbers differ - expected: '7222519215', found: '7222519214'
Test #8:
score: 0
Wrong Answer
time: 228ms
memory: 67368kb
input:
99538 99031 -501609067 -774687736 -928215759 -477038092 -823455674 -871460165 -852927043 -704708804 -775793387 -521621627 -923721630 -811686668 -952989802 -841891941 -482572032 -509003031 -595485934 -831251065 -616219801 -580804479 -951849211 -783134298 -505096225 -625789647 -520043618 -798430551 -6...
output:
999996555 999996555 999996555 999996555 999996555 999996555 999996555 999996555 999996555 999996555 999996555 999996555 999996555 1003771933 1005263884 1005937467 1006453244 1010635394 1020280737 1024269976 1028142056 1038638316 1047767516 1050993476 1054639356 1056180996 1067217815 1072164635 10888...
result:
wrong answer 14th numbers differ - expected: '1003771859', found: '1003771933'
Test #9:
score: 0
Wrong Answer
time: 620ms
memory: 105052kb
input:
99483 590517 -508842 -191922 830365 -321837 163127 -225035 -3981 -222030 721775 -244372 -342954 -692168 -156349 -853744 -606213 687012 -401837 -920227 -198596 -14000 -345069 -628969 -386394 -590462 97339 -974255 -551821 -623120 -673402 -567398 278012 511781 29418 -975780 -416796 902045 -565858 -2455...
output:
999991 999991 1014460 1022594 1030729 1056927 1056927 1076785 1076785 1076785 1086714 1096643 1146288 1146288 1156217 1186004 1195933 1195933 1195933 1195933 1205862 1205862 1235649 1235649 1245578 1245578 1245578 1245578 1245578 1255507 1265436 1265436 1285294 1295223 1305152 1315081 1325010 135479...
result:
wrong answer 3rd numbers differ - expected: '1007282', found: '1014460'
Test #10:
score: 0
Wrong Answer
time: 614ms
memory: 106988kb
input:
99801 597343 -32417 984702 259080 747296 807167 169192 454040 -426594 582296 321692 800273 962596 -968901 42596 -304443 574664 936854 271860 902411 38804 -688175 55613 31189 -930407 -544084 -164683 -442201 118338 -858190 -109300 682685 896380 -887043 357053 -908865 890420 -680972 632527 -106741 -668...
output:
999992 999992 999992 999992 1009495 1019216 1019216 1028937 1058100 1067821 1077542 1096984 1096984 1096984 1096984 1096984 1106705 1145589 1145589 1145589 1155310 1155310 1155310 1155310 1165031 1165031 1174752 1174752 1184473 1184473 1184473 1203915 1203915 1213636 1213636 1213636 1213636 1233078 ...
result:
wrong answer 1176th numbers differ - expected: '9996359', found: '9996200'