Codeforces Round #553 (Div. 2) 題解
阿新 • • 發佈:2019-04-19
scanf turn 讓我 typedef 出了 lap ide std 貢獻
昨晚深夜修仙上紫記,雖然不錯還是很有遺憾的。
A. Maxim and Biology
看完就會做的題,然而手速跟不上
#include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; typedef long long LL; const int _=1e2; const int maxn=510;A. Maxim and Biologychar ss[110]; int a[110]; int getdis(int x,int y) { if(x>y)swap(x,y); return min(y-x,x+26-y); } int main() { int n,m; scanf("%d%s",&n,ss+1); for(int i=1;i<=n;i++)a[i]=ss[i]-‘A‘+1; int mn=(1<<30); for(int i=1;i<=n-3;i++) { mn=min(mn,getdis(a[i],1)+getdis(a[i+1],3)+getdis(a[i+2],20)+getdis(a[i+3],7)); } printf("%d\n",mn); return 0; }
B. Dima and a Bad XOR
其實先開的是B,但是O(nm*1024)相當不靠譜不是很敢寫。。。後來寫得還是磕磕絆絆總之相當不爽。就是那種要搶時間這個題又煩的一批的感覺
#include<cstdio> #include<iostream> #includeB. Dima and a Bad XOR<cstring> #include<cstdlib> #include<algorithm> #include<cmath> using namespace std; typedef long long LL; const int _=1e2; const int maxn=510; int a[maxn][maxn]; bool f[maxn][1024];int d[maxn][1024],fr[maxn][1024]; int as[maxn]; int main() { int n,m,mx=0; scanf("%d%d",&n,&m); f[0][0]=true; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) scanf("%d",&a[i][j]),mx=max(mx,a[i][j]); while(mx!=(mx&-mx))mx-=(mx&-mx); mx<<=1; if(mx==0)mx=2; for(int i=0;i<n;i++) for(int zt=0;zt<mx;zt++) if(f[i][zt]) { for(int j=1;j<=m;j++) f[i+1][zt^a[i+1][j]]=true,d[i+1][zt^a[i+1][j]]=j,fr[i+1][zt^a[i+1][j]]=zt; } for(int zt=1;zt<mx;zt++) if(f[n][zt]) { puts("TAK"); for(int i=n;i>=1;i--) { as[i]=d[i][zt],zt=fr[i][zt]; } for(int i=1;i<=n;i++)printf("%d ",as[i]); puts("");return 0; } puts("NIE"); return 0; }
C. Problem for Nazar
和B一起讓我自閉了半個多小時,看錯一發題意。其實就是按題意模擬,然後寫到45min才過真是!@#¥%……&,也是瘋狂調試沒什麽底的,還好樣例比較強。
C. Problem for Nazar
D. Stas and the Queue at the Buffet
sb微擾。我覺得比A還sb。
D. Stas and the Queue at the Buffet
E. Number of Components
這個E豈不是搞笑的??明明O(n)還放1e5
考慮已經得到前i-1個點的貢獻,現在加入i這個點,假如a[i]不在[l,r]裏面或a[i],a[i-1]都在[l,r]裏面它沒有貢獻,否則就會產生貢獻。
第二天rose_king又給出了一個更直觀的做法:因為聯通塊數=總點數-被刪的邊數,答案就是=總點數-被刪的邊數-不在[l,r]的點數
E. Number of Components
F. Sonya and Informatics
這個F也是我有問題,看錯了一發題意浪費了半個小時,然後腦子不清醒寫了個假的,其實只要設在正確位置的1的個數為i然後明顯矩乘優化就完事了
咕了
這幾場手速都是極大的劣勢
天天又看錯題
還很慢熱,寫完模擬才有點做題的感覺
總之就是菜雞一個
不過沒fail題算是有點安慰吧
Codeforces Round #553 (Div. 2) 題解