比赛 4043级2023省选练习赛3 评测结果 AAAAAAAAAAAAAAAAAAAA
题目名称 吉夫特 最终得分 100
用户昵称 op_组撒头屯 运行时间 3.901 s
代码语言 C++ 内存使用 2.71 MiB
提交时间 2023-03-08 19:47:12
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define vi vector<int>
#define si set<int>
#define unsi unordered_set<int>
#define qi queue<int>
#define sti stack<int>
#define pqi priority_queue<int>
#define mii map<int,int>
#define unmii unordered_map<int,int>
#define fi first
#define se second
#define pb push_back
#define clr(f,n) memset(f,0,sizeof(int)*(n))
#define cpy(f,g,n) memcpy(f,g,sizeof(int)*(n))
const int N=211985+5;
const int M=233333+5;
const ll mod=1000000007;
int n,m;
int a[N],pos[M]; 
ll f[N];
inline void md(ll &x,ll y){
    (x+y<mod)?x+=y:x+=y-mod;
}
int main(){
	freopen ("2017gift.in","r",stdin);
	freopen ("2017gift.out","w",stdout);
	scanf("%d",&n);ll ans=mod-n;
	for (int i=1;i<=n;i++)scanf("%d",&a[i]),pos[a[i]]=i;
	for (int i=n;i>=1;i--){
	    f[i]=1;
	    for (int j=a[i];j;j=a[i]&(j-1))if (pos[j]>i)md(f[i],f[pos[j]]);
	    md(ans,f[i]);
    }printf("%lld\n",ans);
}