結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-07-18 21:25:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 564 bytes |
コンパイル時間 | 2,186 ms |
コンパイル使用メモリ | 209,228 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-18 21:26:12 |
合計ジャッジ時間 | 6,655 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int t; cin >> t; map<string, int> mp; for (int i = 1; i * i <= 1e9; i++){ string S = to_string(i * i); sort(S.rbegin(), S.rend()); mp[S] = i * i; } while (t--)[&]{ string N; cin >> N; int ans = 2e9; sort(N.rbegin(), N.rend()); if (mp.count(N) > 0){ ans = mp[N]; } while (N.back() == '0'){ N.pop_back(); if (mp.count(N) > 0){ ans = mp[N]; } } if (ans == 2e9){ ans = -1; } cout << ans << endl; }(); }