結果

問題 No.3204 Permuted Integer
ユーザー aqua
提出日時 2025-07-18 21:50:06
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 636 bytes
コンパイル時間 3,001 ms
コンパイル使用メモリ 282,264 KB
実行使用メモリ 15,936 KB
最終ジャッジ日時 2025-07-18 21:50:33
合計ジャッジ時間 6,638 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other TLE * 1 -- * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using ll = long long;

bool chmin(auto &a, auto b) { return a > b ? a = b, true : false; }
bool chmax(auto &a, auto b) { return a < b ? a = b, true : false; }

void solve() {
    string N; cin >> N;
    sort(N.begin(), N.end());
    do {
        int x = stoi(N);
        int y = sqrt(x);
        if(y*y == x) {
            cout << x << endl;
            return;
        }
    } while(next_permutation(N.begin(), N.end()));
    cout << -1 << endl;
    return;
}

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

    int T; cin >> T;
    for(int i=0; i<T; ++i) solve();
}
0