結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
aqua
|
| 提出日時 | 2025-07-18 22:37:14 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 957 bytes |
| コンパイル時間 | 3,668 ms |
| コンパイル使用メモリ | 288,640 KB |
| 実行使用メモリ | 7,716 KB |
| 最終ジャッジ日時 | 2025-07-18 22:37:23 |
| 合計ジャッジ時間 | 8,165 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 10 WA * 15 |
ソースコード
#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(map<string, int> &mp) {
string N; cin >> N;
int ans = 2'000'000'000;
sort(N.begin(), N.end(), greater());
while(N.size() > 0) {
if(N.back() == '0') N.pop_back();
else break;
}
while(N.size() < 10) {
if(mp.count(N)) chmin(ans, mp[N]);
N += '0';
}
if(ans == 2'000'000'000) cout << -1 << endl;
else cout << ans << endl;
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
map<string, int> mp;
for(int i=1; i*i<=1'000'000'000; ++i) {
int y = i*i;
string x = to_string(y);
sort(x.begin(), x.end(), greater());
if(!mp.count(x)) mp[x] = y;
}
int T; cin >> T;
for(int i=0; i<T; ++i) solve(mp);
}
aqua