이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define UPLOAD
#define ll long long
#define endl '\n'
const ll MOD = 998244353;
const ll INF = 1e16;
const ll MAX = 1e5+1;
int n,m,c;
vector<vector<int>> moves(200, vector<int>(2));
bool checkValid(int a, int b){
return (b >= 0 && a < n) && (b >= 0 && b < m);
}
void solve(){
cin>>n>>m>>c;
moves['W'] = {0, -1};
moves['S'] = {1, 0};
moves['N'] = {-1, 0};
moves['E'] = {0, 1};
bool arr[n][m];
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
char temp; cin>>temp;
arr[i][j] = temp == '.';
}
}
bool temp[n][m];
for(int x = 0; x < c; x++){
char command; cin>>command;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
bool ans = false;
if(command == '?'){
for(char cur : "WSEN"){
ans = checkValid(i + moves[command][0], j + moves[command][1]);
if(ans){
ans = arr[i + moves[command][0]][j + moves[command][1]];
}
if(ans) break;
}
}else{
ans = checkValid(i + moves[command][0], j + moves[command][1]);
if(ans){
ans = arr[i + moves[command][0]][j + moves[command][1]];
}
}
temp[i][j] = ans;
}
}
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
arr[i][j] = temp[i][j];
}
}
}
int ans = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
ans+= arr[i][j];
}
}
cout<<ans;
}
int main()
{
cin.tie(NULL);
ios::sync_with_stdio(NULL);
int t = 1;
//cin >> t;
while(t--){
//cout<<"----------"<<endl;
solve();
cout<<endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
nautilus.cpp: In function 'void solve()':
nautilus.cpp:42:15: warning: unused variable 'cur' [-Wunused-variable]
42 | for(char cur : "WSEN"){
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |