#include<bits/stdc++.h>
#define maxn 250005
#define MOD 1000000009
#define pii pair<int,int>
using namespace std;
int n;
int a[maxn];
int b[maxn];
int valid()
{
int minn=0;
for(int i=1;i<n;i++)if(a[i]<a[minn])minn=i;
for(int i=0;i<n;i++)b[i]=a[(i+minn)%n];
if(b[0]>n)return true;
sort(a,a+n);
for(int i=0;i<n-1;i++)if(a[i]==a[i+1])return false;
int pre=0;
for(int i=1;i<n;i++)
{
if(b[i]<=n)
{
if(b[i]-b[pre]!=i-pre)return false;
pre=i;
}
}
return true;
}
vector<pii>v;
void replacement()
{
if(!valid())return;
int s=b[0];
for(int i=0;i<n;i++)if(b[i]>n)
{
int br=(s+i)%n;if(br==0)br=n;
v.push_back({b[i],br});
}
sort(v.begin(),v.end());
int len=v.size();
if(len==0)
{
cout<<"0"<<endl;
return;
}
cout<<v[len-1].first-n<<endl;
for(int i=0;i<len;i++)
{
cout<<v[i].second<<" ";
int pre=n;
if(i!=0)pre=v[i-1].first;
for(int j=pre+1;j<v[i].first;j++)cout<<j<<" ";
}
}
long long ste(int x,int y)
{
if(y==0)return 1;
if(y%2==1)return (ste(x,y-1)*x)%MOD;
long long res=ste(x,y/2);
return (res*res)%MOD;
}
vector<int>br;
long long broj()
{
if(!valid())return 0;
for(int i=0;i<n;i++)if(b[i]>n)br.push_back(b[i]);
sort(br.begin(),br.end());
long long sol=1;
int len=br.size();
for(int i=0;i<len;i++)
{
int pre=n;
if(i!=0)pre=br[i-1];
sol*=ste(len-i,br[i]-pre-1);
}
return sol;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int t;
cin>>t;
cin>>n;
for(int i=0;i<n;i++)cin>>a[i];
if(t<=3)cout<<valid()<<endl;
else if(t<=6)replacement();
else cout<<broj()<<endl;
return 0;
}
Compilation message
/tmp/ccYantmp.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccQRDTKp.o:gondola.cpp:(.text.startup+0x0): first defined here
/tmp/ccYantmp.o: In function `main':
grader.cpp:(.text.startup+0xc3): undefined reference to `countReplacement'
grader.cpp:(.text.startup+0xe2): undefined reference to `valid'
grader.cpp:(.text.startup+0x106): undefined reference to `replacement'
collect2: error: ld returned 1 exit status