QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#835380#9926. Flipping Pathsucup-team5657#AC ✓61ms3872kbC++142.9kb2024-12-28 11:33:372024-12-28 11:33:37

Judging History

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

  • [2024-12-28 11:33:37]
  • 评测
  • 测评结果:AC
  • 用时:61ms
  • 内存:3872kb
  • [2024-12-28 11:33:37]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const int N = 205;

int T, n, m, f[N << 1], g[N << 1];

string s[N], tmp[N];
vector <string> ans;

inline void op(int i, int j) {
	s[i][j] = (s[i][j] == 'W') ? 'B' : 'W';
}

inline void op(string S) {
	int x = 1, y = 1;
	op(1, 1);
	for (auto ch: S) {
		if (ch == 'D') {
			++x;
		} else {
			++y;
		}
		op(x, y);
	}
}

inline void solve() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		cin >> s[i];
		s[i] = "#" + s[i];
	}
	bool flg = 0;
	if (n > m) {
		flg = 1;
		for (int i = 1; i <= n; ++i) {
			tmp[i] = s[i];
		}
		swap(n, m);
		for (int i = 1; i <= n; ++i) {
			s[i] = "#";
			for (int j = 1; j <= m; ++j) {
				s[i] += tmp[j][i];
			}
		}
	}
	for (int i = 0; i <= n + m; ++i) {
		f[i] = 0;
		g[i] = 0;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			if (s[i][j] == 'W') {
				f[i + j] ^= 1;
			} else {
				g[i + j] ^= 1;
			}
		}
	}
	bool flg1 = 1, flg2 = 1;
	for (int i = 3; i <= n + m; ++i) {
		if (f[i] != f[i - 1]) {
			flg1 = 0;
		}
		if (g[i] != g[i - 1]) {
			flg2 = 0;
		}
	}
	if (!flg1 && !flg2) {
		cout << "NO\n";
		return;
	}
	cout << "YES\n";
	char col = flg1 ? 'B' : 'W';
	ans.clear();
	for (int k = 1 - m; k < 0; ++k) {
		int x = 1, y = 1;
		string S = "";
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				if (i - j != k) {
					continue;
				}
				if (i == n) {
					continue;
				}
				while (y < j - 1) {
					S += "R";
					++y;
				}
				if (s[i][j] == col) {
					S += "DR";
				} else {
					S += "RD";
				}
				++x, ++y;
			}
		}
		while (x < n) {
			S += "D";
			++x;
		}
		while (y < m) {
			S += "R";
			++y;
		}
		op(S);
		ans.emplace_back(S);
	}
	for (int k = n - 1; k > 1; --k) {
		int x = 1, y = 1;
		string S = "";
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= m; ++j) {
				if (i - j != k) {
					continue;
				}
				while (x < i - 1) {
					S += "D";
					++x;
				}
				if (s[i][j] == col) {
					S += "RD";
				} else {
					S += "DR";
				}
				++x, ++y;
			}
		}
		while (x < n) {
			S += "D";
			++x;
		}
		while (y < m) {
			S += "R";
			++y;
		}
		op(S);
		ans.emplace_back(S);
	}
	if (s[1][1] != col) {
		string S = "";
		int x = 1, y = 1;
		while (x < n || y < m) {
			if (x < n && s[x + 1][y] != col) {
				++x, S += "D";
			} else {
				++y, S += "R";
			}
		}
		op(S);
		ans.emplace_back(S);
	}
	cout << ans.size() << "\n";
	for (auto u: ans) {
		if (flg) {
			for (auto &v: u) {
				v = (v == 'R' ? 'D' : 'R');
			}
		}
		cout << u << "\n";
	}
}

