csp-s模拟测试77(lrd day1)

RP-=inf。。。。。。。

一场考试把rp败光。。。由于本次考试本人在考试中乱说自己AK导致rp--,本人当选为机房倒数第二没素质

不过AK一次还挺开心的。。。

达哥出的题还是比较简单的。

T1:考察位运算的技巧,对于所有的操作按位考虑即可。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 using namespace std;
 6 int a,b,c;
 7 long long bin[50];
 8 long long an[50];
 9 long long ans;
10 inline void init()
11 {
12     for(int i=0;i<=40;++i)bin[i]=1ll<<i;
13     an[0]=1;
14     for(int i=1;i<=32;++i)an[i]=an[i-1]*3;
15 }
16 inline int getnum(int x)
17 {
18     int ret=0;
19     while(x){ret+=x&1;x>>=1;}
20     return ret;
21 }
22 inline void work1()
23 {
24     int t=getnum(b);
25     printf("%lld\n",an[t]);
26 }
27 inline void work5()
28 {
29     if((a^b)!=c){puts("0");return;}
30     int t=getnum(c);
31     printf("%lld\n",bin[t]);
32 }
33 inline void work2()
34 {
35     if((b&c)!=c){puts("0");return;}
36     a=b^c;
37     work5();
38 }
39 inline void work3()
40 {
41     if(a&c){puts("0");return;}
42     b=a|c;work5();
43 }
44 inline void work4()
45 {
46     if((b&a)!=a){puts("0");return;}
47     c=a^b;work5();
48 }
49 int main()
50 {
51     init();
52     int T;scanf("%d",&T);
53     while(T--)
54     {
55         scanf("%d%d%d",&a,&b,&c);
56         if(b==-1&&c==-1)
57         {
58             puts("inf");continue;
59         }
60         if(a==-1&&c==-1)
61         {
62             work1();continue;
63         }
64         if(a==-1&&b==-1)
65         {
66             puts("inf");continue;
67         }
68         if(a==-1)
69         {
70             work2();continue;
71         }
72         if(b==-1)
73         {
74             work3();continue;
75         }
76         if(c==-1)
77         {
78             work4();continue;
79         }
80         work5();
81     }
82 }
冗长讨论

T2:把对于全部的数的加减用变量维护即可,对于取交和取并直接打时间戳维护即可

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstring>
 4 #include<algorithm>
 5 char xch,xB[1<<15],*xS=xB,*xTT=xB;
 6 #define getc() (xS==xTT&&(xTT=(xS=xB)+fread(xB,1,1<<15,stdin),xS==xTT)?0:*xS++)
 7 inline int read()
 8 {
 9     int x=0,f=1;char ch=getc();
10     while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getc();}
11     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
12     return x*f;
13 }
14 using namespace std;
15 const long long kx=1000000;
16 int pd[2000600],n;
17 int sum,num=1;
18 long long plu,ans;
19 inline void work1()
20 {
21     int m=read(),a,b,c;
22     for(int i=1;i<=m;++i)
23     {
24         a=read()+kx;
25         if(pd[a-plu]==num)continue;
26         pd[a-plu]=num;
27         ++sum;ans+=a-plu;
28     }
29 }
30 inline void work2()
31 {
32     int m=read(),a,b,c;
33     sum=0;ans=0;
34     for(int i=1;i<=m;++i)
35     {
36         a=read()+kx;
37         if(pd[a-plu]!=num)continue;
38         pd[a-plu]=num+1;
39         ++sum;ans+=a-plu;
40     }
41     ++num;
42 }
43 int main()
44 {
45 //    freopen("ex_jihe4.in","r",stdin);
46 //    freopen("my.out","w",stdout);//diff -b -B ex_jihe4.ans my.out
47     n=read();int opt;
48     while(n--)
49     {
50         opt=read();
51         switch(opt){
52             case 1:{
53                 work1();
54                 break;
55             }
56             case 2:{
57                 work2();
58                 break;
59             }
60             case 3:{
61                 ++plu;
62                 break;
63             }
64             case 4:{
65                 --plu;
66                 break;
67             }
68         }
69         printf("%lld\n",ans+plu*sum-kx*sum);
70     }
71 }
感谢达哥的fread

