제출 #398710

#제출 시각아이디문제언어결과실행 시간메모리
398710Pichon5열대 식물원 (Tropical Garden) (IOI11_garden)C++17
49 / 100
5071 ms1868 KiB
#include<bits/stdc++.h> #include <iostream> #include "garden.h" #include "gardenlib.h" #define lcm(a,b) (a/__gcd(a,b))*b #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define ll long long int #define vi vector<int> #define vll vector<ll> #define pb push_back #define F first #define S second #define mp make_pair using namespace std; void count_routes(int N, int M, int P, int R[][2], int Q, int g[]) { vi G[N+1]; for(int i=0;i<M;i++){ int a=R[i][0],b=R[i][1]; if(G[a].size()<2){ G[a].pb(b); } if(G[b].size()<2){ G[b].pb(a); } } int k=g[0]; int res=0; for(int i=0;i<N;i++){ int curr=i; int p=-1; for(int l=0;l<k;l++){ //cout<<"nodo "<<curr<<" "<<p<<endl; if(G[curr].size()==2){ if(G[curr][0]!=p){ p=curr; curr=G[curr][0]; }else{ p=curr; curr=G[curr][1]; } continue; } if(G[curr].size()==1){ p=curr; curr=G[curr][0]; } } //cout<<"final "<<curr<<" "<<p<<endl; //cout<<i<<" "<<curr<<endl; if(curr==P)res++; } answer(res); } /* 5 5 2 1 0 1 2 3 2 1 3 4 2 1 3 1 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...