QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#836746 | #9926. Flipping Paths | ucup-team3695# | WA | 1ms | 3612kb | C++20 | 1.6kb | 2024-12-29 05:12:26 | 2024-12-29 05:12:26 |
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;
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();
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.all() : P.none()))
{
odd = !odd;
for (size_t i = 0; i < n; i++)
for (size_t j = 0, u = i; j < m; j++, u++)
{
G[i].flip(j);
P.flip(u);
}
}
if (!(odd ? P.all() : 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: 100
Accepted
time: 1ms
memory: 3612kb
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 4 RRRR RRRR RRRR RRRR YES 2 DR DR NO
result:
ok ok (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3492kb
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 1 R YES 1 D NO NO YES 1 D YES 2 RR RR NO NO NO NO NO NO YES 2 RR RR YES 2 DR DR NO NO NO NO NO YES 2 RD DR NO NO YES 2 RD DR NO NO NO NO NO YES 2 DR DR YES 2 DD DD NO NO NO NO NO NO YES 2 DD DD YES 3 RRR RRR RRR NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES 3 RRR RRR RRR YES 3 RDR ...
result:
wrong answer Jury has answer but participant has not. (test case 19)