D题fst了,生无可恋。第二场rated的CF,打得精神恍惚
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; int n,x[105],part=1; bool f=1; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&x[i]); if(part==1) {if(x[i]==x[i-1])part=2;else if(x[i]<x[i-1])part=3;} else if(part==2) {if(x[i]<x[i-1])part=3;else if(x[i]>x[i-1]){f=0;break;}} else if(part==3) {if(x[i]>x[i-1]){f=0;break;}else if(x[i]==x[i-1]){f=0;break;}} } if(f)printf("YES\n"); else printf("NO\n"); return 0; }
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> using namespace std; char a[26],b[26],s[1001]; int map[26]; int main() { scanf("%s%s%s",a,b,s); for(int i=0;i<26;i++) map[a[i]-‘a‘]=b[i]-‘a‘; for(int i=0;i<strlen(s);i++) { if(s[i]>=‘a‘&&s[i]<=‘z‘)cout<<(char)(map[(int)(s[i]-‘a‘)]+‘a‘); else if(s[i]>=‘A‘&&s[i]<=‘Z‘)cout<<(char)(map[(int)(s[i]-‘A‘)]+‘A‘); else cout<<s[i]; } return 0; }
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> typedef long long LL; int n,k,p,a[1005],b[2005]; using namespace std; LL dis(LL x,LL y){return abs(y-x)+abs(p-y);} bool check(LL mid) { int j=1; for(int i=1;i<=n;i++,j++) { while(j<=k&&dis(a[i],b[j])>mid)++j; if(j>k)return false; } return true; } int main() { scanf("%d%d%d",&n,&k,&p); for(int i=1;i<=n;i++)scanf("%d",&a[i]); for(int i=1;i<=k;i++)scanf("%d",&b[i]); sort(a+1,a+1+n),sort(b+1,b+1+k); LL l=0,r=2000000000,ans; while(l<=r) { LL mid=(l+r)>>1; if(check(mid))ans=mid,r=mid-1; else l=mid+1; } printf("%I64d\n",ans); return 0; }
Codeforces Round #424 (Div. 2, rated, based on VK Cup Finals)
原文:http://www.cnblogs.com/Zars19/p/7173064.html