# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963047 | 2024-04-14T12:13:52 Z | Amr | Tropical Garden (IOI11_garden) | C++17 | 7 ms | 5212 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; //ACAcout << 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;} if(y!=par) lst[par] = 0; else y = v[x][(lst[x]+1)%2].S,lst[par]=0; lst[x] = (lst[x]+1)%2; par = x; x = y; } //cout << endl; if(x==P) ans++; } answer(ans); return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 2 ms | 600 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 856 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 1004 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 2 ms | 600 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 856 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 1004 KB | Output is correct |
10 | Correct | 2 ms | 344 KB | Output is correct |
11 | Runtime error | 7 ms | 5212 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 1 ms | 344 KB | Output is correct |
3 | Correct | 2 ms | 600 KB | Output is correct |
4 | Correct | 1 ms | 348 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1 ms | 856 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 348 KB | Output is correct |
9 | Correct | 3 ms | 1004 KB | Output is correct |
10 | Correct | 2 ms | 344 KB | Output is correct |
11 | Runtime error | 7 ms | 5212 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |