QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#249428 | #7569. Lines | USP_USP_USP | WA | 1ms | 3912kb | C++20 | 3.7kb | 2023-11-12 06:33:09 | 2023-11-12 06:33:09 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
#define int int64_t
#define pb push_back
void dbg_out() { cerr << endl; }
template <typename H, typename... T>
void dbg_out(H h, T... t) { cerr << ' ' << h; dbg_out(t...); }
#define dbg(...) { cerr << #__VA_ARGS__ << ':'; dbg_out(__VA_ARGS__); }
#define fi first
#define se second
using ll = long long;
using db = long double;
struct CHT {
int it;
vector<ll> a, b;
CHT():it(0){}
bool useless(){
int sz = a.size();
int r = sz-1, m = sz-2, l = sz-3;
return (b[l] - b[r]) * (a[m] - a[l]) <= (b[l] - b[m]) * (a[r] - a[l]);
}
void add(ll A, ll B){
a.push_back(A); b.push_back(B);
while (!a.empty()){
if ((a.size() < 3) || !useless()) break;
a.erase(a.end() - 2);
b.erase(b.end() - 2);
}
}
};
void solve() {
int n;
cin >> n;
vector<int> a(n+1), b(n+1), c(n+1);
vector<int> ok(3*n+1);
for(int i = 0; i <= n; i++)
cin >> a[i];
for(int i = 0; i <= n; i++)
cin >> b[i];
for(int i = 0 ; i <= n; i++)
cin >> c[i];
vector<array<int,2>> sad;
auto calcmaq = [&](vector<int> v){
vector<pair<int,int>> mq;
for(int i = 0; i <= n; i++){
mq.push_back({v[i],i});
}
return mq;
};
auto cross = [&] (pair<int, int> x, pair<int, int> y) {
return x.first * y.second - y.first * x.second;
};
assert (cross ({1, 0}, {1, 1}) > 0);
auto fix = [&] (vector<pair<int, int>> points) {
for (auto &[y, x] : points) swap (y, x);
sort(points.begin(),points.end());
CHT cht;
for (auto [x, y] : points) {
cht.add(x,y);
}
vector<pair<int,int>> wtf;
int sz = cht.a.size();
for(int i = 0; i < sz; i++){
int A = cht.a[i];
int B = cht.b[i];
wtf.pb({B,A});
}
return wtf;
};
for(int q = 0; q < 2; q++){
auto ma = calcmaq(a);
auto mb = calcmaq(b);
auto mc = calcmaq(c);
// for (auto u : ma) cout << u.first << " ";
// cout << "\n";
ma = fix (ma);
mb = fix (mb);
mc = fix (mc);
// for (auto u : ma) cout << u.first << " ";
// cout << "\n";
int sa = ma.size();
int sb = mb.size();
int sc = mc.size();
int i = 0;
int j = 0;
int k = 0;
while(i < sa-1 || j < sb-1 || k < sc-1){
auto [va,ida] = ma[i];
auto [vb,idb] = mb[j];
auto [vc,idc] = mc[k];
if(q){
ida = n-ida;
idb = n-idb;
idc = n-idc;
}
int eu = ida+idb+idc;
sad.pb({eu,va+vb+vc});
vector<array<int,3>> op;
if(i < sa-1){
op.pb({ ma[i+1].fi-ma[i].fi ,ma[i+1].se-ma[i].se, 0});
}
if(j < sb-1){
op.pb({ mb[j+1].fi-mb[j].fi, mb[j+1].se-mb[j].se,1});
}
if(k < sc-1){
op.pb({ mc[k+1].fi-mc[k].fi, mc[k+1].se-mc[k].se,2});
}
sort(op.rbegin(),op.rend());
if(op[0][2] == 0){
i++;
}else if(op[0][2] == 1){
j++;
}else{
k++;
}
}
reverse(a.begin(),a.end());
reverse(b.begin(),b.end());
reverse(c.begin(),c.end());
}
sad.pb({0,a[0]+b[0]+c[0]});
sad.pb({3*n,a[n]+b[n]+c[n]});
sort(sad.begin(),sad.end());
sort (all (sad));
sad.resize (unique (all (sad)) - sad.begin ());
CHT cht;
for(auto [A,B] : sad){
cht.add(A,B);
}
for(auto fe : cht.a){
ok[fe] = 1;
}
vector<int> ans;
for(int i = 0; i <= 3*n; i++){
if(!ok[i]) ans.pb(i);
}
cout << ans.size() << '\n';
for(auto x : ans ) cout << x << ' ';
cout << '\n';
}
signed main(){
ios::sync_with_stdio(false); cin.tie(0);
solve();
}
/*
Makefile:
CXXFLAGS=-Wall -Wextra -Wshadow -g -pedantic -fsanitize=address,undefined -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUGPEDANTIC -std=gnu++17
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
input:
3 3 1 8 7 9 1 3 1 5 1 1 6
output:
5 1 3 4 7 8
result:
ok 6 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
1 1 2 1 2 1 2
output:
2 1 2
result:
ok 3 number(s): "2 1 2"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3912kb
input:
252 336470888 634074578 642802746 740396295 773386884 579721198 396628655 503722503 971207868 202647942 2087506 268792718 46761498 443917727 16843338 125908043 691952768 717268783 787375312 150414369 693319712 519096230 45277106 856168102 762263554 674936674 407246545 274667941 279198849 527268921 1...
output:
736 4 5 7 9 10 11 12 14 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106...
result:
wrong answer 1st numbers differ - expected: '733', found: '736'