正文
增加 7 行删除 7 行
64 行未改动65666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091103 行未改动64 行未改动int main(){cin >> n;for (int i = 1; i <= n; i ++ ) cin >> a[i].x >> a[i].y;cin >> sx >> sy;for (int i = 1; i <= n; i ++ ){if (a[i].x != sx) continue;int pre = (i == 1 ? n : i - 1);int nxt = (i == n ? 1 : i + 1);if ((a[pre].x <= sx && a[nxt].x <= sx) || (a[pre].x >= sx && a[nxt].x >= sx)) jd[i] = true;if (a[pre].x == sx && a[nxt].x > sx) jd[i] ^= 1;if (a[nxt].x == sx && a[pre].x > sx) jd[i] ^= 1;}int m = 0;for (int i = 1; i <= n; i ++ ){int j = i % n + 1;if (a[i].x == sx){if (!jd[i]) y[++ m] = a[i].y;}if (a[i].x == a[j].x) continue;if ((a[i].x < sx && sx < a[j].x) || (a[j].x < sx && sx < a[i].x)) y[++ m] = get_y(a[i], a[j], sx);}sort(y + 1, y + m + 1);int j = 1;while (j <= m && y[j] < sy) j ++;if (j > m){cout << "0\n";return 0;}double ans = 0;if (j % 2 == 0) ans += y[j] - sy, j ++ ;while (j <= m){ans += y[j + 1] - y[j];j += 2;}cout << (int)ans << "\n";// cout << fixed << setprecision(0) << ans << "\n";}```3 行未改动64 行未改动65666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091103 行未改动64 行未改动int main(){cin >> n;for (int i = 1; i <= n; i ++ ) cin >> a[i].x >> a[i].y;cin >> sx >> sy;for (int i = 1; i <= n; i ++ ){if (a[i].x != sx) continue;int pre = (i == 1 ? n : i - 1);int nxt = (i == n ? 1 : i + 1);if ((a[pre].x <= sx && a[nxt].x <= sx) || (a[pre].x >= sx && a[nxt].x >= sx)) jd[i] = true;if (a[pre].x == sx && a[nxt].x > sx) jd[i] ^= 1;if (a[nxt].x == sx && a[pre].x > sx) jd[i] ^= 1;}int m = 0;for (int i = 1; i <= n; i ++ ){int j = i % n + 1;if (a[i].x == sx){if (!jd[i]) y[++ m] = a[i].y;}if (a[i].x == a[j].x) continue;if ((a[i].x < sx && sx < a[j].x) || (a[j].x < sx && sx < a[i].x)) y[++ m] = get_y(a[i], a[j], sx);}sort(y + 1, y + m + 1);int j = 1;while (j <= m && y[j] < sy) j ++;if (j > m){cout << "0\n";return 0;}double ans = 0;if (j % 2 == 0) ans += y[j] - sy, j ++ ;while (j <= m){ans += y[j + 1] - y[j];j += 2;}cout << (int)ans << "\n";// cout << fixed << setprecision(0) << ans << "\n";}```3 行未改动