結果
問題 |
No.1028 闇討ち
|
ユーザー |
![]() |
提出日時 | 2020-04-17 22:06:28 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,170 bytes |
コンパイル時間 | 832 ms |
コンパイル使用メモリ | 91,212 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-10-03 13:08:53 |
合計ジャッジ時間 | 3,683 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | WA * 20 |
ソースコード
#include<iostream> #include<iomanip> #include<cmath> #include<string> #include<vector> #include<algorithm> #include<map> #include<queue> #include<stack> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair const int inf=1e9+7; const ll mod=1e9+7; int main() { int N; cin>>N; vector<vector<pair<int, int> > >arr(N); int tmp; for(int i=0;i<N;++i){ for(int j=0;j<N;++j){ cin>>tmp; tmp--; arr[tmp].push_back(make_pair(i, j)); } } vector<int> xarr; vector<int> x1; for(int i=0;i<N;++i){ xarr.clear(); for(int j=0;j<N;++j){ xarr.push_back(arr[i][j].fi); } sort(xarr.begin(), xarr.end()); x1.push_back(xarr[N/2]); } int x, y; for(int i=0;i<N;++i){ for(int j=0;j<N;++j){ x = arr[i][j].fi; y = arr[i][j].se; arr[i][j] = make_pair(abs(x-x1[i]), abs(y)); } } int ans = 0; for(int i=0;i<N;++i){ for(int j=0;j<N;++j){ ans += max(arr[i][j].fi, arr[i][j].se); } } cout<<ans-1<<endl; }