結果

問題 No.2629 A replace B replace C
ユーザー flygon
提出日時 2024-02-16 22:16:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 357 ms
コンパイル使用メモリ 82,704 KB
実行使用メモリ 67,052 KB
最終ジャッジ日時 2024-09-28 20:52:26
合計ジャッジ時間 5,122 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 51 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n = int(input())
s = input().rstrip()
t = input().rstrip()

all = 0
ok = 1
cnt = 0
for i in range(n):
    if (ord(s[i])) > ord(t[i]):
        ok = 0
    all += ord(t[i]) - ord(s[i])
    cnt += (ord(t[i]) - ord(s[i])) >= 1

if ok and all% 2 == 0:
    if all == 0:
        print('Yes')
    elif cnt == 1:
        print('No')
    else:
        print('Yes')

else:
    print('No')
0