답안 #925800

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925800 2024-02-12T09:02:13 Z vjudge1 Nautilus (BOI19_nautilus) C++17
0 / 100
6 ms 7004 KB
#include<bits/stdc++.h>
using namespace  std;
#define ll long long
#define lld long long double
#define pb push_back
#define pf push_front
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define IShowSpeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int N=5e5+100;
const int mod=1e9+7;
const int K=500;
const ll inf=1e18+1337;
const int dx[]={-1, 0, 0, 1};
const int dy[]={0, -1, 1, 0};
char c[K+10][K+10];
ll n,m,k,ans=0;
string s;

ll sol(ll it, ll x, ll y)
{
	if(it==s.size()) c[x][y]='X';
	if(s[it]=='?')
	{
		for(int i=0;i<4;i++)
		{
			ll xx=x+dx[i],yy=y+dy[i];
			if(xx<1 || yy<1 || xx>n || yy>m) continue;
			if(c[xx][yy]!='#') sol(it+1,xx,yy); 
		}
	}
	else
	{
		if(s[it]=='W' && y-1>=1 && c[x][y-1]!='#') sol(it+1,x,y-1);
		if(s[it]=='N' && x-1>=1 && c[x-1][y]!='#') sol(it+1,x-1,y);
		if(s[it]=='E' && y+1<=m && c[x][y+1]!='#') sol(it+1,x,y+1);
		if(s[it]=='S' && x+1<=n && c[x+1][y]!='#') sol(it+1,x+1,y);
	}
}

int main()
{
	IShowSpeed
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>c[i][j];

	cin>>s;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(c[i][j]!='#')
				sol(0,i,j);

	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(c[i][j]=='X')
				ans++;

	cout<<ans;
}

Compilation message

nautilus.cpp: In function 'long long int sol(long long int, long long int, long long int)':
nautilus.cpp:23:7: 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]
   23 |  if(it==s.size()) c[x][y]='X';
      |     ~~^~~~~~~~~~
nautilus.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
   40 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 7004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 7004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 7004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -