# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
955637 | n3rm1n | Nautilus (BOI19_nautilus) | C++17 | 1064 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const int MAXN = 505, MAXCELL = 3e5+10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int n, m, t;
int a[MAXN][MAXN];
string operations;
bitset < MAXCELL > fr;
void read()
{
cin >> n >> m >> t;
char s;
for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
{
cin >> s;
if(s == '#')
{
a[i][j] = 1;
}
else
{
fr[(i-1) * m + j] = 1;
// cout << i << " " << j << " is coded as " << (i-1) * m + j << endl;
}
}
}
cin >> operations;
//cout << fr.count() << endl;
}
bitset < MAXCELL > ans, last, newmove;
void go_south()
{
newmove = (newmove | (last << m));
newmove = (newmove & fr);
}
void go_north()
{
newmove = (newmove | (last >> m));
newmove = (newmove & fr);
}
void go_east()
{
newmove = (newmove | (last << 1));
newmove = (newmove & fr);
}
void go_west()
{
newmove = (newmove | (last >> 1));
newmove = (newmove & fr);
}
void solve_for(int start)
{
last = (last ^ last);
last[start] = 1;
last = (last & fr);
for (int i = 0; i < operations.size(); ++ i)
{
newmove = (newmove ^ newmove);
if(operations[i] == '?' || operations[i] == 'N')go_north();
if(operations[i] == '?' || operations[i] == 'S')go_south();
if(operations[i] == '?' || operations[i] == 'E')go_east();
if(operations[i] == '?' || operations[i] == 'W')go_west();
last = newmove;
}
last = (last & fr);
ans = (ans | last);
}
void solve()
{
for (int start = 1; start <= n*m; ++ start)
{
solve_for(start);
}
cout << ans.count() << endl;
/*for (int i = 1; i <= n; ++ i)
{
for (int j = 1; j <= m; ++ j)
cout << ans[(i-1) * m + j] << " ";
cout << endl;
}*/
}
int main()
{
speed();
read();
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |