Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A,B,C真的菜·(代
Posted pengge666
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A,B,C真的菜·(代相关的知识,希望对你有一定的参考价值。
8说了
1 #include<bits/stdc++.h> 2 3 using namespace std; 4 #define int long long 5 6 signed main(){ 7 string str; 8 cin>>str; 9 int _; 10 cin>>_; 11 int flag1=0; 12 int flag2=0; 13 int flag3=0; 14 int flag4=0; 15 while(_--){ 16 string s; 17 cin>>s; 18 if(s==str){ 19 flag4=1; 20 continue; 21 } 22 if(s[0]==str[1]&&s[1]==str[0]){ 23 flag3=1; 24 continue; 25 } 26 if(str[0]==s[1]){ 27 flag1=1; 28 } 29 if(str[1]==s[0]){ 30 flag2=1; 31 } 32 } 33 // cout<<flag1<<" "<<flag2<<" "<<flag3<<" "<<flag4; 34 if(flag3||flag4||(flag1+flag2==2)){ 35 printf("YES "); 36 }else{ 37 printf("NO "); 38 } 39 return 0; 40 } 41 /* 42 ah 43 oy 44 45 aa 46 47 ha 48 yo 49 */
思路:直接暴力---居然能过.钟表问题转换是真滴难QAQ【小学就没整懂】
1 #include<bits/stdc++.h> 2 3 using namespace std; 4 #define int long long 5 int vis[500]; 6 signed main(){ 7 int h,m, s, t1, t2; 8 cin>>h>>m>>s>>t1>>t2; 9 h*=5;t1*=5; 10 t2*=5; 11 vis[h]++; 12 vis[m]++; 13 vis[s]++; 14 int ss=0; 15 if(t1>t2) 16 swap(t1,t2); 17 for(int i=t1;i<t2;i++){ 18 ss+=vis[i]; 19 } 20 if(ss==0||ss==3){ 21 cout<<"YES"; 22 } 23 else{ 24 cout<<"NO"; 25 } 26 return 0; 27 }
题解:二进制+暴力。
1 #include<bits/stdc++.h> 2 using namespace std; 3 int a[150000]; 4 int vis[150];int n,k; 5 signed main(){ 6 memset(vis,0,sizeof(vis)); 7 cin>>n>>k; 8 for(int i=1;i<=n;i++){ 9 for(int j=1;j<=k;j++){ 10 scanf("%d",&a[j]); 11 } 12 vis[a[1]+a[2]*2+a[3]*4+a[4]*8]=1; 13 } 14 for(int i=0;i<=(1<<k);i++){ 15 for(int j=i;j<=(1<<k);j++){ 16 if(vis[i]&&vis[j]&&(!(i&j))){ 17 printf("YES"); 18 return 0; 19 } 20 } 21 } 22 printf("NO"); 23 return 0; 24 }
以上是关于Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A,B,C真的菜·(代的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) A,B,C真的菜·(代
Codeforces Round #438 by Sberbank and Barcelona Bootcamp (Div. 1 + Div. 2 combined) F. Yet Another M