제출 #248669

#제출 시각아이디문제언어결과실행 시간메모리
248669MarlovJakarta Skyscrapers (APIO15_skyscraper)C++14
10 / 100
19 ms20608 KiB
/* Code by @marlov */ #include <iostream> #include <fstream> #include <string> #include <sstream> #include <vector> #include <string> #include <cmath> #include <algorithm> #include <iomanip> #include <utility> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <stack> #include <queue> #include <iterator> using namespace std; typedef long long ll; typedef pair<int,int> pi; #define maxV 30000 int N,M; pair<int,int> doge[maxV]; //map< int,map<int,bool> > visited; bool visited[maxV][maxV]; queue<int> cnts[maxV]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>N>>M; int b,p; for(int i=0;i<M;i++){ cin>>doge[i].first>>doge[i].second; cnts[doge[i].first].push(i); } //bfs queue< pair< int,pair<int,int> > > q; q.push(make_pair(0,make_pair(0,doge[0].first))); visited[0][doge[0].first]=true; while(!q.empty()){ int cd=q.front().first; int ci=q.front().second.first; int cl=q.front().second.second; q.pop(); //solution if(ci==1){ cout<<cd<<'\n'; return 0; } while(!cnts[cl].empty()){ q.push(make_pair(cd,make_pair(cnts[cl].front(),cl))); cnts[cl].pop(); } if(cl-doge[ci].second>=0&&visited[ci][cl-doge[ci].second]==false){ q.push(make_pair(cd+1,make_pair(ci,cl-doge[ci].second))); visited[ci][cl-doge[ci].second]=true; } if(cl+doge[ci].second<N&&visited[ci][cl+doge[ci].second]==false){ q.push(make_pair(cd+1,make_pair(ci,cl+doge[ci].second))); visited[ci][cl+doge[ci].second]=true; } } cout<<-1<<'\n'; return 0; } /* stuff you should look for * int overflow, array bounds * special cases (n=1,n=0?) * do smth instead of nothing and stay organized */

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:36:9: warning: unused variable 'b' [-Wunused-variable]
     int b,p;
         ^
skyscraper.cpp:36:11: warning: unused variable 'p' [-Wunused-variable]
     int b,p;
           ^
#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...