求调
查看原帖
求调
556181
__Emerald__楼主2024/5/26 09:35

rt

WA:01_random_03.txt,01_random_26.txt,01_random_27.txt.

#include <bits/stdc++.h>
using namespace std;
int n,t,b[200005],r[200005],c[200005],ha,hb;
//r[i]=i行被标记的数量,c[i]=i列被标记的数量,ha,hb为对角线被标记的数量 
//bool a[2005][2005];
int main(){
	cin >> n >> t;
	for (int i = 1;i <= t;i++){
		cin >> b[i];
//		a[(b[i] - 1) / n + 1][(b[i] - 1) % n + 1] = true;
		r[(b[i] - 1) / n + 1]++,c[(b[i] - 1) % n + 1]++;
		if ((b[i] - 1) / n + 1 == (b[i] - 1) % n + 1) ha++;
		if ((b[i] - 1) / n + 1 + (b[i] - 1) / n + 1 == n + 1) hb++;
		if (r[(b[i] - 1) / n + 1] == n || c[(b[i] - 1) % n + 1] == n || ha == n || hb == n){
			cout << i;
			return 0;
		}
	}
	cout << -1;
	return 0;
}
2024/5/26 09:35
加载中...