結果
| 問題 | No.1743 Permutation Code |
| ユーザー |
FplusFplusF
|
| 提出日時 | 2022-11-29 00:49:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,087 bytes |
| 記録 | |
| コンパイル時間 | 2,203 ms |
| コンパイル使用メモリ | 206,544 KB |
| 最終ジャッジ日時 | 2025-02-09 02:03:13 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 3 WA * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
if(a>b){
a=b;
}
}
template<class T> void chmax(T &a,T b){
if(a<b){
a=b;
}
}
string ten_to_two(int x){
string s;
while(0<x){
s.push_back(x%2+'0');
x/=2;
}
reverse(all(s));
return s;
}
int main(){
random_device rd;
mt19937 mt(rd());
auto start=chrono::system_clock::now();
string c;
cin >> c;
int x=0,n=1;
while(x<(int)c.size()){
string s=ten_to_two(n);
x+=s.size();
n++;
}
n--;
string v[n];
map<string,int> mp;
rep(i,n){
v[i]=ten_to_two(i+1);
mp[v[i]]=i+1;
}
int max_score=0;
int p=0;
rep(i,n){
rep(j,v[i].size()){
if(v[i][j]==c[p]) max_score+=100;
p++;
}
}
int now_score=0;
while(true){
int a=mt()%n,b=mt()%n;
swap(v[a],v[b]);
now_score=0;
p=0;
rep(i,n){
rep(j,v[i].size()){
if(v[i][j]==c[p]) now_score+=100;
p++;
}
}
auto now=chrono::system_clock::now();
double sec=chrono::duration_cast<chrono::milliseconds>(now-start).count();
double temp=100.0*8-100.0*8*sec/7950;
double prob=exp((double)(now_score-max_score)/temp);
double rand_double=(double)mt()/(double)(mt19937::max());
if(rand_double<prob){
max_score=now_score;
/*cout << prob << " "<< max_score << endl;
rep(i,n){
cout << mp[v[i]] << " ";
}
cout << endl;*/
}else{
swap(v[a],v[b]);
}
if(7950<sec||max_score==(int)c.size()*100){
rep(i,n){
cout << mp[v[i]] << " ";
}
cout << endl;
return 0;
}
}
}
FplusFplusF