# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
881928 | Requiem | Nautilus (BOI19_nautilus) | C++17 | 193 ms | 160484 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
#define MOD 1000000007
#define INF 1e18
#define fi first
#define se second
#define endl "\n"
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define sz(a) ((int)(a).size())
#define pi 3.14159265359
#define TASKNAME ""
template<typename T> bool maximize(T &res, const T &val) { if (res < val){ res = val; return true; }; return false; }
template<typename T> bool minimize(T &res, const T &val) { if (res > val){ res = val; return true; }; return false; }
using namespace std;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
const int MAXN = 5e2 + 9;
int n,m,k;
char c[MAXN][MAXN];
char dir[MAXN];
bitset<503> dp[5003][MAXN];
bitset<503> sea[MAXN];
main()
{
fast;
if (fopen(TASKNAME".inp","r")){
freopen(TASKNAME".inp","r",stdin);
freopen(TASKNAME".out","w",stdout);
}
cin>>n>>m>>k;
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
cin>>c[i][j];
if (c[i][j] == '.') sea[i][j] = 1;
if (c[i][j] != '#') dp[0][i][j]= 1;
}
}
for(int i=1;i<=k;i++){
cin>>dir[i];
}
int ans = 0;
for(int t=1;t<=k;t++){
for(int i=1;i<=n;i++){
if (dir[t] == 'E') dp[t][i] = (dp[t-1][i] << 1) & sea[i];
if (dir[t] == 'W') dp[t][i] = (dp[t-1][i] >> 1) & sea[i];
if (dir[t] == 'S') dp[t][i] = (dp[t-1][i-1]) & sea[i];
if (dir[t] == 'N') dp[t][i] = (dp[t-1][i+1]) & sea[i];
if (dir[t] == '?') dp[t][i] = (dp[t-1][i-1] | dp[t-1][i+1] | (dp[t-1][i]<<1) | (dp[t-1][i] >> 1)) & sea[i];
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
ans += dp[k][i][j];
}
}
cout<<ans<<endl;
}
컴파일 시 표준 에러 (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... |