FS_NEO @ 2024-11-10 11:01:36
暴力扫描方法轻松AC,甚至不用快读快写
所有测试点900ms内通过
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=200005;
int n,m,a[MAXN],b[MAXN],c[MAXN],s[MAXN],cnt;
int l,r,x;
unordered_map<int,int>orz;
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
if(orz.find(a[i])==orz.end()){
orz[a[i]]=++cnt;
b[i]=cnt;
c[cnt]=a[i];
}
else b[i]=orz[a[i]];
}
while(m--){
int mx=0,ans=0;
cin>>l>>r;
l=(l+x-1)%n+1,r=(r+x-1)%n+1;
if(l>r)swap(l,r);
for(int i=1;i<=cnt;i++)s[i]=0;
for(int i=l;i<=r;i++)s[b[i]]++;
for(int i=1;i<=cnt;i++)if(s[i]>mx||(s[i]==mx&&c[i]<c[ans]))mx=s[i],ans=i;
cout<<c[ans]<<"\n";
x=c[ans];
}
return 0;
}
by follow_mashiro @ 2024-11-13 13:49:22
额......数据雀是NB.