# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963044 | 2024-04-14T11:57:46 Z | Amr | Tropical Garden (IOI11_garden) | C++17 | 1 ms | 348 KB |
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define sz size() #define all(x) (x).begin(),(x).end() const int N = 1002; vector<pair<ll,ll> > v[N]; ll lst[N]; vector<ll> vec; ll vis[N]; void dfs1(ll x) { if(vis[x]) return; vis[x] = 1; vec.push_back(x); for(int i = 0; i < v[x].sz; i++) { dfs1(v[x][i].S); } } void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { for(int i = 0; i < M; i++) { ll x = R[i][0] , y = R[i][1]; v[x].push_back({i,y}); v[y].push_back({i,x}); } for(int i = 0; i < N; i++) sort(all(v[i])); dfs1(P); if(vec.sz==2) { answer(1); return; } ll ans = 0; for(int i = 0; i < vec.sz; i++) { ll x = vec[i],par=N; for(int i = 0; i < N; i++) lst[i] = 0; //cout << x << ": " << endl; ll cnt= G[0]; while(cnt--) { //cout << x << " "; ll y = v[x][lst[x]].S; if(v[x].sz==1) {par = x, x = y; continue;} //lst[par] = 0; lst[x] = (lst[x]+1)%2; par = x; x = y; } if(x==P) ans++; } answer(ans); return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 348 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |