提出 #43178624


ソースコード 拡げる

//oamh namoh bhagwate vaudevaye namah//
 
#include <bits/stdc++.h>
#include <string>
#include <sstream>
#include <ctime>
 
using namespace std;
 
 
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif
 
#define ar array
#define ll long long
#define ld long double
#define sza(x) ((int)x.size())
#define all(a) (a).begin(), (a).end()
#define INF 1e9
 
const int MAX_N = 2e5;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;
 
const long long MAXAI = 1000000000000ll;
 
ll power(int a,int b){
  ll k=0;
  ll p=1;
  while(k<b){
    p=p*a;
    k++;
  }
  return p;
}

bool DFS(ll index,ll x,ll y,vector<vector<ll>> &dp,vector<string> &maze,string &s){
  // cout<<x<<" "<<y<<endl;
  if(x<0 || y<0 || x>=maze.size() || y>=maze[x].size())
    return false;
  if(maze[x][y]!=s[index])
    return false;
  if(x==maze.size()-1 && y==(maze[x].size()-1)){
    return true;
  }
  if(dp[x][y]!=-1){
    return dp[x][y];
  }
  if(DFS((index+1)%5,x+1,y,dp,maze,s) || DFS((index+1)%5,x,y+1,dp,maze,s) || DFS((index+1)%5,x,y-1,dp,maze,s) || DFS((index+1)%5,x-1,y,dp,maze,s)){
    return dp[x][y]=1;
  }
  return dp[x][y]=0;
}
  
int main() {
  #ifndef ONLINE_JUDGE
      freopen("error.txt" , "w" , stderr);
      freopen("input.txt" , "r" , stdin);
      freopen("output.txt" , "w" , stdout);
  #endif
  ios_base::sync_with_stdio(0);
  //cin.tie(0);
  int tc=1;
  // SieveOfEratosthenes();
  // cin >> tc;
  int start_s=clock() ; 
  for (int t = 1; t <= tc; t++){
    ll n,m;
    cin>>n>>m;
    vector<string> maze(n);
    for(int i=0;i<n;i++){
      cin>>maze[i];
    }
    string s="snuke";
    vector<vector<ll>> dp(n,vector<ll>(m,-1));
    // cout<<"here"<<endl;
    if(DFS(0,0,0,dp,maze,s))
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  int stop_s=clock(); 
  // cout<<(stop_s-start_s)/double(CLOCKS_PER_SEC)*1000; 
  return 0;
}

提出情報

提出日時
問題 D - Snuke Maze
ユーザ Vermish
言語 C++ (GCC 9.2.1)
得点 0
コード長 2569 Byte
結果 RE
実行時間 899 ms
メモリ 1054564 KiB

コンパイルエラー

./Main.cpp: In function ‘bool DFS(long long int, long long int, long long int, std::vector<std::vector<long long int> >&, std::vector<std::__cxx11::basic_string<char> >&, std::string&)’:
./Main.cpp:46:21: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   46 |   if(x<0 || y<0 || x>=maze.size() || y>=maze[x].size())
      |                    ~^~~~~~~~~~~~~
./Main.cpp:46:39: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   46 |   if(x<0 || y<0 || x>=maze.size() || y>=maze[x].size())
      |                                      ~^~~~~~~~~~~~~~~~
./Main.cpp:50:7: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::vector<std::__cxx11::basic_string<char> >::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   50 |   if(x==maze.size()-1 && y==(maze[x].size()-1)){
      |      ~^~~~~~~~~~~~~~~
./Main.cpp:50:27: warning: comparison of integer expressions of different signedness: ‘long long int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   50 |   if(x==maze.size()-1 && y==(maze[x].size()-1)){
      |                          ~^~~~~~~~~~~~~~~~~~~~
./Main.cpp:57:20: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   57 |     return dp[x][y]=1;
./Main.cpp:59:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   59 |   return dp[x][y]=0;
./Main.cpp: In function ‘int main()’:
./Main.cpp:73:7: warning: unused variable ‘start_s’ [-Wunused-variable]
   73 |   int start_s=clock() ;
      |       ^~~~~~~
./Main.cpp:89:7: warning: unused variable ‘stop_s’ [-Wunused-variable]
   89 |   int stop_s=clock();
      |       ^~~~~~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 400
結果
AC × 3
AC × 15
RE × 21
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 02_random2_12.txt, 02_random2_13.txt, 02_random2_14.txt, 02_random2_15.txt, 02_random2_16.txt, 02_random2_17.txt, 02_random2_18.txt, 02_random2_19.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt, 03_handmade_04.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 7 ms 3452 KiB
00_sample_01.txt AC 2 ms 3508 KiB
00_sample_02.txt AC 2 ms 3500 KiB
01_random_00.txt AC 2 ms 3540 KiB
01_random_01.txt AC 3 ms 4248 KiB
01_random_02.txt AC 4 ms 4412 KiB
01_random_03.txt AC 2 ms 3752 KiB
01_random_04.txt AC 5 ms 3972 KiB
01_random_05.txt AC 2 ms 3448 KiB
01_random_06.txt AC 2 ms 3700 KiB
01_random_07.txt AC 2 ms 3796 KiB
02_random2_00.txt RE 899 ms 1053360 KiB
02_random2_01.txt RE 790 ms 1054564 KiB
02_random2_02.txt RE 781 ms 1053968 KiB
02_random2_03.txt RE 787 ms 1054080 KiB
02_random2_04.txt RE 788 ms 1054008 KiB
02_random2_05.txt AC 6 ms 5496 KiB
02_random2_06.txt RE 785 ms 1054036 KiB
02_random2_07.txt RE 784 ms 1054056 KiB
02_random2_08.txt RE 784 ms 1054080 KiB
02_random2_09.txt RE 784 ms 1054060 KiB
02_random2_10.txt RE 785 ms 1054172 KiB
02_random2_11.txt RE 785 ms 1054048 KiB
02_random2_12.txt RE 786 ms 1053984 KiB
02_random2_13.txt RE 784 ms 1054032 KiB
02_random2_14.txt RE 786 ms 1053976 KiB
02_random2_15.txt RE 791 ms 1054092 KiB
02_random2_16.txt RE 783 ms 1054044 KiB
02_random2_17.txt RE 785 ms 1054048 KiB
02_random2_18.txt RE 789 ms 1054056 KiB
02_random2_19.txt RE 785 ms 1054052 KiB
03_handmade_00.txt AC 5 ms 3480 KiB
03_handmade_01.txt AC 5 ms 5464 KiB
03_handmade_02.txt AC 13 ms 5376 KiB
03_handmade_03.txt RE 782 ms 1054104 KiB
03_handmade_04.txt RE 777 ms 1054036 KiB