QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226821 | #7629. Make SYSU Great Again II | comeintocalm# | RE | 0ms | 0kb | C++20 | 881b | 2023-10-26 16:50:11 | 2023-10-26 16:50:11 |
answer
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 2105, TEST = 7;
int MX;
int RD()
{
return (rand() ^ (rand() << 14)) % MX;
}
int n;
int a[MAXN][MAXN];
int cnt[MAXN*MAXN*4];
int isfail;
int main()
{
scanf("%d", &n);
MX = 4*n*n;
isfail = 0;
for (int i = 1;i <= n; i++) {
for (int j = 1;j <= n; j++) {
int via = ~(a[i-1][j] | a[i][j-1]);
int MI = RD() & via;
for (int cas = 1; cas <= TEST; cas++) {
int x = RD() & via;
if (cnt[MI] > cnt[x]) {
MI = x;
}
}
if (cnt[MI] > 5) {
isfail = 1;
break;
}
cnt[MI]++;
a[i][j] = MI;
}
if (isfail == 1) {
break;
}
}
if (isfail == 1) {
printf("No\n");
} else {
printf("Yes\n");
for (int i = 1;i <= n; i++) {
for (int j = 1;j <= n; j++) {
printf("%d%c", a[i][j], j==n?'\n':' ');
}
}
}
}
详细
Test #1:
score: 0
Runtime Error
input:
4