結果
| 問題 | No.323 yuki国 |
| コンテスト | |
| ユーザー |
moti
|
| 提出日時 | 2015-12-16 01:37:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,686 bytes |
| 記録 | |
| コンパイル時間 | 881 ms |
| コンパイル使用メモリ | 111,820 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-16 05:27:22 |
| 合計ジャッジ時間 | 2,406 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 4 |
| other | AC * 23 WA * 9 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:42:40: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
42 | int H, W, A, si, sj, B, gi, gj; scanf("%d%d%d%d%d%d%d%d", &H,&W,&A,&si,&sj,&B,&gi,&gj);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
using namespace std;
#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define minimize(a, x) a = std::min(a, x)
#define maximize(a, x) a = std::max(a, x)
typedef long long ll;
int const inf = 1<<29;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
template<class T> constexpr bool in_range(T y, T x, T H, T W) { return 0<=y&&y<H&&0<=x&&x<W; }
int main() {
int H, W, A, si, sj, B, gi, gj; scanf("%d%d%d%d%d%d%d%d", &H,&W,&A,&si,&sj,&B,&gi,&gj);
char yuki[H][W+1];
rep(i, H) {
cin >> yuki[i];
}
queue<tuple<int, int, int>> q;
q.emplace(si, sj, A);
bool vis[H][W][max(A,B)+H+W-2];
vis[si][sj][A] = 1;
while(!q.empty()) {
auto p = q.front(); q.pop();
int i, j, c; tie(i, j, c) = p;
rep(d, 4) {
auto const ni = i + dy[d], nj = j + dx[d];
if(!in_range(ni, nj, H, W)) { continue; }
int const nc = c + (yuki[ni][nj] == '*' ? 1 : -1);
if(nc <= 0 || nc > max(A,B)+H+W-2) { continue; }
if(vis[ni][nj][nc]) { continue; }
if(ni == gi && nj == gj && nc == B) {
puts("Yes");
exit(0);
}
vis[ni][nj][nc] = 1;
q.emplace(ni, nj, nc);
}
}
puts("No");
return 0;
}
moti