#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
using namespace std;
typedef pair<int,int> pii;
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
int n;
cin>>n;
vector<int> a(n+1);
iota(a.begin(),a.end(),0);
vector<vector<pii>> ans;
while(!is_sorted(a.begin()+1,a.end(),greater<int>()))
{
vector<pii> tmp;
for(int i=2;i<=n;i++)
{
if(a[i]>a[i-1])
{
swap(a[i],a[i-1]);
tmp.push_back({a[i],a[i-1]});
i++;
}
}
ans.push_back(tmp);
}
cout<<ans.size()<<endl;
for(auto a:ans)
{
cout<<a.size()<<endl;
for(auto [x,y]:a)
{
cout<<x<<' '<<y<<endl;
}
}
}
标签:tmp,超时,cout,int,vector,ans,include,endl
From: https://www.cnblogs.com/ccag/p/17121408.html