LeetCode Weekly Contest 169 3問目 - Jump Game III [1306]

Source

LeetCode Weekly Contest 169
問題文

問題概要

省略

解法

省略

cLayversion 20200214-1)のコード

C++に変換後のコードはこちら

#define main dummy_main
{}
#undef main

int vis[1d5], st[1d5], sts;

class Solution {
public:
  bool canReach(vector<int>& A, int s) {
    int i, j, N = A.size();
    rep(i,N) vis[i] = 0;
    sts = 0;
    vis[s] = 1;
    st[sts++] = s;
    while(sts){
      i = st[--sts];
      if(A[i]==0) return true;
      rep(d,2){
        j = i if[d, +, -] A[i];
        if(j < 0 || j >= N) continue;
        if(vis[j]==0) vis[j] = 1, st[sts++] = j;
      }
    }
    return false;
  }
};

Current time: 2024年04月18日12時08分57秒
Last modified: 2020年02月16日02時11分22秒 (by laycrs)
Tags: Competitive_Programming_Incomplete LeetCode
トップページに戻る

Logged in as: unknown user (not login)

ログイン: