QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#293349 | #7122. Overtaking | training4usaco | 0 | 2ms | 8040kb | C++17 | 3.6kb | 2023-12-29 05:11:00 | 2024-04-28 08:18:19 |
Judging History
answer
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
#define pll pair<ll, ll>
#define pil pair<int, ll>
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
const int MAXN = 1e3 + 5;
const ll INF = 1e9 + 7;
int tot, tot2; // tot number of things with less, num of checkpoints
ll shift;
pil bus[MAXN]; // speed, time
ll times[MAXN][MAXN], dists[MAXN];
ll ans[2 * MAXN * MAXN];
ll boundaries[2 * MAXN * MAXN];
set<int> checkpoints;
struct Point {
ll t1, t2;
int i;
Point(){}
Point(ll t1, ll t2, int i) : t1(t1), t2(t2), i(i){}
bool operator<(const Point &other) const {
if(t1 == other.t1) {
if(t2 == other.t2) return i < other.i;
return t2 < other.t2;
}
return t1 < other.t1;
}
};
Point points[MAXN];
struct Segment {
ll l, r, t;
Segment(){}
Segment(ll l, ll r, ll t) : l(l), r(r), t(t){}
};
vector<Segment> segments[MAXN];
void init(int l, int n, vector<ll> t, vector<int> w, int x, int m, vector<int> s) {
shift = l * x;
tot = 0;
for(int i = 0; i < n; ++i) {
if(w[i] > x) bus[tot++] = {w[i], t[i]};
}
sort(bus, bus + tot);
for(int i = 0; i < tot; ++i) times[0][i] = bus[i].ss;
for(int i = 1; i < m; ++i) {
dists[i] = s[i] - s[i - 1];
for(int j = 0; j < tot; ++j) points[j] = Point(times[i - 1][j], times[i - 1][j] + dists[i] * bus[j].ff, j);
sort(points, points + tot);
ll mx = 0; int idx = 0;
for(int j = 0; j < tot; ++j) {
while(points[idx].t1 < points[j].t1) {
mx = max(mx, points[idx].t2); ++idx;
}
times[i][points[j].i] = max(mx, points[j].t2) - dists[i] * x;
}
vector<pll> curtime;
for(int j = 0; j < tot; ++j) curtime.push_back({times[i - 1][j], times[i][j]});
sort(all(curtime));
for(int j = 1; j < tot; ++j) curtime[j].ss = max(curtime[j].ss, curtime[j - 1].ss);
for(int j = 0; j < tot; ++j) {
int lbound = curtime[j].ff + 1;
int rbound;
if(j == tot - 1) rbound = INF;
else rbound = curtime[j].ss;
if(lbound <= rbound) segments[i].push_back(Segment(lbound, rbound, curtime[j].ss));
checkpoints.insert(lbound); checkpoints.insert(rbound + 1);
}
}
tot2 = 0;
for(auto checkpoint : checkpoints) {
ans[tot2] = checkpoint;
boundaries[tot2++] = checkpoint;
}
for(int i = 1; i < m; ++i) {
vector<pair<pll, ll>> prs;
for(auto [l, r, val] : segments[i]) {
int lbound = lower_bound(ans, ans + tot2, l) - ans;
int rbound = upper_bound(ans, ans + tot2, r) - ans;
if(lbound < rbound) prs.push_back({{lbound, rbound}, val});
}
for(auto [pr, v] : prs) {
for(int j = pr.ff; j < pr.ss; ++j) ans[j] = v;
}
}
}
ll arrival_time(ll y) {
int pos = upper_bound(boundaries, boundaries + tot2, y) - boundaries - 1;
if(pos == -1 || boundaries[pos] == ans[pos]) {
return y + shift;
}
return ans[pos] + shift;
}
//signed main() {
// int l, n, x, m;
//
// cin >> l >> n;
// vector<ll> t(n);
// vector<int> w(n);
// for(int i = 0; i < n; ++i) cin >> t[i];
// for(int i = 0; i < n; ++i) cin >> w[i];
// cin >> x >> m;
// vector<int> s(m);
// for(int i = 0; i < m; ++i) cin >> s[i];
//
// init(l, n, t, w, x, m, s);
// cout << arrival_time(0) << " " << arrival_time(50) << endl;
//}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8040kb
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 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 295076 29507...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '299664', found: '295076'
Subtask #2:
score: 0
Wrong Answer
Test #12:
score: 10
Accepted
time: 1ms
memory: 7968kb
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: 2ms
memory: 8040kb
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 119341383011 175688218964 202073614096 147551060087 184085691311 26374588557 138821291777 184209654267 55266025562 48307804253 48316556224 147555132056 34639169804 79521287250 108776788671 202075839365 86533925103 127598286688 54047206071 104222315544 202036894127...
result:
wrong answer 3rd lines differ - on the 1st token, expected: '128387906425', found: '119341383011'
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%