cf 469
A
Left-handers, Right-handers and Ambidexters
#include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef double dl ; #define INF ((ll)2e9) const int inf = 987654321; const int sz = 1e6 + 5; const int mod = 1e9 + 7; const int sqrtn = 300; #define f(i,l,r) for(int i=l;i<=r;++i) #define g(i,l,r) for(int i=l;i>=r;--i) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define sz(a) strlen(a) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0); #define lowbit(x) x&(-x) #define X first #define Y second #define pb push_back #define pii pair<int,int> ll poww(ll a,ll b,ll c ) { ll ans=1,base=a; while(b!=0) { if(b&1!=0) ans = ans*base%c; base= base*base%c; b/=2; } return ans; } int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}}; int l,r,n; void work() { cin>>l>>r>>n; if(l==r) { cout<<2*(r+n/2)<<endl; } else if(l< r && n>=r-l) { n=n-r+l; cout<<2*(r+n/2)<<endl; } else if( l< r && n<r-l) { cout<<2*(l+n)<<endl; } else if(r< l && n>=l-r) { n=n-l+r; cout<<2*(l+n/2)<<endl; } else if(r< l && n<l-r) { cout<<2*(r+n)<<endl; } } int main() { FAST_IO ; freopen("in","r",stdin); freopen("out","w",stdout); cout<<"hello"<<endl; work(); return 0; }
#include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef double dl ; #define INF ((ll)2e9) const int inf = 987654321; const int sz = 1e6 + 5; const int mod = 1e9 + 7; const int sqrtn = 300; #define f(i,l,r) for(int i=l;i<=r;++i) #define g(i,l,r) for(int i=l;i>=r;--i) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define sz(a) strlen(a) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0); #define lowbit(x) x&(-x) #define X first #define Y second #define pb push_back #define pii pair<int,int> ll poww(ll a,ll b,ll c ) { ll ans=1,base=a; while(b!=0) { if(b&1!=0) ans = ans*base%c; base= base*base%c; b/=2; } return ans; } int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}}; int n,m; ll a[sz],b[sz],x; void work() { cin>>n>>m; f(i,1,n) { cin>>x; a[i]=a[i-1]+x; } f(i,1,m) { cin>>x; b[i]=b[i-1]+x; } int e1=1; int e2=1; int b1=0; int b2=0; x=0; while(1) { if(e1==n+1) break; ll t = a[e1]-a[b1]; if(t==b[e2]-b[b2]) { b1=e1;e1=e1+1; b2=e2;e2=e2+1; x++; } else if(t>b[e2]-b[b2]) { e2++; } else if(t<b[e2]-b[b2]) { e1++; } } cout<<x<<endl; } int main() { FAST_IO ; freopen("in","r",stdin); freopen("out","w",stdout); cout<<"hello"<<endl; work(); return 0; }
C
Zebras
#include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef double dl ; #define INF ((ll)2e9) const int inf = 987654321; const int sz = 2e6 + 5; const int mod = 1e9 + 7; const int sqrtn = 300; #define f(i,l,r) for(int i=l;i<=r;++i) #define g(i,l,r) for(int i=l;i>=r;--i) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define sz(a) strlen(a) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0); #define lowbit(x) x&(-x) #define X first #define Y second #define pb push_back #define pii pair<int,int> ll poww(ll a,ll b,ll c ) { ll ans=1,base=a; while(b!=0) { if(b&1!=0) ans = ans*base%c; base= base*base%c; b/=2; } return ans; } int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}}; char s[sz]; int top1,top0,st1[sz],st0[sz],ct[sz],nxt[sz]; bool used[sz]; void work1 () { cin>>s; int len=sz(s); f(i,0,len-1) { if(s[i]=='0') { if(top1) nxt[st1[top1--]]=i+1; st0[++top0]=i+1; } if(s[i]=='1') { if (top0) nxt[st0[top0--]]=i+1; else { cout<<-1<<endl; return; } st1[++top1]=i+1; } } if (top1) { cout<<-1<<endl; return; } int k=0; f(i,1,len) { if(!used[i]) { k++; int cnt=0; for(int j=i;j;j=nxt[j]) used[j]=true,cnt++; ct[i]=cnt; } } cout<<k<<endl; f(i,1,len) { if(ct[i]) { cout<<ct[i]<<" "; // for(int j=i;j;j=nxt[j]) // cout<<j<<" "; cout<<endl; } } } void work () { cin>>s; int len =sz(s); f(i,0,len-1) { if(s[i]=='0') { if(top1) nxt[st1[top1--]]=i+1; st0[++top0]=i+1; } if(s[i]=='1') { if (top0) nxt[st0[top0--]]=i+1; else { cout<<-1<<endl; return; } st1[++top1]=i+1; } } if(top1) { cout<<-1<<endl; return; } int k=0; f(i,1,len) { int cnt=0; if(!used[i]) { k++; for(int j=i;j;j=nxt[j]) { used[j]=1; cnt++; } ct[i]=cnt; } } cout<<k<<endl; f(i,1,len) { if(ct[i]) { cout<<ct[i]; for(int j=i;j;j=nxt[j]) cout<<" "<<j; cout<<endl; } } } int main() { FAST_IO ; freopen("in","r",stdin); freopen("out","w",stdout); cout<<"hello"<<endl; work (); return 0; }
D
#include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef double dl ; #define INF ((ll)2e9) const int inf = 987654321; const int sz = 1e6 + 5; const int mod = 1e9 + 7; const int sqrtn = 300; #define f(i,l,r) for(int i=l;i<=r;++i) #define g(i,l,r) for(int i=l;i>=r;--i) #define CLR(arr,val) memset(arr,val,sizeof(arr)) #define sz(a) strlen(a) #define FAST_IO ios::sync_with_stdio(false);cin.tie(0); #define lowbit(x) x&(-x) #define X first #define Y second #define pb push_back #define pii pair<int,int> ll poww(ll a,ll b,ll c ) { ll ans=1,base=a; while(b!=0) { if(b&1!=0) ans = ans*base%c; base= base*base%c; b/=2; } return ans; } int gcd(int a,int b) { if(b==0)return a; return gcd(b,a%b); } int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}}; ll n,q,x,m; void work() { cin>>n>>q; f(i,1,q) { cin>>x; if(x%2)cout<<(x+1)/2<<endl; else { ll p =n-x/2; while(p%2==0) p/=2; cout<<n+1-(p+1)/2<<endl; } } } int main() { FAST_IO ; freopen("in","r",stdin); freopen("out","w",stdout); cout<<"hello"<<endl; work(); return 0; }
不摸着石头过河,难道要在温柔乡睡到天昏地暗。