結果
| 問題 |
No.3204 Permuted Integer
|
| コンテスト | |
| ユーザー |
Jikky1618
|
| 提出日時 | 2025-07-18 23:59:50 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 974 bytes |
| コンパイル時間 | 3,711 ms |
| コンパイル使用メモリ | 288,860 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-07-18 23:59:57 |
| 合計ジャッジ時間 | 6,341 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 = 1; 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], ans = INF;
for (int z = 0; z <= mz; z++) {
c[0] = z;
if (mp.contains(c)) {
ans = min(ans, mp[c]);
}
}
return ans == INF ? -1 : ans;
};
while (T--) {
int N;
cin >> N;
cout << solve(N) << '\n';
}
}
Jikky1618