QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#122772 | #6644. Red Black Grid | wnmrmr# | Compile Error | / | / | C++23 | 2.4kb | 2023-07-11 03:08:29 | 2023-07-11 03:08:30 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-11 03:08:30]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-11 03:08:29]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T){ cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) //cerr<<"(" << #__VA_ARGS__<<"):" , dbg_out(__VA_ARGS__) , cerr << endl
#define pb push_back
// #define int long long
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int n, k;
void solve () {
cin >> n >> k;
int mx = 2 * (n - 1) * n;
if (k == 1 || k == mx - 1) {
cout << "Impossible\n";
return;
}
vector ans (n, vector<int> (n));
cout << "Possible\n";
if (k < n * (n - 1)) {
int i = 0;
while (k > n) {
for (int j = 0; j < n; j++) ans[i][j]++;
i += 2;
if (j) k -= n;
k -= n;
}
if (k > 0) {
for (int j = 0; j < k - 1; j++) ans[i][j]++;
}
}
else if (k >= n * (n - 1)) {
// se for maior que a metade
// vamos quadricular
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) ans[i][j] = (i + j) & 1;
vector<pair<int, int>> adj[5];
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++) if (!ans[i][j]) {
int vis = 0;
for (int p = 0; p < 4; p++) {
int ii = i + dx[p], jj = j + dy[p];
if (ii < 0 || ii >= n || jj < 0 || jj >= n) continue;
vis++;
}
// dbg (vis);
adj[vis].pb ({i, j});
}
auto paint = [&] (int id) {
auto [x, y] = adj[id].back (); adj[id].pop_back ();
ans[x][y] ^= 1;
};
if (k & 1) {
paint (3);
}
while (k > 6) {
if (adj[3].size () < 2) break;
paint (3);
paint (3);
k -= 6;
}
while (k > 2) {
if (adj[4].size () == 0) break;
paint (4);
k -= 4;
}
if (k == 2) paint (2);
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (ans[i][j]) cout << 'R';
else cout << 'B';
}
cout << "\n";
}
}
signed main () {
ios::sync_with_stdio(0);cin.tie(0);
int t; cin >> t;
while (t--)
solve ();
}
详细
answer.code: In function ‘void solve()’: answer.code:36:17: error: ‘j’ was not declared in this scope 36 | if (j) k -= n; | ^