답안 #927528

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927528 2024-02-15T02:49:40 Z Faisal_Saqib Nautilus (BOI19_nautilus) C++17
66 / 100
1000 ms 74320 KB
#include <iostream>
#include <bitset>
using namespace std;
char g[250000];
int n,m,M;
char s[5001];
bitset<250000> pos[5002];
bitset<250000> fx[5002];
bool dfs(int x,int y,int ind)
{
  if(x<0 or y<0 or x>=n or y>=m or g[(x*m)+y]=='#')
    return 0;
  if(fx[ind][(x*m)+y])
    return pos[ind][(x*m)+y];
  fx[ind][(x*m)+y]=1;
  if(ind==M)
    return pos[ind][(x*m)+y]=1;
  if(s[ind]=='?')
    pos[ind][(x*m)+y]=(dfs(x-1,y,ind+1)|dfs(x+1,y,ind+1)|dfs(x,y-1,ind+1)|dfs(x,y+1,ind+1));
  else if(s[ind]=='N')
    pos[ind][(x*m)+y]=dfs(x-1,y,ind+1);   
  else if(s[ind]=='S')
    pos[ind][(x*m)+y]=dfs(x+1,y,ind+1);
  else if(s[ind]=='W')
    pos[ind][(x*m)+y]=dfs(x,y-1,ind+1);   
  else if(s[ind]=='E')
    pos[ind][(x*m)+y]=dfs(x,y+1,ind+1);
  return pos[ind][(x*m)+y];
}
int main()
{
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(0);
  cin>>n>>m>>M;
  for(int i=0;i<n;i++)
    for(int j=0;j<m;j++)
      cin>>g[(i*m)+j];
  for(int j=0;j<M;j++)
    cin>>s[j];
  int cnt=0;
  for(int x=0;x<n;x++)
    for(int y=0;y<m;y++)
      dfs(x,y,0);
  for(int x=0;x<n;x++)
    for(int y=0;y<m;y++)
      cnt+=pos[M][(x*m)+y];
  cout<<cnt<<'\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1404 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1404 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 15 ms 1372 KB Output is correct
8 Correct 5 ms 1372 KB Output is correct
9 Correct 2 ms 1372 KB Output is correct
10 Correct 1 ms 1348 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 19 ms 1372 KB Output is correct
13 Correct 20 ms 1432 KB Output is correct
14 Correct 15 ms 1384 KB Output is correct
15 Correct 2 ms 1332 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 19 ms 3160 KB Output is correct
18 Correct 25 ms 3168 KB Output is correct
19 Correct 7 ms 3164 KB Output is correct
20 Correct 3 ms 3164 KB Output is correct
21 Correct 1 ms 2908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1372 KB Output is correct
2 Correct 1 ms 1372 KB Output is correct
3 Correct 1 ms 1404 KB Output is correct
4 Correct 1 ms 2908 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 2908 KB Output is correct
7 Correct 15 ms 1372 KB Output is correct
8 Correct 5 ms 1372 KB Output is correct
9 Correct 2 ms 1372 KB Output is correct
10 Correct 1 ms 1348 KB Output is correct
11 Correct 1 ms 1116 KB Output is correct
12 Correct 19 ms 1372 KB Output is correct
13 Correct 20 ms 1432 KB Output is correct
14 Correct 15 ms 1384 KB Output is correct
15 Correct 2 ms 1332 KB Output is correct
16 Correct 1 ms 1112 KB Output is correct
17 Correct 19 ms 3160 KB Output is correct
18 Correct 25 ms 3168 KB Output is correct
19 Correct 7 ms 3164 KB Output is correct
20 Correct 3 ms 3164 KB Output is correct
21 Correct 1 ms 2908 KB Output is correct
22 Execution timed out 1041 ms 74320 KB Time limit exceeded
23 Halted 0 ms 0 KB -