제출 #523001

#제출 시각아이디문제언어결과실행 시간메모리
523001DeepessonJakarta Skyscrapers (APIO15_skyscraper)C++17
57 / 100
1100 ms59960 KiB
#include <bits/stdc++.h> #define MAX 31000 typedef std::pair<int,int> pii; ///Skyscraper .first, level .second std::map<pii,std::vector<pii>> con; typedef std::pair<pii,int> ppi; int main() { std::map<pii,bool> visitou; int N,M; std::cin>>N>>M; bool cachorro[N]={}; std::vector<int> poder[N]; int ha[M],hb[M]; for(int i=0;i!=M;++i){ int a,b; std::cin>>a>>b; cachorro[a]=true; poder[a].push_back(b); ha[i]=a; hb[i]=b; } pii origem = {ha[0],hb[0]}; pii fim = {ha[1],hb[1]}; std::deque<ppi> deque; deque.push_back({origem,0}); while(deque.size()){ auto ___ = deque.front(); auto __ = ___.first; deque.pop_front(); if(__.first<0||__.first>=N)continue; if(visitou.find(__)!=visitou.end())continue; visitou[__]=true; if(__==fim){ std::cout<<___.second<<"\n"; return 0; } deque.push_back({{__.first+__.second,__.second},___.second+1}); deque.push_back({{__.first-__.second,__.second},___.second+1}); if(cachorro[__.first]){ cachorro[__.first]=false; for(auto&x:poder[__.first]) deque.push_front({{__.first,x},___.second}); } } std::cout<<"-1\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...