結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
|
提出日時 | 2025-07-18 21:39:27 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 628 bytes |
コンパイル時間 | 3,347 ms |
コンパイル使用メモリ | 295,640 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-18 21:40:02 |
合計ジャッジ時間 | 8,047 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { map<int, vector<int>> mp; for (int i = 1; i * i <= 1e9; i++) { string s = to_string(i * i); sort(s.begin(), s.end()); mp[stoi(s)].push_back(i * i); } int T; cin >> T; while (T--) { int N; cin >> N; string s = to_string(N); sort(s.rbegin(), s.rend()); while (s.back() == '0') { s.pop_back(); } reverse(s.begin(), s.end()); cout << (mp.contains(stoi(s)) ? *min_element(mp[stoi(s)].begin(), mp[stoi(s)].end()) : -1) << endl; } return 0; }