# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1133102 | dhruv05 | Tropical Garden (IOI11_garden) | C++20 | 5 ms | 8768 KiB |
#include <bits/stdc++.h>
using namespace std;
int N, M, P;
// trail #, child
set<pair<int, int>> edges[150000];
bool visited[150000][2] = {{false}};
vector<pair<int, int>> distances(150000, {-1, -1});
bool cycle_found = false;
bool P_found = false;
int distancel;
void dfs(int current_node, int parent){
bool optimal = false;
if (parent == -1 || (*edges[current_node].begin()).second != parent || edges[current_node].size() == 1){
// will act the same way as it would if it were the starting position
optimal = true;
if (visited[current_node][1]){
if (distances[current_node].second == -1){
cycle_found = true;
} else {
P_found = true;
distancel += distances[current_node].second;
}
return;
} else {
visited[current_node][1] = true;
}
} else {
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |