Contest Duration: ~ (local time) (90 minutes) Back to Home

Submission #7135504

Source Code Expand

Copy
```#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
std::cout << "";
for (auto it = vec.begin(); it != vec.end(); ++it)
{
std::cout << *it << " ";
}
cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
std::cout << "";
for (auto it = vec.begin(); it != vec.end(); ++it)
{
std::cout << *it << " ";
}
cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
std::cout << "";
for (auto it = vec.begin(); it != vec.end(); ++it)
{
std::cout << *it << " ";
}
cout << '\n';
}

Int gcd(Int a, Int b)
{
return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
return a / gcd(a, b) * b;
//a*bは64bit integer overflow
}

bool integer(double num)
{
return floor(num) == num;
}

Int fact(int num)
{
if (num == 0)
return 1;
else
return num * fact(num - 1);
}

char maps[502][502];
bool visit[502][502];
int h, w;
void dfs(int hh,int ww){
if(visit[hh][ww])return;
if(maps[hh][ww]=='#'||hh<0||ww<0||hh>=h||ww>=w)return;
visit[hh][ww] = true;
dfs(hh-1, ww);
dfs(hh, ww-1);
dfs(hh+1, ww);
dfs(hh, ww+1);
}

int main(){
IOS;
cin >> h >>w;
int sw, sh,gw, gh;
string s;
for (int i = 0; i < h;i++){
cin >> s;
for (int j = 0; j < w;j++){
if(s[j]=='s'){
sw = j;
sh = i;
}
if(s[j]=='g'){
gw = j;
gh = i;
}
maps[i][j]=s[j];
}
}
dfs(sh, sw);
if(visit[gh][gw])
cout << "Yes";
else
cout << "No";

cout << endl;
return 0;
}

/*
テレビも無ェ ラジオも無ェ

ピアノも無ェ バーも無ェ

バスは一日一度来る

*/
```

#### Submission Info

Submission Time 2019-08-25 18:25:09+0900 A - 深さ優先探索 das08 C++14 (GCC 5.4.1) 100 2783 Byte AC 13 ms 14592 KB

#### Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
 AC × 5
 AC × 83
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt
All 00_min_01.txt, 00_min_02.txt, 00_min_03.txt, 00_min_04.txt, 00_min_05.txt, 00_min_06.txt, 00_min_07.txt, 00_min_08.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_rndhard_00.txt, 02_rndhard_01.txt, 02_rndhard_02.txt, 02_rndhard_03.txt, 02_rndhard_04.txt, 02_rndhard_05.txt, 02_rndhard_06.txt, 02_rndhard_07.txt, 02_rndhard_08.txt, 02_rndhard_09.txt, 02_rndhard_10.txt, 02_rndhard_11.txt, 02_rndhard_12.txt, 02_rndhard_13.txt, 02_rndhard_14.txt, 02_rndhard_15.txt, 02_rndhard_16.txt, 02_rndhard_17.txt, 02_rndhard_18.txt, 02_rndhard_19.txt, 02_rndhard_20.txt, 02_rndhard_21.txt, 02_rndhard_22.txt, 02_rndhard_23.txt, 02_rndhard_24.txt, 02_rndhard_25.txt, 02_rndhard_26.txt, 02_rndhard_27.txt, 02_rndhard_28.txt, 02_rndhard_29.txt, 02_rndhard_30.txt, 02_rndhard_31.txt, 02_rndhard_32.txt, 02_rndhard_33.txt, 02_rndhard_34.txt, 02_rndhard_35.txt, 02_rndhard_36.txt, 02_rndhard_37.txt, 02_rndhard_38.txt, 02_rndhard_39.txt, 03_rndhardsmall_00.txt, 03_rndhardsmall_01.txt, 03_rndhardsmall_02.txt, 03_rndhardsmall_03.txt, 03_rndhardsmall_04.txt, 03_rndhardsmall_05.txt, 03_rndhardsmall_06.txt, 03_rndhardsmall_07.txt, 03_rndhardsmall_08.txt, 03_rndhardsmall_09.txt
Case Name Status Exec Time Memory
00_min_01.txt 1 ms 256 KB
00_min_02.txt 1 ms 256 KB
00_min_03.txt 1 ms 256 KB
00_min_04.txt 1 ms 256 KB
00_min_05.txt 1 ms 256 KB
00_min_06.txt 1 ms 256 KB
00_min_07.txt 1 ms 256 KB
00_min_08.txt 1 ms 256 KB
00_sample_01.txt 1 ms 256 KB
00_sample_02.txt 1 ms 256 KB
00_sample_03.txt 1 ms 256 KB
00_sample_04.txt 1 ms 256 KB
00_sample_05.txt 1 ms 256 KB
01_rnd_00.txt 2 ms 512 KB
01_rnd_01.txt 12 ms 11520 KB
01_rnd_02.txt 8 ms 3968 KB
01_rnd_03.txt 13 ms 14592 KB
01_rnd_04.txt 11 ms 10752 KB
01_rnd_05.txt 2 ms 512 KB
01_rnd_06.txt 8 ms 3200 KB
01_rnd_07.txt 9 ms 4992 KB
01_rnd_08.txt 2 ms 512 KB
01_rnd_09.txt 2 ms 512 KB
01_rnd_10.txt 5 ms 1152 KB
01_rnd_11.txt 2 ms 512 KB
01_rnd_12.txt 10 ms 8320 KB
01_rnd_13.txt 10 ms 7936 KB
01_rnd_14.txt 2 ms 512 KB
01_rnd_15.txt 7 ms 2304 KB
01_rnd_16.txt 2 ms 512 KB
01_rnd_17.txt 6 ms 1792 KB
01_rnd_18.txt 2 ms 512 KB
01_rnd_19.txt 12 ms 13952 KB
02_rndhard_00.txt 2 ms 512 KB
02_rndhard_01.txt 2 ms 512 KB
02_rndhard_02.txt 3 ms 768 KB
02_rndhard_03.txt 3 ms 768 KB
02_rndhard_04.txt 2 ms 512 KB
02_rndhard_05.txt 2 ms 512 KB
02_rndhard_06.txt 2 ms 512 KB
02_rndhard_07.txt 2 ms 512 KB
02_rndhard_08.txt 2 ms 640 KB
02_rndhard_09.txt 2 ms 640 KB
02_rndhard_10.txt 2 ms 640 KB
02_rndhard_11.txt 2 ms 640 KB
02_rndhard_12.txt 2 ms 640 KB
02_rndhard_13.txt 2 ms 640 KB
02_rndhard_14.txt 2 ms 640 KB
02_rndhard_15.txt 2 ms 640 KB
02_rndhard_16.txt 2 ms 512 KB
02_rndhard_17.txt 2 ms 512 KB
02_rndhard_18.txt 2 ms 512 KB
02_rndhard_19.txt 2 ms 512 KB
02_rndhard_20.txt 2 ms 512 KB
02_rndhard_21.txt 2 ms 512 KB
02_rndhard_22.txt 2 ms 640 KB
02_rndhard_23.txt 2 ms 640 KB
02_rndhard_24.txt 2 ms 512 KB
02_rndhard_25.txt 2 ms 512 KB
02_rndhard_26.txt 2 ms 512 KB
02_rndhard_27.txt 2 ms 512 KB
02_rndhard_28.txt 2 ms 512 KB
02_rndhard_29.txt 2 ms 512 KB
02_rndhard_30.txt 2 ms 512 KB
02_rndhard_31.txt 2 ms 512 KB
02_rndhard_32.txt 2 ms 640 KB
02_rndhard_33.txt 2 ms 640 KB
02_rndhard_34.txt 2 ms 512 KB
02_rndhard_35.txt 2 ms 512 KB
02_rndhard_36.txt 2 ms 512 KB
02_rndhard_37.txt 2 ms 512 KB
02_rndhard_38.txt 2 ms 512 KB
02_rndhard_39.txt 2 ms 512 KB
03_rndhardsmall_00.txt 1 ms 256 KB
03_rndhardsmall_01.txt 1 ms 256 KB
03_rndhardsmall_02.txt 1 ms 256 KB
03_rndhardsmall_03.txt 1 ms 256 KB
03_rndhardsmall_04.txt 1 ms 256 KB
03_rndhardsmall_05.txt 1 ms 256 KB
03_rndhardsmall_06.txt 1 ms 256 KB
03_rndhardsmall_07.txt 1 ms 256 KB
03_rndhardsmall_08.txt 1 ms 256 KB
03_rndhardsmall_09.txt 1 ms 256 KB