QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#218122 | #7122. Overtaking | hocky# | 0 | 1ms | 3976kb | C++14 | 3.4kb | 2023-10-17 18:50:16 | 2024-04-28 07:54:13 |
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;
vector <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();
for(int i = 0;i < n;i++){
cari.emplace_back(busList[i].pointInTime, 0);
if(i) cari.emplace_back((busList[i].pointInTime + busList[i - 1].pointInTime) / 2, 0);
else cari.emplace_back(busList[i].pointInTime / 2, 0);
}
sort(all(cari));
cari.erase(unique(all(cari)), end(cari));
for(int i = 0;i < sz(cari);i++){
cari[i].se = arrival_pre(cari[i].fi);
}
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 {
it = prev(it);
//~ cout << (*it).fi << " " << (*it).se << endl;
return (*(it)).se;
}
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: 3892kb
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 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 295000 29500...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '299664', found: '295000'
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 0
Wrong Answer
time: 1ms
memory: 3976kb
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 768034662 768029246 956044052 308007277 768029246 768029246 768039046 768029246 956041170 768029246 768029246 308007277 768039046 308007277 768029246 768029717 956044052 308008550 768029246 418008956 308007277 956044052 768035150 768029246 468010400 768029246 4680...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '768035150', found: '768034662'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%