이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 10;
bitset<MAXN> cur[MAXN];
bitset<MAXN> walls[MAXN];
int main(){
ios_base::sync_with_stdio(false); cin.tie(0);
int rows, cols, K; cin >> rows >> cols >> K;
for(int r = 0;r < rows;r++){
string s; cin >> s;
for(int c = 0;c < cols;c++){
int bit = (s[c] == '.');
cur[r][c] = bit;
walls[r][c] = bit;
}
}
string command; cin >> command;
for(char c : command){
if(c == 'W'){
for(int r = 0;r < rows;r++) cur[r] <<= 1;
}
if(c == 'E'){
for(int r = 0;r < rows;r++) cur[r] >>= 1;
}
if(c == 'N'){
for(int r = 0;r < rows-1;r++) cur[r] = cur[r+1];
for(int c = 0;c < cols;c++) cur[rows-1][c] = 0;
}
if(c == 'S'){
for(int r = rows-1;r >= 1;r--) cur[r] = cur[r-1];
for(int c = 0;c < cols;c++) cur[0][c] = 0;
}
if(c == '?'){
assert(false);
}
for(int r = 0;r < rows;r++) cur[r] &= walls[r];
/*
cout << c << ":\n";
for(int r = 0;r < rows;r++){
for(int c = 0;c < cols;c++){
cout << cur[r][c];
}
cout << "\n";
}
cout << "\n\n";
*/
}
int ans = 0;
for(int r = 0;r < rows;r++) ans += cur[r].count();
cout << ans;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |