Submission #776037

# Submission time Handle Problem Language Result Execution time Memory
776037 2023-07-07T08:53:37 Z vjudge1 Awesome Arrowland Adventure (eJOI19_adventure) C++17
0 / 100
0 ms 212 KB
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 505
int arr[2][N],dp[N][2];
int m,n;
int fark[5][5];             
ll int hesap(int x,int yer,int geldim){
	if(dp[x][yer]!=-1)return dp[x][yer];
	if(x>=n)return 0;
	if(x==n-1&&yer==1)return 0;
	if(arr[yer][x]==0)return 1000000000000000000;
	ll int a,b,c;
	a=b=c=1000000000000000000;
	if(x!=n-1){
		a=hesap(x+1,yer,-1)+fark[arr[yer][x]][1];
	}
	if(yer==1&&geldim!=0){
		b=hesap(x,yer-1,1)+fark[arr[yer][x]][4];
	}
	if(yer==0&&geldim!=1){
		c=hesap(x,yer+1,0)+fark[arr[yer][x]][2];
	}
	//cout<<x<<" "<<yer<<" "<<geldim<<"__"<<a<<" "<<b<<" "<<c<<endl;
	ll int cev=min(a,min(b,c));
	return dp[x][yer]=cev;
}                                                               
int main(){
	lalala;
	cin>>m>>n;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<m;i++){
		string str;cin>>str;
		for(int j=0;j<str.size();j++){
			if(str[j]=='E')arr[i][j]=1;
			if(str[j]=='S')arr[i][j]=2;
			if(str[j]=='W')arr[i][j]=3;
			if(str[j]=='N')arr[i][j]=4;
			if(str[j]=='X')arr[i][j]=0;

		}
	}
	fark[1][2]=1;fark[1][3]=2;fark[1][4]=3;
	fark[2][1]=3;fark[2][3]=1;fark[2][4]=2;

	fark[3][1]=2;fark[3][2]=3;fark[3][4]=1;
	fark[4][1]=1;;fark[4][2]=2;fark[4][3]=3;
	ll int cev=hesap(0,0,-1);
	if(cev==1000000000000000000)cev=-1;
	cout<<cev<<endl;



}

Compilation message

adventure.cpp: In function 'int main()':
adventure.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   for(int j=0;j<str.size();j++){
      |               ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -