이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<pair<int, int>>> adj;
vector<int> U, V;
set<vector<int>> sv;
vector<int> res;
void check_tree(vector<int> edges, set<int> nodes)
{
if (nodes.size() == N)
{
sort(edges.begin(), edges.end());
if (sv.count(edges))
return;
sv.insert(edges);
int common = count_common_roads(edges);
if (common == N - 1)
res = edges;
return;
}
for (auto node : nodes)
{
for (auto edge : adj[node])
{
if (nodes.count(edge.first))
continue;
nodes.insert(edge.first);
edges.push_back(edge.second);
check_tree(edges, nodes);
nodes.erase(edge.first);
edges.pop_back();
}
}
}
vector<int> find_roads(int n, vector<int> u, vector<int> v)
{
N = n; M = u.size();;
u = U; v = V;
adj = vector<vector<pair<int, int>>>(N);
sv.clear();
for (int i = 0; i < M; i++)
{
adj[u[i]].push_back({v[i], i});
adj[v[i]].push_back({u[i], i});
}
check_tree({}, {0});
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
simurgh.cpp: In function 'void check_tree(std::vector<int>, std::set<int>)':
simurgh.cpp:15:19: warning: comparison of integer expressions of different signedness: 'std::set<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
15 | if (nodes.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... |