結果
問題 |
No.3204 Permuted Integer
|
ユーザー |
![]() |
提出日時 | 2025-07-19 00:02:54 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 903 bytes |
コンパイル時間 | 3,441 ms |
コンパイル使用メモリ | 288,688 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-07-19 00:03:00 |
合計ジャッジ時間 | 6,602 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 10 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include <debug.hpp> #else #define debug(...) #endif constexpr int INF = (1 << 30) - 1; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int T; cin >> T; map<vector<int>, int> mp; for (int i = 0; i * i <= 1e9 + 10; i++) { string S = to_string(i * i); vector<int> c(10); for (char x : S) c[x - '0']++; mp[c] = i * i; } auto solve = [&](int N) { string S = to_string(N); vector<int> c(10); for (char x : S) c[x - '0']++; int mz = c[0]; for (int z = 0; z <= mz; z++) { c[0] = z; if (mp.contains(c)) return mp[c]; } return -1; }; while (T--) { int N; cin >> N; cout << solve(N) << '\n'; } }