# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
269211 | 2020-08-17T05:44:13 Z | Autoratch | 열대 식물원 (Tropical Garden) (IOI11_garden) | C++14 | 16 ms | 15044 KB |
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> using namespace std; const int N = 2e5; vector<pair<int,int> > adj[N]; pair<int,int> ed[N << 1]; vector<int> res[N << 1]; queue<tuple<int,int,int,int> > q; void bfs() { while(!q.empty()) { auto [u,p,id,cnt] = q.front(); q.pop(); // if(res[id].size()>=40) continue; if(cnt>100) continue; if(u!=p and p==adj[u][0].second) res[id].push_back(cnt); if(id==-1 or adj[u][0].second==p) { for(auto [w,v] : adj[u]) if(v!=p or adj[u].size()==1) q.push({v,u,w,cnt+1}); } else if(adj[u][1].second==p) { auto [w,v] = adj[u][0]; if(v!=p) q.push({v,u,w,cnt+1}); } } } void dfs(int u,int p,int id,int cnt) { q.push({u,p,id,cnt}); bfs(); return; if(res[id].size()>=5) return; res[id].push_back(cnt); if(id==-1 or adj[u][0].second==p) { for(auto [w,v] : adj[u]) if(v!=p or adj[u].size()==1) dfs(v,u,w,cnt+1); } else if(adj[u][1].second==p) { auto [w,v] = adj[u][0]; if(v!=p) dfs(v,u,w,cnt+1); } } void count_routes(int n,int m,int p,int r[][2],int q,int g[]) { for(int i = 0,j = 0;i < m;i++) { int a = r[i][0],b = r[i][1]; ed[j] = {a,b}; adj[a].push_back({j++,b}); ed[j] = {b,a}; adj[b].push_back({j++,a}); } dfs(p,p,-1,0); for(int i = 0;i < q;i++) { int ans = 0; for(int j = 0;j < m*2;j++) for(int x : res[j]) if(x==g[i]) ans++; /* { if(res[j].size()>0 and res[j][0]==g[i]) ans++; else if(res[j].size()>2 and (g[i]-res[j][1])%(res[j][2]-res[j][1])==0) ans++; } */ answer(ans); for(int j = 0;j < m*2;j++) { for(int k = 1;k+2 < res[j].size();k++) assert(res[j][k+1]-res[j][k]==res[j][k+2]-res[j][k+1] and res[j][k+1]!=res[j][k]); } } return; for(int i = 0;i < m*2;i++) { cout << ed[i].first << ' ' << ed[i].second << endl; for(int x : res[i]) cout << x << ' ' ; cout << endl; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 11 ms | 14592 KB | Output is correct |
3 | Correct | 11 ms | 14592 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 12 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14592 KB | Output is correct |
7 | Correct | 10 ms | 14464 KB | Output is correct |
8 | Correct | 14 ms | 14592 KB | Output is correct |
9 | Correct | 16 ms | 15044 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 11 ms | 14592 KB | Output is correct |
3 | Correct | 11 ms | 14592 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 12 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14592 KB | Output is correct |
7 | Correct | 10 ms | 14464 KB | Output is correct |
8 | Correct | 14 ms | 14592 KB | Output is correct |
9 | Correct | 16 ms | 15044 KB | Output is correct |
10 | Incorrect | 10 ms | 14464 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 14464 KB | Output is correct |
2 | Correct | 11 ms | 14592 KB | Output is correct |
3 | Correct | 11 ms | 14592 KB | Output is correct |
4 | Correct | 10 ms | 14464 KB | Output is correct |
5 | Correct | 12 ms | 14464 KB | Output is correct |
6 | Correct | 11 ms | 14592 KB | Output is correct |
7 | Correct | 10 ms | 14464 KB | Output is correct |
8 | Correct | 14 ms | 14592 KB | Output is correct |
9 | Correct | 16 ms | 15044 KB | Output is correct |
10 | Incorrect | 10 ms | 14464 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |