Codeforces Round #664 (Div. 2)

Codeforces Round #664 (Div. 2)

A. Boboniu Likes to Color Balls

#include
using namespace std;
int main(){
    int t,r,g,b,w;
    for (cin>>t;t--;cout<<(w<2||w>2&&r*g*b?"Yes\n":"No\n")){
        cin>>r>>g>>b>>w,w=w%2+r%2+b%2+g%2;
    }
}

B - Boboniu Plays Chess

#include
using namespace std;
typedef long long ll;
const int MAX=0x3f3f3f3f;
const int len=100005;

void solve(){
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    cout<<x<<" "<<y<<'\n';
    for(int i=1;i<=m;i++){
        if(i==y)continue;
        cout<<x<<" "<<i<<'\n';
    }
    bool is=true;
    for(int i=1;i<=n;i++){
        if(i==x) continue;
        if(is) for(int j=m;j>0;j--)
                    cout<<i<<" "<<j<<endl;
        else   for(int j=1;j<=m;j++)
                    cout<<i<<" "<<j<<endl;
        is=!is;
    }
}

int main() {
    int _=1;
    //cin>>_;
    while(_--) solve();
}


C - Boboniu and Bit Operations

菜鸡日记
第一回被hack,裂开

#include
using namespace std;
typedef long long ll;
const int MAX=0x3f3f3f3f;

void solve(){
    int n,m,ans=0;
    cin>>n>>m;
    int a[210],b[210];
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=0,f=1,j,k;i<513;i++){
        for(j=0,f=1;j<n;j++){
            for (k=0,f=0;k<m;++k)
                if ((a[j]&b[k]|i)==i){
                    f=1;
                    break;
                }
            if (!f)break;
        }
        if (f){ans=i;break;}
    }
    cout<<ans<<endl;
}

int main() {
    int _=1;
    //cin>>_;
    while(_--) solve();
}

D - Boboniu Chats with Du

#include
using namespace std;
typedef long long ll;
const int MAX=0x3f3f3f3f;
const int len=100005;

void solve(){
    ll n,d,m,top=0,top2=0,a[len],b[len],pre[len];
    cin>>n>>d>>m;
    for(int i=1,x;i<=n;i++){
        scanf("%lld",&x),
        //cin>>x,//180+ms
        x<=m?a[++top]=x:b[++top2]=x;
    }
        //
    sort(a+1,a+1+top,greater<int>());
    sort(b+1,b+1+top2,greater<int>());
    for (int j=0;j<=n;++j) pre[j]=pre[j-1]+a[j];
    ll ans=pre[n];
    for(int i=1,sum=0;i<=top2;i++){
        ll day=(i-1)*(d+1)+1;
        if (day>n)break;
        day=n-day,sum+=b[i];
        ans=max(ans,sum+pre[day]);
    }
    cout<<ans;
}

int main() {
    int _=1;
    //cin>>_;
    while(_--) solve();
}

你可能感兴趣的:(acm,C++,cf,c++,acm竞赛)