# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
766866 | danikoynov | Simurgh (IOI17_simurgh) | C++14 | 74 ms | 1576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "simurgh.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 510;
struct disjoint_set_union
{
int par[maxn];
disjoint_set_union(){};
disjoint_set_union(int n)
{
for (int i = 0; i < n; i ++)
par[i] = i;
}
int find_leader(int v)
{
if (v == par[v])
return v;
return (par[v] = find_leader(par[v]));
}
bool is_connected(int v, int u)
{
return find_leader(v) == find_leader(u);
}
void unite(int v, int u)
{
v = find_leader(v);
u = find_leader(u);
if (v == u)
return;
par[v] = u;
}
};
int used[maxn * maxn];
vector<int> find_roads(int n, vector<int> u, vector<int> v) {
vector < int > gold;
int m = u.size();
while(gold.size() < n - 1)
{
disjoint_set_union dsu(n);
int cp = n;
vector < int > res;
for (int edge : gold)
{
dsu.unite(u[edge], v[edge]);
cp --;
res.push_back(edge);
}
for (int j = 0; j < m && cp > 2; j ++)
{
if (!dsu.is_connected(u[j], v[j]))
{
dsu.unite(u[j], v[j]);
cp --;
res.push_back(j);
}
}
vector < pair < int, int > > pot;
for (int i = 0; i < m; i ++)
{
if (!dsu.is_connected(u[i], v[i]))
pot.push_back({i, 0});
}
int mx = -1, rd = -1;
for (int i = 0; i < pot.size(); i ++)
{
res.push_back(pot[i].first);
pot[i].second = count_common_roads(res);
if (pot[i].second > mx)
{
mx = pot[i].second;
}
res.pop_back();
}
for (int i = 0; i < pot.size(); i ++)
{
if (pot[i].second == mx)
gold.push_back(pot[i].first);
}
}
return gold;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |