Submission #895264

#TimeUsernameProblemLanguageResultExecution timeMemory
895264vjudge1Nautilus (BOI19_nautilus)C++17
100 / 100
141 ms6900 KiB
// Problem: A - Nautilus
// Contest: Virtual Judge - Yosik IOI contest #1
// URL: https://vjudge.net/contest/601761#problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define all(v) (v).begin(),(v).end()
#define rall(v) ((v).rbegin()), ((v).rend())
#define out(v)  for(auto& i : v) cout << i << ' ';
#define F first
#define S second
#define int long long

const ll N = 5000 + 17;
const ll MOD = 1e9 + 7;
const string alf = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

char c[N][N];
bitset <505> a[N] , cop[N] , f, no[N] , es[N] , we[N] , so[N];

void solve (){
	int n , m , k;
	cin >> n >> m >> k;
	int ans = 0;
	for(int i = 1; i <= n; i ++){
		for(int j = 1;j <= m; j ++){
			cin >> c[i][j];
			if (c[i][j] == '.'){
				a[i][j] = 1;
				cop[i][j] = 1;
			}
		}
	}
	string s;
	cin >> s;
	for(int i = 0 ; i< s.size(); i ++){
		if (s[i] == 'W'){
			for(int i = 1; i <= n; i ++){
				a[i] >>= 1;
			}
		}
		else if (s[i] == 'E'){
			for(int i = 1; i <= n; i ++){
				a[i] <<= 1;
			}
		}
		else if (s[i] == 'S'){
			for(int i = n; i >= 2; i --){
				a[i] = a[i - 1];
			}
			a[1] = f;
		}
		else if (s[i] == 'N'){
			for(int i = 1; i <= n - 1; i ++){
				a[i] = a[i + 1];
			}
			a[n] = f;
		}
		else {
			for(int i = 1; i <= n; i ++){
				we[i] = (a[i] >> 1);
			}
			for(int i = 1; i <= n; i ++){
				es[i] = (a[i] << 1);
			}
			for (int i = 1; i <= n; i ++) {
   				 if (i != 1)no[i] = a[i - 1];
   				 if (i != n)so[i] = a[i + 1];
  			}
			for(int i =1; i <= n; i ++){
				a[i] = (((we[i] | es[i]) | no[i]) | so[i]);
			}
		}
		for(int i = 1; i <= n; i ++){
			a[i] &= cop[i];
		}
	}
	for(int i = 1; i <= n; i ++){
		for(int j = 1; j <= m; j ++){
			if (a[i][j]){
				ans ++;
			}
		}
	}
	cout << ans;
}

signed main(){
	// freopen("ones.in" , "r" , stdin) ;
	// freopen("ones.out" , "w" , stdout) ;
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	// int cs = 1;
	// cin >>T;
	while (T --){
		// cout <<"Case " << cs ++<< ":" << endl;
		solve ();
		// cout <<endl;
	}
}

Compilation message (stderr)

nautilus.cpp: In function 'void solve()':
nautilus.cpp:44:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(int i = 0 ; i< s.size(); i ++){
      |                  ~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...