이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
template<typename T1, typename T2> bool chkmin(T1 &x, T2 y) { return y < x ? (x = y, true) : false; }
template<typename T1, typename T2> bool chkmax(T1 &x, T2 y) { return y > x ? (x = y, true) : false; }
void debug_out()
{
cerr << endl;
}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B)
{
cerr << ' ' << A;
debug_out(B...);
}
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif
const int maxN = 502;
int n, m, k;
using BitSet = bitset<maxN * maxN>;
BitSet dp[2];
BitSet grid;
BitSet E, W;
signed main()
{
#ifdef DEBUG
freopen("in", "r", stdin);
#endif
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m >> k;
for (int i = 0; i < n; ++i)
{
string s;
cin >> s;
for (int j = 0; j < m; ++j)
{
if (s[j] == '.')
{
grid[i * m + j] = 1;
}
}
}
E = grid;
for (int i = 0; i < n; ++i)
E[i * m] = 0;
W = grid;
for (int i = 0; i < n; ++i)
W[i * m + m - 1] = 0;
dp[0] = grid;
string I;
cin >> I;
for (int l = 1; l <= k; ++l)
{
dp[l & 1].reset();
char c = I[l - 1];
if (c == 'E' || c == '?')
{
dp[l & 1] |= E & (dp[l & 1 ^ 1] << 1);
}
if (c == 'W' || c == '?')
{
dp[l & 1] |= W & (dp[l & 1 ^ 1] >> 1);
}
if (c == 'S' || c == '?')
{
dp[l & 1] |= grid & (dp[l & 1 ^ 1] << m);
}
if (c == 'N' || c == '?')
{
dp[l & 1] |= grid & (dp[l & 1 ^ 1] >> m);
}
}
cout << dp[k & 1].count() << '\n';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
nautilus.cpp: In function 'int main()':
nautilus.cpp:81:36: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
dp[l & 1] |= E & (dp[l & 1 ^ 1] << 1);
~~^~~
nautilus.cpp:85:36: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
dp[l & 1] |= W & (dp[l & 1 ^ 1] >> 1);
~~^~~
nautilus.cpp:89:39: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
dp[l & 1] |= grid & (dp[l & 1 ^ 1] << m);
~~^~~
nautilus.cpp:93:39: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
dp[l & 1] |= grid & (dp[l & 1 ^ 1] >> m);
~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |