QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#143785 | #5710. Solar Flight | lmeowdn | 0 | 5ms | 13680kb | C++14 | 3.2kb | 2023-08-21 14:43:52 | 2023-08-21 14:43:55 |
Judging History
answer
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
template<typename T,typename U> T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U> T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S> bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S> bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x) {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x) {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x) {return (x==0?-1:__builtin_ctzll(x));}
#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--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
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=1e6+5;
const ld inf=1e18;
int n,X,k,m,s[N],id[N],tot,ans[N];
deque<pair<int,ld>> d[2005];
struct Line {int a,b,c,id;} a[N];
struct Opt {ld t; int x,y,id;} q[N*3];
bool operator < (const Line &a,const Line &b) {
return a.a<b.a;
}
bool operator < (const Opt &a,const Opt &b) {
return a.t==b.t?a.id<b.id:a.t<b.t;
}
void add(int x,int val,ld t) {
pair<int,ld> s=make_pair(val,inf);
while(d[x].size()&&d[x].back()<s) d[x].pop_back();
//cout<<"ADD "<<x<<" "<<val<<" "<<t<<endl;
if(d[x].size()) {
pii r=d[x].back(); d[x].pop_back();
chmin(r.se,t); d[x].push_back(r);
} d[x].push_back(s);
}
signed main() {
X=read(), k=read(), n=read(), m=read();
rep(i,1,n) {
a[i].a=read(), a[i].b=read();
a[i].c=read(), a[i].id=i;
}
sort(a+1,a+n+1);
rep(i,1,n) id[a[i].id]=i;
per(i,n,1) s[i]=s[i+1]+a[i+1].c;
// rep(i,1,n) cout<<a[i].a<<" "<<a[i].b<<" "<<a[i].c<<endl;
rep(i,1,n) rep(j,i+1,n) if(a[i].b>a[j].b) {
ld t=X*(a[j].a-a[i].a)/(a[j].a-a[i].a+a[i].b-a[j].b);
q[++tot]={t,i,j,0};
//cout<<" "<<t<<" "<<i<<" "<<j<<endl;
}
rep(i,1,m) {
int x=read(), y=read();
q[++tot]={y+k,id[x],0,i};
//cout<<" "<<y<<" "<<y+k<<" "<<id[x]<<endl;
}
sort(q+1,q+tot+1);
rep(i,1,n) d[i].push_back(make_pair(s[i],inf));
rep(i,1,tot) {
vi used; ld tt=q[i].t;
static int vst[N];
while(!q[i].id&&q[i].t==tt) {
s[q[i].x]-=a[q[i].y].c;
s[q[i].y]+=a[q[i].x].c;
if(!vst[q[i].x]) used.eb(q[i].x);
if(!vst[q[i].y]) used.eb(q[i].y);
i++;
}
//cout<<"MDF "<<tt<<endl;
for(int x:used) add(x,s[x],tt), vst[x]=0;
//for(int x:used) cout<<" "<<x<<" "<<s[x]<<endl;
while(q[i].id) {
int st=q[i].t-k, x=q[i].x;
while(d[x].size()&&d[x][0].se<=st) d[x].pop_front();
//cout<<" QRY "<<d[x][0].fi<<" "<<d[x][0].se<<endl;
ans[q[i].id]=d[x][0].fi;
i++;
}
i--;
}
rep(i,1,m) printf("%lld\n",ans[i]);
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 13680kb
input:
1000 200 200 1000 657 836 23 962 796 47 497 305 25 837 161 23 220 575 33 697 109 37 401 221 43 883 211 46 727 461 26 681 209 28 413 14 49 664 986 27 431 222 47 307 121 38 638 560 45 801 149 24 878 61 36 761 356 43 839 413 32 931 573 35 218 195 46 201 697 25 951 778 21 705 905 42 861 391 23 582 718 2...
output:
6049 5822 2542 5950 1152 2947 2697 2357 1219 3428 1366 6013 6215 3869 2344 2630 2619 2303 4412 6066 6597 1631 6657 3093 3227 1315 2441 1501 6146 2171 3160 992 2914 4234 692 5058 3132 3283 5036 1702 3169 1024 6614 1568 5133 2224 4032 903 6458 4609 6270 1564 877 3155 2752 3172 6136 4958 2563 3579 6027...
result:
wrong answer 25th lines differ - expected: '3199', found: '3227'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%