AtCoder Typical Contest 001

Submission #7135504

Source codeソースコード

#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

Task問題 A - 深さ優先探索
User nameユーザ名 das08
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 2783 Byte
File nameファイル名
Exec time実行時間 13 ms
Memory usageメモリ使用量 14592 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - 00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,00_sample_04.txt,00_sample_05.txt
All 100 / 100 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

Test case

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