Submission #7044313
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[4] = {1,-1,0,0}; vi dy[4] = {0,0,1,-1}; vii 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 | 917 Byte |
Status | CE |
Compile Error
./Main.cpp:13:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested vi dx[4] = {1,-1,0,0}; ^ ./Main.cpp:13:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested ./Main.cpp:13:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested ./Main.cpp:13:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested ./Main.cpp:14:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested vi dy[4] = {0,0,1,-1}; ^ ./Main.cpp:14:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested ./Main.cpp:14:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested ./Main.cpp:14:21: error: conversion from ‘int’ to non-scalar type ‘vi {aka std::vector<int>}’ requested ./Main.cpp: In function ‘int main()’: ./Main.cpp:18:26: error: no match for ‘operator>>’ (operan...