답안 #651290

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
651290 2022-10-18T07:14:09 Z Kenpar Nautilus (BOI19_nautilus) C++17
0 / 100
4 ms 340 KB
#include "bits/stdc++.h"
using namespace std;
#define UPLOAD
#define ll long long
#define endl '\n'

const ll MOD = 998244353;
const ll INF = 1e16;
const ll MAX = 1e5+1;
int n,m,c;

vector<vector<int>> moves(200, vector<int>(2));
bool checkValid(int a, int b){
	return (b >= 0 && a < n) && (b >= 0 && b < m);
}
void solve(){
	cin>>n>>m>>c;

	moves['W'] = {0, -1};
	moves['S'] = {1, 0};
	moves['N'] = {-1, 0};
	moves['E'] = {0, 1};

	bool arr[n][m];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			char temp; cin>>temp;

			arr[i][j] = temp == '.'; 
		}
	}
	bool temp[n][m];

	for(int x = 0; x < c; x++){
		char command; cin>>command;

		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				bool ans = false;

				if(command == '?'){
					for(char cur : "WSEN"){
						ans = checkValid(i + moves[command][0], j + moves[command][1]);

						if(ans){
							ans = arr[i + moves[command][0]][j + moves[command][1]];
						}

						if(ans) break;
					}
				}else{
					ans = checkValid(i + moves[command][0], j + moves[command][1]);

					if(ans){
						ans = arr[i + moves[command][0]][j + moves[command][1]];
					}
				}

				temp[i][j] = ans;
			}
		}

		for(int i = 0; i < n; i++){
			for(int j = 0; j < m; j++){
				arr[i][j] = temp[i][j];
			}
		}
	}

	int ans = 0;

	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			ans+= arr[i][j];
		}
	}

	cout<<ans;
}


int main()
{
	cin.tie(NULL);
	ios::sync_with_stdio(NULL);
	int t = 1;

	//cin >> t;

	while(t--){
		//cout<<"----------"<<endl;
		solve();
		cout<<endl;
	}
}

Compilation message

nautilus.cpp: In function 'void solve()':
nautilus.cpp:42:15: warning: unused variable 'cur' [-Wunused-variable]
   42 |      for(char cur : "WSEN"){
      |               ^~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -