結果

問題 No.397 NO MORE KADOMATSU
ユーザー mai
提出日時 2016-07-15 22:57:03
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,652 bytes
コンパイル時間 1,960 ms
コンパイル使用メモリ 181,404 KB
実行使用メモリ 25,604 KB
平均クエリ数 52.11
最終ジャッジ日時 2024-07-16 10:36:02
合計ジャッジ時間 5,957 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007
template<typename T1,typename T2>
ostream& operator <<(ostream &o,const pair<T1,T2> p){o<<"("<<p.first<<":"<<p.second<<")";return o;}
int data[101];
int main(){
int i,j;
int n;
cin >> n;
vector<int> order(n);
for (i=0;i<n;i++){
order[i]=i+1;
scanf("%d",data+i);
}
//
stable_sort(order.begin(),order.end(),[](int l,int r){return data[l]<data[r];});
vector<int> v(n);
for (i=0;i<n;i++)
v[order[i]-1]=i;
queue<pair<int,int>> result;
// (n+1)
for (i=0;i<n-1;i++){
for (j=i;j<n;j++){
if (v[j]==i){
if (i!=j){
result.push(make_pair(i+1,j+1));
swap(v[i],v[j]);
}
break;
}
}
}
cout<<result.size()<<endl;
while (!result.empty()){
printf("%d %d\n",result.front().first,result.front().second);
result.pop();
}
cout<<endl;
cin>>n;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0