답안 #496229

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496229 2021-12-21T03:28:27 Z vinnipuh01 Nautilus (BOI19_nautilus) C++17
0 / 100
3 ms 332 KB
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>

using namespace std;

const long long oo = 1000000000000000000;

long long int  sum, ans = 0, mx = 0, mn = 1000000000, num, pos;


/*
    ViHHiPuh

   (( `'-""``""-'` ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / `;#'#'# - #'#'#;` \
 \_)) -----'#'----- ((_/
      # --------- #
  '# ------- ------ #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))


    cout << fixed << setprecision(6) << x;

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    freopen ( "sum.in", "r", stdin )
*/

string s;
int n, m, k;
char c[ 501 ][ 501 ];
bool mp[ 501 ][ 501 ];

void ok( int x, int y, int o = 0 ) {
	char i;
	for ( int j = o; j < s.size(); j ++ ) {
		i = s[ j ];
		if ( i == 'N' ) {
			x --;
			if ( x <= 0 || c[ x ][ y ] == '#' )
				return;
		}
		else if ( i == 'E' ) {
			y ++;
			
			if ( y > m || c[ x ][ y ] == '#' )
				return;
		}
		else if ( i == 'S' ) {
			x ++;
			if ( x > n || c[ x ][ y ] == '#' )
				return;
		}
		else if ( i == 'W' ) {
			y--;
			if ( y <= 0 || c[ x ][ y ] == '#' )
				return;
		}
		else {
			if ( x < n )
				ok( x + 1, y, o + 1 );
			if ( x > 1 )
				ok( x - 1, y, o + 1 );
			if ( y < m )
				ok( x, y + 1, o + 1 );
			if ( y > 1 )
				ok( x, y - 1, o + 1 );
		}
	}
	mp[ x ][ y ] = 1;
}

int main () {
	cin >> n >> m >> k;
	for ( int i = 1; i <= n; i ++ ) {
		for ( int j = 1; j <= m; j ++ ) {
			cin >> c[ i ][ j ];
		}
	}
	cin >> s;
	for ( int i = 1; i <= n; i ++ ) {
		for ( int j = 1; j <= m; j ++ ) {
			if ( c[ i ][ j ] != '#' )
				ok( i, j );
		}
	}
	for ( int i = 1; i <= n; i ++ ) {
		for ( int j = 1; j <= m; j ++ )
			ans += mp[ i ][ j ];
	}
	cout << ans / 2;
}


/*
5 9 7
...##....
..#.##..#
..#....##
.##...#..
....#....
WSEEN


*/

Compilation message

nautilus.cpp: In function 'void ok(int, int, int)':
nautilus.cpp:52:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |  for ( int j = o; j < s.size(); j ++ ) {
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -