#include <stdio.h>
#include <string.h>
int r, c, m, dx[] = { -1, 1, 0, 0 }, dy[] = { 0, 0, 1, -1 }, z;
char d[333], s[333][333];
int main() {
scanf("%d%d%d", &r, &c, &m);
for (int i = 0; i < r; ++i)
scanf("%s", s[i]);
scanf("%s", d);
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
int i_, j_, ok;
i_ = i, j_ = j, ok = 1;
if (s[i][j] == '#') continue;
for (int k = m - 1; k >= 0; --k) {
const char *ss = "EWNS";
int k_ = strchr(ss, d[k]) - ss;
i_ += dy[k_], j_ += dx[k_];
if (i_ < 0 || j_ < 0 || i_ >= r || j_ >= c || s[i_][j_] == '#') {
ok = 0;
break;
}
}
if (ok)
++z;
}
}
printf("%d\n", z);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
nautilus.c: In function 'main':
nautilus.c:8:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | scanf("%d%d%d", &r, &c, &m);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
nautilus.c:10:17: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
10 | scanf("%s", s[i]);
| ^~~~~~~~~~~~~~~~~
nautilus.c:11:9: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
11 | scanf("%s", d);
| ^~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |