답안 #304391

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
304391 2020-09-21T08:51:40 Z Hemimor Nautilus (BOI19_nautilus) C++14
100 / 100
225 ms 876 KB
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <bitset>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=500;
bitset<M> a[M],b[M];
int h,w,q;
string s;

int main(){
	cin>>h>>w>>q;
	for(int i=0;i<h;i++) for(int j=0;j<w;j++){
		char c;
		cin>>c;
		if(c=='.') a[i][j]=b[i][j]=1;
	}
	cin>>s;
	for(auto c:s){
		if(c=='E'){
			for(int i=0;i<h;i++) a[i]<<=1;
		}
		else if(c=='W'){
			for(int i=0;i<h;i++) a[i]>>=1;
		}
		else if(c=='N'){
			for(int i=0;i<h-1;i++) a[i]=a[i+1];
			a[h-1].reset();
		}
		else if(c=='S'){
			for(int i=h-1;i>=1;i--) a[i]=a[i-1];
			a[0].reset();
		}
		else{
			bitset<M> c[M],d[M];
			for(int i=0;i<M;i++) c[i]=(a[i]>>1)|(a[i]<<1);
			for(int i=0;i<h-1;i++) d[i]|=a[i+1];
			for(int i=1;i<h;i++) d[i]|=a[i-1];
			for(int i=0;i<M;i++) a[i]=c[i]|d[i];
		}
		for(int i=0;i<h;i++) a[i]&=b[i];
	}
	int res=0;
	for(int i=0;i<h;i++) res+=a[i].count();
	cout<<res<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 416 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 416 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 3 ms 416 KB Output is correct
8 Correct 3 ms 384 KB Output is correct
9 Correct 3 ms 384 KB Output is correct
10 Correct 3 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 4 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 4 ms 384 KB Output is correct
16 Correct 4 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 416 KB Output is correct
21 Correct 5 ms 384 KB Output is correct
22 Correct 113 ms 644 KB Output is correct
23 Correct 104 ms 640 KB Output is correct
24 Correct 102 ms 640 KB Output is correct
25 Correct 99 ms 744 KB Output is correct
26 Correct 98 ms 640 KB Output is correct
27 Correct 171 ms 744 KB Output is correct
28 Correct 170 ms 640 KB Output is correct
29 Correct 169 ms 640 KB Output is correct
30 Correct 175 ms 760 KB Output is correct
31 Correct 167 ms 640 KB Output is correct
32 Correct 219 ms 640 KB Output is correct
33 Correct 220 ms 876 KB Output is correct
34 Correct 221 ms 640 KB Output is correct
35 Correct 219 ms 640 KB Output is correct
36 Correct 225 ms 760 KB Output is correct