結果

問題 No.3558 Dominoes, Black and White
コンテスト
ユーザー ha_chan
提出日時 2026-05-29 19:49:01
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 788 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,537 ms
コンパイル使用メモリ 338,632 KB
実行使用メモリ 13,564 KB
最終ジャッジ日時 2026-05-29 19:49:10
合計ジャッジ時間 7,460 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_1
純コード判定待ち
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点 10 % AC * 30
満点 90 % AC * 89
合計 100 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<VL> VVL;
typedef long long LL;
#define all(a) (a).begin(), (a).end()
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back

int main() {std::ios_base::sync_with_stdio(false);   std::cin.tie(NULL);
  LL n;cin>>n;
  string s;
  VI B;
  LL wa=0;
  rep(i,n){cin>>s;
    rep(j,2*n){
      if(s[j]=='#'){wa+=j+1; B.pb(i);}
    }
  }
  LL ans=n*n*(3*n+1)/2-wa;
  sort(all(B));
  //cout<<ans<<endl;
  VI A;
  rep(i,n)rep(j,n){A.pb(i);}
  rep(i,n*n){ans+=abs(A[i]-B[i]);}
  cout<<ans<<endl;
}
0