結果
| 問題 |
No.2732 Similar Permutations
|
| コンテスト | |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2024-04-05 12:33:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 1,221 bytes |
| コンパイル時間 | 3,319 ms |
| コンパイル使用メモリ | 256,552 KB |
| 実行使用メモリ | 13,952 KB |
| 最終ジャッジ日時 | 2024-10-01 01:04:38 |
| 合計ジャッジ時間 | 18,081 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 101 |
ソースコード
#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);
auto start=chrono::system_clock::now();
ll n;
cin >> n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
vector<ll> p(n);
rep(i,n) p[i]=i+1;
map<ll,vector<ll>> mp;
do{
auto now=chrono::system_clock::now();
int ms=chrono::duration_cast<chrono::milliseconds>(now-start).count();
if(1980<ms) break;
ll x=0;
rep(i,n) x^=(p[i]+a[i]);
if(!mp[x].empty()){
for(auto i:mp[x]) cout << i << ' ';
cout << '\n';
for(auto i:p) cout << i << ' ';
cout << '\n';
return 0;
}
mp[x]=p;
}while(next_permutation(all(p)));
cout << "-1\n";
}
FplusFplusF