QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#835651 | #9926. Flipping Paths | ucup-team5243# | WA | 1ms | 3640kb | C++17 | 1.9kb | 2024-12-28 13:30:12 | 2024-12-28 13:30:12 |
Judging History
answer
#ifdef NACHIA
#define _GLIBCXX_DEBUG
#else
#define NDEBUG
#endif
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using i64 = long long;
using u64 = unsigned long long;
#define rep(i,n) for(int i=0; i<int(n); i++)
const i64 INF = 1001001001001001001;
template<typename A> void chmin(A& l, const A& r){ if(r < l) l = r; }
template<typename A> void chmax(A& l, const A& r){ if(l < r) l = r; }
using namespace std;
void testcase(){
int H, W; cin >> H >> W;
vector<string> A(H); rep(y,H) cin >> A[y];
rep(t,2){
bool ok = true; {
vector<int> Q(H+W);
rep(y,H) rep(x,W) if(A[y][x] == 'W') Q[y+x] ^= 1;
if(Q != vector<int>(H+W,0)) ok = false;
}
if(!ok){
rep(y,H) rep(x,W) A[y][x] ^= 'B' ^ 'W';
continue;
}
rep(y,H) rep(x,W) A[y][x] = (A[y][x] == 'W' ? 1 : 0);
vector<string> ans;
for(int t=-(H-1); t<W-2; t++){
string f;
int y = 0, x = 0;
A[y][x] ^= 1;
rep(i,H+W-2){
if(x==W-1){ f.push_back('D'); y++; }
else if(y==H-1){ f.push_back('R'); x++; }
else if(x-y > t+1){ f.push_back('D'); y++; }
else if(x-y <= t){ f.push_back('R'); x++; }
else{
if(A[y+1][x]){ f.push_back('D'); y++; }
else { f.push_back('R'); x++; }
}
A[y][x] ^= 1;
}
ans.push_back(f);
}
if(A[0][W-1]) ans.push_back(string(W-1,'R') + string(H-1,'D'));
cout << "YES" << endl;
cout << ans.size() << endl;
for(auto& a : ans) cout << a << endl;
return;
}
cout << "NO" << endl;
}
int main(){
ios::sync_with_stdio(false); cin.tie(nullptr);
int T; cin >> T;
rep(t,T) testcase();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
4 3 3 WBB BWB BBW 1 5 WWWWW 2 2 BB BB 4 1 W B B W
output:
YES 4 DDRR RDRD RDRD RRDD YES 4 RRRR RRRR RRRR RRRR YES 2 RD RD NO
result:
ok ok (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3632kb
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 0 NO NO YES 0 YES 0 NO NO YES 0 YES 2 RR RR NO NO NO NO NO NO YES 2 RR RR YES 2 RD RD NO NO NO NO NO YES 2 DR RD NO NO YES 2 DR RD NO NO NO NO NO YES 2 RD RD YES 2 DD DD NO NO NO NO NO NO YES 2 DD DD YES 2 RRR RRR NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES 2 RRR RRR YES 2 RDR RDR NO NO NO NO ...
result:
wrong answer Jury has answer but participant has not. (test case 19)