結果
問題 | No.2732 Similar Permutations |
ユーザー |
![]() |
提出日時 | 2024-04-05 15:01:23 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,355 bytes |
コンパイル時間 | 3,476 ms |
コンパイル使用メモリ | 250,456 KB |
実行使用メモリ | 9,740 KB |
最終ジャッジ日時 | 2024-10-01 01:10:02 |
合計ジャッジ時間 | 20,535 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 66 WA * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;using ll=long long;using pll=pair<ll,ll>;using tll=tuple<ll,ll,ll>;using ld=long double;const ll INF=(1ll<<60);#define rep(i,n) for (ll i=0;i<(ll)(n);i++)#define all(v) v.begin(),v.end()template<class T> inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}template<class T> inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);ll n;cin >> n;vector<ll> a(n);rep(i,n) cin >> a[i];if(n<=2){if(((a[0]+1)^(a[1]+2))==((a[0]+2)^(a[1]+1))){cout << "1 2\n";cout << "2 1\n";}else{cout << "-1\n";}return 0;}vector<ll> x,y;rep(i,n){if(a[i]&1) x.push_back(i);else y.push_back(i);}if((ll)x.size()<=1) swap(x,y);vector<ll> p(n);ll now=1;rep(i,n){if(i==x[0]){p[i]=2;}else if(i==x[1]){p[i]=3;}else{p[i]=now;if(now==1) now=4;else now++;}}vector<ll> q=p;swap(q[x[0]],q[x[1]]);rep(i,n) cout << p[i] << ' ';cout << '\n';rep(i,n) cout << q[i] << ' ';cout << '\n';}