# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
676047 | Tangirkul | Cijanobakterije (COCI21_cijanobakterije) | C++17 | 27 ms | 13196 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define sz size
#define Junanna ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
const ll K = 32;
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;
const ll N = (1e5 + 125);
ll n, m;
vector <ll> g[N];
bool used[N];
ll dfs (ll v, ll st)
{
used[v] = 1;
ll ans1 = 0;
for (ll i = 0; i < g[v].sz (); i++)
{
ll to = g[v][i];
if (!used[to])
{
ans1 = max (ans1, dfs (to, st));
}
}
return ans1 + 1;
}
void ma1n ()
{
cin >> n >> m;
ll ans = 0;
for (ll i = 1; i <= m; i++)
{
ll x, y;
cin >> x >> y;
g[x].pb (y);
g[y].pb (x);
}
for (ll i = 1; i <= n; i++)
{
if (!used[i] && g[i].sz () == 1)
{
ans += dfs (i, i);
}
else
{
if (g[i].sz () == 0)
{
ans++;
}
}
}
cout << ans;
}
int main ()
{
Junanna;
ll t = 1;
while (t--)
{
ma1n ();
}
return 0;
}
컴파일 시 표준 에러 (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... |