CQOI2018

一套被婊到死的题,告诉我自己究竟有多弱.

别人的期望得分:100+100+100+100+100+100+100=AK进队

我的期望得分:100+100+30+100+?+100500=买D苟活/不太丢人地滚粗

我的实际得分:0+30+20+10+30+30=120=??? 晚节不保

 

D1t1是个bsgs模板题

然后我在输出答案的时候输出了ksm(g,(a+b)%p); 

(

//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long LL; 
typedef double db;
using namespace std;
LL g,p,m,n,A,B,mod=1799797,time_cnt,ecnt,H[2000007];
int vis[2000007],fir[2000007],nxt[2000007],pos[2000007];

template<typename T> void read(T &x) {
    char ch=getchar(); x=0; T f=1;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

LL ksm(LL a,LL b) {
    LL rs=1,bs=a;
    while(b) {
        if(b&1) rs=rs*bs%p;
        bs=bs*bs%p;
        b>>=1;
    }
    return rs;
}

void add(int x,LL hh,int id) {
    for(int i=fir[x];i;i=nxt[i]) if(H[i]==hh) return;
    nxt[++ecnt]=fir[x]; fir[x]=ecnt; H[ecnt]=hh; pos[ecnt]=id;
}

int find(LL hh) {
    int tp=hh%mod;
    if(vis[tp]!=time_cnt) return 0;
    for(int i=fir[tp];i;i=nxt[i]) if(H[i]==hh) 
        return pos[i];
    return 0;
}

LL bsgs(LL C) {
    time_cnt++; ecnt=0;
    LL now=C,bs=1;
    For(j,1,m) {
        now=now*g%p;
        bs=bs*g%p;
        int tp=now%mod;
        if(vis[tp]!=time_cnt) {
            vis[tp]=time_cnt;
            fir[tp]=++ecnt; 
            pos[ecnt]=j;
            H[ecnt]=now;
        }
        else add(tp,now,j);
    }
    now=1;
    For(i,1,m) {
        now=now*bs%p;
        int tp=find(now);
        if(tp) return i*m-tp;
    }
    return -1;
}

#define DEBUG
int main() {
#ifdef DEBUG
    freopen("crack.in","r",stdin);
    freopen("crack.out","w",stdout);
#endif
    read(g); read(p);
    m=sqrt(p); if(m*m<p) m++;
    read(n);
    For(ti,1,n) {
        read(A); read(B);
        LL a=bsgs(A),b=bsgs(B);
        printf("%lld\n",ksm(g,a*b)); ///ksm(g,a*b%p) no zuo no die why you try?
    }
    return 0;
}
View Code

 

D1t2是个矩阵树模板题

一开始打了个可以过并且跑得飞快的辗转相除的高斯消元.怕被卡常改成了用double,不知道当时怎么想的..然后GG了.

//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
const int p=10007,N=255;
typedef long long LL; 
typedef double db;
using namespace std;
int n,m;
LL g[N][N];

template<typename T> void read(T &x) {
    char ch=getchar(); x=0; T f=1;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

LL solve(int n) {
    LL rs=1,f=1;
    For(i,1,n) For(j,1,n) g[i][j]=(g[i][j]%p+p)%p;
    For(i,1,n) {
        For(j,i+1,n) if(g[j][i]) {
            LL A=g[i][i],B=g[j][i];
            while(B) {
                LL t=A/B;
                For(k,i,n) g[i][k]=(g[i][k]-t*g[j][k]%p+p)%p;
                For(k,i,n) swap(g[i][k],g[j][k]);
                f=-f; A%=B; swap(A,B);
            }
        }
        if(!g[i][i]) return 0;
        rs=rs*g[i][i]%p;
    }
    if(f==-1) rs=p-rs;
    return rs;
}

#define DEBUG
int main() {
#ifdef DEBUG
    freopen("sns.in","r",stdin);
    freopen("sns.out","w",stdout);
#endif
    read(n); read(m);
    For(i,1,m) {
        int a,b;
        read(a); read(b);
        a--; b--;
        g[a][a]++;
        g[b][a]--;
    }
    LL ans=solve(n-1);
    printf("%lld\n",ans);
    return 0;
}
/*
4
7
2 1
3 1
1 3
2 3
3 2
4 3
4 2
*/
View Code

 

D1t3

目前有一个算法是组合数加各种卡常,但是机房还没人卡过去.

 

D2t1是一个真的十分sb的状压,但是我把ck的时候第二行的y写成了x

 1 //Achen
 2 #include<algorithm>
 3 #include<iostream>
 4 #include<cstring>
 5 #include<cstdlib>
 6 #include<vector>
 7 #include<cstdio>
 8 #include<queue>
 9 #include<cmath>
10 #include<set>
11 #define For(i,a,b) for(register int i=(a);i<=(b);i++)
12 #define Rep(i,a,b) for(register int i=(a);i>=(b);i--)
13 const int N=25,UP=(1<<20)+5,mod=100000007;
14 typedef long long LL; 
15 typedef double db;
16 using namespace std;
17 int n,x[N],y[N],g[N][N],cnt[UP];
18 LL f[N][UP],ans;
19 
20 template<typename T> void read(T &x) {
21     char ch=getchar(); x=0; T f=1;
22     while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
23     if(ch=='-') f=-1,ch=getchar();
24     for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
25 }
26 
27 int ck(int i,int j,int k) {
28     if(x[k]<min(x[i],x[j])||x[k]>max(x[i],x[j])) return 0;
29     if(y[k]<min(y[i],y[j])||y[k]>max(y[i],y[j])) return 0; //    if(y[k]<min(x[i],x[j])||y[k]>max(x[i],x[j])) return 0;
30     //no zuo no die why you try
31     return (y[k]-y[i])*(x[j]-x[k])==(y[j]-y[k])*(x[k]-x[i]);
32 }
33 
34 #define DEBUG
35 int main() {
36 #ifdef DEBUG
37     freopen("android.in","r",stdin);
38     freopen("android.out","w",stdout);
39 #endif
40     read(n);
41     For(i,1,n) {
42         read(x[i]); read(y[i]);
43     }
44     For(i,1,n) For(j,i+1,n) {
45         g[i][j]=0;
46         For(k,1,n) if(k!=i&&k!=j&&ck(i,j,k)) 
47             g[i][j]=(g[i][j]|(1<<(k-1)));
48         g[j][i]=g[i][j];
49     }
50     For(i,1,UP) 
51         for(int j=i;j;j-=(j&(-j))) cnt[i]++;
52     int nn=(1<<n)-1;
53     For(i,1,n) f[i][1<<(i-1)]=1;
54     For(s,1,nn) For(i,1,n) if(f[i][s]) {
55         For(j,1,n) if(((s&(1<<j-1))==0)&&((s&g[i][j])==g[i][j])) 
56             (f[j][s|(1<<j-1)]+=f[i][s])%=mod;
57     }
58     For(i,1,n) For(j,0,nn) if(cnt[j]>=4)(ans+=f[i][j])%=mod;
59     printf("%lld\n",ans);
60     return 0;
61 }
62 /*
63 4
64 0 0
65 1 1
66 2 2
67 3 3
68 */
View Code

 

D2t2是一个可以找规律然后压位高精水过的水题,然而我不仅高精没有压位(实际上不压位也有80)而且把T看成了<=5.把数组炸了

//Achen
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<cstdio>
#include<queue>
#include<cmath>
#include<set>
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rep(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long LL; 
typedef double db;
using namespace std;
LL T,n,a[1000007],len,ans[15][1000007],anslen[15];
LL up=1e17;

template<typename T> void read(T &x) {
    char ch=getchar(); x=0; T f=1;
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=-1,ch=getchar();
    for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
}

struct node {
    int n,id;
    friend bool operator <(const node&A,const node &B) {
        return A.n<B.n;
    }
}q[15];

#define DEBUG
int main() {
#ifdef DEBUG
    freopen("baguenaudier.in","r",stdin);
    freopen("baguenaudier.out","w",stdout);
#endif
    read(T); 
    For(i,1,T) {
        read(q[i].n); q[i].id=i;
    } 
    sort(q+1,q+T+1); int nowq=1;
    a[1]=1; len=1;
    while(q[nowq].n==1) {
        anslen[q[nowq].id]=1;
        ans[q[nowq].id][1]=1;
        nowq++;
    }
    For(ti,2,q[T].n) {
        int pr=0;
        /*For(i,1,len) {
            a[i]=a[i]*2+pr;
            pr=a[i]/up;
            a[i]%=up;
        }*/
        For(i,1,len) a[i]<<=1;
        For(i,1,len) while(a[i]>=up) { a[i]-=up; a[i+1]++; }
        if(a[len+1]) len++;
        if(ti&1) {
            a[1]++;
            int pos=1;
            while(a[pos]>=up) { a[pos]-=up; a[++pos]++; }
            if(pos>=len) len=pos;
            /*int pr=1;
            For(i,1,len) {
                a[i]+=pr;
                pr=a[i]/up;
                if(!pr) break;
                a[i]%=up;
            }
            if(pr) a[++len]=pr;*/
        }
        if(ti==q[nowq].n) {
            For(i,1,len) ans[q[nowq].id][i]=a[i];
            anslen[q[nowq].id]=len;
            nowq++;
        }
    }
    For(i,1,T) {
        Rep(j,anslen[i],1) {
            if(j!=anslen[i]&&ans[i][j]!=up-1) {
                printf("%017lld",ans[i][j]);
            }
            else printf("%lld",ans[i][j]);
        }
        printf("\n");
    }
    return 0;
}
View Code

 

D2t3一开始以为k是不同的,然后发现是相同的,就是一个十分水水水水水的莫队

然而我莫队模板,特判了这一次的区间和上一次没有交点的情况,在这种情况下却没有把l,r移过去.

 1 //Achen
 2 #include<algorithm>
 3 #include<iostream>
 4 #include<cstring>
 5 #include<cstdlib>
 6 #include<vector>
 7 #include<cstdio>
 8 #include<queue>
 9 #include<cmath>
10 #include<set>
11 #define For(i,a,b) for(int i=(a);i<=(b);i++)
12 #define Rep(i,a,b) for(int i=(a);i>=(b);i--)
13 const int N=1e5+7;
14 typedef long long LL; 
15 typedef double db;
16 using namespace std;
17 int n,m,k,cnt[N],a[N],sz,tot;
18 LL now,ans[N];
19 
20 template<typename T> void read(T &x) {
21     char ch=getchar(); x=0; T f=1;
22     while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
23     if(ch=='-') f=-1,ch=getchar();
24     for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0'; x*=f;
25 }
26 
27 struct node {
28     int ql,qr,id;
29     friend bool operator <(const node&A,const node &B) {
30         return A.ql/sz<B.ql/sz||(A.ql/sz==B.ql/sz&&A.qr/sz<B.qr/sz);
31     }
32 }q[N];
33 
34 void add(int x) {
35     now+=cnt[x^k];
36     cnt[x]++;
37 }
38 
39 void del(int x) {
40     if(k==0) now-=(cnt[x]-1);
41     else now-=cnt[x^k];
42     cnt[x]--;
43 }
44 
45 #define DEBUG
46 int main() {
47 #ifdef DEBUG
48     freopen("xor.in","r",stdin);
49     freopen("xor.out","w",stdout);
50 #endif
51     read(n); read(m); read(k);
52     For(i,1,n) { read(a[i]); a[i]^=a[i-1]; }
53     sz=sqrt(n); tot=n/sz; if(tot*sz!=n) tot++;
54     For(i,1,m) {
55         read(q[i].ql); read(q[i].qr); 
56         q[i].ql--; q[i].id=i;
57     }
58     sort(q+1,q+m+1);
59     int l=1,r=0;
60     For(i,1,m) {
61         if(r<q[i].ql||l>q[i].qr) {
62             For(j,l,r) del(a[j]);
63             For(j,q[i].ql,q[i].qr) add(a[j]);
64             l=q[i].ql; r=q[i].qr; /////no zuo no die why you try
65         }
66         int ql=q[i].ql,qr=q[i].qr;
67         while(l>ql) add(a[--l]);
68         while(l<ql) del(a[l++]);
69         while(r<qr) add(a[++r]);
70         while(r>qr) del(a[r--]); 
71         ans[q[i].id]=now;
72     }
73     For(i,1,m) printf("%lld\n",ans[i]);
74     return 0;
75 }
76 /*
77 10 1 6
78 8 2 6 9 8 0 1 1 6 2 
79 2 9
80 */
View Code

 

人呐就都不知道,自己就不可以预料。你一个人的命运啊,当然要靠自我奋斗,但是也要考虑到历史的行程,

 

之前感觉SCOI2018画风诡密,成心送我退役.现在庆幸自己没生在CQ,这不是连买D的一毛钱机会都没有了,还晚节不保.

学OI这么久,虽然知道经常爆炸主要还是自己太弱,但还是更深刻地体会到了,sxy也说过的一句话,

一个人真的无法掌握自己的命运啊.

稳如yyh,沦落到D类Cu滚粗的境地.

稳如pyh,也因为炸整被卡出省队线.

本校今年也是,以为会进队结果被卡线上的比我强到不知道哪里去的选手.

被CQOI2018这套神题送退役的人也数不清.

NOIp之前大家都没有预料到,SCOI之前也没有人预料到.那NOI谁又能说的准呢.

自己弱是事实,但是历史的进程仍然轻松踩爆个人的命运,

你永远不会知道明天等待你的命运究竟是AK还是爆0.

强校强选手都难以掌握自己的命运,弱校弱选手更是了.

话说回来,不只是OI,不只是竞赛,在任何其他方面何尝不是这样呢.

只要努力就会有回报,这句话我向来是不信的.

努力和回报从来都不成正比关系.

何况,人的命运应该是从出生起就注定了的.

任何鸡汤励志文都不过是一些好命者的自以为是

有一句话虽然有点矫情,但是很有道理

"从来没有什么感同身受,针不是扎在你身上你永远也不会痛"

一直以来我有个比较歪的价值观,我觉得任何坏人坏事都是,即使不能被原谅,但可以被理解的.

一些站着说话不腰疼的人总喜欢说,如果是我就会怎样怎样,如果多一点理解宽容善良耐心努力勤奋就可以云云

实际上前提是不存在的,如果你是他,你也会作出相同的选择,你是他的前提是,你经历所有他经历过的事,而没有经历过任何你经历的事

一个人在任意一秒所作出的决定,一个是靠天性,上天注定,一个是他在这一秒之前经历过的所有事--认识的所有人,他们为人处世的方式,他们对他说过的所有话,他读过的所有书,他每一秒看到的风景,每一秒听到的声音,每一秒感受的气息--决定.

当前状态只由之前的状态决定,而最初的状态,天性,也是他自身所无法改变的.也就是说他经历的所有事都是从一开始决定好的,命中注定的.

换到你身上,当你经历了同样的过程,感受了同样的喜怒哀乐,接触了完全相同的信息.在人类大多数天性一致的情况下,你只会作出跟他相同的选择.

并不是为错事开脱,错的就是错的,无法被原谅,但是只能说,你没有做错,不过是因为你好运罢了.

所有人都只是命运脚下的蝼蚁.

除了相信自己将拥有好运外别无办法,逆天改命什么的,不存在的.

 

posted @ 2018-04-17 20:02  啊宸  阅读(460)  评论(1编辑  收藏  举报