50pts求调
查看原帖
50pts求调
769907
WSZZ666楼主2024/1/23 15:29
#include <bits/stdc++.h>
using namespace std;
double fa[1001],fb[1001];
struct out{
	int a,b;
}buffer[1000001];
int cnt=0;
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		double fc=0;
		double pj=0;
		double a[1001];
		for(int j=1;j<=m;j++){
			cin>>a[j];
			pj+=a[j];
		}
		pj/=m;
		for(int j=1;j<=m;j++){
			fc+=pow(a[j]*1.00-pj,2);
		}
		fa[i]=fc;
	}
	for(int i=1;i<=n;i++){
		double fc=0;
		double pj=0;
		double a[1001];
		for(int j=1;j<=m;j++){
			cin>>a[j];
			pj+=a[j];
		}
		pj/=m;
		for(int j=1;j<=m;j++){
			fc+=pow(a[j]*1.00-pj,2);
		}
		fa[i]+=fc;
	}
	int ans=0;;
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n-1;j++){
			if(fa[j]>fa[j+1]){
				swap(fa[j],fa[j+1]);
				buffer[++ans]={j,j+1};
			}
		}
	}
	cout<<ans<<endl;
	for(int i=1;i<=ans;i++){
		cout<<buffer[i].a<<' '<<buffer[i].b<<endl;
	}
}

WA on #4 未升序 #7 #8 #9 #10 wrong answer Integer 999 violates the range [1, 998]

2024/1/23 15:29
加载中...