結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
![]() |
提出日時 | 2025-07-18 23:49:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,125 bytes |
コンパイル時間 | 3,343 ms |
コンパイル使用メモリ | 282,664 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-07-18 23:49:26 |
合計ジャッジ時間 | 7,055 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include <debug.hpp> #else #define debug(...) #endif int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int T; cin >> T; vector<int> sq; vector<vector<int>> cnt; for (int i = 1; i * i <= 1e9 + 10; i++) { string S = to_string(i * i); vector<int> c(10); for (char x : S) c[x - '0']++; sq.emplace_back(i * i); cnt.emplace_back(c); } auto solve = [&](int N) { string S = to_string(N); vector<int> c(10); for (char x : S) c[x - '0']++; for (int i = 0; i < ssize(sq); i++) { bool ok = true; for (int j = 0; j < 10; j++) { if (c[j] == cnt[i][j]) continue; if (j == 0 && c[j] > cnt[i][j]) continue; ok = false; } if (ok) { return sq[i]; } } return -1; }; while (T--) { int N; cin >> N; cout << solve(N) << '\n'; } }