結果

問題 No.2184 A○B問題
ユーザー ineedyourlovepineedyourlovep
提出日時 2023-01-13 21:32:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,329 bytes
コンパイル時間 2,014 ms
コンパイル使用メモリ 202,796 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 03:08:29
合計ジャッジ時間 2,631 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
//const int mod = 1000000007;
//const int mod = 998244353;

struct Perm : vector<int> {
#define n (int)(size())
#define p (*this)
  Perm(int _n): vector<int>(_n) {
    iota(begin(), end(), 0);
  }
  template<class...Args> Perm(Args...args): vector<int>(args...) {}
  Perm(initializer_list<int> a): vector<int>(a.begin(),a.end()) {}
  Perm operator+(const Perm& a) const {
    Perm r(n);
    for (int i = 0; i < n; ++i) r[i] = p[a[i]];
    return r;
  }
  Perm& operator+=(const Perm& a) {
    return *this = (*this)+a;
  }
  Perm operator-() const {
    Perm r(n);
    for (int i = 0; i < n; ++i) r[p[i]] = i;
    return r;
  }
  Perm operator-(const Perm& a) const {
    return *this + -a;
  }
  Perm& operator-=(const Perm& a) {
    return *this += -a;
  }
  // next permutation
  bool operator++() {
    return next_permutation(begin(),end());
  }
#undef n
#undef p
};

int main()
{
  const int n = 5;
  vector<int> a(n), b(n);
  rep(i, 0, n) {
    cin >> a[i];
    a[i]--;
  }
  rep(i, 0, n) {
    cin >> b[i];
    b[i]--;
  }
  Perm p(a);
  p += b;
  rep(i, 0, n) cout << p[i]+1 << " \n"[i == n-1];
  return 0;
}
0