比赛 果蝇王邀请赛div2 评测结果 ATTTTTWWWW
题目名称 果蝇炸弹 最终得分 10
用户昵称 __0w0__ 运行时间 6.038 s
代码语言 C++ 内存使用 5.33 MiB
提交时间 2026-08-27 11:22:42
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long 
int c,ans;
int n;
int a[300001],r[300001];
bool f[1<<17];
inline int solve(int x){
    for(int k=1;k<=n;k++){
        bool f=0;
        for(int i=1;i<=n;i++){
            if(x&(1<<i-1)){
                for(int j=i-1;j>=1;j--){
                    if(a[j]<a[i]-r[i])break;
                    x|=(1<<j-1);
                }
                for(int j=i;j<=n;j++){
                    if(a[j]>a[i]+r[i])break;
                    x|=(1<<j-1);
                }
                f=1;
            }
        }
        if(!f)break;
    }
    return x;
}
inline int read(){
    
}
inline void ns(int x){
    int l=log2(x);
    if(!x)for(int i=n-1;i>=0;i--)cout<<0;
    else for(int i=n-1;i>=0;i--)cout<<(x&(1<<i)?1:0);
}
signed main(){
    freopen("bombmine.in","r",stdin);
    freopen("bombmine.out","w",stdout);
    cin>>c>>n;
    for(int i=1;i<=n;i++){
        scanf("%lld%lld",&a[i],&r[i]);
//        printf("%lld can reach from %lld to %lld\n",i,a[i]-r[i]+1,a[i]+r[i]-1);
    }
    for(int i=0;i<(1<<n);i++){
        int x=solve(i);
        if(!f[x])ans++;
//            cout<<i<<':',ns(i),cout<<' '<<x<<':',ns(x),cout<<'\n';
        f[x]=1;
    }
    cout<<ans;
    fclose(stdin);
    fclose(stdout);
    return 0;
}