社区讨论

95分求助

P14358[CSP-J 2025] 座位参与者 2已保存回复 2

讨论操作

快速查看讨论及其快照的属性,并进行相关操作。

当前回复
2 条
当前快照
1 份
快照标识符
@mhqm506j
此快照首次捕获于
2025/11/09 02:23
3 个月前
此快照最后确认于
2025/11/16 14:06
3 个月前
查看原帖
CPP
#include<bits/stdc++.h>
using namespace std;
int n,m,b[100],xb;
bool cmp(int x,int y){
	return x>y;
}
int main(){
	//freopen("seat.in","r",stdin);
	//freopen("seat.out","w",stdout);
	cin>>n>>m;
	for(int i=1;i<=n*m;i++){
		cin>>b[i];
	}
	int a=b[1];
	sort(b+1,b+n*m+1,cmp);
	for(int i=1;i<=n*m;i++){
		if(a==b[i]){
			xb=i;
			break;
		}
	}
	if(xb%n==0){
		if((xb/n)%2!=0) cout<<(xb/n)<<" "<<n;
		else cout<<(xb/n)<<" "<<1;
	}else{
		if(((xb/n)+1)%2!=0) cout<<(xb/n)+1<<" "<<xb%n;
		else cout<<(xb/n)+1<<" "<<n+1-(xb%n);
	}
	return 0;
}

回复

2 条回复,欢迎继续交流。

正在加载回复...