結果

問題 No.1028 闇討ち
ユーザー penguinhumpenguinhum
提出日時 2020-04-17 21:57:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,923 bytes
コンパイル時間 2,010 ms
コンパイル使用メモリ 196,904 KB
実行使用メモリ 16,140 KB
最終ジャッジ日時 2024-04-14 14:08:35
合計ジャッジ時間 21,291 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 25 ms
6,940 KB
testcase_10 AC 41 ms
6,940 KB
testcase_11 AC 258 ms
6,940 KB
testcase_12 AC 1,942 ms
15,504 KB
testcase_13 AC 1,914 ms
15,472 KB
testcase_14 AC 827 ms
11,648 KB
testcase_15 AC 171 ms
6,940 KB
testcase_16 TLE -
testcase_17 TLE -
testcase_18 TLE -
testcase_19 TLE -
testcase_20 TLE -
testcase_21 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG//TLEの原因になるので注意!!!!!!!!!!!
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

vector<pair<int,int>> A[1005];

int main(){
    int n;
    cin >> n;
    int a[n][n];
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
            a[i][j]--;
            A[a[i][j]].push_back(mp(i,j));
        }
    }
    ll ans=0;
    rep(k,n){//社員kについて
        int tt=INF;
        rep(i,n){//点(i,0)より出撃
            int temp=0;
            rep(j,n){//爆撃地点
                int x,y;
                tie(x,y)=A[k][j];
                temp+=max(abs(x-i),y);
            }
            //if(temp<tt) cerr<<i;
            tt=min(tt,temp);
        }
        //cerr<<endl;
        ans+=tt;
    }
    cout<<ans<<endl;
    return 0;
}

0