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 <bits/stdc++.h>
using namespace std;
long long n, q, V, x[100005], y[100005], prijasnji[100005];
void update(int vrh){
int minus=0;
for (int i=1; i<vrh; i++){
if (prijasnji[i]) minus++;
} prijasnji[vrh]++; vrh-=minus;
for (int i=vrh+1; i<=n; i++){
x[i-1]=x[i]; y[i-1]=y[i];
} return;
}
bool ok (int idx1, int idx2){
idx1 = (idx1+n-1)%n+1; idx2 = (idx2+n-1)%n+1;
long long dx1 = x[idx1] - x[idx1-1];
long long dy1 = y[idx1] - y[idx1-1];
long long dx2 = x[idx2] - x[idx2-1];
long long dy2 = y[idx2] - y[idx2-1];
// cout << dx1 << " " << dy1 << " " << dx2 << " " << dy2 << endl;
// cout << dx1*dy2 << " " << dx2*dy1 << endl;
return (dx1*dy2 > dx2*dy1);
}
long double leng(int idx){
idx = (idx+n-1)%n+1;
long long dx = x[idx] - x[idx-1];
long long dy = y[idx] - y[idx-1];
// cout << "duljina izmedu " << idx << " i " << idx-1 << " iznosi: " << sqrtl(dx*dx + dy*dy) << endl;
return sqrtl(dx*dx + dy*dy);
}
long double dp[200005];
void check(){
long double ans=0.0000000000;
x[0]=x[n]; y[0]=y[n];
int cur=1; dp[1] = leng(1); ans=dp[1];
// cout << "pomoc: 1 1" << endl << "udaljenost: " << dp[1] << endl << "ans: " << ans << endl << endl;
for (int i=2; i<=2*n; i++){
while (!ok(cur, i)) cur++;
// cout << "pomoc: " << i << " " << cur << endl;
dp[i] = dp[i-1] + leng(i);
// cout << "udaljenost: " << dp[i] << endl;
ans = max(ans, dp[i] - dp[cur-1]);
// cout << "ans: " << ans << endl << endl;
} cout << ans << endl; return;
}
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i=1; i<=n; i++){
cin >> x[i] >> y[i];
}
cout << fixed << setprecision(10);
check(); cin >> q;
while (q--){
cin >> V; update(V); n--; check();
}
return 0;
}
# | 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... |