結果
| 問題 | No.3204 Permuted Integer |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-18 21:52:47 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,034 bytes |
| 記録 | |
| コンパイル時間 | 665 ms |
| コンパイル使用メモリ | 134,900 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-13 08:08:24 |
| 合計ジャッジ時間 | 4,052 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 11 WA * 15 |
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <unordered_map>
string cnt_kazus(int n) {
string cnt(10, '0');
while (n) {
cnt[n % 10]++;
if (n%10 == 0){
cnt[0]--;
}
n /= 10;
}
return cnt;
}
int main(){
int T; cin >> T;
unordered_map<string, int> mins;
for (int i = 0;; i++) {
int crr = 1LL * i * i;
if (crr > 1e9) break;
string cnt = cnt_kazus(crr);
if (mins.count(cnt)) {
mins[cnt] = min(mins[cnt], crr);
} else {
mins[cnt] = crr;
}
}
while (T--) {
int N; cin >> N;
string cnt = cnt_kazus(N);
if (mins.count(cnt)) {
cout << mins[cnt] << endl;
} else {
cout << -1 << endl;
}
}
}