結果
| 問題 | No.3558 Dominoes, Black and White |
| コンテスト | |
| ユーザー |
forest3
|
| 提出日時 | 2026-06-09 13:51:35 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 644 bytes |
| 記録 | |
| コンパイル時間 | 1,209 ms |
| コンパイル使用メモリ | 188,244 KB |
| 実行使用メモリ | 15,228 KB |
| 最終ジャッジ日時 | 2026-06-09 13:51:44 |
| 合計ジャッジ時間 | 8,741 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
| 純コード判定待ち |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| 部分点 | 10 % | AC * 30 |
| 満点 | 90 % | AC * 89 |
| 合計 | 100 点 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < b; i++)
using ll = long long;
int main(){
int n;
cin >> n;
vector<string> s(n);
rep(i, 0, n) cin >> s[i];
vector<int> l, r;
int n2 = n * 2;
rep(i, 0, n) {
rep(j, 0, n2) {
if(s[i][j] == '#' && j < n) l.push_back(i * n2 + j);
if(s[i][j] == '.' && j >= n) r.push_back(i * n2 + j);
}
}
sort(l.begin(), l.end());
sort(r.begin(), r.end());
ll ans = 0;
int sz = l.size();
rep(i, 0, sz) {
int ry = r[i] / n2;
int rx = r[i] % n2;
int ly = l[i] / n2;
int lx = l[i] % n2;
ans += abs(ry - ly) + abs(rx - lx);
}
cout << ans << endl;
}
forest3