# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
138876 | mosesmayer | Aliens (IOI16_aliens) | C++17 | 2068 ms | 10220 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "aliens.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
struct Line{
LL m, c;
Line(LL m = 0, LL c = 0): m(m), c(c){}
LL get(LL x){return m * x + c;}
};
struct ConvexHull{
int sz, B, fr;
Line *hull;
int *cnt;
ConvexHull(int n): sz(0), B(0), fr(0){
hull = new Line[++n];
cnt = new int[n];
}
bool is_bad(int curr, int prev, int next){
Line c = hull[curr], p = hull[prev], n = hull[next];
return make_pair((c.c - n.c) * (c.m - p.m), cnt[next]) < make_pair((p.c - c.c) * (n.m - c.m), cnt[curr]);
}
void add_line(LL m, LL c, int newcnt){
hull[sz++] = Line(m, c);
cnt[sz - 1] = newcnt;
while (sz - fr > 2 && is_bad(sz-2, sz-3, sz-1)){
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |