Submission #420210


Source Code Expand

#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int dp[550][550];
int h,w;
int dd[]={1,0,-1,0,1};
bool check(int a,int b){
    if(0<=a&&a<h&&0<=b&&b<w) return true;
    return false;
}
bool foo(vector<string> &v,int a,int b){
    if(!check(a,b)) return false;
    if(dp[a][b]) return false;
    dp[a][b]=1;
    if(v[a][b]=='#') return false;
    if(v[a][b]=='g') return true;
    rep(i,4){
        if(foo(v,a+dd[i],b+dd[i+1])) return true;
    }
    return false;
}
void mainmain(){
    // int h,w;
    cin>>h>>w;
    vector<string> v(h);
    rep(i,h) cin>>v[i];
    rep(i,h){
        rep(j,w){
            if(v[i][j]=='s'){
                if(foo(v,i,j)){
                    cout<<"Yes"<<endl;
                }
                else{
                    cout<<"No"<<endl;
                }
                    return;
            }
        }
    }
}


signed main() {
    mainmain();
}

Submission Info

Submission Time
Task A - 深さ優先探索
User j_gui0121
Language C++11 (GCC 4.9.2)
Score 100
Code Size 2819 Byte
Status AC
Exec Time 74 ms
Memory 15900 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 100 / 100
Status
AC × 5
AC × 83
Set Name Test Cases
Sample 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt
All 00_min_01.txt, 00_min_02.txt, 00_min_03.txt, 00_min_04.txt, 00_min_05.txt, 00_min_06.txt, 00_min_07.txt, 00_min_08.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 00_sample_04.txt, 00_sample_05.txt, 01_rnd_00.txt, 01_rnd_01.txt, 01_rnd_02.txt, 01_rnd_03.txt, 01_rnd_04.txt, 01_rnd_05.txt, 01_rnd_06.txt, 01_rnd_07.txt, 01_rnd_08.txt, 01_rnd_09.txt, 01_rnd_10.txt, 01_rnd_11.txt, 01_rnd_12.txt, 01_rnd_13.txt, 01_rnd_14.txt, 01_rnd_15.txt, 01_rnd_16.txt, 01_rnd_17.txt, 01_rnd_18.txt, 01_rnd_19.txt, 02_rndhard_00.txt, 02_rndhard_01.txt, 02_rndhard_02.txt, 02_rndhard_03.txt, 02_rndhard_04.txt, 02_rndhard_05.txt, 02_rndhard_06.txt, 02_rndhard_07.txt, 02_rndhard_08.txt, 02_rndhard_09.txt, 02_rndhard_10.txt, 02_rndhard_11.txt, 02_rndhard_12.txt, 02_rndhard_13.txt, 02_rndhard_14.txt, 02_rndhard_15.txt, 02_rndhard_16.txt, 02_rndhard_17.txt, 02_rndhard_18.txt, 02_rndhard_19.txt, 02_rndhard_20.txt, 02_rndhard_21.txt, 02_rndhard_22.txt, 02_rndhard_23.txt, 02_rndhard_24.txt, 02_rndhard_25.txt, 02_rndhard_26.txt, 02_rndhard_27.txt, 02_rndhard_28.txt, 02_rndhard_29.txt, 02_rndhard_30.txt, 02_rndhard_31.txt, 02_rndhard_32.txt, 02_rndhard_33.txt, 02_rndhard_34.txt, 02_rndhard_35.txt, 02_rndhard_36.txt, 02_rndhard_37.txt, 02_rndhard_38.txt, 02_rndhard_39.txt, 03_rndhardsmall_00.txt, 03_rndhardsmall_01.txt, 03_rndhardsmall_02.txt, 03_rndhardsmall_03.txt, 03_rndhardsmall_04.txt, 03_rndhardsmall_05.txt, 03_rndhardsmall_06.txt, 03_rndhardsmall_07.txt, 03_rndhardsmall_08.txt, 03_rndhardsmall_09.txt
Case Name Status Exec Time Memory
00_min_01.txt AC 23 ms 800 KB
00_min_02.txt AC 23 ms 928 KB
00_min_03.txt AC 24 ms 932 KB
00_min_04.txt AC 25 ms 924 KB
00_min_05.txt AC 24 ms 804 KB
00_min_06.txt AC 26 ms 752 KB
00_min_07.txt AC 25 ms 928 KB
00_min_08.txt AC 24 ms 800 KB
00_sample_01.txt AC 23 ms 924 KB
00_sample_02.txt AC 25 ms 928 KB
00_sample_03.txt AC 25 ms 928 KB
00_sample_04.txt AC 24 ms 804 KB
00_sample_05.txt AC 23 ms 924 KB
01_rnd_00.txt AC 41 ms 1056 KB
01_rnd_01.txt AC 63 ms 12068 KB
01_rnd_02.txt AC 54 ms 5668 KB
01_rnd_03.txt AC 74 ms 15900 KB
01_rnd_04.txt AC 69 ms 14048 KB
01_rnd_05.txt AC 39 ms 1060 KB
01_rnd_06.txt AC 48 ms 3744 KB
01_rnd_07.txt AC 52 ms 5408 KB
01_rnd_08.txt AC 39 ms 1064 KB
01_rnd_09.txt AC 39 ms 1056 KB
01_rnd_10.txt AC 50 ms 2976 KB
01_rnd_11.txt AC 39 ms 1060 KB
01_rnd_12.txt AC 65 ms 11172 KB
01_rnd_13.txt AC 72 ms 12704 KB
01_rnd_14.txt AC 39 ms 1064 KB
01_rnd_15.txt AC 47 ms 2840 KB
01_rnd_16.txt AC 38 ms 1060 KB
01_rnd_17.txt AC 55 ms 3752 KB
01_rnd_18.txt AC 38 ms 1056 KB
01_rnd_19.txt AC 47 ms 4384 KB
02_rndhard_00.txt AC 40 ms 1188 KB
02_rndhard_01.txt AC 41 ms 1192 KB
02_rndhard_02.txt AC 45 ms 1964 KB
02_rndhard_03.txt AC 43 ms 1828 KB
02_rndhard_04.txt AC 38 ms 1060 KB
02_rndhard_05.txt AC 37 ms 1060 KB
02_rndhard_06.txt AC 42 ms 1192 KB
02_rndhard_07.txt AC 40 ms 1056 KB
02_rndhard_08.txt AC 42 ms 1436 KB
02_rndhard_09.txt AC 41 ms 1444 KB
02_rndhard_10.txt AC 39 ms 1444 KB
02_rndhard_11.txt AC 41 ms 1444 KB
02_rndhard_12.txt AC 40 ms 1320 KB
02_rndhard_13.txt AC 40 ms 1316 KB
02_rndhard_14.txt AC 42 ms 1576 KB
02_rndhard_15.txt AC 41 ms 1572 KB
02_rndhard_16.txt AC 40 ms 1056 KB
02_rndhard_17.txt AC 39 ms 1120 KB
02_rndhard_18.txt AC 38 ms 1188 KB
02_rndhard_19.txt AC 40 ms 1188 KB
02_rndhard_20.txt AC 40 ms 1188 KB
02_rndhard_21.txt AC 39 ms 1188 KB
02_rndhard_22.txt AC 41 ms 1440 KB
02_rndhard_23.txt AC 41 ms 1312 KB
02_rndhard_24.txt AC 43 ms 1196 KB
02_rndhard_25.txt AC 41 ms 1188 KB
02_rndhard_26.txt AC 40 ms 1188 KB
02_rndhard_27.txt AC 39 ms 1056 KB
02_rndhard_28.txt AC 40 ms 1180 KB
02_rndhard_29.txt AC 43 ms 1188 KB
02_rndhard_30.txt AC 39 ms 1120 KB
02_rndhard_31.txt AC 40 ms 1052 KB
02_rndhard_32.txt AC 40 ms 1308 KB
02_rndhard_33.txt AC 39 ms 1308 KB
02_rndhard_34.txt AC 39 ms 1056 KB
02_rndhard_35.txt AC 39 ms 1064 KB
02_rndhard_36.txt AC 40 ms 1052 KB
02_rndhard_37.txt AC 40 ms 1120 KB
02_rndhard_38.txt AC 40 ms 1180 KB
02_rndhard_39.txt AC 40 ms 1248 KB
03_rndhardsmall_00.txt AC 24 ms 924 KB
03_rndhardsmall_01.txt AC 24 ms 928 KB
03_rndhardsmall_02.txt AC 24 ms 928 KB
03_rndhardsmall_03.txt AC 24 ms 924 KB
03_rndhardsmall_04.txt AC 22 ms 800 KB
03_rndhardsmall_05.txt AC 24 ms 796 KB
03_rndhardsmall_06.txt AC 25 ms 928 KB
03_rndhardsmall_07.txt AC 25 ms 736 KB
03_rndhardsmall_08.txt AC 24 ms 924 KB
03_rndhardsmall_09.txt AC 23 ms 924 KB