社区讨论
90pts求助
P14358[CSP-J 2025] 座位参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @mhphxq8p
- 此快照首次捕获于
- 2025/11/08 07:38 4 个月前
- 此快照最后确认于
- 2025/11/09 02:29 4 个月前
CPP
#include <bits/stdc++.h>
using namespace std;
int n,m,ans,x = 1,y = 1,sum = 1,fx = 0,vis = 0;
int a[105];
int main() {
// freopen("seat.in","r",stdin);
// freopen("seat.out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
cin >> n >> m;
for(int i = 1; i <= n * m; i++) {
cin >> a[i];
}
ans = a[1];
sort(a+1,a+1+n*m,greater<int>());
for(int i = 1; i <= n * m; i++) {
if(a[i] == ans) {
ans = i;
break;
}
}
// cout << ans << endl;
while(sum <= n * m) {
if(sum == ans) {
cout << y << " " << x;
return 0;
}
// cout << x << " " << y << endl;
// cout << sum << endl;
if(!vis && sum % n == 0) {
vis = true;
y++;
if((sum / n) % 2 == 1) {
fx = 1;
} else {
fx = 0;
}
} else {
vis = false;
if(fx == 0) {
x++;
} else {
x--;
}
}
sum++;
}
return 0;
}
机试原码,不知道错哪了
回复
共 2 条回复,欢迎继续交流。
正在加载回复...