QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226817 | #7629. Make SYSU Great Again II | comeintocalm# | RE | 0ms | 0kb | C++20 | 881b | 2023-10-26 16:48:21 | 2023-10-26 16:48:22 |
answer
#include <cstdio>
#include <algorithm>
using namespace std;
const int MAXN = 2005, 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':' ');
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Runtime Error
input:
4