Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <iomanip>
- #include <cstring>
- #define task ""
- using namespace std;
- using ll = long long;
- using ld = long double;
- const int N = 2e2 + 2;
- int n, k, par[N][N];
- int x[N], y[N];
- ll dp[N][N];
- int ances[N], res[N];
- void Read(){
- cin >> n >> k;
- for(int i = 1; i <= n; ++i)
- cin >> x[i] >> y[i];
- }
- ll S(int i, int j, int h){
- struct Vector{
- ll x, y;
- Vector() {}
- Vector(int a, int b){
- x = a;
- y = b;
- }
- ll operator * (const Vector &a) const{
- return x * a.y - y * a.x;
- }
- };
- Vector OA, OB, OC;
- OA = Vector(x[i], y[i]);
- OB = Vector(x[j], y[j]);
- OC = Vector(x[h], y[h]);
- return abs(OA * OB + OB * OC + OC * OA);
- }
- void trace(int i, int k){
- if(i == 0)
- return;
- trace(par[i][k], k - 1);
- ances[k] = i;
- }
- void Solve(){
- ll ans = 0;
- for(int i = 1; i <= n - k + 1; ++i){
- memset(dp, 0, sizeof dp);
- memset(par, 0, sizeof par);
- for(int j = i + 1; j <= n; ++j)
- par[j][2] = i;
- for(int j = i + 2; j <= n; ++j)
- for(int t = 3; t <= k; ++t)
- for(int h = i + 1; h < j; ++h){
- ll sqr = S(i, j, h);
- if(dp[j][t] < dp[h][t - 1] + sqr){
- dp[j][t] = dp[h][t - 1] + sqr;
- par[j][t] = h;
- }
- }
- ll cur = 0, endhere;
- for(int j = i + 2; j <= n; ++j){
- if(cur < dp[j][k]){
- cur = dp[j][k];
- endhere = j;
- }
- }
- trace(endhere, k);
- if(ans < cur){
- ans = cur;
- for(int i = 1; i <= k; ++i)
- res[i] = ances[i];
- }
- }
- cout << fixed << setprecision(2) << (ld) 1.0 * ans / 2 << "\n";
- for(int i = 1; i <= k; ++i)
- cout << res[i] << " ";
- }
- signed main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0); if(fopen(task".INP", "r"))
- freopen(task".INP", "r", stdin),
- freopen(task".OUT", "w", stdout);
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment