This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
typedef long long ll;
using namespace std;
const int N = 5e3 + 10;
int a[N], x[N], y[N];
int dist[N][N];
char dir[N];
bool used[N];
int main() {
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i] >> dir[i];
}
priority_queue <pair<int, pair<int, int>>> Q;
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (dir[i] == 'N') {
if (dir[j] == 'W') {
if (x[j] > x[i] && (x[j] - x[i]) == (y[i] - y[j])) {
Q.push({ -(x[j] - x[i]), { i, j } });
}
}
else if (dir[j] == 'E') {
if (x[j] < x[i] && (x[i] - x[j]) == (y[i] - y[j])) {
Q.push({ -(x[i] - x[j]), { i, j } });
}
}
else if (dir[j] == 'S') {
if (x[i] == x[j] && y[i] > y[j]) {
Q.push({ -(y[i] - y[j]) / 2, { i, j } });
}
}
continue;
}
if (dir[i] == 'S') {
if (dir[j] == 'W') {
if (x[j] > x[i] && (x[j] - x[i]) == (y[j] - y[i])) {
Q.push({ -(x[j] - x[i]), { i, j } });
}
}
else if (dir[j] == 'E') {
if (x[j] < x[i] && (x[i] - x[j]) == (y[j] - y[i])) {
Q.push({ -(x[i] - x[j]), { i, j } });
}
}
else if (dir[j] == 'N') {
if (x[i] == x[j] && y[j] > y[i]) {
Q.push({ -(y[j] - y[i]) / 2, { i, j } });
}
}
continue;
}
if (dir[i] == 'E') {
if (dir[j] == 'N') {
if (x[j] > x[i] && (x[j] - x[i]) == (y[j] - y[i])) {
Q.push({ -(x[j] - x[i]), { i, j } });
}
}
else if (dir[j] == 'S') {
if (x[j] > x[i] && (x[j] - x[i]) == (y[i] - y[j])) {
Q.push({ -(x[j] - x[i]), { i, j } });
}
}
else if (dir[j] == 'W') {
if (y[i] == y[j] && x[i] < x[j]) {
Q.push({ -(x[j] - x[i]) / 2, { i, j } });
}
}
continue;
}
if (dir[i] == 'W') {
if (dir[j] == 'N') {
if (x[j] > x[i] && (x[i] - x[j]) == (y[j] - y[i])) {
Q.push({ -(x[i] - x[j]), { i, j } });
}
}
else if (dir[j] == 'S') {
if (x[j] > x[i] && (x[i] - x[j]) == (y[i] - y[j])) {
Q.push({ -(x[i] - x[j]), { i, j } });
}
}
else if (dir[j] == 'E') {
if (y[i] == y[j] && x[i] > x[j]) {
Q.push({ -(x[i] - x[j]) / 2, { i, j } });
}
}
continue;
}
}
}
while (1) {
if (Q.empty()) break;
pair <int, pair<int, int>> t = Q.top();
vector <int> v;
while (!Q.empty() && Q.top().first == t.first) {
int x = Q.top().second.first, y = Q.top().second.second;
if (!used[x] && !used[y]) {
v.push_back(x);
v.push_back(y);
}
Q.pop();
}
for (auto it : v) {
used[it] = true;
}
}
for (int i = 1; i <= n; i++) {
if (!used[i]) {
cout << i << "\n";
}
}
}
# | 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... |