台州学院ICPC赛前训练5

人生第一次ak,而且ak得还蛮快的,感谢队友带我飞

A 直接用claris的模板啊,他模板确实比较强大,其实就是因为更新的很快

#include<bits/stdc++.h>
using namespace std;
int fun(int x,int y)
{
    return x&y;
}
const int N=1e5+5;
int n,a[N],l[N],v[N];
int main()
{
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n;
        for(int i=1; i<=n; i++)cin>>a[i];
        long long ans=0;
        for(int i=1,j; i<=n; i++)
            for(v[i]=a[i],j=l[i]=i; j; j=l[j]-1)
            {
                v[j]=fun(v[j],a[i]);
                while(l[j]>1&&fun(a[i],v[l[j]-1])==fun(a[i],v[j]))l[j]=l[l[j]-1];
                ans+=v[j]*1LL*(j-l[j]+1);
            }
        cout<<ans<<"\n";
    }
    return 0;
}
View Code

相关文章:

  • 2021-09-17
  • 2021-10-18
  • 2021-11-07
  • 2021-11-09
  • 2021-07-10
  • 2021-11-13
  • 2021-11-19
  • 2022-01-08
猜你喜欢
  • 2022-01-10
  • 2021-07-17
  • 2021-07-18
  • 2021-05-26
  • 2021-10-09
  • 2021-07-01
  • 2022-12-23
相关资源
相似解决方案