結果
問題 | No.397 NO MORE KADOMATSU |
ユーザー |
![]() |
提出日時 | 2016-07-14 21:01:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 27 ms / 2,000 ms |
コード長 | 790 bytes |
コンパイル時間 | 1,696 ms |
コンパイル使用メモリ | 173,572 KB |
実行使用メモリ | 25,476 KB |
平均クエリ数 | 33.44 |
最終ジャッジ日時 | 2024-07-17 00:02:08 |
合計ジャッジ時間 | 3,433 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> /*門松コンはいいぞ*/ /*絶対門松全問解こうな*/ using namespace std; typedef pair<int,int> P; vector<P> mysort(vector<int> A,int m){ vector<P> res; int N=A.size(); for(int i=0;i<N;i++)A[i]*=m; for(int i=0;i<N;i++){ int bottom=A[i],id=i; for(int j=i+1;j<N;j++) if(bottom>A[j]){ bottom=A[j]; id=j; } if(id!=i)res.push_back(P(i,id)); swap(A[i],A[id]); } return res; string s;cin>>s; } void print(vector<P>& v){ cout<<v.size()<<endl; for(auto &p:v)cout<<p.first<<" "<<p.second<<endl; } int main(){ int N;cin>>N; vector<int> A(N); for(auto &it:A)cin>>it; auto p=mysort(A,1); auto q=mysort(A,-1); if(p.size()<q.size())print(p); else print(q); return 0; }