# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1043578 |
2024-08-04T11:39:33 Z |
KarolZ |
Nautilus (BOI19_nautilus) |
C++14 |
|
1000 ms |
4700 KB |
#include<iostream>
#include<queue>
#include<tuple>
using namespace std;
char a[510][510];
string s;
int poz[250];
int m,r,c;
pair<int,int>p[4]={{-1,0},{0,1},{1,0},{0,-1}};
int czy_odw[510][510];
queue< pair< pair<int,int>,int> >q;
int suck_int(){
int wyn=0;
char c=getchar_unlocked();
while(c>='0'&&c<='9'){
wyn=wyn*10+c-'0';
c=getchar_unlocked();
}
return wyn;
}
int beefes(){
pair<int,int>xy;
int wyn=0;
int kt;
while(!q.empty()){
tie(xy,kt)=q.front();
q.pop();
// cout<<kt<<' ';
if(kt==m){
wyn++;
// a[xy.first][xy.second]='X';
continue;
}
if(s[kt]=='?'){
for(int i=0;i<4;i++){
if(czy_odw[xy.first+p[i].first][xy.second+p[i].second]<kt+1&&a[xy.first+p[i].first][xy.second+p[i].second]=='.'){
q.push({{xy.first+p[i].first,xy.second+p[i].second},kt+1});
czy_odw[xy.first+p[i].first][xy.second+p[i].second]=kt+1;
}
}
}
else{
// cout<<kt<<' '<<xy.first<<' '<<xy.second<<'\n';
if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
// cout<<kt<<' '<<xy.first<<' '<<xy.second<<'\n';
q.push({{xy.first+p[poz[s[kt]]].first,xy.second+p[poz[s[kt]]].second},kt+1});
czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=kt+1;
}
}
}
/*for(int i=0;i<=r+1;i++){
for(int j=0;j<=c+1;j++)cout<<a[i][j];
cout<<'\n';
}*/
return wyn;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
//cin>>r>>c>>m;
r=suck_int();
c=suck_int();
m=suck_int();
poz['N']=0;
poz['E']=1;
poz['S']=2;
poz['W']=3;
for(int i=0;i<=r+1;i++){
for(int j=0;j<=c+1;j++){
if(i>0&&i<=r&&j>0&&j<=c)a[i][j]=getchar_unlocked();
else a[i][j]='#';
if(a[i][j]=='.')q.push({{i,j},0});
}
if(i>0&&i<=r)getchar_unlocked();
}
s="";
for(int i=0;i<m;i++)s+=getchar_unlocked();
cout<<beefes();
return 0;
}
Compilation message
nautilus.cpp: In function 'int beefes()':
nautilus.cpp:44:35: warning: array subscript has type 'char' [-Wchar-subscripts]
44 | if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
| ^
nautilus.cpp:44:66: warning: array subscript has type 'char' [-Wchar-subscripts]
44 | if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
| ^
nautilus.cpp:44:105: warning: array subscript has type 'char' [-Wchar-subscripts]
44 | if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
| ^
nautilus.cpp:44:136: warning: array subscript has type 'char' [-Wchar-subscripts]
44 | if(czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]<kt+1&&a[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=='.'){
| ^
nautilus.cpp:46:34: warning: array subscript has type 'char' [-Wchar-subscripts]
46 | q.push({{xy.first+p[poz[s[kt]]].first,xy.second+p[poz[s[kt]]].second},kt+1});
| ^
nautilus.cpp:46:64: warning: array subscript has type 'char' [-Wchar-subscripts]
46 | q.push({{xy.first+p[poz[s[kt]]].first,xy.second+p[poz[s[kt]]].second},kt+1});
| ^
nautilus.cpp:47:33: warning: array subscript has type 'char' [-Wchar-subscripts]
47 | czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=kt+1;
| ^
nautilus.cpp:47:64: warning: array subscript has type 'char' [-Wchar-subscripts]
47 | czy_odw[xy.first+p[poz[s[kt]]].first][xy.second+p[poz[s[kt]]].second]=kt+1;
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
9 ms |
604 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
360 KB |
Output is correct |
12 |
Correct |
10 ms |
604 KB |
Output is correct |
13 |
Correct |
14 ms |
828 KB |
Output is correct |
14 |
Correct |
11 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
10 ms |
852 KB |
Output is correct |
18 |
Correct |
16 ms |
824 KB |
Output is correct |
19 |
Correct |
7 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
5 |
Correct |
0 ms |
604 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
9 ms |
604 KB |
Output is correct |
8 |
Correct |
3 ms |
604 KB |
Output is correct |
9 |
Correct |
1 ms |
604 KB |
Output is correct |
10 |
Correct |
0 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
360 KB |
Output is correct |
12 |
Correct |
10 ms |
604 KB |
Output is correct |
13 |
Correct |
14 ms |
828 KB |
Output is correct |
14 |
Correct |
11 ms |
604 KB |
Output is correct |
15 |
Correct |
1 ms |
604 KB |
Output is correct |
16 |
Correct |
0 ms |
348 KB |
Output is correct |
17 |
Correct |
10 ms |
852 KB |
Output is correct |
18 |
Correct |
16 ms |
824 KB |
Output is correct |
19 |
Correct |
7 ms |
600 KB |
Output is correct |
20 |
Correct |
2 ms |
604 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Execution timed out |
1032 ms |
4700 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |