QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#849313#9926. Flipping Pathsucup-team3161#WA 106ms75348kbC++141.8kb2025-01-09 14:31:202025-01-09 14:31:30

Judging History

你现在查看的是最新测评结果

  • [2025-01-09 14:31:30]
  • 评测
  • 测评结果:WA
  • 用时:106ms
  • 内存:75348kb
  • [2025-01-09 14:31:20]
  • 提交

answer

// what is matter? never mind. 
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define ull unsigned long long
//#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 2000005
#define inf 0x3f3f3f3f

int n,m;
string s[maxn];
int a[205][205];

vector<string>res;
void op(int x,int y){
	string now;
	a[1][1]^=1;
	For(i,2,y) now+='R',a[1][i]^=1;
	For(i,2,x) now+='D',a[i][y]^=1;
	For(i,y+1,m) now+='R',a[x][i]^=1;
	For(i,x+1,n) now+='D',a[i][m]^=1;
	res.pb(now);
}

bool tmp[maxn];
bool chk(){
	For(i,2,n+m)tmp[i]=0;
	For(i,1,n)For(j,1,m)tmp[i+j]^=a[i][j];
	For(i,2,n+m)if(tmp[i]!=tmp[2])return 0;
	return 1;
}

void work()
{
	n=read(),m=read(); res.clear();
	For(i,0,n-1)cin>>s[i];
	For(i,1,n)For(j,1,m)a[i][j]=(s[i-1][j-1]=='B');
	if(!chk()){
		For(i,1,n)For(j,1,m)a[i][j]^=1;
		if(!chk()){
			puts("NO");
			return;
		}
	}
	
	For(j,1,m-1){
		Rep(i,n,2){
			if(a[i][j]){
				op(i,j);
			}
		}
	}
	if(a[n][m]) op(n,m);
	For(i,1,n)For(j,1,m)if(a[i][j]){
		puts("NO");
		return;
	}
	puts("YES");
	cout<<res.size()<<"\n";
	for(auto it:res) cout<<it<<"\n";
}

signed main()
{
	int T=read();
	while(T--)work();
	return 0;
}
/*

*/

詳細信息

Test #1:

score: 100
Accepted
time: 7ms
memory: 68156kb

input:

4
3 3
WBB
BWB
BBW
1 5
WWWWW
2 2
BB
BB
4 1
W
B
B
W

output:

YES
2
DDRR
RRDD
YES
0
YES
0
NO

result:

ok ok (4 test cases)

Test #2:

score: 0
Accepted
time: 16ms
memory: 66360kb

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
0
YES
1
D
NO
NO
YES
0
YES
1
RR
NO
NO
NO
NO
NO
NO
YES
0
YES
0
NO
YES
1
RD
NO
YES
1
DR
NO
YES
2
DR
RD
NO
NO
YES
2
DR
RD
NO
YES
1
DR
NO
YES
1
RD
NO
YES
0
YES
1
DD
NO
NO
NO
NO
NO
NO
YES
0
YES
1
RRR
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
0
YES
0
NO
NO
NO
NO
NO
YES
1
RRD
NO
NO
NO
...

result:

ok ok (323 test cases)

Test #3:

score: 0
Accep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RD
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
3
DDRR
RDDR
RRDD
NO
NO
NO
NO
NO
YES
3
DDRR
RDRD
RRDD
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
3
DRRD
RDRD
RRDD
NO
NO
NO
NO
NO
YES
3
DRRD
RDDR
RRDD
NO
NO
NO
YES
2
DRRD
RDRD
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
2
DRRD
...

result:

ok ok (333 test cases)

Test #5:

score: 0
Accepted
time: 12ms
memory: 67996kb

input:

266
3 3
WWB
WWW
WWW
3 3
WWW
BBB
BBB
3 3
WWW
BBB
BBW
3 3
WWW
BBB
BWB
3 3
WWW
BBB
BWW
3 3
WWW
BBB
WBB
3 3
WWW
BBB
WBW
3 3
WWW
BBB
WWB
3 3
WWW
BBB
WWW
3 3
WWW
BBW
BBB
3 3
WWW
BBW
BBW
3 3
WWW
BBW
BWB
3 3
WWW
BBW
BWW
3 3
WWW
BBW
WBB
3 3
WWW
BBW
WBW
3 3
WWW
BBW
WWB
3 3
WWW
BBW
WWW
3 3
WWW
BWB
BBB
3 3
WWW
...

output:

NO
NO
NO
NO
YES
3
RDDR
RDRD
RRDD
NO
NO
NO
NO
NO
YES
1
RRDD
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
3
DDRR
DRRD
RRDD
NO
NO
NO
NO
NO
YES
5
DDRR
DRRD
RDDR
RDRD
RRDD
NO
NO
NO
YES
2
DDRR
DRRD
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
4
DDRR
DRRD
RDDR
RDRD
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
2
RDDR
RDRD
NO
NO
NO
NO
NO...

result:

ok ok (266 test cases)

Test #6:

score: 0
Accepted
time: 15ms
memory: 67224kb

input:

245
4 2
WW
BB
WB
BW
4 2
WW
BB
WB
WB
4 2
WW
BB
WB
WW
4 2
WW
BB
WW
BB
4 2
WW
BB
WW
BW
4 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NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
...

result:

ok ok (200 test cases)

Test #8:

score: 0
Accepted
time: 14ms
memory: 67264kb

input:

200
5 4
BWWB
WBWW
WBWW
WBWW
WBBW
5 4
BWWB
WBWW
WBWW
WBWW
WBWB
5 4
BWWB
WBWW
WBWW
WBWW
WBWW
5 4
BWWB
WBWW
WBWW
WBWW
WWBB
5 4
BWWB
WBWW
WBWW
WBWW
WWBW
5 4
BWWB
WBWW
WBWW
WBWW
WWWB
5 4
BWWB
WBWW
WBWW
WBWW
WWWW
5 4
BWWB
WBWW
WBWW
WWBB
BBBB
5 4
BWWB
WBWW
WBWW
WWBB
BBBW
5 4
BWWB
WBWW
WBWW
WWBB
BBWB
5 4
BW...

output:

NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
6
DDDDRRR
RDDDRRD
RDDRRDD
RRDDDDR
RRDDRDD
RRDRDDD
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
6
DDDDRRR
RDDDRRD
RDDRRDD
RRDDDRD
RRDDRDD
RRDRDDD
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
6
DDDDRRR
RDDDDRR
RDDRRDD
RRDDDRD
RRDDRDD
RRDRDDD
NO
...

result:

ok ok (200 test cases)

Test #9:

score: -100
Wrong Answer
time: 106ms
memory: 75348kb

input:

5
200 200
WBWWWBWBWWWWBWWWBBBBBBWBWWBWWBBWBWWBWBBBWBBWBBWBWBBWWWWWWBWWWBBWBWBWBWBBWBWWBWWBWBBBWWWBWBBWWBBBBBWWBBBBWWBBWBWWWBBWBWBWWWWBBWBWWBWWWWWBWWBBBBBWBBWBWWWWWBWWWBWBWWBBBBWWBWWWWBWBBWBWBBWWBWWBBWBWBWWBWBWB
BBWBBBBBWBWWWWWWWWWWBBWWWWBWWBWWBBBBBWWWBWBWWBBWBBWWBBBBBWWBWBWBWWBWBWBBBBWWWWBWBBBBBWBBB...

output:

YES
19742
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR...

result:

wrong answer Integer 19742 violates the range [0, 400] (test case 1)