# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
349198 | arnold518 | Fence (CEOI08_fence) | C++14 | 438 ms | 492 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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 100;
struct Point
{
int x, y;
};
Point operator + (Point p, Point q) { return {p.x+q.x, p.y+q.y}; }
Point operator - (Point p, Point q) { return {p.x-q.x, p.y-q.y}; }
ll ccw(Point p, Point q) { return p.x*q.y-p.y*q.x; }
int N, M;
Point A[MAXN+10], B[MAXN+10];
int C[MAXN+10][MAXN+10];
int dp[MAXN+10], ans=0;
int main()
{
scanf("%d%d", &N, &M);
for(int i=1; i<=N; i++) scanf("%d%d", &A[i].x, &A[i].y);
for(int i=1; i<=M; i++) scanf("%d%d", &B[i].x, &B[i].y);
for(int i=1; i<=N; i++)
{
vector<int> V;
for(int j=1; j<=N; j++) if(i!=j) V.push_back(j);
sort(V.begin(), V.end(), [&](const int &p, const int &q)
{
return ccw(A[p]-A[i], A[q]-A[i])>0;
});
for(int j=1; j<=N; j++)
{
if(j==i) continue;
for(int k=1; k<=N; k++)
{
if(k==i) continue;
if(k==j) continue;
C[j][k]=0;
for(int p=1; p<=M; p++)
{
if(ccw(A[j]-A[i], B[p]-A[i])>0 && ccw(A[k]-A[j], B[p]-A[j])>0 && ccw(A[i]-A[k], B[p]-A[k])>0) C[j][k]++;
}
}
}
for(int j=0; j<V.size(); j++)
{
dp[j]=40;
for(int k=0; k<j; k++)
{
dp[j]=min(dp[j], dp[k]+20-C[V[k]][V[j]]*111);
}
ans=min(ans, dp[j]);
}
}
printf("%d\n", ans+M*111);
}
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... |
# | 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... |