# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1162946 | spongb | Tropical Garden (IOI11_garden) | C++20 | 1679 ms | 29800 KiB |
#include<bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
int cycle_len;
vector<int> succ, color, dist, dist1, dist2;
vector<bool> visited;
vector<vector<int>> revGraph;
int find_cycle_length(int node){
int slow = node;
int fast = node;
do {
if(succ[fast] == -1 || succ[succ[fast]] == -1) return 1e9+1;
slow = succ[slow];
fast = succ[succ[fast]];
} while(slow != fast);
//cycle exists
//now check if P is part of cycle
bool inCycle = false;
int temp = slow;
int len = 0;
do {
if (temp == node) inCycle = true;
len++;
temp = succ[temp];
} while (temp != slow);
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |