提出 #32002676


ソースコード 拡げる

Copy
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void fast_io() {
cin.tie(0)->sync_with_stdio(0);
}
const int MAX = 100;
char board[MAX + 1][MAX + 1];
void solve() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) cin >> board[i];
int si = -1, sj = -1;
for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
if (board[i][j] == '-') continue;
if (si == -1) si = i, sj = j;
else {
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void fast_io() {
  cin.tie(0)->sync_with_stdio(0);
}

const int MAX = 100;
char board[MAX + 1][MAX + 1];

void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> board[i];

  int si = -1, sj = -1;
  for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
    if (board[i][j] == '-') continue;
    if (si == -1) si = i, sj = j;
    else {
      cout << abs(si - i) + abs(sj - j) << '\n';
      return;
    }
  }
}

int main() {
  fast_io();

  int t = 1;
  // cin >> t;
  while (t--) solve();
}

提出情報

提出日時
問題 B - Distance Between Tokens
ユーザ megagenie
言語 C++ (GCC 9.2.1)
得点 200
コード長 624 Byte
結果 AC
実行時間 7 ms
メモリ 3536 KB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 200 / 200
結果
AC × 2
AC × 13
セット名 テストケース
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 7 ms 3456 KB
example_01.txt AC 2 ms 3512 KB
test_00.txt AC 3 ms 3524 KB
test_01.txt AC 3 ms 3520 KB
test_02.txt AC 3 ms 3524 KB
test_03.txt AC 6 ms 3460 KB
test_04.txt AC 3 ms 3536 KB
test_05.txt AC 2 ms 3536 KB
test_06.txt AC 3 ms 3464 KB
test_07.txt AC 2 ms 3472 KB
test_08.txt AC 3 ms 3524 KB
test_09.txt AC 2 ms 3532 KB
test_10.txt AC 3 ms 3512 KB


2025-03-20 (木)
07:29:25 +00:00