結果

問題 No.971 いたずらっ子
ユーザー 夜
提出日時 2020-11-17 17:40:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,324 bytes
コンパイル時間 3,369 ms
コンパイル使用メモリ 107,576 KB
実行使用メモリ 106,664 KB
最終ジャッジ日時 2023-09-30 14:19:58
合計ジャッジ時間 7,719 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
string s[2020];
int main() {
	int h, w;
	cin >> h >> w;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	set<pair<int, int>> st;
	priority_queue<tuple<long long,int,int>,vector<tuple<long long, int, int>>,greater<tuple<long long, int, int>>> que;
	long long ans = 1000000007;
	que.push(make_tuple(0, 0, 0));
	while (!que.empty()) {
		tuple<long long, int, int> p = que.top();
		int x = get<1>(p);
		int y = get<2>(p);
		long long z = get<0>(p);
		int co = st.size();
		st.insert(make_pair(x, y));
		que.pop();
		if (co == st.size()) {
			continue;
		}
		if (x == h - 1 && y == w - 1) {
			cout << z << endl;
			return 0;
		}
		if (x != h - 1) {
			if (s[x + 1][y] == 'k') {
				que.push(make_tuple((z + 1) + x + 1 + y, x + 1, y));
			}
			else {
				que.push(make_tuple(z + 1, x + 1, y));

			}
		}
		if (y != w - 1) {
			if (s[x][y + 1] == 'k') {
				que.push(make_tuple((z + 1) + x + y + 1, x, y + 1));
			}
			else {
				que.push(make_tuple(z + 1, x, y + 1));
			}
		}
	}
}
0