Submission #7044304
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) using vi=vector<int>; using vii=vector<vi>; using vc=vector<char>; struct Point{ int x,y; }; vc c[50][50]; vi dx={1,-1,0,0}; vi dy={0,0,1,-1}; vi dist[50][50]; int main(){ rep(i,50) rep(j,50) cin>>dist[i][j]; int r,c; cin>>r>>c; int sx,sy,gx,gy; cin>>sy>>sx; cin>>gy>>gx; sy--;sx--; gy--;gx--; rep(i,r) rep(j,c) cin>>c[i][j]; queue<Point> q; q.push({sx,sy}); dist[sy][sx] = 0; while(!q.empty()){ Point now = q.front(); q.pop(); rep(i,4){ Point next = {now.x+dx[i],now.y+dy[i]}; if( c[next.y][next.x] == '#' ) continue; if( dist[next.y][next.x] != -1 ) continue; dist[next.y][next.x] = dist[now.y][now.x] + 1; Q.push({next.x,next.y}); } } cout << dist[gy][gx] << endl; }
Submission Info
Submission Time | |
---|---|
Task | A - 幅優先探索 |
User | fujimura |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 906 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:18:26: error: no match for ‘operator>>’ (operand types are ‘std::istream {aka std::basic_istream<char>}’ and ‘vi {aka std::vector<int>}’) rep(i,50) rep(j,50) cin>>dist[i][j]; ^ In file included from /usr/include/c++/5/sstream:38:0, from /usr/include/c++/5/complex:45, from /usr/include/c++/5/ccomplex:38, from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52, from ./Main.cpp:1: /usr/include/c++/5/istream:120:7: note: candidate: std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::basic_istream<_CharT, _Traits>::__istream_type& (*)(std::basic_istream<_CharT, _Traits>::__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>] operator>>(__istream_type& (*__pf)(__istream_type&)) ^ /usr/include/c++/5/istream...