T3:稍神奇,图论+容斥原理。

先对所有的白块染色,相连的染成同一种颜色。顺手用桶统计答案

这时发现统计多了,对于一些情况会统计多。考虑容斥,奇加偶减,对于每个非空白点,先把周围的块统计一下,排序去重,手动枚举集合,用hash搞掉,用hash_map储存

分类讨论奇加偶减即可。。。

  1 #include<iostream>
  2 #include<cstdio>
  3 #include<cstring>
  4 #include<algorithm>
  5 inline int read()
  6 {
  7     int x=0,f=1;char ch=getchar();
  8     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
  9     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
 10     return x*f;
 11 }
 12 #define N 1050
 13 using namespace std;
 14 int a[N][N];
 15 int bk[1000500];
 16 long long ans;
 17 int n,num=1,m,k;
 18 int pd[N][N];
 19 const int dx[4]={1,-1,0,0};
 20 const int dy[4]={0,0,1,-1};
 21 struct QaQ{
 22     pair<int,int>a[1000500];
 23     int fr,ba;
 24     inline int size(){return ba-fr;}
 25     inline void push(int x,int y){a[ba]=make_pair(x,y);++ba;}
 26     inline void clear(){ba=fr=0;}
 27     inline void pop(){++fr;}
 28     inline int fir(){return a[fr].first;}
 29     inline int sec(){return a[fr].second;}
 30 }q;
 31 inline void bfs1(int x,int y)
 32 {
 33     q.clear();++num;pd[x][y]=num;
 34     int tx,ty,c;q.push(x,y);
 35     while(q.size())
 36     {
 37         x=q.fir();y=q.sec();q.pop();
 38         for(int i=0;i<4;++i)
 39         {
 40             tx=x+dx[i];ty=y+dy[i];
 41             if(tx<=0||ty<=0||tx>n||ty>m||pd[tx][ty]==num)continue;
 42             pd[tx][ty]=num;c=a[tx][ty];
 43             if(c){ans+=bk[c];++bk[c];}
 44             else q.push(tx,ty);
 45         }
 46     }
 47 }
 48 inline void bfs2(int x,int y)
 49 {
 50     q.clear();++num;pd[x][y]=num;
 51     int tx,ty,c;q.push(x,y);
 52     while(q.size())
 53     {
 54         x=q.fir();y=q.sec();q.pop();
 55         for(int i=0;i<4;++i)
 56         {
 57             tx=x+dx[i];ty=y+dy[i];
 58             if(tx<=0||ty<=0||tx>n||ty>m||pd[tx][ty]==num)continue;
 59             pd[tx][ty]=num;c=a[tx][ty];
 60             if(c)bk[c]=0;
 61             else q.push(tx,ty);
 62         }
 63     }
 64 }
 65 int pd2[1500000],t1[10];
 66 inline int get1(int x,int y)
 67 {
 68     int tx,ty;t1[0]=0;
 69     for(int i=0;i<4;++i)
 70     {
 71         tx=x+dx[i];ty=y+dy[i];
 72         if(tx<=0||ty<=0||tx>n||ty>m||a[tx][ty])continue;
 73         t1[++t1[0]]=pd[tx][ty];pd2[pd[tx][ty]]=1;
 74     }
 75 }
 76 inline int get2(int x,int y)
 77 {
 78     int tx,ty;
 79     for(int i=0;i<4;++i)
 80     {
 81         tx=x+dx[i];ty=y+dy[i];
 82         if(tx<=0||ty<=0||tx>n||ty>m||a[tx][ty])continue;
 83         if(pd2[pd[tx][ty]])return 0;
 84     }
 85     return 1;
 86 }
 87 void down1()
 88 {
 89     for(int i=1;i<=t1[0];++i)pd2[t1[i]]=0;
 90 }
 91 inline void work2()
 92 {
 93     for(int i=1;i<=n;++i)
 94         for(int j=1;j<=m;++j)
 95         {
 96             get1(i,j);
 97             if(a[i][j]&&a[i][j]==a[i][j+1])
 98                 ans+=get2(i,j+1);
 99             if(a[i][j]&&a[i][j]==a[i+1][j])
100                 ans+=get2(i+1,j);
101 //            printf("i:%d j:%d ans:%lld\n",i,j,ans);
102             down1();
103         }
104 }
105 const int mod=233337;
106 const int tt=1000003;
107 #define ull unsigned long long
108 struct hash_map{
109     int he[mod],tot;
110     int ne[10000007],to[10000007];
111     ull val[10000007];
112     inline void add(ull x){
113         int k=x%mod;
114         for(int i=he[k];i;i=ne[i])
115         {
116             if(val[i]==x)
117             {
118                 ++to[i];
119                 return;
120             }
121         }
122         to[++tot]=1;ne[tot]=he[k];he[k]=tot;val[tot]=x;
123     }
124     inline int getval(ull x){
125         int k=x%mod;
126         for(int i=he[k];i;i=ne[i])
127             if(val[i]==x)
128                 return to[i];
129         return 0;
130     }
131 }H;
132 inline void duce(int x,int y,int z)
133 {
134     ull t=x;t=t*tt+y;t=t*tt+z;
135     ans-=H.getval(t);H.add(t);
136 }
137 inline void pluss(int w,int x,int y,int z)
138 {
139     ull t=w;t=t*tt+x;t=t*tt+y;t=t*tt+z;
140     ans+=H.getval(t);H.add(t);
141 }
142 inline void duce2(int v,int w,int x,int y,int z)
143 {
144     ull t=v;t=t*tt+w;t=t*tt+x;t=t*tt+y;t=t*tt+z;
145     ans-=H.getval(t);H.add(t);
146 }
147 inline void work3()
148 {
149     int c;
150     for(int i=1;i<=n;++i)
151         for(int j=1;j<=m;++j)
152         {
153             if(!a[i][j]||!pd[i][j])continue;
154             get1(i,j);c=a[i][j];
155             if(t1[0]<2)continue;
156             sort(t1+1,t1+t1[0]+1);
157             t1[0]=unique(t1+1,t1+t1[0]+1)-t1-1;
158             if(t1[0]<2)continue;
159             if(t1[0]==2)
160             {
161                 duce(t1[1],t1[2],c);
162                 continue;
163             }
164             if(t1[0]==3)
165             {
166                 duce(t1[1],t1[2],c);
167                 duce(t1[1],t1[3],c);
168                 duce(t1[2],t1[3],c);
169                 pluss(t1[1],t1[2],t1[3],c);
170             }
171             if(t1[0]==4)
172             {
173                 duce(t1[1],t1[2],c);
174                 duce(t1[1],t1[3],c);
175                 duce(t1[1],t1[4],c);
176                 duce(t1[2],t1[3],c);
177                 duce(t1[2],t1[4],c);
178                 duce(t1[3],t1[4],c);
179                 pluss(t1[1],t1[2],t1[3],c);
180                 pluss(t1[1],t1[2],t1[4],c);
181                 pluss(t1[1],t1[3],t1[4],c);
182                 pluss(t1[2],t1[3],t1[4],c);
183                 duce2(t1[1],t1[2],t1[3],t1[4],c);
184             }
185         }
186 }
187 int main()
188 {
189 //    freopen("ex_link5.in","r",stdin);
190 //    freopen("my.out","w",stdout);
191     scanf("%d%d%d",&n,&m,&k);
192     for(int i=1;i<=n;++i)
193         for(int j=1;j<=m;++j)
194             a[i][j]=read();
195     for(int i=1;i<=n;++i)
196         for(int j=1;j<=m;++j)
197             if(!a[i][j]&&!pd[i][j])
198             {
199                 bfs1(i,j);bfs2(i,j);
200             }
201     work2();
202     work3();
203     cout<<ans<<endl;
204     /*
205     for(int i=1;i<=n;++i)
206     {
207         for(int j=1;j<=m;++j)
208         {
209             printf("%d ",pd[i][j]);
210         }
211         puts("");
212     }
213     */
214 }
rp++

