이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 550;
int r,c,m;
bitset<maxn> dp[2][maxn], a[maxn];
vector<pair<int,int>> adj = {mp(0,-1),mp(0,1),mp(1,0),mp(-1,0)};
void solve() {
cin >> r >> c >> m;
for(int i = 0; i < r; i++) {
string s; cin >> s;
for(int j = 0; j < c; j++) {
if(s[j] == '.') a[i+1][j+1] = 1;
}
}
string s; cin >> s;
for(int i = 1; i <= r; i++) {
for(int j = 1; j <= c; j++) {
dp[0][i][j] = a[i][j];
}
}
for(int k = 1; k <= m; k++) {
for(int i = 1; i <= r; i++) {
if(s[k-1] == '?') {
dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
}
else {
if(s[k-1] == 'S') dp[k&1][i] = a[i]&dp[k&1^1][i-1];
if(s[k-1] == 'N') dp[k&1][i] = a[i]&dp[k&1^1][i+1];
if(s[k-1] == 'W') dp[k&1][i] = a[i]&(dp[k&1^1][i]>>1);
if(s[k-1] == 'E') dp[k&1][i] = a[i]&(dp[k&1^1][i]<<1);
}
}
}
int ans = 0;
for(int i = 1; i <= r; i++) {
for(int j = 1; j <= c; j++) {
ans+= dp[m&1][i][j];
}
}
cout << ans << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
nautilus.cpp: In function 'void solve()':
nautilus.cpp:38:41: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
38 | dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
| ~^~
nautilus.cpp:38:59: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
38 | dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
| ~^~
nautilus.cpp:38:77: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
38 | dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
| ~^~
nautilus.cpp:38:94: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
38 | dp[k&1][i] = a[i]&((dp[k&1^1][i]>>1)|(dp[k&1^1][i]<<1)|(dp[k&1^1][i-1])|(dp[k&1^1][i+1]));
| ~^~
nautilus.cpp:41:57: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
41 | if(s[k-1] == 'S') dp[k&1][i] = a[i]&dp[k&1^1][i-1];
| ~^~
nautilus.cpp:42:57: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
42 | if(s[k-1] == 'N') dp[k&1][i] = a[i]&dp[k&1^1][i+1];
| ~^~
nautilus.cpp:43:58: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
43 | if(s[k-1] == 'W') dp[k&1][i] = a[i]&(dp[k&1^1][i]>>1);
| ~^~
nautilus.cpp:44:58: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
44 | if(s[k-1] == 'E') dp[k&1][i] = a[i]&(dp[k&1^1][i]<<1);
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |