QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#836756 | #9926. Flipping Paths | ucup-team3695# | WA | 0ms | 3624kb | C++20 | 1.8kb | 2024-12-29 05:33:50 | 2024-12-29 05:33:50 |
Judging History
answer
#include <bits/extc++.h>
using namespace std;
namespace rg = ranges;
namespace vw = views;
static inline void go(size_t), pre();
static constexpr size_t MN = 200, MK = 2 * MN - 1;
static bitset<MN> G[MN];
static bitset<MK> P, P1;
static size_t n, m, k;
int main()
{
cin.tie(0)->sync_with_stdio(0);
size_t T;
cin >> T;
for (size_t i = 0; i < T; i++)
go(i);
}
void pre() {}
void go(size_t)
{
cin >> n >> m;
k = n + m - 2;
P.reset();
P1.reset();
for (size_t u = 0; u <= k; u++)
P1.set(u);
for (size_t i = 0; i < n; i++)
for (size_t j = 0, u = i; j < m; j++, u++)
{
char c;
cin >> c;
bool g = (c == 'W');
G[i][j] = g;
P[u] = P[u] ^ g;
}
bool odd = P[0];
if (!(odd ? P == P1 : P.none()))
{
odd = !odd;
for (size_t i = 0; i < n; i++)
G[i].flip();
for (size_t u = 0; u <= k; u++)
{
size_t len = n + m - (u > (n - 1) ? u - (n - 1) : (n - 1) - u) - (u > (m - 1) ? u - (m - 1) : (m - 1) - u);
P[u] = P[u] ^ (((len + 1) / 2) & 1);
}
}
if (!(odd ? P == P1 : P.none()))
{
cout << "NO\n";
return;
}
cout << "YES\n" << k + odd << '\n';
for (size_t ai = 0; ai < k; ai++)
{
size_t i = 0, j = 0, v = m - 1;
G[0].flip(0);
auto const R = [&]()
{
cout << 'R';
j++;
v--;
G[i].flip(j);
};
auto const D = [&]()
{
cout << 'D';
i++;
v++;
G[i].flip(j);
};
while (v > ai + 1)
R();
while (v < ai + 1)
D();
while (i < n - 1 & j < m - 1)
{
if (G[i][j + 1])
{
R();
D();
}
else
{
D();
R();
}
}
while (i < n - 1)
D();
while (j < m - 1)
R();
cout << '\n';
}
if (odd)
{
cout << string('D', n - 1) << string('R', m - 1) << '\n';
}
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
input:
4 3 3 WBB BWB BBW 1 5 WWWWW 2 2 BB BB 4 1 W B B W
output:
YES 4 RRDD DRDR DRDR DDRR YES 5 RRRR RRRR RRRR RRRR
result:
wrong answer Line "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~...\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04\x04" doesn't correspond to pattern "[RD]{4}" (test case 2)