| Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|---|
| 439065 | 方相宜 | 26年4月-A组(萌新)C. 电视塔选址 | C++ | 通过 | 100 | 51 MS | 1048 KB | 1567 | 2026-05-04 21:19:12 |
#include <iostream> #include <vector> #include <set> using namespace std; int main() { int N, K; cin >> N >> K; vector<pair<int, int>> points(K); for (int i = 0; i < K; i++) { cin >> points[i].first >> points[i].second; } if (K == 0) { cout << N * N << endl; return 0; } set<pair<int, int>> feasible; // 第一个点 int x1 = points[0].first, y1 = points[0].second; // 4 条直线的点枚举 vector<pair<int, int>> candidates; // 直线 x = x1 for (int y = 1; y <= N; y++) candidates.emplace_back(x1, y); // 直线 y = y1 for (int x = 1; x <= N; x++) candidates.emplace_back(x, y1); // 直线 x - y = d1, d1 = x1 - y1 int d1 = x1 - y1; for (int x = 1; x <= N; x++) { int y = x - d1; if (y >= 1 && y <= N) candidates.emplace_back(x, y); } // 直线 x + y = s1, s1 = x1 + y1 int s1 = x1 + y1; for (int x = 1; x <= N; x++) { int y = s1 - x; if (y >= 1 && y <= N) candidates.emplace_back(x, y); } // 去重检查 for (auto [x, y] : candidates) { bool ok = true; for (auto [xi, yi] : points) { if (x == xi || y == yi || x - y == xi - yi || x + y == xi + yi) { continue; } else { ok = false; break; } } if (ok) feasible.emplace(x, y); } cout << feasible.size() << endl; return 0; }