Submission #925804

# Submission time Handle Problem Language Result Execution time Memory
925804 2024-02-12T09:03:16 Z vjudge1 Nautilus (BOI19_nautilus) C++17
29 / 100
1000 ms 600 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;

void sol(ll it, ll x, ll y)
{
	if(it==s.size())
	{
		c[x][y]='X';
		return;
	}
	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 'void 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())
      |     ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 1065 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Execution timed out 1065 ms 348 KB Time limit exceeded
8 Halted 0 ms 0 KB -