結果

問題 No.3204 Permuted Integer
ユーザー tau1235
提出日時 2025-07-18 22:57:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 432 bytes
コンパイル時間 3,053 ms
コンパイル使用メモリ 288,452 KB
実行使用メモリ 507,048 KB
最終ジャッジ日時 2025-07-18 22:57:26
合計ジャッジ時間 7,668 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

using ll=long long;
map<ll,bool> mp;

void solve(){
  ll inf=1e18;
  string n;
  cin>>n;
  sort(n.begin(),n.end());
  ll ans=inf;
  do{
    ll x=stoll(n);
    if (mp[x]) ans=min(ans,x);
  }while(next_permutation(n.begin(),n.end()));
  if (ans==inf) cout<<-1<<endl;
  else cout<<ans<<endl;
}

int main(){
  for (ll i=0;i<1e6;i++) mp[i*i]=true;
  int t;
  cin>>t;
  while (t--) solve();
}
0