이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;
vector<pii> moves = {{-1, -1}, {-1, 0}, {-1, 1}, {0, -1}, {0, 1}, {1, -1}, {1, 0}, {1, 1}};
map<pii, int> ind;
set<pii> there;
set<pii> visited;
void dfs(pii a) {
visited.insert(a);
for (pii b : moves){
pii neww(a.first + b.first, a.second + b.second);
if (!visited.count(neww) and there.count(neww))
dfs(neww);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
int t;
cin >> n >> t;
for (int i = 0; i < n; i++) {
pii a;
cin >> a.first >> a.second;
there.insert(a);
ind[a] = i + 1;
}
dfs(*there.begin());
if (visited.size() != n) {
cout <<"NO\n";
return 0;
}
cout << "YES\n";
queue<pii> q;
q.push(*there.begin());
visited.clear();
while (!q.empty()) {
pii a = q.front(); q.pop();
cout << ind[a] << "\n";
visited.insert(a);
for (pii b : moves) {
pii neww(a.first + b.first, a.second + b.second);
if (!visited.count(neww) and there.count(neww))
q.push(neww);
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
skyscrapers.cpp: In function 'int main()':
skyscrapers.cpp:39:24: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<int, int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
39 | if (visited.size() != 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... |