QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#865202 | #9926. Flipping Paths | piggy123# | WA | 0ms | 3712kb | C++17 | 4.2kb | 2025-01-21 16:01:19 | 2025-01-21 16:01:19 |
Judging History
answer
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll a[205][205];
char c[205][205];
int main() {
cin.tie(0);cout.tie(0);
ios::sync_with_stdio(false);
ll t;
cin >> t;
while (t--) {
ll n,m;
cin >> n >> m;
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++) {
cin >> c[i][j];
a[i][j]=(c[i][j]=='W'?0:1);
}
}
vector<string> ans;
bool ok=0;
for (ll C=0; C<=1; C++) {
for (ll i=1; i<=n; i++) {
for (ll j=1; j<=m; j++) {
a[i][j]^=1;
}
}
bool fl=1;
vector<string> all;
for (ll i=1; i<=n+m; i++) {
vector<pair<ll,ll>> vct;
for (ll j=1; j<=n; j++) {
ll t=i-j;
if (t<1||t>m)continue;
vct.push_back({j,t});
}
ll xo=0;
for (auto j:vct) {
xo^=a[j.first][j.second];
}
if (xo!=0) {
fl=0;
break;
}else{
ll rev=0;
for (ll j=0;j+1<vct.size();j++){
if ((a[vct[j].first][vct[j].second]^rev)!=0){
string s="";
ll nwx=1,nwy=1;
for (;nwx<vct[j].first;){
s+="D";
nwx++;
}
for (;nwy<vct[j].second;){
s+="R";
nwy++;
}
for (;nwx<n;){
s+="D";
nwx++;
}
for (;nwy<m;){
s+="R";
nwy++;
}
all.push_back(s);
nwx=1,nwy=1;s="";
for (;nwx<vct[j].first;){
s+="D";
nwx++;
}
for (;nwy+1<vct[j].second;){
s+="R";
nwy++;
}
s+="D";
s+="R";
nwx++,nwy++;
for (;nwx<n;){
s+="D";
nwx++;
}
for (;nwy<m;){
s+="R";
nwy++;
}
all.push_back(s);
rev=1;
}else{
rev=0;
}
}
}
}
if (fl&&all.size()<=400){
ans=all;ok=1;
}
}
if (ok){
cout<<"YES\n";
cout<< ans.size()<<"\n";
for (auto i:ans)cout<<i<<"\n";
}else{
cout<<"NO\n";
}
}
return 0;
}
/*
■■■■■ ■■ ■■■ ■■■ ■ ■ ■ ■■■■ ■■■■
■ ■■ ■■ ■ ■■ ■ ■■ ■ ■ ■■ ■ ■■ ■■ ■
■ ■ ■■ ■ ■ ■ ■ ■ ■ ■■■ ■■ ■■ ■ ■■
■ ■ ■■ ■ ■ ■ ■ ■ ■ ■■ ■ ■■ ■■
■ ■ ■■ ■ ■ ■■ ■■ ■■ ■
■ ■■ ■■ ■ ■■■ ■ ■■■ ■■ ■■ ■■ ■■■
■■■■■ ■■ ■ ■ ■ ■ ■■ ■■ ■■ ■■
■ ■■ ■ ■ ■ ■ ■■ ■■ ■■ ■
■ ■■ ■ ■ ■ ■ ■■ ■■ ■ ■ ■■
■ ■■ ■■ ■■ ■■ ■■ ■■ ■■ ■ ■■ ■■
■ ■■ ■■■■ ■■■■ ■■ ■■ ■■■■■■ ■■■■
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3584kb
input:
4 3 3 WBB BWB BBW 1 5 WWWWW 2 2 BB BB 4 1 W B B W
output:
YES 8 RDDR DRDR RRDD RDRD DRDR DDRR DRRD DRDR YES 0 YES 0 NO
result:
ok ok (4 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3712kb
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 0 NO NO NO NO NO NO YES 0 YES 0 NO NO NO NO NO YES 2 RD DR NO NO YES 2 RD DR NO NO NO NO NO YES 0 YES 0 NO NO NO NO NO NO YES 0 YES 0 NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES 0 YES 0 NO NO NO NO NO NO NO NO NO YES 2 RRD RDR NO NO NO NO NO NO NO NO NO YES ...
result:
wrong answer Jury has answer but participant has not. (test case 19)