제출 #1080979

#제출 시각아이디문제언어결과실행 시간메모리
1080979antonText editor (CEOI24_editor)C++17
0 / 100
4086 ms378504 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> int N; vector<int> l; vector<pii> get_adj(pii pos){ int line = pos.first; vector<pii> res; if(pos.second == l[line]-1){ if(pos.first<N-1){ res.push_back({line+1, 0}); } } else{ res.push_back({line, pos.second+1}); } if(pos.second == 0){ if(pos.first>0){ res.push_back({line-1, l[line-1]-1}); } } else{ res.push_back({line, pos.second-1}); } if(pos.first<N-1){ res.push_back({pos.first+1, min(l[pos.first+1]-1, pos.second)}); } if(pos.first>0){ res.push_back({pos.first-1, min(l[pos.first-1]-1, pos.second)}); } return res; } int BFS(pii begin, pii dest){ deque<pair<int, pii>> q; q.push_back({0, begin}); set<pii> vis; while(q.size()>0){ auto cur= q.front(); q.pop_front(); if(cur.second == dest){ return cur.first; } else{ for(auto e: get_adj(cur.second)){ if(vis.find(e)==vis.end()){ q.push_back({cur.first+1, e}); vis.insert(e); } } } } } signed main(){ cin>>N; l.resize(N); pii begin; pii dest; cin>>begin.first>>begin.second; cin>>dest.first>>dest.second; begin.first--; begin.second--; dest.first--; dest.second--; for(int i = 0; i<N; i++){ cin>>l[i]; l[i]++; } cout<<BFS(begin, dest)<<endl; }

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

Main.cpp: In function 'long long int BFS(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
Main.cpp:39:27: warning: control reaches end of non-void function [-Wreturn-type]
   39 |     deque<pair<int, pii>> q;
      |                           ^
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...