結果
問題 |
No.2449 square_permutation
|
ユーザー |
![]() |
提出日時 | 2023-09-01 01:05:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 656 bytes |
コンパイル時間 | 2,206 ms |
コンパイル使用メモリ | 197,588 KB |
最終ジャッジ日時 | 2025-02-16 15:56:10 |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 |
ソースコード
#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include<bits/stdc++.h> using namespace std; priority_queue<int> P[300300]; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector<int> B(n+1); for(int i=1;i<=n;i++){ if(B[i]==0){ B[i]=i; P[i].push(i); for(int j=2;i*j*j<=n;j++){ B[i*j*j]=i; P[i].push(i*j*j); } } } vector<int> ANS; for(int i=1;i<=n;i++){ ANS.push_back(P[B[i]].top()); P[B[i]].pop(); } rep(i,n){ if(i) cout<<" "; cout<<ANS[i]; } cout<<endl; return 0; }