Submission #496536

# Submission time Handle Problem Language Result Execution time Memory
496536 2021-12-21T13:17:14 Z Nuraly_Serikbay Nautilus (BOI19_nautilus) C++14
29 / 100
2 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];
	}
}

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;
	for (int i = 0; i < s.size(); ++ i) {
		if (s[i] == '?' || s[i] == 'E') {
			for (int j = 1; j <= n; ++ j) {
				left (j);
			}
		}	
		if (s[i] == '?' || s[i] == 'W') {
			for (int j = 1; j <= n; ++ j) {
				right(j);
			}
		}
		if (s[i] == '?' || s[i] == 'N') {
			for (int j = 1; j <= n; ++ j) {
				up (j);
			}
		}
		if (s[i] == '?' || s[i] == 'S') {
			for (int j = n; j >= 1; -- j) {
				down (j);
			}
		}
	}
	ll totalans = 0;
	for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= m; ++ j) {
	//		cout << ships[i][j];
			if (ships[i][j]) totalans ++;
		}
	//	cout << '\n';
	}
	cout << totalans;
	/*for (int i = 1; i <= n; ++ i) {
		for (int j = 1; j <= m; ++ j) {
			cout << ships[i][j];
		}
		cout << '\n';
	}
	cout << '\n';
	for (int i = n; i >= 1; -- i) {
		down (i);
		for (int j = 1; j <= m; ++ j) {
			cout << ships[i][j];
		}
		cout << '\n';
	}*/
	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 'int main()':
nautilus.cpp:112:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  112 |  for (int i = 0; i < s.size(); ++ i) {
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Incorrect 2 ms 332 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Incorrect 2 ms 332 KB Output isn't correct
8 Halted 0 ms 0 KB -