이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "islands.h"
#include <cassert>
#include <cstdio>
#include <variant>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;
variant<bool, vector<int>> find_journey(int N, int M, vector<int> U, vector<int> V) {
if (N == 2){
if(count(U.begin(), U.end(), 0) >= 2 && count(U.begin(), U.end(), 1) >= 1){
vector<pair<int, int>> ans(M);
for(int i = 0; i < M; i ++){
ans[i] = {U[i], i};
}
sort(ans.begin(), ans.end());
vector<int> ret = {ans[0].second, ans.back().second, ans[1].second, ans[0].second, ans.back().second, ans[1].second};
return ret;
}
return false;
}
bool N2 = true;
for(int i = 0; i < N; i ++){
N2 &= ((count(U.begin(), U.end(), i) + count(V.begin(), V.end(), i)) == 2 * N - 2);
}
if(N2){
vector<vector<pair<int, int>>> tree(N);
for(int i = 0; i < M; i ++){
tree[U[i]].push_back({V[i], i});
}
for(int i = 0; i < N; i ++){
sort(tree[i].begin(), tree[i].end());
}
vector<int> ret = {tree[0][0].second, tree[1][0].second, tree[0][1].second, tree[2][0].second, tree[1][0].second, tree[0][0].second, tree[2][0].second, tree[0][1].second};
return ret;
}
vector<vector<pair<int,int>>> tree(N);
for(int i = 0; i < M; i ++){
tree[U[i]].push_back({V[i], i});
}
int id = 0;
bool back = false;
for(int i = 0; i < N; i ++){
if(tree[i].size() > 2) back = true;
}
back |= tree[0].size() > 1;
if(!back){
return false;
}
else{
vector<int> ans = {0, 0, 0};
return ans;
}
}
컴파일 시 표준 에러 (stderr) 메시지
islands.cpp: In function 'std::variant<bool, std::vector<int, std::allocator<int> > > find_journey(int, int, std::vector<int>, std::vector<int>)':
islands.cpp:41:9: warning: unused variable 'id' [-Wunused-variable]
41 | int id = 0;
| ^~
# | 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... |