結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
![]() |
提出日時 | 2025-07-18 21:24:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 955 bytes |
コンパイル時間 | 1,990 ms |
コンパイル使用メモリ | 199,504 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-18 21:24:51 |
合計ジャッジ時間 | 5,793 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 24 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using a2 = array<ll, 2>; using a3 = array<ll, 3>; template <typename A> void chmin(A &l, const A &r) { if (r < l) l = r; } template <typename A> void chmax(A &l, const A &r) { if (l < r) l = r; } ll mod = 998244353; int main() { ios::sync_with_stdio(false); cin.tie(0); ll t; cin >> t; for (int tt = 0; tt < t; tt++) { string s; cin >> s; sort(s.begin(), s.end()); bool ok = false; do { ll n = stoll(s); for (ll i = sqrt(n) - 1; i <= sqrt(n) + 1; i++) { if (i * i == n) { ok = true; } } if (ok) { cout << n << endl; break; } } while (next_permutation(s.begin(), s.end())); if (!ok) cout << -1 << endl; } return 0; }