#include <bits/stdc++.h>
#define nemeshay ios_base::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
#define int long long
#define sigma signed
#define pb push_back
#define pii pair<int, int>
#define fr first
#define sc second
using namespace std;
const int N = 2e5 + 2, inf = 1e18 + 7;
pair<pii, char> a[N];
int used[N];
int clash(int i, int j) {
int xi = a[i].fr.fr, yi = a[i].fr.sc, xj = a[j].fr.fr, yj = a[j].fr.sc;
if (a[i].sc == a[j].sc) return inf;
if ((a[i].sc == 'S' && a[j].sc == 'N') || (a[i].sc == 'N' && a[j].sc == 'S')) {
if (xi == xj) return (abs(yi - yj) + 1) / 2;
return inf;
}
if ((a[i].sc == 'W' && a[j].sc == 'E') || (a[i].sc == 'E' && a[j].sc == 'W')) {
if (yi == yj) return (abs(xi - xj) + 1) / 2;
return inf;
}
if ((a[i].sc == 'E' && a[j].sc == 'S') || (a[i].sc == 'S' && a[j].sc == 'E')
|| (a[i].sc == 'W' && a[j].sc == 'N') || (a[i].sc == 'N' && a[j].sc == 'W')) {
if (xi + yi == xj + yj) return abs(xi - xj);
return inf;
}
if ((a[i].sc == 'E' && a[j].sc == 'N') || (a[i].sc == 'N' && a[j].sc == 'E')
|| (a[i].sc == 'W' && a[j].sc == 'S') || (a[i].sc == 'S' && a[j].sc == 'W')) {
if (abs(xi - xj) == abs(yi - yj)) return abs(xi - xj);
return inf;
}
}
sigma main() {
int n;
cin >> n;
vector <pair<int, pii>> pon;
for (int i = 1; i <= n; i++) cin >> a[i].fr.fr >> a[i].fr.sc >> a[i].sc;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
int t = clash(i, j);
if (t != inf) pon.pb({t, {i, j}});
}
}
sort(pon.begin(), pon.end());
int mn = 0;
vector <int> kill;
for (int i = 0; i < pon.size(); i++) {
if (used[pon[i].sc.fr] || used[pon[i].sc.sc]) continue;
if (pon[i].fr > mn) for (auto j: kill) used[j] = 1;
kill.pb(pon[i].sc.fr), kill.pb(pon[i].sc.sc);
}
for (auto j: kill) used[j] = 1;
for (int i = 1; i <= n; i++) if (!used[i]) cout << i << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'long long int clash(long long int, long long int)':
Main.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
34 | }
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |