QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754601#9621. 连方Xiaoying0418AC ✓9ms4356kbC++234.8kb2024-11-16 15:23:102024-11-16 15:23:12

Judging History

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

  • [2024-11-16 15:23:12]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:4356kb
  • [2024-11-16 15:23:10]
  • 提交

answer

#include<bits/stdc++.h>

#define ff first
#define ss second

#define typet typename T
#define typeu typename U
#define types typename... Ts
#define tempt template < typet >
#define tempu template < typeu >
#define temps template < types >
#define final constexpr const

tempt struct range {
	T b, e;
	range (T b, T e): b(b), e(e) {}
	T begin() const {return b;}
	T end() const {return e;}
};
tempt range<T> make_range(T b, T e) {return range <T> (b, e);}

tempt struct is_cont {
	static final bool value = false;
};
tempt struct is_cont<range<T>>{
	static final bool value = true;
};
temps struct is_cont<std::vector<Ts...>>{
	static final bool value = true;
};
temps struct is_cont<std::set<Ts...>>{
	static final bool value = true;
};
temps struct is_cont<std::map<Ts...>>{
	static final bool value = true;
};
template < typet, typeu > std::ostream &
operator << (std::ostream &os, const std::pair<T, U> &p) {
	return os << '<' << p.ff << ',' << p.ss << '>';
}
tempt std::enable_if_t<is_cont<T>::value, std::ostream> &
operator << (std::ostream &os, const T &c) {
	auto it = c.begin();
	if (it == c.end()) return os << "{}";
	for (os << '{' << *it; ++it != c.end(); os << ',' << *it);
	return os << '}';
}
void dbg() {std::cerr << std::endl;}
template < typet, types > void dbg(T arg, Ts... args) {
	std::cerr << ' ' << arg; dbg(args...);
}
#ifndef ONLINE_JUDGE
#define debug(arg...) do {std::cerr << "["#arg"] :"; dbg(arg);} while (false)
#else
#define debug(...) do {} while (false)
#endif

using i64 = long long;
using vi = std::vector<int>;
using vl = std::vector<i64>;
using pii = std::pair<int, int>;
using vp = std::vector<pii>;
using vvi = std::vector<vi>;

#define lowbit(x) ((x) & (-x))
#define all(x) x.begin(), x.end()
#define set_all(x, y) std::memset(x, y, sizeof(x))
#define set_n(x, y, n) std::memset(x, y, sizeof(decltype(*(x))) * (n))

tempt void Min(T &x, const T &y) {if (x > y) x = y;}
tempt void Max(T &x, const T &y) {if (x < y) x = y;}

final int mod = 998244353;
inline int add(int x, int y) { return x + y < mod ? x + y : x + y - mod; }
inline int sub(int x, int y) { return x < y ? mod + x - y : x - y; }
inline int mul(i64 x, int y) { return x * y % mod; }
inline void Add(int& x, int y) { x = add(x, y); }
inline void Sub(int& x, int y) { x = sub(x, y); }
inline void Mul(int& x, int y) { x = mul(x, y); }
int pow(int x, int y) {
	int z = 1;
	for (; y; y /= 2) {
		if (y & 1) Mul(z, x);
		Mul(x, x);
	}
	return z;
}

