Codeforces Round #438(Div.1+Div.2)總結
阿新 • • 發佈:2017-10-06
splay || div sans har .com eve pre 希望
本來興致勃勃的想乘著這一次上紫,於是很早很早的到了機房
但是好像並沒有什麽用,反而rating-=47
Codeforces Round #438(Div.1+Div.2)
今天就這樣匆匆的總結一下,心情不好qaq
首先是 A.Bark to Unlock
啟示:(1)不能直接把char數組進行比較!!!
(2)讀題要讀清,不能漏讀條件!!!
1 #include<bits/stdc++.h> 2 using namespace std; 3 int bo[3][30],n; 4 string s,t; 5 int main(){ 6 cin>>s;View Code7 scanf("%d",&n); cin>>t; 8 bo[1][t[0]-‘a‘]=1; bo[2][t[1]-‘a‘]=1; 9 if (bo[1][s[0]-‘a‘]&&bo[2][s[1]-‘a‘]||bo[2][s[0]-‘a‘]&&bo[1][s[1]-‘a‘]){ 10 printf("YES"); return 0; 11 } 12 for (int i=2;i<=n;++i){ 13 cin>>t; 14 if(s==t){ 15 printf("YES"); return 0; 16 } 17 bo[1][t[0]-‘a‘]=1; bo[2][t[1]-‘a‘]=1; 18 if (bo[2][s[0]-‘a‘]&&bo[1][s[1]-‘a‘]){ 19 printf("YES"); return 0; 20 } 21 } 22 printf("NO"); 23 }
然後是 B. Race Against Time
總之我的做法時先把時針,分針,秒針在秒意義下的位置,進行排序
然後把t1和t2也轉化成相同狀態,最後判斷t1和t2分別在哪個位置
大概就是這樣
1 #include<bits/stdc++.h> 2 using namespace std; 3 int h,m,s,t1,t2,s1,s2,s3,a1,a2; 4 int main(){ 5 cin>>h>>m>>s>>t1>>t2; 6 s1=3600*(h%12)+60*m+s; s2=720*m+12*s; s3=720*s; 7 a1=3600*(t1%12); a2=3600*(t2%12); 8 if(s1>s2)swap(s1,s2); if(s2>s3)swap(s2,s3); if(s1>s2)swap(s1,s2); 9 if(a1>a2)swap(a1,a2); bool bo=0; 10 if(s1<=a1&&a2<=s2|| s2<=a1&&a2<=s3)bo=1; 11 if(a2<=s1||a1>=s3)bo=1; if(a1<=s1&&a2>=s3)bo=1; 12 if(bo) puts("YES"); else puts("NO"); 13 }View Code
最後只希望今天的CF我的rating不會掉吧,上紫我的水平可能還不夠吧
Codeforces Round #438(Div.1+Div.2)總結