結果
| 問題 | No.3558 Dominoes, Black and White |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-06-01 11:45:11 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 427 ms / 2,000 ms |
| コード長 | 777 bytes |
| 記録 | |
| コンパイル時間 | 1,350 ms |
| コンパイル使用メモリ | 216,080 KB |
| 実行使用メモリ | 99,456 KB |
| 最終ジャッジ日時 | 2026-06-01 11:45:25 |
| 合計ジャッジ時間 | 13,967 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
| 純コード判定待ち |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 10 % | AC * 30 |
| 満点 | 90 % | AC * 89 |
| 合計 | 100 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
const int N = 2000010, MOD = 998244353, INF = 0x3f3f3f3f;
int n, m, w[N];
char s[1001][2002];
void solve() {
scanf("%d", &n);
for (int i = 1; i < n + 1; i++) scanf("%s", s[i] + 1);
set<pii> a, b;
for (int i = 1; i < n + 1; i++) {
for (int j = 1; j < n * 2 + 1; j++) {
if (j <= n && s[i][j] == '#') a.insert({i, j});
if (j > n && s[i][j] == '.') b.insert({i, j});
}
}
int res = 0;
while (a.size() && b.size()) {
auto x = *a.begin(), y = *b.begin();
a.erase(a.begin()), b.erase(b.begin());
res += abs(x.first - y.first) + abs(x.second - y.second);
}
printf("%d\n", res);
}
int main() {
int T = 1;
// scanf("%d", &T);
while (T--) solve();
return 0;
}