QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#779796#9621. 连方victoryACAC ✓15ms10248kbC++173.5kb2024-11-24 21:49:012024-11-24 21:49:02

Judging History

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

  • [2024-11-24 21:49:02]
  • 评测
  • 测评结果:AC
  • 用时:15ms
  • 内存:10248kb
  • [2024-11-24 21:49:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pos string::npos
#define endl '\n'
#define inf 1e18
typedef unsigned long long ull;
const int mod = 998244353;
const int N = 5e5+10;
const int Maxn = 2e5+5;
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
int Inv[N],F[N];//组合数C2
int gcd(int a,int b){ return b == 0 ? a : gcd(b,a%b);}
int lcm(int a,int b){return (a/gcd(a,b)*b);}
int km(int a,int b,int mod)
{int ans=1;while(b){if(b&1) ans=ans*a%mod;b>>=1;a=a*a%mod;}return ans;}
int km1(int a,int b,int mod)//指数取模,2^2^i,单求2^i要取模MOD-1
{int ans=1;mod--;while(b){if(b&1) ans=ans*a%mod;b>>=1;a=a*a%mod;}return ans;}
int C(int a,int b,int p){if(b>a) return 0;int res=1;for(int i=b,j=a;i>=1;i--,j--){res=res*j%p;res=res*km(i,p-2,p)%p;}return res;}
int Lucas(int a,int b,int p){if(a<p&&b<p) return C(a,b,p);return C(a%p,b%p,p)*Lucas(a/p,b/p,p)%p;}
int C2(int a,int b,int p){return F[a]*Inv[a-b]%p*Inv[b]%p;}
void C2init(int n,int p){n--;F[0]=F[1]=1;for(int i=2;i<=n;i++)F[i]=F[i-1]*i%p;Inv[n]=km(F[n],p-2,p);for(int i=n-1;i>=0;i--)Inv[i]=Inv[i+1]*(i+1)%p;}
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
int n,m,k,q,a[N],din[N];
char mp[10][N];
void solve() 
{
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    for(int i=1;i<=7;i++){
        for(int j=0;j<=n+1;j++){
            if(i==1) mp[i][j]=s1[j-1];
            else if(i==7) mp[i][j]=s2[j-1];
            else mp[i][j]='.';
        }
    }
    int cnt1=0,cnt2=0;
    for(int i=0;i<n;i++){
        if(s1[i]=='#') cnt1++;
        if(s2[i]=='#') cnt2++;
    }
    if((cnt1==n)&&(cnt2==n)){
        cout<<"Yes"<<endl;
        for(int i=1;i<=7;i++){
            for(int j=1;j<=n;j++){
                cout<<"#";
            }
            cout<<endl;
        }
    }
    else if((cnt1==n)||(cnt2==n)){
        cout<<"No"<<endl;
    }
    else{
        for(int i=1;i<=n;i++) {
            if(mp[1][i]=='#') mp[2][i]='.';
            else mp[2][i]='#';
            if(mp[7][i]=='#') mp[6][i]='.';
            else mp[6][i]='#';
        }
        bool ok1=0,ok2=0;
        for(int i=1;i<=n;i++){
            if(mp[2][i]=='.'&&(mp[2][i+1]=='#'||mp[2][i-1]=='#')&&ok1==0) ok1=1,mp[3][i]='#';
            if(mp[6][i]=='.'&&(mp[6][i+1]=='#'||mp[6][i-1]=='#')&&ok2==0) ok2=1,mp[5][i]='#';
        }
        // if(!ok1) mp[3][n]='#';
        // if(!ok2) mp[5][n]='#';
        int cnt=0,l1=0,l2=0;
        for(int i=1;i<=n;i++){
            if(mp[3][i]=='#'&&l1==0) l1=i;
            if(mp[5][i]=='#'&&l2==0) l2=i;
            if(cnt) break;
            if(mp[3][i]=='#'&&mp[5][i]=='#') mp[4][i]='#',cnt++;
            else if(mp[3][i]=='#'&&(mp[5][i+1]=='#'||mp[5][i-1]=='#')) mp[4][i]='#',cnt++;
            else if(mp[5][i]=='#'&&(mp[3][i+1]=='#'||mp[3][i-1]=='#')) mp[4][i]='#',cnt++;
            else if(mp[3][i]=='.'&&mp[5][i]=='.'&&(mp[3][i-1]=='#'||mp[3][i+1]=='#')&&(mp[5][i-1]=='#'||mp[5][i+1]=='#')) mp[4][i]='#',cnt++;
        }
        if(cnt==0){
            if(l1>l2) swap(l1,l2);
            for(int i=l1+1;i<=l2-1;i++) mp[4][i]='#';
        }
        cout<<"Yes"<<endl;
        for(int i=1;i<=7;i++){
            for(int j=1;j<=n;j++){
                cout<<mp[i][j];
            }
            cout<<endl;
        }
    }
}
signed main()
{
    ios;
    int T=1;
    //C2init(N,mod);
    cin>>T;
    while(T--)
    {
        solve();
    }
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

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

result:

ok Correct.

Test #2:

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

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: 7ms
memory: 7956kb

input:

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

output:

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

result:

ok Correct.

Test #4:

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

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: 15ms
memory: 9812kb

input:

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

output:

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

result:

ok Correct.

Test #6:

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

input:

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

output:

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

result:

ok Correct.

Test #7:

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

input:

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

output:

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

result:

ok Correct.