답안 #496541

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
496541 2021-12-21T13:24:23 Z Nuraly_Serikbay Nautilus (BOI19_nautilus) C++14
0 / 100
1 ms 332 KB
#include <bits/stdc++.h>
  
#define endl "\n"
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz size()
#define rep(i,k,n) for(int i = k ; i <= n ; ++i)
#define per(i,k,n) for(int i = k ; i >= n ; --i)
#define Zymraq() ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define fr(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
#define toqta return 0
#define PERMUTE next_permutation
#define no cout<<"No"<<endl;
#define yes cout<<"Yes"<<endl;
#define a() a + 1, a + n + 1  
 
  
using namespace std;
   
typedef long long ll;
typedef unsigned long long ull;
typedef string S;
typedef double ld;
typedef long double lld;
   
const int N = 1e6 + 17;
const int modd = 1e9 + 7;
const int INF = 1e9 - 19;
const int P = 37;
const ll NN = 1e7 + 17;
const ld eps = 1e-19;
const double pi = 3.141592653589793238462643383279 ;
   
 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b){
    return (a.second < b.second);
}
 
void pre (ll a) {
    cout << fixed << setprecision(a);
    return;
} 

ll n, m, k;
bool grid [200][200], ships[200][200];
string s;

void left (ll j) {
	ll last = ships[j][1], new_last;
	ships[j][1] = 0;
	for (int i = 2; i <= m; ++ i) {
		new_last = ships[j][i];
		ships[j][i] = last;
		last =  new_last;
	}
	for (int i = 1; i <= m; ++ i) {
		ships[j][i] = ships[j][i] & grid[j][i]; 
	}
	return;
}

void right (ll i) {
	for (int j = 1; j < m; ++ j) {
		ships[i][j] = ships[i][j + 1];
	}
	ships[i][m] = 0;
	for (int j = 1; j <= m; ++ j) {
		ships[i][j] = ships[i][j] & grid[i][j];
	}
	return;
}

void up (ll i) {
	if (i == n) {
		for (int j = 1; j <= m; ++ j) {
			ships[i][j] = 0;
		}
	}
	for (int j = 1; j <= m; ++ j) {
		ships[i][j] = ships[i + 1][j] & grid[i][j];
	}
	return;
}

void down (ll i) {
	for (int j = 1; j <= m; ++ j) {
		ships[i][j] = ships[i - 1][j] & grid[i][j];
	}
}


void solution () {
	for (int i = 0; i < s.size(); ++ i) {
		if (s[i] == 'E') {
			for (int j = 1; j <= n; ++ j) {
				left (j);
			}
		}	
		if (s[i] == 'W') {
			for (int j = 1; j <= n; ++ j) {
				right(j);
			}
		}
		if (s[i] == 'N') {
			for (int j = 1; j <= n; ++ j) {
				up (j);
			}
		}
		if (s[i] == 'S') {
			for (int j = n; j >= 1; -- j) {
				down (j);
			}
		}
	}
	return;
}

int main (/*Serikbay Nuraly*/) {
	Zymraq();
	cin >> n >> m >> k;	
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= m; ++ j) {
			char x;
			cin >> x;
			if (x == '#') {
				grid[i][j] = 0;
				ships[i][j] = 0;
			}
			else {
				grid[i][j] = 1;
				ships[i][j] = 1;
			}
		}
	}
	cin >> s;
	solution ();	
	return 0;
}
/*
3 3 2 1
1 2 1
1 3 1
1 2 3
2 2 
3 1


*/

Compilation message

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