結果
| 問題 | No.2449 square_permutation |
| ユーザー |
|
| 提出日時 | 2026-08-06 17:28:51 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 210 ms / 2,000 ms |
| + 546µs | |
| コード長 | 571 bytes |
| 記録 | |
| コンパイル時間 | 1,394 ms |
| コンパイル使用メモリ | 199,572 KB |
| 実行使用メモリ | 24,832 KB |
| 最終ジャッジ日時 | 2026-08-06 17:28:59 |
| 合計ジャッジ時間 | 6,662 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
#include <iostream>
#include <map>
#include <ranges>
#include <algorithm>
#include <vector>
using namespace std;
using ll=long long;
int main(){
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n;
cin>>n;
map<int,vector<int>> mp;
for(int i=1;i<=n;i++){
int x=i;
for(int j=2;j*j<=x;j++){
while(x%(j*j)==0){
x/=(j*j);
}
}
mp[x].push_back(i);
}
vector<int> ans(n+1);
for(auto[key,vec]:mp){
ranges::sort(vec,greater{});
for(int i=0;i<vec.size();i++)ans[vec[i]]=vec[vec.size()-1-i];
}
for(int i=1;i<=n;i++)cout<<ans[i]<<(i==n?"\n":" ");
}