Submission #761057


Source Code Expand

#include<iostream>
#include<iomanip>
#include<map>
#include<vector>
#include<string>
#include<stack>
using namespace std;

enum {
	WALL = 0,
	ROAD = 1,
	SEARCHED = 2,
	GOAL = 3
};

int main() {
	int H, W;
	cin >> H >> W;
	int state[502][502] = { 0 };
	stack<pair<int, int>> place;

	for (int i = 1; i <= H; i++) {
		string s;
		cin >> s;
		for (int j = 1; j <= s.length(); j++) {
			switch (s[j]) {
			case 's':
				state[i][j] = SEARCHED;
				place.push(make_pair(i, j));
				break;
			case 'g':
				state[i][j] = GOAL;
				break;
			case '.':
				state[i][j] = ROAD;
				break;
			case '#':
				state[i][j] = WALL;
				break;
			}
		}
	}

	const int xy[5] = { 0, 1, 0, -1, 0 };

	while (1 <= place.size()) {
		auto p = place.top();
		place.pop();
		state[p.second][p.first] = SEARCHED;

		for (int i = 0; i < 4; i++) {
			const int y = p.first + xy[i];
			const int x = p.second + xy[i + 1];
			switch (state[y][x]) {
			case GOAL:
				cout << 'Yes' << endl;
				return 0;
			case ROAD:
				place.push(make_pair(y, x));
				break;
			}
		}
	}
	cout << 'No' << endl;
}

Submission Info

Submission Time
Task A - 深さ優先探索
User eukaryo
Language C++14 (Clang++ 3.4)
Score 0
Code Size 1133 Byte
Status WA
Exec Time 2110 ms
Memory 543312 KB

Compile Error

./Main.cpp:56:13: warning: multi-character character constant [-Wmultichar]
                                cout << 'Yes' << endl;
                                        ^
./Main.cpp:64:10: warning: multi-character character constant [-Wmultichar]
        cout << 'No' << endl;
                ^
2 warnings generated.

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
WA × 5
WA × 28
TLE × 55
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 WA 44 ms 1820 KB
00_min_02.txt WA 27 ms 1812 KB
00_min_03.txt WA 28 ms 1812 KB
00_min_04.txt WA 29 ms 1816 KB
00_min_05.txt WA 28 ms 1812 KB
00_min_06.txt WA 29 ms 1808 KB
00_min_07.txt WA 27 ms 1816 KB
00_min_08.txt WA 27 ms 1812 KB
00_sample_01.txt WA 29 ms 1812 KB
00_sample_02.txt WA 28 ms 1808 KB
00_sample_03.txt WA 27 ms 1808 KB
00_sample_04.txt WA 27 ms 1812 KB
00_sample_05.txt WA 26 ms 1756 KB
01_rnd_00.txt WA 43 ms 1812 KB
01_rnd_01.txt TLE 2097 ms 460800 KB
01_rnd_02.txt TLE 2108 ms 543312 KB
01_rnd_03.txt TLE 2110 ms 493772 KB
01_rnd_04.txt TLE 2078 ms 354308 KB
01_rnd_05.txt TLE 2063 ms 208096 KB
01_rnd_06.txt TLE 2082 ms 381184 KB
01_rnd_07.txt TLE 2090 ms 457092 KB
01_rnd_08.txt WA 43 ms 1776 KB
01_rnd_09.txt TLE 2084 ms 354800 KB
01_rnd_10.txt TLE 2079 ms 345892 KB
01_rnd_11.txt WA 43 ms 1772 KB
01_rnd_12.txt TLE 2094 ms 437636 KB
01_rnd_13.txt TLE 2091 ms 454624 KB
01_rnd_14.txt TLE 2090 ms 373368 KB
01_rnd_15.txt TLE 2094 ms 438796 KB
01_rnd_16.txt WA 46 ms 1888 KB
01_rnd_17.txt TLE 2102 ms 500436 KB
01_rnd_18.txt WA 44 ms 1760 KB
01_rnd_19.txt TLE 2065 ms 228592 KB
02_rndhard_00.txt TLE 2091 ms 458368 KB
02_rndhard_01.txt TLE 2094 ms 456572 KB
02_rndhard_02.txt TLE 2086 ms 346108 KB
02_rndhard_03.txt TLE 2082 ms 346240 KB
02_rndhard_04.txt TLE 2086 ms 345184 KB
02_rndhard_05.txt TLE 2082 ms 347268 KB
02_rndhard_06.txt TLE 2085 ms 367016 KB
02_rndhard_07.txt TLE 2079 ms 367488 KB
02_rndhard_08.txt TLE 2079 ms 343808 KB
02_rndhard_09.txt TLE 2076 ms 349312 KB
02_rndhard_10.txt TLE 2062 ms 212312 KB
02_rndhard_11.txt TLE 2062 ms 212508 KB
02_rndhard_12.txt TLE 2079 ms 355976 KB
02_rndhard_13.txt TLE 2077 ms 355476 KB
02_rndhard_14.txt WA 42 ms 1756 KB
02_rndhard_15.txt WA 43 ms 1820 KB
02_rndhard_16.txt TLE 2081 ms 349564 KB
02_rndhard_17.txt TLE 2080 ms 351156 KB
02_rndhard_18.txt TLE 2064 ms 211928 KB
02_rndhard_19.txt TLE 2061 ms 208348 KB
02_rndhard_20.txt TLE 2077 ms 337536 KB
02_rndhard_21.txt TLE 2082 ms 347908 KB
02_rndhard_22.txt TLE 2091 ms 458252 KB
02_rndhard_23.txt TLE 2096 ms 458112 KB
02_rndhard_24.txt TLE 2065 ms 210840 KB
02_rndhard_25.txt TLE 2065 ms 212704 KB
02_rndhard_26.txt TLE 2093 ms 456188 KB
02_rndhard_27.txt TLE 2092 ms 455292 KB
02_rndhard_28.txt TLE 2063 ms 225108 KB
02_rndhard_29.txt TLE 2065 ms 224608 KB
02_rndhard_30.txt TLE 2060 ms 200020 KB
02_rndhard_31.txt TLE 2061 ms 213464 KB
02_rndhard_32.txt TLE 2096 ms 436608 KB
02_rndhard_33.txt TLE 2096 ms 455360 KB
02_rndhard_34.txt TLE 2063 ms 225748 KB
02_rndhard_35.txt TLE 2066 ms 227288 KB
02_rndhard_36.txt TLE 2082 ms 363836 KB
02_rndhard_37.txt TLE 2077 ms 355592 KB
02_rndhard_38.txt TLE 2078 ms 353920 KB
02_rndhard_39.txt TLE 2086 ms 352508 KB
03_rndhardsmall_00.txt WA 27 ms 1764 KB
03_rndhardsmall_01.txt WA 27 ms 1760 KB
03_rndhardsmall_02.txt TLE 2063 ms 233952 KB
03_rndhardsmall_03.txt TLE 2063 ms 233952 KB
03_rndhardsmall_04.txt WA 27 ms 1856 KB
03_rndhardsmall_05.txt WA 27 ms 1764 KB
03_rndhardsmall_06.txt WA 27 ms 1728 KB
03_rndhardsmall_07.txt WA 27 ms 1856 KB
03_rndhardsmall_08.txt WA 28 ms 1820 KB
03_rndhardsmall_09.txt WA 27 ms 1780 KB