結果

問題 No.3109 Swap members
ユーザー moti
提出日時 2025-04-19 00:38:14
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 534 bytes
コンパイル時間 1,098 ms
コンパイル使用メモリ 133,632 KB
実行使用メモリ 22,948 KB
最終ジャッジ日時 2025-04-19 00:38:21
合計ジャッジ時間 5,633 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 4 TLE * 1 -- * 47
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  int n, k; cin >> n >> k;
  vector<string> s(n), t(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  for (int i = 0; i < n; i++) cin >> t[i];
  //cout << "------" << endl;
  for (int i = 0; i < n; i++) {
    const auto it = find(t.begin(), t.end(), s[i]);
    const auto diff = abs(it - t.begin() - i);
    if (diff % k != 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
0