結果
問題 | No.3109 Swap members |
ユーザー |
|
提出日時 | 2025-04-19 00:13:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 121 ms / 2,000 ms |
コード長 | 685 bytes |
コンパイル時間 | 391 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 28,240 KB |
最終ジャッジ日時 | 2025-04-19 00:13:20 |
合計ジャッジ時間 | 5,501 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 52 |
ソースコード
def solve(): import sys input = sys.stdin.read data = input().split() idx = 0 N, K = map(int, data[idx:idx+2]) idx +=2 S = data[idx:idx+N] idx +=N T = data[idx:idx+N] # Check for each equivalence class modulo K for i in range(K): # Collect elements from S and T for positions i, i+K, i+2K, etc. s_group = [] t_group = [] pos = i while pos < N: s_group.append(S[pos]) t_group.append(T[pos]) pos += K # Check if the multisets are the same if sorted(s_group) != sorted(t_group): print("No") return print("Yes") solve()