結果
| 問題 | 
                            No.3109 Swap members
                             | 
                    
| コンテスト | |
| ユーザー | 
                             aoblue2547
                         | 
                    
| 提出日時 | 2025-04-18 21:28:50 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 158 ms / 2,000 ms | 
| コード長 | 2,611 bytes | 
| コンパイル時間 | 5,509 ms | 
| コンパイル使用メモリ | 332,252 KB | 
| 実行使用メモリ | 14,352 KB | 
| 最終ジャッジ日時 | 2025-04-18 21:29:03 | 
| 合計ジャッジ時間 | 11,035 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 52 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmin(T& a, T b) { return a > b ? a = b, true : false; }
template<class T> bool chmax(T& a, T b) { return a < b ? a = b, true : false; }
template<typename T>
concept Iterable = requires(T t) { std::begin(t); std::end(t); };
template<typename T>
	requires Iterable<T> && (!is_same_v<T, string>)
ostream& operator<<(ostream& os, const T& container) { for (auto& element : container) os << element << ' '; return os; }
template<typename R>
	requires ranges::range<R> && (!is_same_v<decay_t<R>, string>) && (!is_same_v<decay_t<R>, const char*>)
ostream& operator<<(ostream& os, R&& range) { for (auto& element : range)os << element << ' '; return os; }
template<typename T>
	requires Iterable<T> && (!is_same_v<T, string>)
istream& operator>>(std::istream& is, T& container) { for (auto& e : container)is >> e; return is; }
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
template<class T = ll> struct Edge {
	int to;
	T weight;
	bool operator==(Edge e) { return this->to == e.to and this->weight == e.weight; }
	bool operator<(Edge e) { return this->to == e.to ? this->weight < e.weight : this->to < e.to; }
};
#ifdef _DEBUG
#define SHOW(n) {const auto& _ret = n; cerr << #n << ": " << _ret << endl;}
#define MSG(x) cerr << x << endl;
#else
#define SHOW(n)
#define MSG(x)
#endif
//AtCoder Library
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;
using mint = modint1000000007;
//using mint1 = dynamic_modint<0>;
//using mint = modint;
//mint::set_mod();
istream& operator>>(istream& is, mint& x) { ll r; is >> r; x = r; return is; }
ostream& operator<<(ostream& os, mint& x) { os << x.val(); return os; }
//boost
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//using l3 = int128_t;
int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	map<string, int> mp;
	vector<int> a, b;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		mp[s] = i;
		a.push_back(i);
	}
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		int j = mp[s];
		b.push_back(j);
	}
	vector<bool> seen(n, false);
	for (int i = 0; i < n - k; ++i) {
		if (seen[i])continue;
		set<int> st1, st2;
		for (int j = i; j < n; j += k) {
			seen[j] = true;
			st1.insert(a[j]);
			st2.insert(b[j]);
		}
		if (st1 != st2) {
			cout << "No" << endl;
			return 0;
		}
	}
	for (int i = 0; i < n; ++i) {
		if (seen[i])continue;
		if (a[i] != b[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}
            
            
            
        
            
aoblue2547