QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#530785#7122. Overtakinggreen_gold_dog#0 1ms3932kbC++203.3kb2024-08-24 17:14:272024-08-24 17:14:27

Judging History

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

  • [2024-08-24 17:14:27]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3932kb
  • [2024-08-24 17:14:27]
  • 提交

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<ll> ns, nw;
ll nx;

random_device rd;
mt19937 rnd(rd());

void init(int gl, int gn, vector<ll> t, vector<int> gw, int gx, int gm, vector<int> gs) {
	ll n = gn, l = gl, x = gx, m = gm;
	vector<ll> w(n), s(m);
	for (ll i = 0; i < n; i++) {
		w[i] = gw[i];
	}
	for (ll i = 0; i < n; i++) {
		s[i] = gs[i];
	}
	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

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: 3932kb

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
104632
103224
104162
102964
100102
103066
102104
103618
103242
101390
101472
103054
100828
101910
101888
102368
103654
100180
100604
104062
101354
103684
103110
102916
104516
103706
100962
104062
101784
103984
104736
101414
103580
101874
100078
104850
100590
10076...

result:

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

Subtask #2:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

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:


result:


Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%