結果

問題 No.367 ナイトの転身
ユーザー 🍡yurahuna🍡yurahuna
提出日時 2016-04-04 22:02:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,420 bytes
コンパイル時間 812 ms
コンパイル使用メモリ 77,948 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 21:33:19
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <complex>
#include <queue>
#include <map>
#include <string>
#include <cassert>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define rep(i,n) for (int i=0;i<(n);i++)
#define Rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

#define PI 3.1415926535

typedef long long ll;
typedef pair<int, int> P;

const int INF = 99999999;
const int MAX_H = 500;
const int MAX_W = 500;

int H, W;
vector<string> field;

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

int main() {
    /* assert code */
	cin >> H >> W;

    assert(1 <= H && H <= MAX_H);
    assert(1 <= W && W <= MAX_W);
    

	field.clear();
	field.resize(H);

	// 盤面の読み込み & スタート位置、ゴール位置の取得
	int sx = -1, sy = -1, gx = -1, gy = -1;
    int cntS = 0, cntG = 0;
	rep(i, H) {
		cin >> field[i];
        assert(field[i].size() == W);
		rep(j, W) {
			if (field[i][j] == 'S') {
				sx = i;
				sy = j;
                cntS++;
			} else if (field[i][j] == 'G') {
				gx = i;
				gy = j;
                cntG++;
			} else {
                assert(field[i][j] == '.' || field[i][j] == 'R');
            }
		}
	}

    assert(inside(sx, sy));
    assert(inside(gx, gy));
    assert(cntS == 1);
    assert(cntG == 1);

}
0