第四个点总提示第4个位置和第5个位置不相等,过不了,样例调完后没问题,求大佬帮忙检查代码:
#include<bits/stdc++.h>
using namespace std;
int n , a[200005] , b[200005] , ai , atmp , tmp = -1;
int main()
{
ios::sync_with_stdio(0);
cin >> n;
for(int i = 1 ; i <= n ; i++)
{
cin >> a[i];
b[a[i]]++;
}
for(int i = 0 ; i <= 200000 ; i++)
{
if(b[i] >= tmp)
{
tmp = b[i];
ai = i;
}
}
for(int i = n ; i >= 1 ; i--)
{
if(a[i] == ai)
{
atmp = i;
}
}
cout << n - tmp << " " << endl;
for(int i = atmp - 1 ; i >= 1 ; i--)
{
if(a[i] == a[i + 1])
{
continue;
}
if(a[i] > a[i + 1])
{
cout << "2 ";
}
else
{
cout << "1 ";
}
cout << i << " " << i + 1 << endl;
}
for(int i = atmp + 1 ; i <= n ; i++)
{
if(a[i] == a[i - 1])
{
continue;
}
if(a[i] > a[i - 1])
{
cout << "2 ";
}
else
{
cout << "1 ";
}
cout << i << " " << i - 1 << endl;
}
return 0;
}