QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#836760 | #9926. Flipping Paths | ucup-team3695# | WA | 1ms | 3764kb | C++20 | 1.8kb | 2024-12-29 05:36:37 | 2024-12-29 05:36:44 |
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(n - 1, 'D') << string(m - 1, 'R') << '\n';
}
}
/*
4
3 3
WBB
BWB
BBW
1 5
WWWWW
2 2
BB
BB
4 1
W
B
B
W
*/
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3532kb
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 RRRR YES 2 DR DR NO
result:
ok ok (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3764kb
input:
323 1 2 BB 1 2 BW 1 2 WB 1 2 WW 2 1 B B 2 1 B W 2 1 W B 2 1 W W 1 3 BBB 1 3 BBW 1 3 BWB 1 3 BWW 1 3 WBB 1 3 WBW 1 3 WWB 1 3 WWW 2 2 BB BB 2 2 BB BW 2 2 BB WB 2 2 BB WW 2 2 BW BB 2 2 BW BW 2 2 BW WB 2 2 BW WW 2 2 WB BB 2 2 WB BW 2 2 WB WB 2 2 WB WW 2 2 WW BB 2 2 WW BW 2 2 WW WB 2 2 WW WW 3 1 B B B 3 ...
output:
YES 1 R NO NO YES 2 R R YES 1 D NO NO YES 2 D D YES 2 RR RR NO NO NO NO NO NO YES 3 RR RR RR YES 2 DR DR NO YES 3 RD DR DR NO YES 3 DR DR DR NO YES 2 RD DR NO NO YES 2 RD DR NO YES 3 DR DR DR NO YES 3 RD DR DR NO YES 2 DR DR YES 2 DD DD NO NO NO NO NO NO YES 3 DD DD DD YES 3 RRR RRR RRR NO NO NO NO ...
result:
wrong answer cell (1,2) contains different color with (1,1) after all ops. (test case 57)