QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#293314#7122. OvertakingFeet_McYeetCompile Error//C++172.8kb2023-12-29 03:52:302024-04-28 08:16:14

Judging History

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

  • [2024-04-28 08:16:14]
  • 管理员手动重测本题所有提交记录
  • [2023-12-29 03:52:32]
  • 评测
  • [2023-12-29 03:52:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize ("Ofast")
// #pragma GCC target ("avx2")
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define el << '\n'
#define nl cout << '\n'
#define spc << ' '
#define forn(i,n) for (int i=0; i<n; i++)
#define forl(i,s,e) for (int i=s; i<e; i++)
#define pb push_back
#define fi first
#define se second
#define rsz resize
#define sz(x) ((int) x.size())
#define all(x) x.begin(), x.end()
const int inf = 1000000000;
const ll inf2 = 4000000000000000000;

#define int long long

const int MAXN = 1005;
int l, n, x, m;
ll os;
ll t[MAXN];
ll w[MAXN];
int s[MAXN];
vector<pair<ll, vector<ll>>> st[MAXN];

set<pair<pll, ll>> tr;

ll arrival_time(ll Y) {
	auto ptr = tr.lower_bound({{Y+1, -inf2},-inf2});
	if (ptr == tr.begin()) return Y+os;
	const auto& temp = *(--ptr);
	if (temp.fi.fi <= Y && temp.fi.se >= Y) return temp.se+os;
	return Y+os;
}

void wrt(ll rl, ll ru, ll rt) {
	auto ptr = tr.lower_bound({{rl+1, -inf2},-inf2});
	if (ptr != tr.begin()) {
		ptr--;
		if ((*ptr).fi.fi <= rl && (*ptr).fi.se >= rl) {
			auto temp = *ptr;
			tr.erase(ptr);
			temp.fi.se = rl-1;
			if (temp.fi.se >= temp.fi.fi) tr.insert(temp);
		}
	}
	ptr = tr.lower_bound({{ru+1, -inf2},-inf2});
	if (ptr != tr.begin()) {
		ptr--;
		if ((*ptr).fi.fi <= ru && (*ptr).fi.se >= ru) {
			auto temp = *ptr;
			tr.erase(ptr);
			temp.fi.fi = ru+1;
			if (temp.fi.se >= temp.fi.fi) tr.insert(temp);
		}
	}
	// cout << "r " << rl spc << ru spc << rt el;
	while (1) {
		auto ptr = tr.lower_bound({{rl, -inf2},-inf2});
		if (ptr == tr.end()) break;
		if ((*ptr).fi.se > ru) break;
		tr.erase(ptr);
	}
	tr.insert({{rl, ru}, rt});
}

void init(int L, int N, vector<ll> T, vector<int> W, int X, int M, vector<int> S) {
	l = L; n = N; x = X; m = M;
	os = (ll) l*x;
	forn(i,n) t[i] = T[i];
	forn(i,n) w[i] = W[i]-x;
	forn(i,m) s[i] = S[i];
	pair<ll, int> bp[n];
	forn(i,n) bp[i] = {t[i], w[i]};
	sort(bp,bp+n);
	forn(i,n) {
		if (bp[i].se <= 0) continue;
		if (sz(st[0]) && bp[i].fi == st[0].back().fi) st[0].back().se.pb(bp[i].se);
		else st[0].pb({bp[i].fi, {bp[i].se}});
	}
	for (auto& i : st[0]) sort(all(i.se));
	forl(i,1,m) {
		for (const auto& j : st[i-1]) {
			for (ll k : j.se) {
				if (sz(st[i]) && st[i].back().fi >= j.fi + k*(s[i] - s[i-1])) st[i].back().se.pb(k);
				else st[i].pb({j.fi + k*(s[i] - s[i-1]), {k}});
			}
		}
		for (auto& j : st[i]) sort(all(j.se));
	}
	for (int i = m-1; i>0; i--) {
		for (const auto& j : st[i]) {
			ll ct = arrival_time(j.fi)-os;
			wrt(j.fi - j.se.back() * (s[i] - s[i-1])+1, j.fi, ct);
		}
	}
	// cout << "AAA\n";
	// forn(i,n) {
	// 	for (const auto& j : st[i]) {
	// 		cout << j.fi spc spc;
	// 		for (ll k : j.se) cout << k spc;
	// 		nl;
	// 	}
	// 	nl;
	// }
	// cout << "AAA\n";
}

Details

/usr/bin/ld: /tmp/ccYJ5YP0.o: in function `main':
implementer.cpp:(.text.startup+0x46d): undefined reference to `init(int, int, std::vector<long long, std::allocator<long long> >, std::vector<int, std::allocator<int> >, int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status