이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "fun.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
/*
int H = hoursRequired(0, N - 1);
int A = attractionsBehind(0, N - 1);
return std::vector<int>(N);
*/
const int mxn = 550;
vector<int> tree[mxn];
int dist[mxn];
bitset<mxn> del;
vector<int> ans;
void dfs(int now,int par){
for(auto nxt:tree[now]){
if(nxt == par||del[nxt])continue;
dist[nxt] = dist[now]+1;
dfs(nxt,now);
}
return;
}
std::vector<int> createFunTour(int N, int Q) {
for(int i = 0;i<N;i++){
for(int j = i+1;j<N;j++){
if(hoursRequired(i,j) == 1){
tree[i].push_back(j);
tree[j].push_back(i);
}
}
}
dfs(1,1);
int now = max_element(dist,dist+N)-dist;
ans.push_back(now);
while(ans.size()<N){
memset(dist,-1,sizeof(dist));
dist[now] = 0;
dfs(now,now);
del[now] = true;
now = max_element(dist,dist+N)-dist;
ans.push_back(now);
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
fun.cpp: In function 'std::vector<int> createFunTour(int, int)':
fun.cpp:40:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | while(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... |