結果
| 問題 | 
                            No.3204 Permuted Integer
                             | 
                    
| コンテスト | |
| ユーザー | 
                             titia
                         | 
                    
| 提出日時 | 2025-07-19 00:07:33 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 449 ms / 2,000 ms | 
| コード長 | 504 bytes | 
| コンパイル時間 | 361 ms | 
| コンパイル使用メモリ | 82,288 KB | 
| 実行使用メモリ | 108,212 KB | 
| 最終ジャッジ日時 | 2025-07-19 00:07:47 | 
| 合計ジャッジ時間 | 11,156 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 26 | 
ソースコード
import sys
input = sys.stdin.readline
D=dict()
for i in range(1,100000):
    x=i*i
    s=tuple(sorted(str(x)))
    if s in D:
        pass
    else:
        D[s]=x
    
    
T=int(input())
for tests in range(T):
    X=tuple(sorted(input().strip()))
    ANS=-1
    while True:
        if X in D:
            if ANS==-1:
                ANS=D[X]
            else:
                ANS=min(ANS,D[X])
        if X[0]=="0":
            X=X[1:]
        else:
            break
    print(ANS)
        
            
            
            
        
            
titia