提出 #32005549
ソースコード 拡げる
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &a) {
char c;for (c = getchar(); (c < '0' || c > '9') && c != '-'; c = getchar());bool f = c == '-';T x = f ? 0 : (c ^ '0');for (c = getchar(); c >= '0' && c <= '9'; c = getchar()) {x = x * 10 + (c ^ '0');}a = f ? -x : x;
}
template <typename T, typename ...Argv>
inline void read(T &a, Argv &...argv) {
read(a), read(argv...);
}
int n, m;
char a[1000][1000];
signed main() {
read(n, m);
for (int i = 1; i <= n; ++i) {
scanf("%s", a[i] + 1);
}
int x1 = 0, x2 = 0, y1, y2;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (a[i][j] == 'o') {
if (x1) {
x2 = i;
y2 = j;
} else {
x1 = i;
y1 = j;
}
}
}
}
printf("%d\n", abs(x1 - x2) + abs(y1 - y2));
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | B - Distance Between Tokens |
| ユーザ | rsdbk_husky_undo |
| 言語 | C++ (GCC 9.2.1) |
| 得点 | 200 |
| コード長 | 838 Byte |
| 結果 | AC |
| 実行時間 | 8 ms |
| メモリ | 3820 KiB |
コンパイルエラー
./Main.cpp: In function ‘int main()’:
./Main.cpp:18:8: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
18 | scanf("%s", a[i] + 1);
| ~~~~~^~~~~~~~~~~~~~~~
./Main.cpp:34:39: warning: ‘y2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
34 | printf("%d\n", abs(x1 - x2) + abs(y1 - y2));
| ~~~^~~~
./Main.cpp:34:39: warning: ‘y1’ may be used uninitialized in this function [-Wmaybe-uninitialized]
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 200 / 200 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example_00.txt, example_01.txt |
| All | example_00.txt, example_01.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_00.txt | AC | 8 ms | 3668 KiB |
| example_01.txt | AC | 2 ms | 3468 KiB |
| test_00.txt | AC | 2 ms | 3752 KiB |
| test_01.txt | AC | 2 ms | 3532 KiB |
| test_02.txt | AC | 2 ms | 3684 KiB |
| test_03.txt | AC | 2 ms | 3668 KiB |
| test_04.txt | AC | 3 ms | 3764 KiB |
| test_05.txt | AC | 2 ms | 3520 KiB |
| test_06.txt | AC | 2 ms | 3820 KiB |
| test_07.txt | AC | 2 ms | 3528 KiB |
| test_08.txt | AC | 2 ms | 3820 KiB |
| test_09.txt | AC | 3 ms | 3792 KiB |
| test_10.txt | AC | 2 ms | 3696 KiB |