QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218138 | #7122. Overtaking | hocky | 0 | 8ms | 4196kb | C++14 | 3.9kb | 2023-10-17 19:04:58 | 2024-04-28 07:54:28 |
Judging History
answer
#include "overtaking.h"
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i = a;i < b;i++)
#define trav(nx, v) for(auto &nx: v)
#define sz(v) (int) v.size()
#define all(v) begin(v), end(v)
#define pb push_back
#define fi first
#define se second
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
typedef long long LL;
typedef pair<LL, LL> PLL;
namespace Solver{
struct Bus {
LL pointInTime, speed, idx;
bool operator <(const Bus &other) const {
if(pointInTime != other.pointInTime) return pointInTime < other.pointInTime;
if(speed != other.speed) return speed < other.speed;
return idx < other.idx;
//~ return tie(pointInTime, idx, other) < tie(other.pointInTime, idx, other.speed);
}
};
LL n, roadLength;
vector <Bus> busList;
LL m;
LL sortingStation[1005];
Bus reserved;
vector <Bus> precompute[1005];
vector <Bus> sortedPrecompute[1005];
vector <PLL> precomputeJawaban;
set <PLL> cari;
};
using namespace Solver;
void initDP(){
vector <Bus> busses = busList;
sort(all(busses));
sortedPrecompute[0] = busses;
int curSize = sz(busses);
rep(i,1,m){
LL distance = sortingStation[i] - sortingStation[i - 1];
LL maksi = LLONG_MIN;
for(int j = 0;j < curSize;j++){
busses[j].pointInTime += distance * busses[j].speed;
maksi = max(maksi, busses[j].pointInTime);
busses[j].pointInTime = maksi;
}
precompute[i] = busses;
sort(all(busses));
sortedPrecompute[i] = busses;
}
}
long long arrival_pre(long long Y){
Bus curReserved = reserved;
curReserved.pointInTime = Y;
auto position = upper_bound(all(sortedPrecompute[0]), curReserved)
- begin(sortedPrecompute[0]);
//~ cout << "querying " << Y << " " << position << endl;
rep(i,1,m){
//~ cout << position << endl;
LL distance = sortingStation[i] - sortingStation[i - 1];
curReserved.pointInTime += distance * curReserved.speed;
// binser
curReserved.pointInTime = max(curReserved.pointInTime,
position > 0 ? precompute[i][position - 1].pointInTime : LLONG_MIN);
//~ cout << "Here " << curReserved.pointInTime << endl;
position = upper_bound(all(sortedPrecompute[i]), curReserved)
- begin(sortedPrecompute[i]);
}
return curReserved.pointInTime;
}
void init(int L, int N, std::vector<long long> T, std::vector<int> W, int X, int M, std::vector<int> S){
n = N;
roadLength = L;
m = M;
for(int i = 0;i < m;i++) sortingStation[i] = S[i];
rep(i,0,n){
if(W[i] <= X) continue;
Bus currentBus = {T[i], W[i], sz(busList)};
busList.pb(currentBus);
}
n = sz(busList);
reserved.speed = X;
reserved.idx = n;
sort(all(busList));
initDP();
vector <PLL> candidate;
for(int i = 0;i < n;i++){
candidate.emplace_back(busList[i].pointInTime, 0);
if(i) candidate.emplace_back((busList[i].pointInTime + busList[i - 1].pointInTime) / 2, 0);
else candidate.emplace_back(busList[i].pointInTime / 2, 0);
}
sort(all(candidate));
candidate.erase(unique(all(candidate)), end(candidate));
for(int i = 0;i < sz(candidate);i++){
//~ cout << cari[i].fi << endl;
candidate[i].se = arrival_pre(candidate[i].fi);
cari.insert(candidate[i]);
}
//~ cout << "here " << sz(cari) << endl;
return;
}
long long arrival_time(long long Y){
auto it = upper_bound(all(cari), PLL(Y, 0));
//~ cout << "Here " << endl;
if(it == begin(cari)){
//~ cout << "Begin " << endl;
return Y + roadLength * reserved.speed;
} else {
if(it != cari.end()) {
auto pre = prev(it);
LL atas = (*it).se;
LL bawah = (*pre).se;
//~ cout << "here " << atas << " " << bawah << endl;
if(atas == bawah) return atas;
LL tmp = arrival_pre(Y);
cari.insert({Y, tmp});
return tmp;
} else {
//~ cout << "Here " << endl;
return max(Y + roadLength * reserved.speed, (*(prev(it))).se);
}
//~ cout << (*it).fi << " " << (*it).se << endl;
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3876kb
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 299632 298224 299162 297964 295102 298066 297104 298618 298242 296390 296472 298054 295828 296910 296888 297368 298654 295180 295604 299062 296354 298684 298110 297916 299516 298706 295962 299062 296784 298984 299736 296414 298580 296874 295078 299850 295590 29576...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '299664', found: '299632'
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 10
Accepted
time: 2ms
memory: 4196kb
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 768035150 768029581 1144044184 308008207 768029581 768029581 956039191 768029581 956041170 768029581 768029581 308008207 956039191 308008207 768029581 768029891 1144044184 418008550 768029581 468009953 308008207 1144044184 768035150 768029581 468010817 768029581 6...
result:
ok
Test #13:
score: 0
Wrong Answer
time: 8ms
memory: 3968kb
input:
XwWPuInrOjpekAwGKojzwKw3yVDtdkGS 10000000 400 1011 2 1000 173387969125 200337983261 77920310897 77652037350 182097978669 118267907350 174157972712 57062023028 118267909308 107247901578 174157973485 146027951049 53742020545 118267912197 174167974422 207927989121 137207921414 143227933063 77992040344 ...
output:
mGlgT4yvr1qPbquFwkxRVh9hMn0Mrxoz OK 128387906425 192867977136 218447987834 162297954325 192867978986 34992000977 147437922857 192867979350 67182020640 56912011273 63862013824 162297954325 43302006404 92682052132 120767905711 218447987834 98882054684 138667917161 63862014242 117367898279 210667984418...
result:
wrong answer 363rd lines differ - on the 1st token, expected: '218447990426', found: '218447990351'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%