# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1114299 | Marco_Escandon | Nautilus (BOI19_nautilus) | C++11 | 994 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef int ll;
ll dx[]={1, 0, -1, 0};
ll dy[]={0, 1, 0, -1};
char cad[505][505];
string s;
pair<ll,ll> d(char car)
{
if(car=='N')
return {1,0};
if(car=='S')
return {-1,0};
if(car=='W')
return {0,1};
if(car=='E')
return {0,-1};
}
vector<vector<unordered_map<ll,ll>>> mapa;
ll sol(ll px, ll py, ll p)
{
if(cad[px][py]=='#') return -1;
if(p==s.size()) return 1;
if(mapa[px][py][p]!=0) return mapa[px][py][p];
if(s[p]!='?')
{
pair<ll,ll> car=d(s[p]);
return mapa[px][py][p]=sol(car.first+px,py+car.second,p+1);
}
ll bs=-1;
for(int i=0; i<4; i++){
bs=max(bs,sol(px+dx[i],py+dy[i],p+1));
if(bs==1) break;
}
return mapa[px][py][p] = bs;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
ll n,m,k;
cin>>n>>m>>k;
for(int i=0; i<=n+2; i++)
for(int j=0;j<=m+2; j++)
cad[i][j]='#';
for(int i=1; i<=n; i++)
for(int j=1; j<=m; j++)
cin>>cad[i][j];
mapa.assign(505,vector<unordered_map<ll,ll>>(505));
cin>>s;
reverse(s.begin(),s.end());
ll cont=0;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=m; j++)
{
cont+=max(sol(i,j,0),0);
}
}
cout<<cont;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |