結果
問題 | No.2184 A○B問題 |
ユーザー | ineedyourlovep |
提出日時 | 2023-01-13 21:32:48 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,329 bytes |
コンパイル時間 | 2,410 ms |
コンパイル使用メモリ | 203,668 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 16:38:31 |
合計ジャッジ時間 | 2,904 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#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; }