結果

問題 No.2629 A replace B replace C
ユーザー tentententen
提出日時 2024-02-21 15:16:41
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,810 bytes
コンパイル時間 6,593 ms
コンパイル使用メモリ 77,752 KB
実行使用メモリ 57,736 KB
最終ジャッジ日時 2024-02-21 15:16:59
合計ジャッジ時間 17,781 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
55,912 KB
testcase_01 AC 107 ms
55,640 KB
testcase_02 AC 108 ms
55,372 KB
testcase_03 AC 124 ms
57,736 KB
testcase_04 AC 69 ms
54,492 KB
testcase_05 AC 103 ms
55,656 KB
testcase_06 AC 87 ms
55,652 KB
testcase_07 AC 99 ms
55,632 KB
testcase_08 AC 112 ms
55,652 KB
testcase_09 AC 111 ms
55,520 KB
testcase_10 AC 133 ms
55,388 KB
testcase_11 AC 117 ms
55,632 KB
testcase_12 AC 108 ms
55,528 KB
testcase_13 AC 107 ms
55,536 KB
testcase_14 AC 118 ms
55,528 KB
testcase_15 AC 117 ms
55,500 KB
testcase_16 AC 98 ms
55,400 KB
testcase_17 AC 109 ms
55,640 KB
testcase_18 AC 115 ms
55,400 KB
testcase_19 AC 102 ms
55,508 KB
testcase_20 AC 107 ms
55,276 KB
testcase_21 AC 116 ms
55,496 KB
testcase_22 AC 109 ms
55,636 KB
testcase_23 AC 120 ms
55,504 KB
testcase_24 AC 115 ms
55,520 KB
testcase_25 AC 111 ms
55,656 KB
testcase_26 AC 108 ms
55,416 KB
testcase_27 AC 109 ms
55,640 KB
testcase_28 AC 110 ms
55,656 KB
testcase_29 AC 142 ms
55,540 KB
testcase_30 AC 89 ms
55,656 KB
testcase_31 AC 117 ms
55,676 KB
testcase_32 AC 113 ms
55,548 KB
testcase_33 AC 121 ms
57,440 KB
testcase_34 AC 95 ms
55,260 KB
testcase_35 AC 108 ms
55,260 KB
testcase_36 AC 114 ms
55,672 KB
testcase_37 AC 118 ms
55,564 KB
testcase_38 AC 114 ms
55,648 KB
testcase_39 AC 109 ms
55,400 KB
testcase_40 AC 103 ms
55,252 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 AC 112 ms
55,396 KB
testcase_52 AC 107 ms
55,512 KB
testcase_53 AC 89 ms
55,632 KB
testcase_54 AC 100 ms
55,640 KB
testcase_55 AC 103 ms
55,520 KB
testcase_56 AC 90 ms
54,876 KB
testcase_57 AC 115 ms
55,644 KB
testcase_58 AC 133 ms
55,736 KB
testcase_59 AC 114 ms
56,796 KB
testcase_60 AC 99 ms
55,648 KB
testcase_61 AC 56 ms
53,964 KB
testcase_62 AC 56 ms
53,988 KB
testcase_63 AC 55 ms
51,896 KB
testcase_64 AC 56 ms
53,960 KB
testcase_65 AC 55 ms
53,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;
import java.util.function.*;
import java.util.stream.*;

public class Main {
    static List<Set<Integer>> graph;
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();
        int ab = 0;
        int ac = 0;
        int bc = 0;
        for (int i = 0; i < n; i++) {
            if (s[i] == t[i]) {
                continue;
            }
            if (s[i] == 'A') {
                if (t[i] == 'B') {
                    ab++;
                } else {
                    ac++;
                }
            } else if (s[i] == 'B' && t[i] == 'C') {
                bc++;
            } else {
                System.out.println("No");
                return;
            }
        }
        System.out.println((ac > 0 && bc == 0) ? "No" : "Yes");
    }
}
class Scanner {
    BufferedReader br;
    StringTokenizer st = new StringTokenizer("");
    StringBuilder sb = new StringBuilder();
    
    public Scanner() {
        try {
            br = new BufferedReader(new InputStreamReader(System.in));
        } catch (Exception e) {
            
        }
    }
    
    public int nextInt() {
        return Integer.parseInt(next());
    }
    
    public long nextLong() {
        return Long.parseLong(next());
    }
    
    public double nextDouble() {
        return Double.parseDouble(next());
    }
    
    public String next() {
        try {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(br.readLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            return st.nextToken();
        }
    }
    
}
0