結果
| 問題 | 
                            No.3109 Swap members
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2025-04-18 23:11:01 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 768 ms / 2,000 ms | 
| コード長 | 1,102 bytes | 
| コンパイル時間 | 4,500 ms | 
| コンパイル使用メモリ | 87,724 KB | 
| 実行使用メモリ | 92,296 KB | 
| 最終ジャッジ日時 | 2025-04-18 23:11:33 | 
| 合計ジャッジ時間 | 27,638 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 52 | 
ソースコード
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;
public class Main implements Runnable {
    public static void main(String[] args) {
        new Thread(null, new Main(), "", 512 * 1024 * 1024).start();
    }
    
    public void run() {
    	Scanner sc=new Scanner(System.in);
    	int N=sc.nextInt();
    	int K=sc.nextInt();
    	ArrayList<String>[] x=new ArrayList[K];
    	ArrayList<String>[] y=new ArrayList[K];
    	Arrays.setAll(x, i->new ArrayList<>());
    	Arrays.setAll(y, i->new ArrayList<>());
    	for(int i=0;i<N;++i) {
    		x[i%K].add(sc.next());
    	}
    	for(int i=0;i<N;++i) {
    		y[i%K].add(sc.next());
    	}
    	for(int i=0;i<K;++i)Collections.sort(x[i]);
    	for(int i=0;i<K;++i)Collections.sort(y[i]);
    	boolean ans=true;
    	for(int i=0;i<K;++i) {
    		for(int j=0;j<N/K;++j) {
    			ans&=x[i].get(j).equals(y[i].get(j));
    		}
    	}
    	System.out.println(ans?"Yes":"No");
    }
    
    void tr(Object...objects) {System.out.println(Arrays.deepToString(objects));}
}