最后:

 1  此刻我十分后悔,我做了一件错事,我简直不能原谅我自我!昨日我无视学校的规章制度,藐视校领导的决定,私自乱说AK。
 2 
 3   这天,我怀着愧疚、懊悔和忐忑的情绪给您写下这份检讨书,以向您表示我对这种恶劣行为的深痛恶绝及保证不再犯的决心。
 4 
 5   早在我刚踏进这个学校的时候,学校就已经三令五申,一再强调,学生,不得乱说AK。这两天,老师反复教导言犹在耳,严肃认真的表情犹在眼前,我深为震撼,也已经深刻认识到此事的重要性,在老师的耐心教导下,透过学习学生手则中学生管理规定,使我认识到了问题的严重性,并对自我违反校纪校规的行为进行了认真的反思和深刻的自剖。
 6 
 7   在此,我谨向各位领导、老师做出深刻检讨,并将我这两天透过反思认为深藏在本人思想中的致命错误有以下几点结果汇报如下:
 8 
 9   第一,我的行为不贴合一个中学生的要求。作为当代中学生,我们就应识大体、顾大局,在校纪校规面前人人平等,我不就应为了一己之便违反校纪校规。
10 
11   第二,思想觉悟不高,对重要事项重视严重不足。就算是有认识,也没能在行动上真正实行起来。
12 
13   第三,在学习期间,我们应主动配合学院搞好安全工作,学院老师三令五申、班干也一再强调,要求我们不能乱说AK,但我把这些都成了耳旁风,这些都是不就应的。
14 
15   第四,我的行为还在同学间造成了极坏的影响。同学之间本就应互相学习,互相促进,而我的表现给同学们带了一个坏头,不利于校风和院风的建设。同时,也对学校形象造成了必须损害。想着带一次也无所谓,当时的侥幸心理酿成了此刻的后果。虽然我这种行为方便了自我,但是,我是在自私自利的帽子下,方便自我的。只有认真反思,寻找极大错误后面的深刻根源,认清问题的本质,才能给群众和自我一个交待,从而得以进步。做为一名学生,我没有做好自我的本职,给学校老师和学生会干部的工作带来了很大的麻烦。
16 
17   据上,在深刻的自我反思之后,我决定有如下个人整改措施:第一,从错误根源进行深挖细找的整理,并认清其可能造成严重。第二,提高认识,狠抓落实,大力开展批评与自我批评。
18 
19   第三,制定学习计划,认真克服生活懒散、粗心的坏习惯,按照老师要求上交资料深刻的检讨书一份,对自我思想上心大意的缺点,努力将期考考好,以好成绩弥补我的过错。
20 
21   第四,和同学、班干以及学生会干部加强沟通。保证今后不再出现违反校纪校规的状况。我十分感谢老师和学生会干部对我所犯错误的及时指正,我保证今后不会再有类似行为发生在我身上,并决心为我校的安全工作和迎评工作作出自我的一份微薄之力。
22 
23   第五,从思想上,我重新检讨自我,坚持从认识上,从观念上转变,要求上进,关心群众,关心他人,多和优秀同学接触,交流。纪律上,此刻我必须要比以前要有了很大改变,此刻的我对自我的言行,始终持续严格的约束,不但能遵守校规校纪,更加懂得了身为一名学生哪些事能够做的,哪些是不能够做的。学习上,我能够不避困难,自始至终为掌握更多知识,使自我的素质全面得到提升。
24 
25   第六,保证不再出现上述错误。期望老师能够原谅我!最后请关心爱护我的老师同学继续监督、帮忙我改正缺点,取得更大的进步。
buyaotui

猜你喜欢

转载自www.cnblogs.com/loadingkkk/p/11695300.html