QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#456426 | #8768. Arrested Development | ucup-team2307# | RE | 0ms | 0kb | C++20 | 1.7kb | 2024-06-27 22:09:30 | 2024-06-27 22:09:31 |
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using pii = pair<int, int>;
using vi = vector<int>;
#define fi first
#define se second
#define pb push_back
vector<pair<double, double> > bad;
const double INF = -1e18;
double cross(int x1, int y1, int x2, int y2)
{
return x1-y1*(x2-x1)*1.0/(y2-y1);
}
void add(int x, int y1, int y2, int a, int b1, int b2)
{
vector<double> v = {-INF, 0};
if (y1 != b2)
v.pb(cross(x, y1, a, b2));
if (y2 != b1)
v.pb(cross(x, y2, a, b1));
sort(v.begin(), v.end());
while (v.back() > 0)
v.pop_back();
int k = v.size();
for (int i : v)
cout<<i<<" ";
cout<<"\n";
for (int i=0; i+1<k; i++)
{
double X = (v[i] + v[i+1])/2;
if (y1*1.0/(x-X) > b2*1.0/(a-X) ||
b1*1.0/(a-X) > y2*1.0/(x-X))
bad.pb({v[i], v[i+1]});
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n, w;
cin>>n>>w;
vector<array<int, 3> > v(n);
for (auto& [x, y, z] : v) cin>>x>>y>>z;
for (int i=0; i<n; i++)
for (int j=i+1; j<n; j++)
add(v[i][0], v[i][1], v[i][2], v[j][0], v[j][1], v[j][2]);
double c = INF;
double ans = 0;
sort(bad.begin(), bad.end());
for (auto [l, r] : bad)
{
cout<<l<<" "<<r<<"\n";
if (l>0)
break;
if (l > c)
ans += c-l;
c = max(c, r);
}
ans += max<double>(0, 0-c);
cout<<ans<<"\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
4 100 1 1 90 1 20 1 20