QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385870 | #7629. Make SYSU Great Again II | KKT89 | WA | 1ms | 3860kb | C++17 | 1.3kb | 2024-04-11 09:17:39 | 2024-04-11 09:17:40 |
Judging History
answer
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) { return (ull)rng() % B; }
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<vector<int>> a(n, vector<int>(n));
int m = 4 * n * n;
vector<short> cnt(m);
auto dfs = [&](auto dfs, int x, int y) -> void {
if (x == n) {
cout << "Yes\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (j) cout << " ";
cout << a[i][j];
}
cout << "\n";
}
exit(0);
}
if (y == n) {
dfs(dfs, x + 1, 0);
return;
}
for (int _ = 0; _ < 100; _++) {
int u = myRand(m);
if (cnt[u] == 5) continue;
if (x and (a[x - 1][y] & a[x][y])) continue;
if (y and (a[x][y - 1] & a[x][y])) continue;
cnt[u] += 1;
a[x][y] = u;
dfs(dfs, x, y + 1);
cnt[u] -= 1;
}
};
dfs(dfs, 0, 0);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3860kb
input:
4
output:
Yes 29 25 38 57 25 9 1 22 20 42 7 14 14 13 13 27
result:
wrong answer There exist two adjacent numbers whose bitwise AND value is greater than 0.