233

#include<bits/stdc++.h>
#define reg register int
#define il inline
#define fi first
#define se second
#define mk(a,b) make_pair(a,b)
#define numb (ch^'0')
#define pb push_back
#define solid const auto &
#define enter cout<<endl
#define pii pair<int,int>
using namespace std;
typedef long long ll;
template<class T>il void rd(T &x){
    char ch;x=0;bool fl=false;while(!isdigit(ch=getchar()))(ch=='-')&&(fl=true);
    for(x=numb;isdigit(ch=getchar());x=x*10+numb);(fl==true)&&(x=-x);}
template<class T>il void output(T x){if(x/10)output(x/10);putchar(x%10+'0');}
template<class T>il void ot(T x){if(x<0) putchar('-'),x=-x;output(x);putchar(' ');}
template<class T>il void prt(T a[],int st,int nd){for(reg i=st;i<=nd;++i) ot(a[i]);putchar('\n');}
namespace Modulo{
const int mod=998244353;
il int ad(int x,int y){return x+y>=mod?x+y-mod:x+y;}
il int sub(int x,int y){return ad(x,mod-y);}
il int mul(int x,int y){return (ll)x*y%mod;}
il void inc(int &x,int y){x=ad(x,y);}
il void inc2(int &x,int y){x=mul(x,y);}
il int qm(int x,int y=mod-2){int ret=1;while(y){if(y&1) ret=mul(x,ret);x=mul(x,x);y>>=1;}return ret;}
template<class ...Args>il int ad(const int a,const int b,const Args &...args) {return ad(ad(a,b),args...);}
template<class ...Args>il int mul(const int a,const int b,const Args &...args) {return mul(mul(a,b),args...);}
}
//using namespace Modulo;
namespace Miracle{
const int N=22;
const int inf=0x3f3f3f3f;
int n,p;
int f[1<<N];
int len[N],st[N],nd[N],tim[N];
int id[N];
int g[1<<N];
bool cmp(int x,int y){
    return tim[x]<tim[y];
}
struct po{
    int p,id;
    bool friend operator <(po a,po b){
        return a.p<b.p;
    }
}p[N];
int main(){
    rd(n);rd(p);
    for(reg i=0;i<n;++i){
        rd(st[i]);rd(len[i]);rd(tim[i]);
        nd[i]=st[i]+len[i]-1;
        id[i]=i;
        p[i].p=st[i];
        p[i].id=i;
    }
    sort(id,id+n);
    sort(p,p+n);
    memset(f,0x3f,sizeof f);
    f[0]=0;
    g[0]=1;
    for(reg s=1;s<(1<<n);++s){
        int now=log2(s&(-s));
        g[s]=g[s^(s&(-s))];
        for(reg i=0;i<n;++i){
            if(i==now) continue;
            if((s>>i)&1){
                if(!((nd[now]<st[i])||(st[now]>nd[i]))) g[s]=0;
            }
        }    
    }
    for(reg s=0;s<(1<<n)-1;++s){
        if(f[s]!=inf){
            int lp=0;
            while(lp<n&&((!((s>>p[lp].id)&1))||p[lp].p<f[s]+1)) ++lp;
            for(reg o=0;o<n;++o){
                int c=id[o];
                ptr=lp;
                if(!((s>>c)&1)){
                    if(g[s|(1<<c)]){
                        int t=f[s]+1;
                        
                    }
                }
            }
        }
    }
}

}
signed main(){
    Miracle::main();
    return 0;
}

/*
   Author: *Miracle*
*/

 

posted @ 2019-06-29 22:18  *Miracle*  阅读(235)  评论(0编辑  收藏  举报