我真的看不懂怎么回事
查看原帖
我真的看不懂怎么回事
917713
Secretive_Fighter楼主2022/12/25 14:03

代码:

#include<bits/stdc++.h>
using namespace std;
const int S=2*1e3+200;
int M,N,K,L,D,fx,fy,sx,sy,id=1;
int g[S][S];
struct node{
	int id;
	int number;
	node(){
		id=0;
	}
	node(int a,int b){
		id=a;
		number=b;
	}
}row[S],col[S];
int p,q;
//struct talk{
//	int fx,fy;
//	int sx,sy;
//}sp[S];
//bool cmp(talk a,talk b){
//	
//}
bool cmp1(node a,node b){
	return a.number>b.number;
}
bool cmp2(node a,node b){
	return a.id<b.id;
}
int main(){
//  freopen(".in","r",stdin);
//  freopen(".out","w",stdout);
	scanf("%d%d%d%d%d",&M,&N,&K,&L,&D);
	for(int i=1;i<=D;++i){
		scanf("%d%d%d%d",&fx,&fy,&sx,&sy);
		g[fx][fy]=id;
		g[sx][sy]=id++;
	}
//	sort(sp+1,sp+1+D,cmp);
//	for(int i=1;i<=M;++i){
//		for(int j=1;j<=N;++j)
//			cout<<g[i][j]<<" ";
//		cout<<endl;
//	}
	for(int i=1;i<=M-1;++i){
		int now=0;
		for(int j=1;j<=N;++j)
			if(g[i+1][j]!=0&&g[i][j]!=0&&g[i][j]==g[i+1][j]){
				++now;
//				cout<<i<<" "<<j<<" "<<i+1<<" "<<j<<endl;
			}
//		cout<<now<<" ";
		col[++p]=node(i,now);
	}
	//cout<<p<<endl;
//	cout<<endl;
	sort(col+1,col+1+p,cmp1);
	for(int i=1;i<=N-1;++i){
		int now=0;
		for(int j=1;j<=M;++j)
			if(g[j][i]!=0&&g[j][i+1]!=0&&g[j][i]==g[j][i+1])
				++now;
//		cout<<now<<" ";
		row[++q]=node(i,now);
	}	
	sort(row+1,row+1+q,cmp1);
	
	sort(col+1,col+1+K,cmp2);
	sort(row+1,row+1+L,cmp2);
	for(int i=1;i<=K;++i)
		printf("%d ",col[i].id);
	printf("\n");
	for(int i=1;i<=L;++i)
		printf("%d ",row[i].id);
	return 0;
}
//5 5 3 3 5
//1 1 0 3 0
//2 2 0 3 0
//0 0 0 0 0
//0 4 4 5 5
//0 0 0 0 0
/*
5 5 3 3 5
1 1 1 2
2 1 2 2
1 4 2 4
4 2 4 3
4 4 4 5
*/

30分,谁救救我啊!

2022/12/25 14:03
加载中...