提交时间:2022-10-04 11:24:32
运行 ID: 57446
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; int s[N << 2], g[N][4]; int n; int main() { scanf("%d", &n); for (int a, b, i = 1; i <= n; i++) { scanf("%d%d", &a, &b); for (int j = 0; j < 4; j++) { int h = (j & 1) * a + ((j >> 1) & 1) * b; g[i][j] = h; s[(i << 2) - 4 + j] = h; } } sort(s, s + (n << 2), greater<int>()); for (int i = 1; i <= n; i++) { int ans = 0; for (int j = 0; j < 4; j++) { int pos = lower_bound(s, s + (n << 2), g[i][j], greater<int>()) - s; for (int k = 0; k < 4; k++) { if (g[i][k] > g[i][j]) pos--; } ans += pos; } printf("%.10lf\n", ans / 16.0 + 1); } return 0; } /* ans_i = 1+P(fj>fi) 10000 10000 10000 5000 0 10000 10000 20000 0 5000 10000 15000 //0 0 5000 10000 10000 10000 15000 20000 20000 15000 10000 10000 10000 5000 0 0 1 2 3 3 3 6 7 7 0 + 1 + 1 + 3 5/16 + 1 2 * 2 * 2 * 2 */ /* 10 10000 7000 3000 8000 3000 10000 6000 4000 2000 8000 4000 1000 9000 9000 8000 10000 3000 6000 3000 7000 */