# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
16431 | rhdmstjr | Cactus? Not cactus? (kriii1_C) | C++98 | 0 ms | 1580 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 <cstdio>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
int N,M;
int visited_cnt;
map<pair<int,int>, int> visited_edge;
void cnt_cycle(vector<vector<int> > &graph, int &cnt, vector<int> &visited, int pre, int now){
//printf("cycle now == %d, pre == %d, visited_cnt = %d\n", now, pre, visited_cnt);
if(visited_cnt > M) return ;
visited_cnt++; // count edge
visited_edge[pair<int,int>(min(pre,now), max(pre,now))] = 1;
if(visited[now] != 0){
// printf("now == %d\n", now);
cnt++;
return;
}
visited[now] = 1;
for(int i=0;i<graph[now].size();i++){
int to = graph[now][i];
if( pre != to && visited_edge[pair<int,int>(min(now, to), max(now, to))] == 0 )
cnt_cycle(graph, cnt, visited, now, to);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |