QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#689978#7878. Matrix Distanceszyq_313#RE 0ms3628kbC++14693b2024-10-30 19:31:242024-10-30 19:31:24

Judging History

你现在查看的是最新测评结果

  • [2024-10-30 19:31:24]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3628kb
  • [2024-10-30 19:31:24]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define BUG cout << "HERE IS A BUG !!!!\n"

#define endl '\n'
#define ll long long
const int N = 1010;

int n, m;
vector<pair<int,int> >a[1010];
int main(){
    cin >> n >> m;
    for (int i = 1; i <= n; i ++){
        for (int j = 1; j <= m; j ++){
            int x;
            cin >> x;
            a[x].push_back({i,j});
        }
    }
    ll ans=0;
    for(int i=1;i<=1000;i++){
        for(int j=0;j<a[i].size();j++){
            for(int k=j+1;k<a[i].size();k++){
                ans=ans+abs(a[i][j].first-a[i][k].first)+abs(a[i][j].second-a[i][k].second);
            }
        }
    }
    cout<<ans*2;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3624kb

input:

2 2
1 1
2 2

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

4 4
1 3 2 4
2 1 2 3
1 3 3 2
3 2 1 4

output:

152

result:

ok 1 number(s): "152"

Test #3:

score: -100
Runtime Error

input:

1000 1000
227980299 227980299 227980299 227980299 227980299 776958596 227980299 227980299 227980299 227980299 227980299 227980299 227980299 227980299 227980299 227980299 776958596 227980299 227980299 329001637 227980299 227980299 227980299 329001637 227980299 227980299 227980299 227980299 227980299 ...

output:


result: