QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#530648#7122. Overtakinggreen_gold_dog#0 1ms4156kbC++203.2kb2024-08-24 16:49:392024-08-24 16:49:39

Judging History

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

  • [2024-08-24 16:49:39]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:4156kb
  • [2024-08-24 16:49:39]
  • 提交

answer

#include "overtaking.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll INF = 3'000'000'000'000'000'000;

vector<vector<pair<ll, ll>>> all;
vector<vector<ll>> ph;
vector<vector<ll>> aws;
vector<int> ns, nw;
int nx;

random_device rd;
mt19937 rnd(rd());

void init(int l, int n, vector<ll> t, vector<int> w, int x, int m, vector<int> s) {
	nx = x;
	ns = s;
	nw = w;
	vector<pair<ll, ll>> need;
	for (ll i = 0; i < n; i++) {
		if (w[i] > x) {
			need.emplace_back(t[i], i);
		}
	}
	sort(need.begin(), need.end());
	all.resize(m);
	all[0] = need;
	ph.resize(m);
	for (ll i = 1; i < m; i++) {
		ll now = s[i] - s[i - 1];
		vector<tuple<ll, ll, ll>> nneed;
		ll lst = 0;
		for (ll j = 0; j < all[i - 1].size(); j++) {
			auto[nt, ni] = all[i - 1][j];
			nt += w[ni] * now;
			nt = max(nt, lst);
			nneed.emplace_back(nt, w[ni], ni);
			lst = nt;
		}
		sort(nneed.begin(), nneed.end());
		for (auto[nt, _, ni] : nneed) {
			all[i].emplace_back(nt, ni);
		}
	}
	vector<ll> to(n);
	for (ll i = 0; i < n; i++) {
		to[i] = rnd();
	}
	for (ll i = 0; i < m; i++) {
		ph[i].push_back(0);
		for (auto[_, ni] : all[i]) {
			ph[i].push_back(ph[i].back() + to[ni]);
		}
	}
	aws.resize(m);
	for (ll i = m - 1; i >= 0; i--) {
		for (ll j = 0; j < all[i].size(); j++) {
			auto[nt, ni] = all[i][j];
			ll l = i, r = m;
			while (r - l > 1) {
				ll mid = (l + r) / 2;
				if (ph[mid][j] != ph[i][j] || (j > 0 && all[mid][j - 1].first >= nt + x * (s[mid] - s[i]))) {
					r = mid;
				} else {
					l = mid;
				}
			}
			l++;
			if (l == m) {
				aws[i].push_back(nt + x * (s.back() - s[i]));
			} else {
				nt = all[l - 1][j - 1].first + w[all[l - 1][j - 1].second] * (s[l] - s[l - 1]);
				ll it = lower_bound(all[l].begin(), all[l].end(), make_pair(nt, -1ll)) - all[l].begin();
				aws[i].push_back(aws[l][it]);
			}
		}
	}
}

ll arrival_time(ll y) {
	ll nt = y;
	ll i = 0;
	ll m = all.size();
	ll j = lower_bound(all[0].begin(), all[0].end(), make_pair(y, -1ll)) - all[0].begin();
	ll l = 0, r = m;
	while (r - l > 1) {
		ll mid = (l + r) / 2;
		if (ph[mid][j] != ph[i][j] || (j > 0 && all[mid][j - 1].first >= nt + nx * (ns[mid] - ns[i]))) {
			r = mid;
		} else {
			l = mid;
		}
	}
	l++;
	if (l == m) {
		return nt + nx * (ns.back() - ns[i]);
	} else {
		nt = all[l - 1][j - 1].first + nw[all[l - 1][j - 1].second] * (ns[l] - ns[l - 1]);
		ll it = lower_bound(all[l].begin(), all[l].end(), make_pair(nt, -1ll)) - all[l].begin();
		return aws[l][it];
	}
}

#ifdef LOCAL
int main()
{
    int L, N, X, M, Q;
    assert(5 == scanf("%d %d %d %d %d", &L, &N, &X, &M, &Q));
    std::vector<long long> T(N);
    for (int i = 0; i < N; i++)
        assert(1 == scanf("%lld", &T[i]));
    std::vector<int> W(N);
    for (int i = 0; i < N; i++)
        assert(1 == scanf("%d", &W[i]));
    std::vector<int> S(M);
    for (int i = 0; i < M; i++)
        assert(1 == scanf("%d", &S[i]));
    std::vector<long long> Y(Q);
    for (int i = 0; i < Q; i++)
        assert(1 == scanf("%lld", &Y[i]));

    fclose(stdin);

    init(L, N, T, W, X, M, S);
    std::vector<long long> res(Q);
    for (int i = 0; i < Q; i++)
        res[i] = arrival_time(Y[i]);

    for (int i = 0; i < Q; i++)
        printf("%lld\n", res[i]);
    fclose(stdout);
    return 0;
}
#endif

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 9
Accepted
time: 1ms
memory: 3840kb

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: 0
Wrong Answer
time: 1ms
memory: 4156kb

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
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
85184160532580
851841605...

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #12:

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

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:

wrong answer 38th lines differ - on the 1st token, expected: '308002692', found: '308000271'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%