結果

問題 No.3204 Permuted Integer
ユーザー GOTKAKO
提出日時 2025-07-18 21:52:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 578 bytes
コンパイル時間 1,867 ms
コンパイル使用メモリ 206,764 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-07-18 23:38:48
合計ジャッジ時間 4,867 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);


    map<string,int> M;
    for(int i=1; i*i<=1001001001; i++){
        int v = i*i;
        string s = to_string(v);
        sort(s.begin(),s.end());
        while(s.size() <= 10){    
            if(!M.count(s)) M[s] = v;
            s.insert(s.begin(),'0');
        }

    }

    int T; cin >> T;
    while(T--){
        string s; cin >> s;
        sort(s.begin(),s.end());
        if(M.count(s)) cout << M[s] << "\n";
        else cout << "-1\n";
    }
}
0