結果
問題 |
No.3109 Swap members
|
ユーザー |
|
提出日時 | 2025-04-19 05:25:33 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 536 bytes |
コンパイル時間 | 519 ms |
コンパイル使用メモリ | 11,904 KB |
実行使用メモリ | 34,136 KB |
最終ジャッジ日時 | 2025-04-19 05:25:39 |
合計ジャッジ時間 | 5,241 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 47 |
ソースコード
from collections import Counter def can_sort_with_k_swaps(N, K, S, T): for r in range(K): s_group = [S[i] for i in range(N) if i % K == r] t_group = [T[i] for i in range(N) if i % K == r] if Counter(s_group) != Counter(t_group): return False return True def main(): import sys input = sys.stdin.read data = input().split() N = int(data[0]) K = int(data[1]) S = data[2:N+2] T = data[N+2:] print("Yes" if can_sort_with_k_swaps(N, K, S, T) else "No") main()