QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#293488 | #7122. Overtaking | Goldenglow1427 | 0 | 2ms | 12048kb | C++14 | 6.6kb | 2023-12-29 11:26:55 | 2024-04-28 08:22:47 |
Judging History
answer
/*
ID: Victor Chen [mail_vi1]
PROG: Overtaking
LANG: C++
*/
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#define lson x<<1
#define rson x<<1|1
using namespace std;
typedef long long ll;
map<ll, int> mp;
const int Maxn = 1000;
class SegTreeMin
{
public:
struct Node
{
int l, r;
int val, lazy;
}p[4*Maxn*Maxn*2+10];
void buildtree(int x, int l, int r)
{
p[x].l = l, p[x].r = r;
if(p[x].l == p[x].r)
{
p[x].val = p[x].lazy = 0;
return;
}
int mid = (l+r)/2;
buildtree(lson, l, mid);
buildtree(rson, mid+1, r);
p[x].val = max(p[lson].val, p[rson].val);
}
void pushdown(int x)
{
if(p[x].lazy == 0)
return;
if(p[x].l == p[x].r)
{
p[x].lazy = 0;
return;
}
p[lson].val = max(p[lson].val, p[x].lazy);
p[lson].lazy = max(p[lson].lazy, p[x].lazy);
p[rson].val = max(p[rson].val, p[x].lazy);
p[rson].lazy = max(p[rson].lazy, p[x].lazy);
p[x].lazy = 0;
}
void modify(int x, int l, int r, int k)
{
pushdown(x);
if(l <= p[x].l && p[x].r <= r)
{
p[x].val = max(p[x].val, k);
p[x].lazy = max(p[x].val, k);
return;
}
if(l <= p[lson].r) modify(lson, l, r, k);
if(p[rson].l <= r) modify(rson, l, r, k);
p[x].val = max(p[lson].val, p[rson].val);
}
int query(int x, int l, int r)
{
pushdown(x);
if(l <= p[x].l && p[x].r <= r)
return p[x].val;
int ret = 0;
if(l <= p[lson].r) ret = max(ret, query(lson, l, r));
if(p[rson].l <= r) ret = max(ret, query(rson, l, r));
return ret;
}
}tree;
struct Ranges
{
ll l, r;
}p[Maxn+10][Maxn+10];
ll dp[Maxn+10];
int n, m;
ll dis[Maxn+10], spd[Maxn+10];
int cnt, cnt2;
ll st[Maxn*Maxn*2+10], mst[Maxn*Maxn*2+10];
struct Node
{
int id;
ll bg, ed;
bool operator < (const Node &x) const
{
return x.bg < bg;
}
Node(){}
Node(int id, ll bg, ll ed)
{
this->id = id;
this->bg = bg, this->ed = ed;
}
};
priority_queue<Node> q;
struct Pair
{
ll bg, ed;
bool operator < (const Pair &x) const
{
if(x.ed != ed)
return x.ed < ed;
else
return x.bg < bg;
}
Pair(){}
Pair(ll bg, ll ed)
{
this->bg = bg; this->ed = ed;
}
};
priority_queue<Pair> pq;
void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S)
{
// Pre-processing everything.
m = M-1;
for(int i=0; i<M; i++)
dis[i] = S[i];
spd[0] = X;
for(int i=0; i<N; i++)
{
W[i] -= X;
if(W[i] <= 0)
continue;
spd[++n] = W[i];
q.push(Node(n, T[i], T[i] + dis[1] * spd[n]));
}
ll cur = 0, curmx = 0, mx = 0;
while(!q.empty())
{
Node tp = q.top();
q.pop();
p[tp.id][1].l = tp.bg;
p[tp.id][1].r = max(mx, tp.ed);
if(tp.bg == cur)
curmx = max(curmx, tp.ed);
else
{
mx = max(mx, curmx);
curmx = tp.ed;
cur = tp.bg;
}
}
for(int i=2; i<=m; i++)
{
for(int j=1; j<=n; j++)
q.push(Node(j, p[j][i-1].r, p[j][i-1].r + (dis[i]-dis[i-1]) * spd[j]));
cur = 0, curmx = 0, mx = 0;
while(!q.empty())
{
Node tp = q.top();
q.pop();
if(tp.bg == cur)
curmx = max(curmx, tp.ed);
else
{
mx = max(mx, curmx);
curmx = tp.ed;
cur = tp.bg;
}
p[tp.id][i].l = tp.bg;
p[tp.id][i].r = max(mx, tp.ed);
}
}
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
{
st[++cnt] = p[i][j].l;
st[++cnt] = p[i][j].r;
// printf("%d %d\n", st[cnt-1], st[cnt]);
}
sort(st+1, st+cnt+1);
st[0] = -1;
for(int i=1; i<=cnt; i++)
if(st[i] != st[i-1])
{
mp[st[i]] = ++cnt2;
mst[cnt2] = st[i];
}
// printf("%d\n", cnt2);
tree.buildtree(1, 1, cnt2);
// Consider the ending case.
for(int i=1; i<=n; i++)
tree.modify(1, mp[p[i][m].l]+1, mp[p[i][m].r], mp[p[i][m].r]);
for(int i=m-1; i>=1; i--)
{
for(int j=1; j<=n; j++)
pq.push(Pair(p[j][i].l, p[j][i].r));
ll pred = 0;
while(!pq.empty())
{
Pair tp = pq.top();
pq.pop();
if(tp.ed == pred)
continue;
else
pred = tp.ed;
// printf("%lld %lld %lld\n", mp[tp.bg]+1, mp[tp.ed], max(tree.query(1, mp[tp.ed], mp[tp.ed]), mp[tp.ed]));
tree.modify(1, mp[tp.bg]+1, mp[tp.ed], max(tree.query(1, mp[tp.ed], mp[tp.ed]), mp[tp.ed]));
}
}
// for(int i=1; i<=cnt2; i++)
// printf("%lld ", tree.query(1, i, i));
// printf("\n");
}
ll arrival_time(ll Y)
{
int l = 1, r = cnt2, ans = cnt2+1;
while(l <= r)
{
int mid = (l+r)/2;
if(Y <= mst[mid])
{
r = mid - 1;
ans = mid;
}
else
l = mid + 1;
}
if(ans == cnt2+1) return Y+spd[0]*dis[m];
else
{
ll ed = tree.query(1, ans, ans);
if(ed == 0) return Y + spd[0] * dis[m];
else return mst[ed] + spd[0] * dis[m];
}
}
// int main()
// {
// int L = 6, N = 4;
// vector<ll> T; T.clear();
// T.push_back(20); T.push_back(10); T.push_back(40); T.push_back(0);
// vector<int> W; W.clear();
// W.push_back(5); W.push_back(20); W.push_back(20); W.push_back(30);
// int X = 10, M = 4;
// vector<int> S; S.clear();
// S.push_back(0); S.push_back(1); S.push_back(3); S.push_back(6);
// init(L, N, T, W, X, M, S);
// printf("%lld\n", arrival_time(50));
// return 0;
// }
詳細信息
Subtask #1:
score: 0
Runtime Error
Test #1:
score: 9
Accepted
time: 2ms
memory: 9980kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 2500 1 78 100 1000 100000 80 0 38 51 89 92 105 117 119 122 126 142 179 259 355 385 410 419 443 483 496 551 671 691 698 709 762 778 818 860 888 897 909 930 938 946 951 955 995 1045 1091 1164 1187 1215 1243 1264 1301 1363 1409 1416 1448 1504 1518 1535 1555 1562 1597 16...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 299664 298224 299166 298008 295102 298070 297182 298650 298312 296396 296524 298070 295838 296910 296892 297374 298684 295184 295710 299062 296382 298684 298110 298008 299530 298766 295966 299062 296794 298998 299738 296418 298588 296876 295102 299860 295710 29577...
result:
ok
Test #2:
score: 9
Accepted
time: 2ms
memory: 10020kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 80000001 1 151251000 400 1000 10000 151251252 0 563193 647572 715146 1130358 1138744 1557704 2110181 2300143 2420378 2557533 2614949 2657752 2838017 2861875 3146425 3202178 3240281 3248583 3280296 3310987 3401711 3683587 3943976 4135364 4214616 4277932 4503844 476465...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 12100095744014512 12100080944160100 12100085508223828 12100095197505388 12100090627084960 12100097311519276 12100080683026612 12100093846636708 12100099968098740 12100096796223124 12100096142019784 12100097662974856 12100083572845936 12100099936140100 121000877792...
result:
ok
Test #3:
score: 9
Accepted
time: 0ms
memory: 10036kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 700000000 1 199 800 1000 2000 200 0 2547880 2899696 3746196 5005561 5262711 7391315 7766094 8058134 12302379 14113798 14139018 16263685 19246991 20293858 21308475 21531629 21609437 22819772 23818245 23866117 24082599 24830023 25092620 25219376 27345462 27398799 28906...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 139981678448 139714673517 139493728857 139777641660 139908912147 139434676500 139585452046 139704974839 139718370512 139701821327 139448528458 139463864882 139927337590 139754511858 139416197864 139844650005 139808181948 139577750390 139643626646 139688190761 1396...
result:
ok
Test #4:
score: 9
Accepted
time: 0ms
memory: 10092kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 1000000000 1 99 1000 1000 1000000000000 100 0 1817308 2789727 3514387 5238876 5972281 7743105 8541339 9248161 10089380 11281389 11329343 14077050 14155477 16510318 19268709 19528706 19612683 19893513 20400622 21278533 21582205 24880066 27530395 27569486 28339765 2922...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 1099248330619 1099325193168 1099666752580 1099563034876 1099525957106 1099785654428 1099996241055 1099847005338 1099823366993 1099082743936 1099501468836 1099332698857 1099168227471 1099262165670 1099409777071 1099821586703 1099761464774 1099878195061 109999213744...
result:
ok
Test #5:
score: 9
Accepted
time: 0ms
memory: 10316kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 1000000000 1 880000000 1000 1000 100000000000000000 880001000 0 709332 1017351 1905741 3045292 3464378 3632596 5704941 6735246 9747846 10704021 12434640 13264129 14081255 14176931 15634238 17365369 18691988 19399867 20069605 21121920 23160840 23345820 24551706 255281...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 980000473593602000 980000328241893000 980000496751131000 980000100732727000 980000460850951000 980000615531582000 980000605439144000 980000435818946000 980000696831126000 980000166079150000 980000940725540000 980000805086273000 980000698057886000 98000016833636000...
result:
ok
Test #6:
score: 9
Accepted
time: 0ms
memory: 10056kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 100000000 1 498 1000 1000 100000000000000000 500 0 160783 205816 346327 347823 367191 395170 441295 639474 718881 831118 875863 1298479 1319125 1431282 1514976 1596686 1644592 1644648 1671765 1680769 1760215 1869745 1989596 2020399 2106354 2289587 2488522 2594930 272...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 100000049926232916 100000049864514052 100000049973025928 100000049995005458 100000049930515196 100000049843074864 100000049920623428 100000049897187068 100000049802862564 100000049946008956 100000049946867894 100000049917050904 100000049822989734 10000004993122233...
result:
ok
Test #7:
score: 0
Runtime Error
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 100000000 1 401 1000 1000 100000000000000000 400 0 31311 143468 183347 233725 256130 444842 481905 486233 527809 549435 664450 1549723 1573249 1619077 1673590 1911655 1913292 2059722 2158189 2259116 2349409 2426923 2437811 2474156 2510525 2528753 2614955 2695324 2871...
output:
result:
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 2ms
memory: 12048kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 2000000 100 100 2 1000 566035866 424023571 564031634 266012245 266012901 566037245 106005324 106003684 266012594 424028440 424019007 106005224 564034079 424024371 424024546 566039191 424016814 424029581 82000890 754044052 566036512 424018510 424017279 424019925 42401...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 768038285 768029581 1144044184 308008207 768029581 768029581 956039191 768029581 956044052 768029581 768029581 308008207 956039191 308008207 768029581 768037245 1144044184 418008550 768029581 468009953 308008207 1144044184 768038285 768029581 468012245 768029581 6...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '768035150', found: '768038285'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%