QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#593920 | #6677. Puzzle: Sashigane | Proaes | WA | 0ms | 3804kb | C++20 | 5.7kb | 2024-09-27 16:59:28 | 2024-09-27 16:59:28 |
Judging History
answer
/**
* title: l.cpp
* author: Proaes Meluam
* created: 2024-09-27 15:09:35
**/
#include <bits/stdc++.h>
#ifdef LOCAL
#include "algo/debug.h"
#else
#define debug(...) 42
#endif
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double pi = acos(-1);
const double E = exp(1);
constexpr ll mod = 1e9 + 7;
constexpr int inf = 0x3f3f3f3f;
// constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
class dur {
public:
int l, r;
};
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n, x, y;
cin >> n >> x >> y;
vector<tuple<int, int, int, int>> tl;
vector<vector<int>> g(n + 1, vector<int>(n + 1));
auto add = [&](int x, int y, int h, int w) {
tl.emplace_back(x, y, h, w);
g[x][y]++;
for (int i = 1; i <= h; ++ i) {
g[x + i][y]++;
}
for (int i = h; i <= -1; ++ i) {
g[x + i][y]++;
}
for (int i = 1; i <= w; ++ i) {
g[x][y + i]++;
}
for (int i = w; i <= -1; ++ i) {
g[x][y + i]++;
}
};
auto f = [&](dur row, dur col) {
if (x - row.l <= row.r - x) {
if (y - col.l <= col.r - y) {
return 1;
} else {
return 2;
}
} else {
if (y - col.l <= col.r - y) {
return 3;
} else {
return 4;
}
}
};
auto f2 = [&](dur row, dur col) {
if (x == row.l) {
if (y == col.l) {
// tl.emplace_back(row.r, col.r, -1, -1);
// cout << row.r << " " << col.r << " " << -1 << " " << -1 << "\n";
add(row.r, col.r, -1, -1);
} else {
// tl.emplace_back(row.r, col.l, -1, 1);
// cout << row.r << " " << col.l << " " << -1 << " " << 1 << "\n";
add(row.r, col.l, -1, 1);
}
} else {
if (y == col.l) {
// tl.emplace_back(row.l, col.r, 1, -1);
// cout << row.l << " " << col.r << " " << 1 << " " << -1 << "\n";
add(row.l, col.r, 1, -1);
} else {
// tl.emplace_back(row.l, col.l, 1, 1);
// cout << row.l << " " << col.l << " " << 1 << " " << 1 << "\n";
add(row.l, col.l, 1, 1);
}
}
};
if (n == 1) {
cout << "Yes" << "\n";
cout << 0 << "\n";
} else {
cout << "Yes" << "\n";
dur row, col;
row.l = 1, row.r = n;
col.l = 1, col.r = n;
int need = inf;
need = min(need, x - row.l);
need = min(need, row.r - x);
need = min(need, y - col.l);
need = min(need, col.r - y);
int h, w;
for (int i = 1; i <= need; ++ i) {
h = row.r - i - 1;
w = col.r - i;
// tl.emplace_back(i, i, h, w);
// cout << i << " " << i << " " << h << " " << w << "\n";
add(i, i, h, w);
h = -(row.r - i - 1);
w = -(col.r - i);
// tl.emplace_back(row.r, col.r, h, w);
// cout << row.r << " " << col.r << " " << h << " " << w << "\n";
add(row.r, col.r, h, w);
row.l ++;
row.r --;
col.l ++;
col.r --;
}
int flag = f(row, col);
if (flag == 1) {
while (1) {
if (x == row.r || y == col.r) break;
int h = -(row.r - row.l);
int w = -(col.r - col.l);
// tl.emplace_back(row.r, col.r, h, w);
// cout << row.r << " " << col.r << " " << h << " " << w << "\n";
add(row.r, col.r, h, w);
row.r --;
col.r --;
}
if (x != row.r || y != col.r) f2(row, col);
} else if (flag == 2) {
while (1) {
if (x == row.r || y == col.l) break;
int h = -(row.r - row.l);
int w = (col.r - col.l);
// tl.emplace_back(row.r, col.l, h, w);
// cout << row.r << " " << col.l << " " << h << " " << w << "\n";
add(row.r, col.l, h, w);
row.r --;
col.l ++;
}
if (x != row.r || y != col.l) f2(row, col);
} else if (flag == 3) {
while (1) {
if (x == row.l || y == col.r) break;
int h = (row.r - row.l);
int w = -(col.r - col.l);
// tl.emplace_back(row.l, col.r, h, w);
// cout << row.l << " " << col.r << " " << h << " " << w << "\n";
add(row.l, col.r, h, w);
row.l ++;
col.r --;
}
if (x != row.l || y != col.r) f2(row, col);
} else if (flag == 4) {
while (1) {
if (x == row.l || y == col.l) break;
int h = (row.r - row.l);
int w = (col.r - col.l);
// tl.emplace_back(row.l, col.l, h, w);
// cout << row.l << " " << col.l << " " << h << " " << w << "\n";
add(row.l, col.l, h, w);
row.l ++;
col.l ++;
}
if (x != row.l || y != col.l) f2(row, col);
}
cout << (int)tl.size() << "\n";
for (auto [a, b, c, d] : tl) {
cout << a << " " << b << " " << c << " " << d << "\n";
}
}
// for (int i = 1; i <= n; ++ i) {
// for (int j = 1; j <= n; ++ j) {
// cout << g[i][j];
// }
// cout << "\n";
// }
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3636kb
input:
5 3 4
output:
Yes 4 1 1 3 4 5 5 -3 -4 4 2 -2 2 2 3 1 1
result:
ok Correct. (1 test case)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3532kb
input:
1 1 1
output:
Yes 0
result:
ok Correct. (1 test case)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 2 3
output:
Yes 2 3 1 -2 2 1 2 1 1
result:
ok Correct. (1 test case)
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3636kb
input:
10 10 5
output:
Yes 6 1 10 9 -9 2 9 8 -8 3 8 7 -7 4 7 6 -6 5 6 5 -5 6 1 1 1
result:
wrong answer At least one cell is left uncovered. (test case 1)