이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
using namespace std;
int collision(int x1, int y1, char c1, int x2, int y2, char c2) {
if(c1 == c2) return -1;
if((c2 == 'N' && c1 == 'S') or (c2 == 'W' && c1 == 'E')) {
swap(x1, x2);
swap(y1, y2);
swap(c1, c2);
}
if(c1 == 'N' && c2 == 'S') {
if(x1 != x2 or y1 < y2) return -1;
return y1 - y2;
}
if(c1 == 'W' && c2 == 'E') {
if(y1 != y2 or x1 < x2) return -1;
return x1 - x2;
}
int X = abs(x1 - x2), Y = abs(y1 - y2);
if(X != Y) return -1;
if(c1 == 'E' or c1 == 'W') {
swap(x1, x2);
swap(y1, y2);
swap(c1, c2);
}
if(c1 == 'N' && (y1 - Y) != y2) return -1;
else if(c1 == 'S' && (y1 + Y) != y2) return -1;
if(c2 == 'W' && (x2 - X) != x1) return -1;
else if(c2 == 'E' && (x2 + X) != x1) return -1;
return X;
}
bool cmp(pair<int,pair<int,int>>x, pair<int,pair<int,int>>y) {
return x.first < y.first;
}
void solve() {
int n;
cin >> n;
int x[n], y[n];
char c[n];
for(int i=0; i<n; ++i) {
cin >> x[i] >> y[i] >> c[i];
}
vector<pair<int,pair<int,int>>>v;
for(int i=0; i<n; ++i) {
for(int j = i+1; j<n; ++j) {
int X = collision(x[i], y[i], c[i], x[j], y[j], c[j]);
if(X != -1) v.push_back({X, {i, j}});
}
}
sort(v.begin(), v.end(), cmp);
vector<int>taken(n, -1);
for(int i=0; i<v.size(); ++i) {
int first = v[i].second.first, second = v[i].second.second;
if((taken[first] == v[i].first or taken[first] == -1) && (taken[second] == v[i].first or taken[second] == -1)) {
taken[first] = v[i].first;
taken[second] = v[i].first;
}
}
for(int i=0; i<n; ++i) {
if(taken[i] == -1) cout << i+1 << endl;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1;
while(t--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
Main.cpp: In function 'void solve()':
Main.cpp:56:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, std::pair<long long int, long long int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for(int i=0; i<v.size(); ++i) {
| ~^~~~~~~~~
# | 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... |