이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 17;
int n, sank[N], ww;
pair <int, int> ship[N];
char dir[N];
vector <tuple <int, int, int>> vtp;
void collide (int i, int j)
{
char d1 = dir[i], d2 = dir[j];
auto [x1, y1] = ship[i];
auto [x2, y2] = ship[j];
int w = (abs (x1 - x2) + abs (y1 - y2)) / 2;
if (d1 == 'N')
{
if (d2 == 'S' && y1 - y2 == w * 2)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'E' && x2 + w == x1 && y1 - w == y2)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'W' && x2 - w == x1 && y1 - w == y2)
{
vtp.push_back ({w, i, j});
}
}
if (d1 == 'S')
{
if (d2 == 'N' && y2 - y1 == w * 2)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'E' && x2 + w == x1 && y1 + w == y2)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'W' && x2 - w == x1 && y1 + w == y2)
{
vtp.push_back ({w, i, j});
}
}
if (d1 == 'E')
{
if (d2 == 'W' && x2 - x1 == w * 2)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'N' && x1 + w == x2 && y2 - w == y1)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'S' && x1 + w == x2 && y2 + w == y1)
{
vtp.push_back ({w, i, j});
}
}
if (d1 == 'W')
{
if (d2 == 'E' && x1 - x2 == w * 2)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'N' && x1 - w == x2 && y2 - w == y1)
{
vtp.push_back ({w, i, j});
}
if (d2 == 'S' && x1 - w == x2 && y2 + w == y1)
{
vtp.push_back ({w, i, j});
}
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i)
{
cin >> ship[i].first >> ship[i].second >> dir[i];
}
for (int i = 1; i < n; ++i)
{
for (int j = i + 1; j <= n; ++j)
{
collide (i, j);
}
}
sort (vtp.begin(), vtp.end());
for (auto [w, u, v]: vtp)
{
if (!sank[u] && !sank[v])
{
sank[u] = sank[v] = w;
}
if (!sank[u] && sank[v] == w)
{
sank[u] = w;
}
if (!sank[v] && sank[u] == w)
{
sank[v] = w;
}
ww = w;
}
ww = 0;
for (int i = 1; i <= n; ++i)
{
if (!sank[i])
{
++ww;
cout << i << "\n";
}
}
if (!ww)
{
cout << 0;
}
}
# | 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... |