結果
| 問題 | No.3204 Permuted Integer |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-12 15:33:38 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 188 ms / 2,000 ms |
| + 369µs | |
| コード長 | 635 bytes |
| 記録 | |
| コンパイル時間 | 1,959 ms |
| コンパイル使用メモリ | 186,248 KB |
| 実行使用メモリ | 7,168 KB |
| 最終ジャッジ日時 | 2026-09-12 15:33:49 |
| 合計ジャッジ時間 | 7,406 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 26 |
ソースコード
#include<iostream>
#include<vector>
#include<array>
#include<map>
#include<algorithm>
using namespace std;
using ll = long long;
using ar = array<int, 10>;
ar f(ll n){
ar ans={};
while(n){
ans[n%10]++;
n/=10;
}
return ans;
}
int main(void){
map<ar, ll> mi;
for(ll i=1; i*i<=1e10; i++){
ar now=f(i*i);
if(mi.count(now)==0) mi[now]=i*i;
}
int t; cin >> t;
while(t--){
ll n; cin >> n;
ar now=f(n);
//cout << now[0] << endl;
ll ans=1e18;
while(now[0]>=0){
if(mi.count(now)) ans=min(ans, mi[now]);
now[0]--;
}
cout << (ans==1e18?-1:ans) << '\n';
}
return 0;
}