QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#689978 | #7878. Matrix Distances | zyq_313# | RE | 0ms | 3628kb | C++14 | 693b | 2024-10-30 19:31:24 | 2024-10-30 19:31:24 |
Judging History
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;
}
詳細信息
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 ...