Submission #933578

#TimeUsernameProblemLanguageResultExecution timeMemory
933578Ice_manSightseeing in Kyoto (JOI22_kyoto)C++14
Compilation error
0 ms0 KiB
#include <iostream> #include <chrono> #include <vector> #define maxn 200005 #define maxlog 20 #define INF 1000000010 #define LINF 1000000000000000005 #define endl '\n' #define pb(x) push_back(x) #define X first #define Y second #define control cout<<"passed"<<endl; #pragma GCC optimize("O3" , "Ofast" , "unroll-loops" , "fast-math") #pragma GCC target("avx2") using namespace std; std::chrono::high_resolution_clock::time_point startT, currT; constexpr double TIME_MULT = 1; double timePassed() { using namespace std::chrono; currT = high_resolution_clock::now(); double time = duration_cast<duration<double>>(currT - startT).count(); return time * TIME_MULT; } struct point { long long x, y; point() {}; point(long long _x, long long _y) { x = _x; y = _y; } int direction(const point &a, const point &b) { long long face = 0; face += (a.x - x) * (a.y + y); face += (b.x - a.x) * (b.y + a.y); face += (x - b.x) * (y + b.y); return face > 0? 1 : face < 0? -1 : 0; } }; long long dist(long long x1, long long x2, long long y) { return (x1 - x2) * y; } long long n, m; long long a[maxn], b[maxn]; long long dp[maxn][maxn]; void read() { cin >> n >> m; for(long long i = 1; i <= n; i++) cin >> a[i]; for(long long i = 1; i <= m; i++) cin >> b[i]; } long long ans = 0; vector <point> hulla, hullb; void gen_hull_a() { for(long long i = 1; i <= n; i++) { point e = {i, a[i]}; while(hulla.size() >= 2 && hulla[hulla.size() - 2].direction(hulla[hulla.size() - 1], e) >= 0) hulla.pop_back(); hulla.pb(e); } } void gen_hull_b() { for(long long i = 1; i <= m; i++) { point e = {i, b[i]}; while(hullb.size() >= 2 && hullb[hullb.size() - 2].direction(hullb[hullb.size() - 1], e) >= 0) hullb.pop_back(); hullb.pb(e); } } long long try_dist(long long x1, long long x2, long long y1, long long y2) { return (x1 - x2) * (y1 - y2); } void solve() { point e, e2; while(hulla.size() > 1 || hullb.size() > 1) { //cout << hulla.size() << " - " << hullb.size() << endl; //cout << ans << endl; if(hulla.size() == 1) { ///control e = hullb[hullb.size() - 1]; hullb.pop_back(); e2 = hullb[hullb.size() - 1]; ans += dist(e.x, e2.x, hulla[hulla.size() - 1].y); continue; } if(hullb.size() == 1) { ///cout << "inb" << endl; e = hulla[hulla.size() - 1]; hulla.pop_back(); e2 = hulla[hulla.size() - 1]; ans += dist(e.x, e2.x, hullb[hullb.size() - 1].y); continue; } long long dist1 = try_dist(hulla[hulla.size() - 1].x, hulla[hulla.size() - 2].x, hullb[hullb.size() - 1].y, hullb[hullb.size() - 2].y); long long dist2 = try_dist(hullb[hullb.size() - 1].x, hullb[hullb.size() - 2].x, hulla[hulla.size() - 1].y, hulla[hulla.size() - 2].y); ///cout << ":: " << dist1 << " " << dist2 << endl; if(dist2 > dist1) { e = hulla[hulla.size() - 1]; hulla.pop_back(); e2 = hulla[hulla.size() - 1]; ans += dist(e.x, e2.x, hullb[hullb.size() - 1].y); continue; } e = hullb[hullb.size() - 1]; hullb.pop_back(); e2 = hullb[hullb.size() - 1]; ans += dist(e.x, e2.x, hulla[hulla.size() - 1].y); continue; } cout << ans << endl; } int main() { /**#ifdef ONLINE_JUDGE freopen("taxi.in", "r", stdin); freopen("taxi.out", "w", stdout); #endif*/ ios_base::sync_with_stdio(false); cin.tie(nullptr); startT = std::chrono::high_resolution_clock::now(); read(); gen_hull_a(); /**cout << "-----------------------" << endl; for(point e : hulla) cout << e.x << " " << e.y << endl;*/ gen_hull_b(); /**cout << "----------------------" << endl; for(point e : hullb) cout << e.x << " " << e.y << endl; cout << "----------------------" << endl;*/ solve(); return 0; }

Compilation message (stderr)

/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status