void solve(int cas) {
	int n;
    std::cin >> n;
    std::vector<std::string> Ans(7);
    for (int i = 1; i < 6; i++) {
        int last = n;
        while (last--) {
            Ans[i] += '.';
        }
    }
    std::cin >> Ans[0];
    std::cin >> Ans[6];
    int cnt0 = 0, cnt6 = 0;
    for (int i = 0; i < n; i++) {
        cnt0 += (Ans[0][i] == '#');
        cnt6 += (Ans[6][i] == '#');
    }

    // Case 1
    if (cnt0 == n and cnt6 == n) {
        std::cout << "Yes\n";
        for (int i = 0; i < 7; i++) {
            for (int j = 0; j < n; j++) {
                std::cout << '#';
            }
            std::cout << '\n';
        }
        return ;
    }

    // Case 2
    if (cnt0 == n or cnt6 == n) {
        std::cout << "No\n";
        return ;
    }
    
    // Others
    std::cout << "Yes\n";
    for (int i = 0; i < n; i++) {
        Ans[1][i] = (Ans[0][i] == '#' ? '.' : '#');
    }
    for (int i = 0; i < n; i++) {
        Ans[5][i] = (Ans[6][i] == '#' ? '.' : '#');    
    }
    debug("Test");
    int id1 = 0, id2 = 0;
    for (int i = 0; i < n; i++) {
        if (Ans[1][i] == '#' and (Ans[1][i + 1] == '.')) {
            Ans[2][i + 1] = '#';
            id1 = i + 1;
            break;
        }
        if (Ans[1][i] == '#' and (i - 1 >= 0 and Ans[1][i - 1] == '.')) {
            Ans[2][i - 1] = '#';
            id1 = i - 1;
            break;
        }
    }
    for (int i = 0; i < n; i++) {
        if (Ans[5][i] == '#' and Ans[5][i + 1] == '.') {
            Ans[4][i + 1] = '#';
            id2 = i + 1;
            break;
        }
        if (Ans[5][i] == '#' and (i - 1 >= 0 and Ans[5][i - 1] == '.')) {
            Ans[4][i - 1] = '#';
            id2 = i - 1;
            break;
        }
    }
    debug(id1, id2);
    if (std::abs(id1 - id2) <= 1) {
        Ans[3][id1] = '#';
    } else {
        for (int i = std::min(id1, id2) + 1; i <= std::max(id1, id2) - 1; i++) {
            Ans[3][i] = '#';
        }
    }

    for (int i = 0; i < 7; i++) {
        std::cout << Ans[i] << '\n';
    }
}

signed main() {
	std::cin.tie(nullptr) -> sync_with_stdio(false);
	int T = 1;
	std::cin >> T;
	for (int cas = 1; cas <= T; cas++) {
		solve(cas);
	}
	return 0;
}
/*
4
4
#..#
.##.
5
##.#.
.#.##
6
######
.####.
27
.######.######.####.#.#####
.####...####..#.......#####

*/

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

score: 0
Accepted
time: 8ms
memory: 3632kb

input:

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

output:

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

result:

ok Correct.

Test #3:

score: 0
Accepted
time: 4ms
memory: 3692kb

input:

10000
41
#######.#######.#########################
################.###.#######.############
6
..#..#
#..##.
6
#.#...
#...#.
6
.#.##.
....##
6
...#.#
##..#.
33
#####.###########################
###########.#####################
6
.##.##
.##.#.
5
..##.
####.
17
#.###.##########.
####.##.#####.##.
5
....

output:

Yes
#######.#######.#########################
.......#.......#.........................
........#................................
.........########........................
.................#.......................
................#...#.......#............
################.###.#######.############
Ye...

result:

ok Correct.

Test #4:

score: 0
Accepted
time: 9ms
memory: 3688kb

input:

10000
6
..####
.#....
6
...#.#
#..##.
9
..####.##
######..#
33
#######################.#####..##
######.######.###########.#######
6
####.#
#..##.
6
...###
##.###
25
######.#.#.##############
.#########.##########.###
17
############.####
###############.#
6
#..#.#
#####.
6
.#.###
..#...
49
########...

output:

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

result:

ok Correct.

Test #5:

score: 0
Accepted
time: 4ms
memory: 3708kb

input:

10000
5
...#.
#####
6
###...
##..#.
9
.#.######
#.#..####
49
######.##########################################
########.#############.##########################
41
###########.#######.#####################
##############.##########################
6
###..#
###.##
49
#################################...

output:

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

result:

ok Correct.

Test #6:

score: 0
Accepted
time: 4ms
memory: 4356kb

input:

2
100000
###.#...#..####...#####..####.#.######.##.##..#..#..####...###.#..##.#.##.####.#.#.###...#.##...####.#.#.####...####.#..##.##.#.#.....####..####..#...#..#.##..#.##.#.....#..#.#.###.#....####...####..##.#.#####..####.##.#.###.#.#....#.##.##...#.######.#..##..##...#.....#....#.####...#...##.#...

output:

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

result:

ok Correct.

Test #7:

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

input:

2
100000
##.####.#..#..#.##..#.#..###..##..#####.....#..##.##.#...#.###..##..#...##...####..#...##...##.......#.#..##.##..###.#.###.##.#########..#...###.####.##...#..#.....#####.....#.####.#####..#.#....#..###.#.##..#..#.##.......#.###.##...####.....######..#.##....#.#.###.#.###.#..#.....####....##...

output:

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

result:

ok Correct.