結果
| 問題 |
No.1028 闇討ち
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-04-17 21:52:20 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 986 bytes |
| コンパイル時間 | 2,215 ms |
| コンパイル使用メモリ | 198,864 KB |
| 最終ジャッジ日時 | 2025-01-09 19:56:51 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 18 |
ソースコード
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using ld=long double;
template<class T>using numr=std::numeric_limits<T>;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n;std::cin>>n;
std::vector<std::vector<lint>>a(n,std::vector<lint>(n));
for(lint i=0;i<n;i++)for(lint j=0;j<n;j++){
lint x;std::cin>>x;x--;
a.at(x).at(i)=j;
}
lint ans=0;
for(auto&&v:a){
std::vector<lint>b(2*n);
for(lint i=0;i<n;i++){
lint j=v.at(i);
for(lint k:{n+i-j+1,n+i+j+1})if(k<2*n)b.at(k)++;
}
b.at(0)=-n;
std::partial_sum(ALL(b),b.begin());
b.at(0)=0;
for(lint i=0;i<n;i++){
b.at(0)+=n+i;
}
std::partial_sum(ALL(b),b.begin());
ans+=*std::min_element(b.begin()+n,b.begin()+2*n);
}
std::cout<<ans<<'\n';
}
ngtkana