제출 #123344

#제출 시각아이디문제언어결과실행 시간메모리
123344baluteshih열대 식물원 (Tropical Garden) (IOI11_garden)C++14
49 / 100
5053 ms4856 KiB
#include "garden.h" #include "gardenlib.h" #include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define ET cout << "\n" #define MEM(i,j) memset(i,j,sizeof i) #define F first #define S second #define MP make_pair #define ALL(v) v.begin(),v.end() #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; vector<int> Gr[150005]; int to[300005]; void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) { for(int i=0;i<M;++i) Gr[R[i][0]].pb(R[i][1]),Gr[R[i][1]].pb(R[i][0]); for(int i=0;i<N;++i) { if(i==Gr[Gr[i][0]][0]) to[i<<1]=Gr[i][0]<<1|1; else to[i<<1]=Gr[i][0]<<1; if(Gr[i].size()>1) if(i==Gr[Gr[i][1]][0]) to[i<<1|1]=Gr[i][1]<<1|1; else to[i<<1|1]=Gr[i][1]<<1; else if(i==Gr[Gr[i][0]][0]) to[i<<1|1]=Gr[i][0]<<1|1; else to[i<<1|1]=Gr[i][0]<<1; } for(int i=0;i<Q;++i) { int ans=0; for(int j=0;j<N;++j) { int nw=j<<1; for(int k=0;k<G[i];++k) nw=to[nw]; if((nw>>1)==P) ++ans; } answer(ans); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...