QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#293564 | #7122. Overtaking | HaccerKat | Compile Error | / | / | C++20 | 7.3kb | 2023-12-29 12:54:30 | 2024-04-28 08:24:49 |
Judging History
你现在查看的是最新测评结果
- [2024-04-28 08:24:49]
- 管理员手动重测本题所有提交记录
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-29 12:54:30]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-12-29 12:54:30]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
template<typename T>
int SIZE(T (&t)){
return t.size();
}
template<typename T, size_t N>
int SIZE(T (&t)[N]){
return N;
}
string to_string(char t){
return "'" + string({t}) + "'";
}
string to_string(bool t){
return t ? "true" : "false";
}
string to_string(const string &t, int x1=0, int x2=1e9){
string ret = "";
for(int i = min(x1,SIZE(t)), _i = min(x2,SIZE(t)-1); i <= _i; ++i){
ret += t[i];
}
return '"' + ret + '"';
}
string to_string(const char* t){
string ret(t);
return to_string(ret);
}
template<size_t N>
string to_string(const bitset<N> &t, int x1=0, int x2=1e9){
string ret = "";
for(int i = min(x1,SIZE(t)); i <= min(x2,SIZE(t)-1); ++i){
ret += t[i] + '0';
}
return to_string(ret);
}
template<typename T, typename... Coords>
string to_string(const T (&t), int x1=0, int x2=1e9, Coords... C);
template<typename T, typename S>
string to_string(const pair<T, S> &t){
return "(" + to_string(t.first) + ", " + to_string(t.second) + ")";
}
template<typename T, typename... Coords>
string to_string(const T (&t), int x1, int x2, Coords... C){
string ret = "[";
x1 = min(x1, SIZE(t));
auto e = begin(t);
advance(e,x1);
for(int i = x1, _i = min(x2,SIZE(t)-1); i <= _i; ++i){
ret += to_string(*e, C...) + (i != _i ? ", " : "");
e = next(e);
}
return ret + "]";
}
template<int Index, typename... Ts>
struct print_tuple{
string operator() (const tuple<Ts...>& t) {
string ret = print_tuple<Index - 1, Ts...>{}(t);
ret += (Index ? ", " : "");
return ret + to_string(get<Index>(t));
}
};
template<typename... Ts>
struct print_tuple<0, Ts...> {
string operator() (const tuple<Ts...>& t) {
return to_string(get<0>(t));
}
};
template<typename... Ts>
string to_string(const tuple<Ts...>& t) {
const auto Size = tuple_size<tuple<Ts...>>::value;
return print_tuple<Size - 1, Ts...>{}(t);
}
void dbgr(){;}
template<typename Heads, typename... Tails>
void dbgr(Heads H, Tails... T){
cout << to_string(H) << " | ";
dbgr(T...);
}
void dbgs(){;}
template<typename Heads, typename... Tails>
void dbgs(Heads H, Tails... T){
cout << H << " ";
dbgs(T...);
}
/*
formatted functions:
*/
/*
consider __VA_ARGS__ as a whole:
dbgv() prints values only
dbg() prints name and values
*/
#define dbgv(...) cout << to_string(__VA_ARGS__) << endl;
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgv(__VA_ARGS__);
//#define dbg(...)
/*
consider __VA_ARGS__ as a sequence of arguments:
dbgr() prints values only
dbgm() prints names and values
*/
#define dbgr(...) dbgr(__VA_ARGS__); cout << endl;
#define dbgm(...) cout << "[" << #__VA_ARGS__ << "]: "; dbgr(__VA_ARGS__);
struct custom_hash {
static uint64_t splitmix64(uint64_t x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
};
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
// using u128 = __uint128_t;
// using i128 = __int128;
const int mod = 1000000007;
const int N = 200005;
const int LOG = 20;
const ll inf = 5e18;
const double eps = 1e-11;
int n, m, k, qq, L, X;
set<array<ll, 3>> s;
void init(int LL, int N, vector<ll> T, vector<int> W, int XX, int M, vector<int> S) {
L = LL, X = XX;
vector<int> pos;
vector<vector<int>> needed(M - 1);
vector<vector<ll>> TT(M - 1, vector<ll>(N));
for (int i = 0; i < N; i++) {
W[i] -= X;
if (W[i] > 0) pos.push_back(i);
}
for (int i = 0; i < M - 1; i++) {
vector<array<ll, 3>> b;
for (int p : pos) {
ll l = T[p] + (ll)W[p] * S[i], r = T[p] + (ll)W[p] * S[i + 1];
b.push_back({l, -r, p});
TT[i][p] = (i == 0 ? T[p] : TT[i - 1][p]);
}
sort(b.begin(), b.end());
ll curr = -inf, curl = -inf;
for (auto [l, r, p] : b) {
r = -r;
if (r > curr) {
needed[i].push_back(p);
curr = r, curl = l;
}
else {
if (l != curl) {
TT[i][p] += curr - r;
}
}
}
}
for (int i = M - 2; i >= 0; i--) {
vector<pll> a;
for (auto p : needed[i]) {
ll l = TT[i][p] + (ll)W[p] * S[i] + 1, r = TT[i][p] + (ll)W[p] * S[i + 1];
a.push_back({r, l});
}
sort(a.rbegin(), a.rend());
ll curl = inf;
vector<array<ll, 3>> b;
for (auto [r, l] : a) {
ll rr = min(r, curl - 1);
if (l <= rr) {
b.push_back({l, rr, r});
}
curl = min(l, curl);
}
for (auto &[l, r, x] : b) {
auto it = s.upper_bound({x, inf});
if (it == s.begin()) continue;
it--;
auto [lx, rx, y] = *it;
if (x >= lx && x <= rx) x = y;
}
for (auto [l, r, x] : b) {
auto it = s.upper_bound({l, inf});
if (it != s.begin()) it--;
vector<array<ll, 3>> add;
while (it != s.end()) {
auto [lx, rx, y] = *it;
if (lx > r) break;
if (lx < l) {
add.push_back({lx, l - 1, y});
}
if (rx > r) {
add.push_back({r + 1, rx, y});
}
auto itx = it;
itx++;
s.erase(it);
it = itx;
}
s.insert({l, r, x});
for (auto p : add) s.insert(p);
}
}
}
ll arrival_time(ll Y) {
auto it = s.upper_bound({Y, inf});
if (it == s.begin()) return Y + (ll)L * X;
it--;
auto [l, r, x] = *it;
return (Y >= l && Y <= r ? x : Y) + (ll)L * X;
}
void solve() {
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);
}
int32_t main() {
std::ios::sync_with_stdio(false);
cin.tie(NULL);
solve();
}
詳細信息
/usr/bin/ld: /tmp/cc0X7NxX.o: in function `main': answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/ccJqFEpY.o:implementer.cpp:(.text.startup+0x0): first defined here collect2: error: ld returned 1 exit status