제출 #1134264

#제출 시각아이디문제언어결과실행 시간메모리
1134264viwlesxqNaval battle (CEOI24_battle)C++20
0 / 100
1484 ms1114112 KiB
#include <bits/stdc++.h> using namespace std; #define int long long template<class A, class B> bool chmin(A &a, const B &b) { return a > b ? (a = b) == b : false; } template<class A, class B> bool chmax(A &a, const B &b) { return a < b ? (a = b) == b : false; } const int inf = 1e18; signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; int x[n], y[n]; char d[n]; for (int i = 0; i < n; ++i) { cin >> x[i] >> y[i] >> d[i]; } vector<array<int, 3>> v; for (int i = 0; i < n; ++i) { for (int j = i + 1; j < n; ++j) { if (d[i] == 'N' && d[j] == 'S') { if (y[i] > y[j]) v.push_back({(y[i] - y[j]) / 2, i, j}); } else if (d[i] == 'N' && d[j] == 'E') { if (x[i] - x[j] == y[i] - y[j]) v.push_back({x[i] - x[j], i, j}); } else if (d[i] == 'N' && d[j] == 'W') { if (x[j] - x[i] == y[i] - y[j]) v.push_back({x[j] - x[i], i, j}); } else if (d[i] == 'S' && d[j] == 'N') { if (y[i] < y[j]) v.push_back({(y[i] - y[j]) / 2, i, j}); } else if (d[i] == 'S' && d[j] == 'E') { if (x[i] - x[j] == y[j] - y[i]) v.push_back({x[i] - x[j], i, j}); } else if (d[i] == 'S' && d[j] == 'W') { if (x[j] - x[i] == y[j] - y[i]) v.push_back({x[j] - x[i], i, j}); } else if (d[i] == 'E' && d[j] == 'S') { if (x[j] - x[i] == y[i] - y[j]) v.push_back({x[j] - x[i], i, j}); } else if (d[i] == 'E' && d[j] == 'N') { if (x[j] - x[i] == y[j] - y[i]) v.push_back({x[j] - x[i], i, j}); } else if (d[i] == 'E' && d[j] == 'W') { if (x[i] < x[j]) v.push_back({(x[j] - x[i]) / 2, i, j}); } else if (d[i] == 'W' && d[j] == 'S') { if (x[i] - x[j] == y[i] - y[j]) v.push_back({x[i] - x[j], i, j}); } else if (d[i] == 'W' && d[j] == 'E') { if (x[j] < x[i]) v.push_back({(x[i] - x[j]) / 2, i, j}); } else if (d[i] == 'W' && d[j] == 'N') { if (x[i] - x[j] == y[j] - y[i]) v.push_back({x[i] - x[j], i, j}); } } } sort(v.begin(), v.end(), greater<array<int, 3>>()); vector<int> del(n, -1); while (!v.empty()) { auto [d, i, j] = v.back(); v.pop_back(); if (del[i] != -1 && del[i] < d) continue; if (del[j] != -1 && del[j] < d) continue; del[i] = del[j] = d; } for (int i = 0; i < n; ++i) { if (del[i] == -1) { cout << i + 1 << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...