結果
| 問題 |
No.3109 Swap members
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-18 21:12:56 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 259 ms / 2,000 ms |
| コード長 | 1,414 bytes |
| コンパイル時間 | 1,978 ms |
| コンパイル使用メモリ | 203,344 KB |
| 実行使用メモリ | 25,072 KB |
| 最終ジャッジ日時 | 2025-04-18 21:13:11 |
| 合計ジャッジ時間 | 8,663 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 52 |
ソースコード
// MARK: - コード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// using mint = modint998244353;
const int dx[8] = {0, -1, 1, 0, -1, 1, -1, 1};
const int dy[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
#define reps(i, l, r) for (std::decay_t<decltype(r)> i##_right = (r), i = (l); i < i##_right; i++)
#define rep(i, n) reps(i, 0, n)
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main() {
int N, K;
cin >> N >> K;
vector<string> A(N), B(N);
rep(i, N) cin >> A[i];
rep(i, N) cin >> B[i];
map<string, int> mp;
rep(i, N) {
string s = B[i];
mp[s] = i;
}
bool check = true;
rep(i, N) {
string s = A[i];
int B_index = mp.find(s)->second;
if (abs(B_index - i) % K != 0) {
check = false;
break;
}
}
if (check) {
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}
}
/*
MARK: - メモ
*/