結果
| 問題 | No.3587 Too Good to Swap |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-07-10 18:51:09 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 222 ms / 2,000 ms |
| コード長 | 517 bytes |
| 記録 | |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 95,980 KB |
| 実行使用メモリ | 86,160 KB |
| 最終ジャッジ日時 | 2026-07-10 21:08:52 |
| 合計ジャッジ時間 | 6,187 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 49 |
ソースコード
def is_wall(X):
rgidx = -1
ldidx = -1
for i in range(len(X)):
if X[i] == "g":
rgidx = i
elif X[i] == "d" and ldidx == -1:
ldidx = i
return rgidx != -1 and ldidx != -1 and ldidx - rgidx > 3
Q = int(input())
for _ in range(Q):
S = input()
T = input()
cnts = {c: S.count(c) for c in "dog"}
cntt = {c: T.count(c) for c in "dog"}
if cnts != cntt:
print("No")
continue
print("Yes" if is_wall(S) == is_wall(T) else "No")