QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#293353#7122. Overtakingtraining4usaco0 1ms8260kbC++173.6kb2023-12-29 05:16:252024-04-28 08:18:26

Judging History

你现在查看的是最新测评结果

  • [2024-04-28 08:18:26]
  • 管理员手动重测本题所有提交记录
  • 测评结果:0
  • 用时:1ms
  • 内存:8260kb
  • [2023-12-29 05:16:26]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4144kb
  • [2023-12-29 05:16:25]
  • 提交

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] - x, 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: 1ms
memory: 8260kb

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
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
194376
19437...

result:

wrong answer 3rd lines differ - on the 1st token, expected: '299664', found: '194376'

Subtask #2:

score: 0
Wrong Answer

Test #12:

score: 0
Wrong Answer
time: 1ms
memory: 7916kb

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
764551708
625005433
954136298
306500697
624768640
624669498
766301295
625136434
947580853
625100943
624760284
306475062
766644615
306776294
625698807
737888912
955288081
326658949
624965258
416149655
306877619
954101982
765386432
624737296
463254712
624909072
4668...

result:

wrong answer 3rd lines differ - on the 1st token, expected: '768035150', found: '764551708'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%