AtCoder Beginner Contest 075 D - Axis-Parallel Rectangle
我要崩溃,当时还以为是需要什么离散化的,原来是暴力,特么五层循环。。。。我自己写怎么都错。。。。。暴力都不会了,,,,,
1 #include<iostream> 2 #include<vector> 3 #include<limits> 4 #include<algorithm> 5 using namespace std; 6 typedef long long ll; 7 const int maxn = 105; 8 int N, K; 9 10 int main() 11 { 12 cin >> N >> K; 13 ll x[maxn], y[maxn], a[maxn], b[maxn]; 14 for (int i = 0; i<N; i++) { 15 cin >> a[i] >> b[i]; 16 x[i] = a[i], y[i] = b[i]; 17 } 18 sort(x, x + N); 19 sort(y, y + N); 20 ll ans = 1ll << 62; 21 for (int i = 0; i < N; i++) { 22 for(int j=i+1;j<N;j++) 23 for (int k = 0; k < N; k++) { 24 for (int l = k + 1; l < N; l++) { 25 ll sx = x[i]; 26 ll gx = x[j]; 27 ll sy = y[k]; 28 ll gy = y[l]; 29 int cnt = 0; 30 for (int m = 0; m < N; m++) { 31 if (a[m] >= sx&&a[m] <= gx&&b[m] >= sy&&b[m] <= gy) 32 cnt++; 33 } 34 if (cnt >= K) 35 ans = min(ans, (gx - sx)*(gy - sy)); 36 } 37 } 38 } 39 cout << ans << endl; 40 return 0; 41 }