int main() {
	#ifdef LOCAL
		assert(freopen("test.in", "r", stdin));
		assert(freopen("test.out", "w", stdout));
	#endif
	ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	cin >> T;
	while (T--) {
		solve();
	}
	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3844kb

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
DDRR
DRDR
YES
5
RRRR
RRRR
RRRR
RRRR
RRRR
YES
2
DR
DR
NO

result:

ok ok (4 test cases)

Test #2:

score: 0
Accepted
time: 1ms
memory: 3804k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DRR
RDRR
DRRR
NO
NO
NO
YES
3
RRDR
RRDR
DRRR
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
4
RRRD
RDRR
RDRR
DRRR
NO
NO
YES
4
RRRD
RDRR
RDRR
DRRR
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
3
RRDR
RRDR
DRRR
NO
NO
NO
YES
4
RRDR
R...

result:

ok ok (278 test cases)

Test #4:

score: 0
Accepted
time: 0ms
memory: 3644kb

input:

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

output:

YES
3
RDRD
DRDR
DDRR
NO
NO
NO
NO
NO
YES
3
RDRD
DRRD
DDRR
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
3
RRDD
RDDR
DDRR
NO
NO
NO
NO
NO
YES
3
RRDD
RDRD
DDRR
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
3
RRDD
RDDR
DRDR
NO
NO
NO
NO
NO
YES
3
RRDD
RDRD
DRDR
NO
NO
NO
YES
4
RDRD
DRRD
DRDR
DRDR
NO
NO
NO
NO
NO
NO
NO
NO
NO
Y...

result:

ok ok (333 test cases)

Test #5:

score: 0
Accepted
time: 0ms
memory: 3564kb

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
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
YES
4
DDRD
DRDD
RDDD
RDDD
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
NO
YES
4
DDDR
DDRD
RDDD
RDDD
NO
NO
NO
NO
...

result:

ok ok (245 test cases)

Test #7:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

200
5 3
BBB
BBB
WBW
BBW
BBW
5 3
BBB
BBB
WBW
BBW
BWB
5 3
BBB
BBB
WBW
BBW
BWW
5 3
BBB
BBB
WBW
BBW
WBB
5 3
BBB
BBB
WBW
BBW
WBW
5 3
BBB
BBB
WBW
BBW
WWB
5 3
BBB
BBB
WBW
BBW
WWW
5 3
BBB
BBB
WBW
BWB
BBB
5 3
BBB
BBB
WBW
BWB
BBW
5 3
BBB
BBB
WBW
BWB
BWB
5 3
BBB
BBB
WBW
BWB
BWW
5 3
BBB
BBB
WBW
BWB
WBB
5 3
BBB
...

output:

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
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
NO
NO
NO
NO
NO
NO
...

result:

ok ok (200 test cases)

Test #8:

score: 0
Accepted
time: 0ms
memory: 3540kb

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
WWW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DDDDDDDDDDDDDDDDDDDDDDD...

result:

ok ok (5 test cases)

Test #10:

score: 0
Accepted
time: 61ms
memory: 3808kb

input:

5
200 200
WBWBWWBBBWWWWBWWWBBBBWWWWBWWBBBBWWBWWWWBWWBWWBWBBWBWWWWWWBBBWWWBWBBWBBBBBBWBBBWWBWBWBWWWWWWBBWBWWBWWBWWBWBBWBWBWWWWWBBWBWBWWWBWBBBBWWBBBBWWWWBBBBBWWWBBWWBBBBWWWBWBWBWWWBWBBWBBBBWWWWBWBWWBBBWBBBBWBBWWW
BWBBWBWBWWBWWWBWBWBWBBWBWWWWWBBWBBWBBBWWBWBBBWWWBWWWBBBBWWWBBWWBBBWWBWBWWWWBBBWWBBWWBWWWB...

output:

YES
398
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRDRDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD...

result:

ok ok (5 test cases)

Test #11:

score: 0
Accepted
time: 37ms
memory: 3840kb

input:

5
200 200
WBBWWBBBBBBBBWWBBBWBWBBWWBBBBWBWBWBWBWBBBBBWBWWBWBBWWBBWBWBWBBBWWWWBWWBBWWBBWWWBBWBBWBBWBWWBBBBBWBBBWBBWWWBWWWWBWBWBWWBWWWBBBWBBWWWBBBBWWBWBBBBBWBWBWWBWWBWWWBBBBWBWBBWWBBWWWWWWBBWBBBBBWBBWBBWWBWBWBWBW
BBBWWBWBWBWBBBWBBBBWWWWWWBBWWWWWBWWBBWWBWBWWBBWBBBBBBBWBWWBWWBBBWWWWWWBWBWWBBWBBBWBBWBBWW...

output:

YES
398
RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRDRDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD...

result:

ok ok (5 test cases)

Test #12:

score: 0
Accepted
time: 27ms
memory: 3848kb

input:

8
156 104
WWWBWWWBWBWBWWBWBWWBBBWBWWWBBWWBBWWWBBWWBBBBWBWWWWBWBBBBBWWWBBWBBWBBBWBWWBWWBWWBBWBWBWBWBBWWBWWWWBBBWBBW
WBBWWBBWWBWBWWBWWBBWBBWBWWWWWWWWWBBWBBBBWWBBBBWBBBBWBBWWBBBWWWBWWWWBBWWWBWBWWBWBBWWWWBBBWWBBWWWBBWWBBWWW
BBBWBBBWWWBBBBWBBWBBWWBWWBBWBBWWWBWWBBBBWBBWWWBBWWWBBBBBBBBBBBWWWBBWBWWWWBWBBWWW...

output:

YES
258
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD...

result:

ok ok (8 test cases)

Test #13:

score: 0
Accepted
time: 28ms
memory: 3872kb

input:

5
114 120
BWWBBWWWWBWBBWWBW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RDRDDDD
DDDDDDDDDDDDRRDDDDD
DDDDDDDDDDRDDRDDDDD
DDDDDDDDDDRDRDDDDDD
DDDDDDDDRDRDDDDDDDD
DDDDDDDDRRDDDDDDDDD
DDDDDDDRDRDDDDDDDDD
DDDDDRDDRDDDDDDDDDD
DDDDDRDRDDDDDDDDDDD
DDDRDRDDDDDDDDDDDDD
DDRDRDDDDDDDD...

result:

ok ok (100 test cases)

Test #15:

score: 0
Accepted
time: 3ms
memory: 3624kb

input:

50
1 14
BBBBBBBBBBBBBB
15 3
WWW
WBB
BBB
WWB
BBB
WBB
WWW
BBW
BWB
WBW
WWW
WBB
BBB
WWB
BBW
3 19
WBWBBBWWBBWBWBWBBWB
BBBWWWBWBBWWBBWBBWW
BWBBWBBWBBWWBBWBBWW
77 21
WWWBBBBBWBWBWBWWWWWWW
WBBWBBBWWBBWBWBWWWWBW
BBBWBWWWWWWWWBWBWBBBW
BWBBBWBWWWWBBBWBBBBWW
WBBWWWBWWBWWBWWBBBBWB
WWWBBBWBBWBBBBBBWBWBB
BWWWWWBWW...

output:

YES
14
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
RRRRRRRRRRRRR
YES
16
DDDDDDDDDDDDDDRR
DDDDDDDDDDDDDRRD
DDDDDDDDDDDDRDRD
DDDDDDDDDDDRRDDD
DDDDDDDDDRDRDDDD
DDDDD...

result:

ok ok (50 test cases)

Test #16:

score: 0
Accepted
time: 19ms
memory: 3812kb

input:

10
2 23
BBWWBBWWWBWBWBBWBBBWWBW
BWWBBWWWBWBWBBWBBBWWBWB
87 44
BBWBWBWBWWWWWWBWWBBBWBBBBWWWWBBBBBBWBWWWWBWW
BBWBBBWBWBWBBWWBBBWWBWWWWBWBBBBWWWWBBBBBWBWW
WBWBBWBWBBBWBWWWBBBBWWBWBWWBWBWWWWWBBBWWBBWB
WBWWWWWWBWWWBBBBBWBBBWBBWWWBBBBBBBWWWWWWWWWB
BWBWWBBWBBBBBBBBWBBBWBBWWBBBBBWBWBWBBWWBWBWW
BBBWBBBBBBWWB...

output:

YES
22
RRRRRRRRRRRRRRRRRRRRRRD
RRRRRRRRRRRRRRRRRRRRRDR
RRRRRRRRRRRRRRRRRRRRDRR
RRRRRRRRRRRRRRRRRRDRRRR
RRRRRRRRRRRRRRRRRDRRRRR
RRRRRRRRRRRRRRRRRDRRRRR
RRRRRRRRRRRRRRRDRRRRRRR
RRRRRRRRRRRRRRDRRRRRRRR
RRRRRRRRRRRRRDRRRRRRRRR
RRRRRRRRRRRRRDRRRRRRRRR
RRRRRRRRRRRRDRRRRRRRRRR
RRRRRRRRRRRDRRRRRRRRRRR
RRRRR...

result:

ok ok (10 test cases)

Extra Test:

score: 0
Extra Test Passed