# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
171051 |
2019-12-27T08:38:05 Z |
dndhk |
Nautilus (BOI19_nautilus) |
C++14 |
|
1000 ms |
1528 KB |
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define pb push_back
#define FI first
#define SE second
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define test 1
#define TEST if(test)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
const int MOD = 1000000007; // 998244353
const int INF = 2e9;
const ll INFLL = 1e18;
const int MAX_N = 500;
int N, M, Q;
string arr[MAX_N+1];
bool dp[2][MAX_N+1][MAX_N+1];
string str;
int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
char c[4] = {'W', 'E', 'N', 'S'};
bool chk(int x, int y){
if(x<0 || x>=N || y<0 || y>=M) return false;
return (dp[0][x][y]);
}
int main(){
scanf("%d%d%d", &N, &M, &Q);
for(int i=0; i<N; i++){
cin>>arr[i];
for(int j=0; j<M; j++){
dp[0][i][j] = (arr[i][j]=='.');
//cout<<dp[0][i][j];
}//cout<<endl;
}
cin>>str;
for(int k=0; k<Q; k++){
if(str[k]=='?'){
for(int i=0; i<N; i++){
for(int j=0; j<M; j++){
if(chk(i+1, j) || chk(i-1, j) || chk(i, j+1) || chk(i, j-1)){
dp[1][i][j] = true;
}else{
dp[1][i][j] = false;
}
}
}
}else{
int t;
for(t=0; t<4; t++){
if(str[k]==c[t]) break;
}
//cout<<t<<endl;
for(int i=0; i<N; i++){
for(int j=0; j<M; j++){
if(chk(i+dx[t], j+dy[t])){
dp[1][i][j] = true;
}else{
dp[1][i][j] = false;
}
}
}
}
for(int i=0; i<N; i++){
for(int j=0; j<M; j++){
dp[0][i][j] = dp[1][i][j];
if(arr[i][j]=='#') dp[0][i][j] = false;
dp[1][i][j] = 0;
//cout<<dp[0][i][j];
}//cout<<endl;
}
//cout<<endl;
}
int ans = 0;
for(int i=0; i<N; i++){
for(int j=0; j<M; j++){
ans+=(int)dp[0][i][j];
}
}
cout<<ans;
return 0;
}
Compilation message
nautilus.cpp: In function 'int main()':
nautilus.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d", &N, &M, &Q);
~~~~~^~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
9 ms |
504 KB |
Output is correct |
3 |
Correct |
11 ms |
504 KB |
Output is correct |
4 |
Correct |
11 ms |
508 KB |
Output is correct |
5 |
Correct |
8 ms |
504 KB |
Output is correct |
6 |
Correct |
7 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
9 ms |
504 KB |
Output is correct |
3 |
Correct |
11 ms |
504 KB |
Output is correct |
4 |
Correct |
11 ms |
508 KB |
Output is correct |
5 |
Correct |
8 ms |
504 KB |
Output is correct |
6 |
Correct |
7 ms |
504 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
15 ms |
504 KB |
Output is correct |
9 |
Correct |
15 ms |
540 KB |
Output is correct |
10 |
Correct |
12 ms |
504 KB |
Output is correct |
11 |
Correct |
10 ms |
504 KB |
Output is correct |
12 |
Correct |
7 ms |
504 KB |
Output is correct |
13 |
Correct |
13 ms |
504 KB |
Output is correct |
14 |
Correct |
20 ms |
504 KB |
Output is correct |
15 |
Correct |
16 ms |
632 KB |
Output is correct |
16 |
Correct |
13 ms |
504 KB |
Output is correct |
17 |
Correct |
7 ms |
504 KB |
Output is correct |
18 |
Correct |
12 ms |
420 KB |
Output is correct |
19 |
Correct |
23 ms |
504 KB |
Output is correct |
20 |
Correct |
19 ms |
632 KB |
Output is correct |
21 |
Correct |
16 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
504 KB |
Output is correct |
2 |
Correct |
9 ms |
504 KB |
Output is correct |
3 |
Correct |
11 ms |
504 KB |
Output is correct |
4 |
Correct |
11 ms |
508 KB |
Output is correct |
5 |
Correct |
8 ms |
504 KB |
Output is correct |
6 |
Correct |
7 ms |
504 KB |
Output is correct |
7 |
Correct |
8 ms |
504 KB |
Output is correct |
8 |
Correct |
15 ms |
504 KB |
Output is correct |
9 |
Correct |
15 ms |
540 KB |
Output is correct |
10 |
Correct |
12 ms |
504 KB |
Output is correct |
11 |
Correct |
10 ms |
504 KB |
Output is correct |
12 |
Correct |
7 ms |
504 KB |
Output is correct |
13 |
Correct |
13 ms |
504 KB |
Output is correct |
14 |
Correct |
20 ms |
504 KB |
Output is correct |
15 |
Correct |
16 ms |
632 KB |
Output is correct |
16 |
Correct |
13 ms |
504 KB |
Output is correct |
17 |
Correct |
7 ms |
504 KB |
Output is correct |
18 |
Correct |
12 ms |
420 KB |
Output is correct |
19 |
Correct |
23 ms |
504 KB |
Output is correct |
20 |
Correct |
19 ms |
632 KB |
Output is correct |
21 |
Correct |
16 ms |
504 KB |
Output is correct |
22 |
Execution timed out |
1073 ms |
1528 KB |
Time limit exceeded |
23 |
Halted |
0 ms |
0 KB |
- |