# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5195 | ainta | 작은 사이클들 (YDX13_smallcycles) | C++98 | 4 ms | 4560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
vector<int>E[100010];
int n, num[100001], cnt, par[100010], res;
bool chk[100010];
void DFS(int a){
num[a] = ++cnt;
int i, x, c = 0;
for (i = 0; i < E[a].size(); i++){
if (num[E[a][i]]){
if (E[a][i] != par[a] && num[E[a][i]] < num[a]){
x = a;
while (x != E[a][i]){
chk[x] = true;
x = par[x];
}
}
continue;
}
par[E[a][i]] = a;
DFS(E[a][i]);
if (!chk[E[a][i]])c++;
}
res += c / 2;
if (c % 2 == 1 && !chk[a]){
chk[a] = true;
res++;
}
}
int main()
{
int i, m, a, b;
scanf("%d%d", &n, &m);
while (m--){
scanf("%d%d", &a, &b);
E[a].push_back(b);
E[b].push_back(a);
}
DFS(1);
printf("%d\n", res);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |