QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#757573 | #7878. Matrix Distances | surenjamts# | WA | 289ms | 19312kb | C++20 | 1.1kb | 2024-11-17 10:47:20 | 2024-11-17 10:47:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define S second
#define F first
void solve(){
int n,m;
cin>>n>>m;
int a[n][m];
map<int,vector<int>> vx,vy;
map<int,int> mp, sum;
int ans=0;
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin>>a[i][j];
vx[a[i][j]].push_back(i);
vy[a[i][j]].push_back(j);
mp[a[i][j]]++;
}
}
// int ans=0;
for(auto x: vx){
sort(x.second.begin(),x.second.end());
int sum=0, cnt=0;
for(int j: x.second){
if(cnt>0){
ans+=j*cnt-sum;
}
sum+=j;
cnt++;
}
// cout<<x.first<<" "<<ans<<endl;
}
for(auto y: vy){
sort(y.second.begin(),y.second.end());
int sum=0, cnt=0;
for(int j: y.second){
if(cnt>0){
ans+=j*cnt-sum;
}
sum+=j;
cnt++;
}
}
cout<<ans*2<<endl;
}
int main(){
int t=1; // cin >> t; while(t--) solve();
solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
2 2 1 1 2 2
output:
4
result:
ok 1 number(s): "4"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3548kb
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
Wrong Answer
time: 289ms
memory: 19312kb
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:
-579751876
result:
wrong answer 1st numbers differ - expected: '506784086339644', found: '-579751876'