Educational Codeforces Round 53 (Rated for Div. 2)
Posted chunibyo
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 53 (Rated for Div. 2)相关的知识,希望对你有一定的参考价值。
Educational Codeforces Round 53 (Rated for Div. 2)
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #pragma GCC optimize(2) 26 //#pragma comment(linker, "/STACK:102400000,102400000") 27 28 const double PI = acos (-1.0); 29 const int INF = 0x3f3f3f3f; 30 const int EXP = 1e-8; 31 const int N = 1e5 + 5; 32 const int MOD = 1e9 + 7; 33 const int MAXN = 2e3+5; 34 35 using namespace std; 36 37 int flag,n; 38 string s; 39 40 int main() { 41 //std::ios::sync_with_stdio(false); 42 //cin.tie(NULL); 43 44 while(cin>>n) { 45 cin>>s; 46 flag=1; 47 for(int i=0;i<s.size()-1;++i) { 48 if(s[i]!=s[i+1]) { 49 flag=0; 50 cout<<"YES"<<endl; 51 cout<<s.substr(i,2)<<endl; 52 break; 53 } 54 } 55 if(flag) cout<<"NO"<<endl; 56 } 57 }
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #pragma GCC optimize(2) 26 //#pragma comment(linker, "/STACK:102400000,102400000") 27 28 const double PI = acos (-1.0); 29 const int INF = 0x3f3f3f3f; 30 const int EXP = 1e-8; 31 const int N = 1e5 + 5; 32 const int MOD = 1e9 + 7; 33 const int MAXN = 2e5+50; 34 35 using namespace std; 36 37 int flag,n; 38 int a[MAXN],b; 39 int c[MAXN]; 40 int maxi; 41 42 int main() { 43 std::ios::sync_with_stdio(false); 44 cin.tie(NULL); 45 46 while(cin>>n) { 47 maxi=0; 48 for(int i=1;i<=n;++i) { 49 cin>>a[i]; 50 c[a[i]]=i; 51 } 52 for(int i=1;i<=n;++i) { 53 cin>>b; 54 if(i-1)cout<<‘ ‘; 55 if(c[b]>=maxi) { 56 cout<<c[b]-maxi; 57 maxi=c[b]; 58 } 59 else cout<<0; 60 } 61 } 62 }
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 //#define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #pragma GCC optimize(2) 26 //#pragma comment(linker, "/STACK:102400000,102400000") 27 28 const double PI = acos (-1.0); 29 //const ll INF = 0x3f3f3f3f3f3f; 30 const int EXP = 1e-8; 31 const int N = 1e5 + 5; 32 const int MOD = 1e9 + 7; 33 const int MAXN = 2e5+15; 34 35 using namespace std; 36 37 int n; 38 char s[MAXN]; 39 int x,y; 40 int l,r,u,d; 41 int p1,p2; 42 43 bool check(int m) { 44 int ll=l,rr=r,uu=u,dd=d; 45 for(int i=1; i<=m; ++i) { 46 if(s[i]==‘L‘) 47 ll--; 48 else if(s[i]==‘R‘) 49 rr--; 50 else if(s[i]==‘U‘) 51 uu--; 52 else if(s[i]==‘D‘) 53 dd--; 54 } 55 if(abs(y+dd-uu)+abs(x+ll-rr)<=m) 56 return true; 57 for(int i=m+1; i<=n; ++i) { 58 if(s[i-m]==‘L‘) 59 ll++; 60 else if(s[i-m]==‘R‘) 61 rr++; 62 else if(s[i-m]==‘U‘) 63 uu++; 64 else if(s[i-m]==‘D‘) 65 dd++; 66 67 if(s[i]==‘L‘) 68 ll--; 69 else if(s[i]==‘R‘) 70 rr--; 71 else if(s[i]==‘U‘) 72 uu--; 73 else if(s[i]==‘D‘) 74 dd--; 75 if(abs(y+dd-uu)+abs(x+ll-rr)<=m) 76 return true; 77 } 78 return false; 79 } 80 81 int main() { 82 std::ios::sync_with_stdio(false); 83 cin.tie(NULL); 84 85 while(cin>>n) { 86 l=r=u=d=0; 87 for(int i=1; i<=n; ++i) { 88 cin>>s[i]; 89 if(s[i]==‘L‘) 90 ++l; 91 else if(s[i]==‘R‘) 92 ++r; 93 else if(s[i]==‘U‘) 94 ++u; 95 else if(s[i]==‘D‘) 96 ++d; 97 } 98 cin>>x>>y; 99 if(abs(x)+abs(y)>n||((abs(l-r)&1)^(abs(u-d)&1))!=((y&1)^(x&1))) { 100 cout<<-1<<endl; 101 continue; 102 } 103 //int ans=0x3f3f3f; 104 p1=0,p2=n+1; 105 int ans=0; 106 for(int i=1; i<=100; ++i) { 107 int mid=(p1+p2)/2; 108 if(check(mid)) 109 p2=mid-1; 110 //p2=mid; 111 else 112 ans=p1,p1=mid+1; 113 //p1=mid; 114 } 115 cout<<ans<<endl; 116 //cout<<p2<<endl; 117 } 118 119 return 0; 120 }
1 #include<bits/stdc++.h> 2 #include<iostream> 3 #include<cstdio> 4 #include<cstdlib> 5 #include<cstring> 6 #include<cmath> 7 #include<algorithm> 8 #include<queue> 9 #include<vector> 10 #include<map> 11 #define lson i<<1 12 #define rson i<<1|1 13 #define LS l,mid,lson 14 #define RS mid+1,r,rson 15 #define mem(a,x) memset(a,x,sizeof(a)) 16 #define gcd(a,b) __gcd(a,b) 17 #define ll long long 18 #define ull unsigned long long 19 #define lowbit(x) (x&-x) 20 #define pb(x) push_back(x) 21 #define enld endl 22 #define mian main 23 #define itn int 24 #define prinft printf 25 #pragma GCC optimize(2) 26 //#pragma comment(linker, "/STACK:102400000,102400000") 27 28 const double PI = acos (-1.0); 29 const ll INF = 0x3f3f3f3f3f3f; 30 const int EXP = 1e-8; 31 const int N = 1e5 + 5; 32 const int MOD = 1e9 + 7; 33 const int MAXN = 2e5+15; 34 35 using namespace std; 36 37 ll n,t,k; 38 ll sum; 39 ll a[MAXN]; 40 ll mini=INF; 41 int flag=0; 42 int main() { 43 std::ios::sync_with_stdio(false); 44 cin.tie(NULL); 45 46 while(cin>>n>>t) { 47 sum=0; 48 ll ans=0; 49 for(int i=1; i<=n; ++i) { 50 cin>>a[i]; 51 sum=sum+a[i]*1ll; 52 mini=min(a[i],mini); 53 } 54 ans=ans+t/sum*n*1ll; 55 t=t%sum; 56 flag=1; 57 while(flag&&t>=mini) { 58 sum=k=0; 59 for(int i=1; i<=n; ++i) { 60 if(t<mini) { 61 flag=0; 62 break; 63 } 64 if(t>=a[i]) { 65 t=t-a[i]; 66 if(t>=a[i]) 67 sum=sum+a[i]*1ll,k++; 68 ans++; 69 } 70 //cout<<ans<<endl; 71 } 72 if(flag) { 73 ans+=t/sum*k*1ll; 74 t=t%sum; 75 } 76 } 77 cout<<ans<<endl; 78 } 79 80 return 0; 81 }
以上是关于Educational Codeforces Round 53 (Rated for Div. 2)的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 7 A
Educational Codeforces Round 7
Educational Codeforces Round 90
Educational Codeforces Round 33