| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1367121 | lizi14 | Nautilus (BOI19_nautilus) | C++20 | 1092 ms | 2884 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define ss second
#define ina insert
#define pb push_back
signed main(){
// string a[2];
// a[1]="a";
// a[1]+='b';
// cout<<a[1]<<endl;
int n,m,k;
cin>>n>>m>>k;
char x[n][m];
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin>>x[i][j];
}
}
string s;
cin>>s;
set<pair<int,int>>sasalele;
for(int ii=0; ii<n; ii++){
for(int jj=0; jj<m; jj++){
if(x[ii][jj]=='#')continue;
string l[n][m];
int li[n][m];
for(int h=0; h<n; h++){
for(int kk=0; kk<m; kk++){
l[h][kk]="";
li[h][kk]=0;
}
}
queue<pair<int,int>>q;
q.push({ii,jj});
li[ii][jj]=1;
while(q.size()){
pair<int,int>p=q.front();
int i=p.f,j=p.ss;
q.pop();
if(l[i][j].size()==k){
//cout<<l[i][j]<<endl;
int hi=0;
for(int wi=0; wi<k; wi++){
if(s[wi]=='?')continue;
if(s[wi]!=l[i][j][wi]){
hi=1;
break;
}
}
if(hi==0){
sasalele.ina({i,j});
}
}
if(i+1<n && x[i+1][j]=='.' && li[i+1][j]==0){
q.push({i+1,j});
l[i+1][j]=l[i][j];
l[i+1][j]+='S';
li[i+1][j]=1;
}
if(i-1>=0 && x[i-1][j]=='.' && li[i-1][j]==0){
q.push({i-1,j});
l[i-1][j]=l[i][j];
l[i-1][j]+='N';
li[i-1][j]=1;
}
if(j+1<m && x[i][j+1]=='.' && li[i][j+1]==0){
q.push({i,j+1});
l[i][j+1]=l[i][j];
l[i][j+1]+='E';
li[i][j+1]=1;
}
if(j-1>=0 && x[i][j-1]=='.' && li[i][j-1]==0){
q.push({i,j-1});
l[i][j-1]=l[i][j];
l[i][j-1]+='W';
li[i][j-1]=1;
}
}
}
}
cout<<sasalele.size()<<endl;
}| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
