| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 869387 | vjudge1 | Commuter Pass (JOI18_commuter_pass) | C++17 | 1 ms | 2136 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdint>
using namespace std;
constexpr int64_t maxn = 100000;
int64_t n, m, c;
int64_t parent[maxn + 1];
int64_t GetSet(int64_t v)
{
if (parent[v] == v)
return v;
return parent[v] = GetSet(parent[v]);
}
void Union(int64_t v, int64_t u)
{
if (v != u)
c--;
parent[v] = u;
}
int main()
{
cin >> n >> m;
c = n;
for (int64_t i = 1; i <= n; i++)
parent[i] = i;
for (int64_t i = 1; i <= m; i++)
{
int64_t v, u;
cin >> v >> u;
Union(GetSet(v), GetSet(u));
}
cout << m - n + c << '\n';
return 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... | ||||
