# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
439889 | dutch | 열대 식물원 (Tropical Garden) (IOI11_garden) | C++17 | 2834 ms | 27408 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 <bits/stdc++.h>
using namespace std;
#include "garden.h"
#include "gardenlib.h"
const int LIM = 1.5e5, INF = 2e9;
int n, cnt[LIM], c, d[2][LIM*2], p, r[2] = {INF, INF};
vector<int> g[LIM*2];
void dfs(int u, int dist){
if(!d[c][u]) return void(r[c] = dist);
d[c][u] = dist;
for(int v : g[u]) dfs(v, dist + 1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
n = N, p = P;
for(int i=0; i<M; ++i){
for(int j=0; j<2; ++j){
int u = R[i][j], v = R[i][!j];
if(cnt[u] == 0) g[v + (!cnt[v])*n].push_back(u);
if(cnt[u] == 1) g[v + (!cnt[v])*n].push_back(u+n);
}
for(int j=0; j<2; ++j) ++cnt[R[i][j]];
}
for(int u=0; u<n; ++u) if(cnt[u] < 2){
for(int v : g[u+n]) g[u].push_back(v);
g[u+n].clear();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |