QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#757573#7878. Matrix Distancessurenjamts#WA 289ms19312kbC++201.1kb2024-11-17 10:47:202024-11-17 10:47:20

Judging History

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

  • [2024-11-17 10:47:20]
  • 评测
  • 测评结果:WA
  • 用时:289ms
  • 内存:19312kb
  • [2024-11-17 10:47:20]
  • 提交

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();
}

Details

Tip: Click on the bar to expand more detailed information

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'