QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#789984#9621. 连方fuchenRE 0ms0kbJava112.3kb2024-11-27 23:23:092024-11-27 23:23:09

Judging History

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

  • [2024-11-27 23:23:09]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-11-27 23:23:09]
  • 提交

answer

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static  int N=100010,n;
    static  char [][] str=new char[8][N];
    public  static  boolean check(int i,int j){
        if(str[i][j]=='.' && (j-1>=0 && str[i][j-1]=='#') ||(j+1<n && str[i][j+1]=='#')) return true;
        return  false;
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int T=sc.nextInt();
        while(T-->0){
            n=sc.nextInt();
            for(int i=0;i<7;i++){
                Arrays.fill(str[i],'.');
            }
            String str1=sc.next();
            String str2=sc.next();
            String s="";
            for(int i=0;i<n;i++) s+="#";
            if(str1.equals(s) && str2.equals(s)){
                for(int i=0;i<7;i++){
                    System.out.println(s);
                }
            }else if(str1.equals(s) || str2.equals(s)){
                System.out.println("No");
                continue;
            }
            str[1]=str1.toCharArray();
            str[7]=str2.toCharArray();
            for(int i=0;i<n;i++){
                if(str[1][i]=='.'){
                    str[2][i]='#';
                }else{
                   str[2][i]='.';
                }
                if(str[7][i]=='.'){
                    str[6][i]='#';
                }else{
                    str[6][i]='.';
                }
            }
            int l=-1,r=-1;
            for(int i=0;i<n;i++){
                if(check(2,i)){
                    l=i;
                }
                if(check(6,i)){
                    r=i;
                }
            }
            str[3][l]='#';
            str[5][r]='#';
            if(l>r){
                int t=l;
                l=r;
                r=t;
            }
            if(l==r || l+1==r){
                str[4][l]='#';
            }else{
                for(int i=l+1;i<=r-1;i++){
                    str[4][i]='#';
                }
            }
            System.out.println("Yes");
            for(int i=1;i<=7;i++){
               for(int j=0;j<n;j++){
                   System.out.print(str[i][j]);
               }
                System.out.println();
            }
        }
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

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

output:

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

result: