이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fun.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(v) v.begin(), v.end()
#define endl '\n'
#define pl(var) " [" << #var << ": " << (var) << "] "
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "[" << p.first << ", " << p.second << "]"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { cout << "["; for(int i = 0; i < (int)v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) { cin >> p.first; return cin >> p.second; }
std::vector<int> createFunTour(int n, int Q) {
vector<vector<pair<int, int>>> distances(n);
int diameter = 0;
int a, b;
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++) {
int d = hoursRequired(i, j);
if (d > diameter) {
a = i;
b = j;
diameter = d;
}
distances[i].emplace_back(d, j);
distances[j].emplace_back(d, i);
}
}
// cout << pl(a) << pl(b) << endl;
vector<int> ans;
ans.push_back(b);
ans.push_back(a);
int u = a;
// cout << pl(u) << endl;
// cout << pl(distances[u]) << endl;
for (int i = 0; i < n; i++) {
sort(all(distances[i]));
reverse(all(distances[i]));
}
vector<bool> vis(n, 0);
vis[a] = vis[b] = 1;
while (ans.size() != n) {
// cout << pl(u) << endl;
for (auto [d, v] : distances[u]) {
if (!vis[v]) {
ans.push_back(v);
vis[v] = 1;
u = v;
break;
}
}
}
assert(ans.size() == n);
// cout << ans << endl;
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:47:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
47 | while (ans.size() != n) {
| ~~~~~~~~~~~^~~~
In file included from /usr/include/c++/10/cassert:44,
from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
from fun.cpp:2:
fun.cpp:59:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
59 | assert(ans.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... |