結果
問題 | No.3109 Swap members |
ユーザー |
|
提出日時 | 2025-04-19 09:32:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 173 ms / 2,000 ms |
コード長 | 808 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 82,040 KB |
実行使用メモリ | 87,948 KB |
最終ジャッジ日時 | 2025-04-19 09:32:07 |
合計ジャッジ時間 | 7,076 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
import sys input = sys.stdin.readline def can_sort(N, K, S, T): # r = 0~K-1 の剰余クラスごとにグループを作ってチェック for r in range(K): # グループに属するインデックスを集める idxs = list(range(r, N, K)) # それぞれのユーザーネームを取り出してソート s_group = sorted(S[i] for i in idxs) t_group = sorted(T[i] for i in idxs) # マルチセット(ソート結果)が異なれば不可 if s_group != t_group: return False return True def main(): N, K = map(int, input().split()) S = [input().rstrip() for _ in range(N)] T = [input().rstrip() for _ in range(N)] print("Yes" if can_sort(N, K, S, T) else "No") if __name__ == "__main__": main()