結果

問題 No.1588 Connection
ユーザー 👑 NachiaNachia
提出日時 2021-07-08 23:53:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 961 bytes
コンパイル時間 858 ms
コンパイル使用メモリ 85,004 KB
実行使用メモリ 823,300 KB
最終ジャッジ日時 2023-09-24 11:47:58
合計ジャッジ時間 8,390 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
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 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,1,0,-1};

int N,M;
vector<vector<int>> visited;

int main(){
  cin >> N >> M;
  visited.assign(N+2,vector<int>(N+2,0));
  rep(i,N+2) visited[i][0] = visited[i][N+1] = 1;
  rep(i,N+2) visited[0][i] = visited[N+1][i] = 1;
  vector<int> I;
  I.push_back(0);
  visited[1][1] = 0;
  rep(i,I.size()){
    int p = I[i];
    int x = p%N;
    int y = p/N;
    rep(d,4){
      int nx = x+dx[d];
      int ny = y+dy[d];
      if(visited[ny+1][nx+1]) continue;
      int ni = ny*N+nx;
      I.push_back(ni);
      visited[ny][nx] = 1;
    }
  }
  if(visited[N][N] == 1) cout << "Yes\n"; else cout << "No\n";
  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_inst;
0