이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <random>
#include <algorithm>
#include <bitset>
#include <chrono>
#include <cmath>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((x).size())
typedef long long ll;
using ull = unsigned long long;
using namespace std;
mt19937 rnd(348502);
ll mod1 = 998244353;
ll mod = 1e9 + 7;
const ll N = 200007;
int herav(pair<pair<int, int>, int> a, int x, int y)
{
if (a.second == 'N')
{
if (x != a.first.first || y > a.first.second)
return -1;
return abs(y - a.first.second);
}
if (a.second == 'S')
{
if (x != a.first.first || y < a.first.second)
return -1;
return abs(y - a.first.second);
}
if (a.second == 'E')
{
if (y != a.first.second || x < a.first.first)
return -1;
return abs(x - a.first.first);
}
if (a.second == 'W')
{
if (y != a.first.second || x > a.first.first)
return -1;
return abs(x - a.first.first);
}
}
int hatvel(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b)
{
if (a.first.first == b.first.first)
{
if (herav(a, a.first.first, (a.first.second + b.first.second) / 2) != -1 && herav(b, a.first.first, (a.first.second + b.first.second) / 2) != -1)
{
return herav(a, a.first.first, (a.first.second + b.first.second) / 2);
}
return -1;
}
if (a.first.second == b.first.second)
{
if (herav(a, (a.first.first + b.first.first)/2, a.first.second) != -1 && herav(b, (a.first.first + b.first.first) / 2, a.first.second) != -1)
{
return herav(a, (a.first.first + b.first.first) / 2, a.first.second);
}
return -1;
}
if (herav(a, a.first.first, b.first.second) != -1 && herav(b, a.first.first, b.first.second) == herav(a, a.first.first, b.first.second))
{
return herav(a, a.first.first, b.first.second);
}
if (herav(a, b.first.first, a.first.second) != -1 && herav(b, b.first.first, a.first.second) == herav(a, b.first.first, a.first.second))
{
return herav(a, b.first.first, a.first.second);
}
return -1;
}
int paher[N];
void solve()
{
int n, i, j, x, y;
cin >> n;
char c;
vector<pair<pair<int, int>, int>> v;
for ( i = 0; i < n; i++)
{
cin >> x >> y >> c;
v.push_back({ {x, y}, c });
}
vector<pair<int, pair<int ,int>>> hatumner;
for ( i = 0; i < v.size(); i++)
{
for ( j = i + 1; j < v.size(); j++)
{
if (hatvel(v[i], v[j]) != -1)
{
hatumner.push_back({ hatvel(v[i], v[j]), {i, j} });
}
}
}
sort(all(hatumner));
for ( i = 0; i < hatumner.size(); i++)
{
if ((paher[hatumner[i].second.first] == 0 || paher[hatumner[i].second.first] == hatumner[i].first) && (paher[hatumner[i].second.second] == 0 || paher[hatumner[i].second.second] == hatumner[i].first))
{
paher[hatumner[i].second.first] = hatumner[i].first;
paher[hatumner[i].second.second] = hatumner[i].first;
}
}
for ( i = 0; i < n; i++)
{
if (!paher[i])
cout << i + 1 << '\n';
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
ll tt = 1;
//cin >> tt;
while (tt--) {
solve();
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void solve()':
Main.cpp:102:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
102 | for ( i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
Main.cpp:104:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
104 | for ( j = i + 1; j < v.size(); j++)
| ~~^~~~~~~~~~
Main.cpp:113:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
113 | for ( i = 0; i < hatumner.size(); i++)
| ~~^~~~~~~~~~~~~~~~~
Main.cpp: In function 'int herav(std::pair<std::pair<int, int>, int>, int, int)':
Main.cpp:57:1: warning: control reaches end of non-void function [-Wreturn-type]
57 | }
| ^
# | 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... |