QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#788811#9621. 连方masttf#WA 4ms3704kbC++202.2kb2024-11-27 18:23:442024-11-27 18:23:44

Judging History

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

  • [2024-11-27 18:23:44]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3704kb
  • [2024-11-27 18:23:44]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
#define dbg(x...) \
do { \
    cout << #x << " -> "; \
    err(x); \
} while (0)

void err() {
    cout << endl << endl;
}
 
template<class T, class... Ts>
void err(T arg, Ts ... args) {
    cout << fixed << setprecision(10) << arg << ' ';
    err(args...);
}
void solve(){
    int n; cin >> n;
    string a, b; cin >> a >> b;
    int cnt1 = 0, cnt2 = 0;
    for(auto x : a){
    	if(x == '#')cnt1++;
    }
    for(auto x : b){
    	if(x == '#')cnt2++;
    }
    if(cnt1 == 0 || cnt2 == 0 || (cnt1 == n && cnt2 == n)){
    	cout << "Yes\n";
    	cout << a << '\n';
    	for(int i = 1; i <= 6; i++){
    		cout << b << '\n';
    	}
    	return ;
    }
    if(cnt1 == n || cnt2 == n){
    	cout << "No\n";
    	return ;
    }
    vector<string> ans;
    ans.push_back(a);
    int pa = -1, pb = -1;
    for(int i = 0; i < n; i++){
    	if(a[i] == '#'){
    		if(i && a[i - 1] == '.')pa = i;
    		if(i + 1 < n && a[i + 1] == '.')pa = i;
    	}
    }
    for(int i = 0; i < n; i++){
    	if(b[i] == '#'){
    		if(i && b[i - 1] == '.')pb = i;
    		if(i + 1 < n && b[i + 1] == '.')pb = i;
    	}
    }
    string res = "";
    for(auto x : a){
    	if(x == '#')res += '.';
    	else res += '#';
    }
    ans.push_back(res);
    res = "";
    for(int i = 0; i < n; i++){
    	if(i == pa)res += '#';
    	else res += '.';
    }
    ans.push_back(res);

    string res2 = "";
    for(int i = 0; i < n; i++){
    	if(i == pb)res2 += '#';
    	else res2 += '.';
    }
    if(pa - pb == 1){
    	ans.push_back(res);
    }else{
    	string res3 = "";
	    for(int i = 0; i < n; i++){
	    	if(res[i] == '.' && res2[i] == '.')res3 += '#';
	    	else res3 += '.';
	    }
	    ans.push_back(res3);
    }
    
    ans.push_back(res2);
    res = "";
    for(auto x : b){
    	if(x == '#')res += '.';
    	else res += '#';
    }
    ans.push_back(res);
    ans.push_back(b);
    cout << "Yes\n";
    for(auto x : ans){
    	cout << x << '\n';
    }
    return ;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    cin >> t;
    while(t--)solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

5
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####
10
##########
##########

output:

Yes
#..#
.##.
...#
...#
..#.
#..#
.##.
Yes
##.#.
..#.#
...#.
###.#
...#.
#.#..
.#.##
No
Yes
.######.######.####.#.#####
#......#......#....#.#.....
......................#....
######################.####
......................#....
#....###....##.#######.....
.####...####..#.......#####
Yes
########...

result:

ok Correct.

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3704kb

input:

10000
6
.#..##
..#...
5
#..#.
##...
6
.###.#
...###
17
.####..#######..#
###########.#####
6
..##.#
#.##.#
25
#.##.##############.####.
####################.##.#
9
##.#..##.
##..#####
6
.###.#
##.###
6
###..#
#.####
25
#####################.#.#
######.##################
6
.#.###
.##..#
6
..####
#......

output:

Yes
.#..##
#.##..
....#.
##.#.#
..#...
##.###
..#...
Yes
#..#.
.##.#
...#.
#.#.#
.#...
..###
##...
Yes
.###.#
#...#.
.....#
###.#.
...#..
###...
...###
Yes
.####..#######..#
#....##.......##.
................#
############.###.
............#....
...........#.....
###########.#####
Yes
..##.#
##..#.
...

result:

wrong answer Testcase 6: Connected condition failed.