• Educational Codeforces Round 26 B,C


    B. Flag of Berland

    链接:http://codeforces.com/contest/837/problem/B

    思路:题目要求判断三个字母是否是条纹型的,而且宽和高相同,那么先求出三个字母的边界,算下面积,是否和数量相同,不相同的话肯定不为条纹型,然后判断下他们宽和高的关系就行了

    实现代码:

    #include<bits/stdc++.h>
    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<cstring>
    #include<cmath>
    #include<algorithm>
    #include<map>
    #include<queue>
    #include<stack>
    #include<set>
    #include<list>
    using namespace std;
    #define ll long long
    #define sd(x) scanf("%d",&x)
    #define sdd(x,y) scanf("%d%d",&x,&y)
    #define sddd(x,y,z) scanf("%d%d%d",&x,&y,&z)
    #define sf(x) scanf("%s",x)
    #define ff(i,x,y) for(int i = x;i <= y;i ++)
    #define fj(i,x,y) for(int i = x;i >= y;i --)
    #define mem(s,x) memset(s,x,sizeof(s));
    #define pr(x) printf("%d",x);
    const int Mod = 1e9+7;
    const int inf = 1e9;
    const int Max = 1e5+10;
    //void exgcd(ll a,ll b,ll& d,ll& x,ll& y){if(!b){d=a;x=1;y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}
    //ll inv(ll a,ll n){ll d, x, y;exgcd(a,n,d,x,y);return (x+n)%n;}  
    //int gcd(int a,int b)  {  return (b>0)?gcd(b,a%b):a;  }  
    //int lcm(int a, int b)  {  return a*b/gcd(a, b);   }    
    
    int main()
    {
        int n,m,en_rx=1,be_rx=inf,en_ry=1,be_ry=inf,en_gx=1,en_gy=1,en_bx=1,en_by=1,be_gx=inf,be_gy=inf,be_bx=inf,be_by=inf,r,g,b;
        char mp[110][110];
        sdd(n,m);
        r=0;g=0;b=0;
        ff(i,1,n){
            ff(j,1,m){
                cin>>mp[i][j];
               if(mp[i][j]=='R'){
                    r++; en_rx = max(i,en_rx);en_ry = max(j,en_ry);be_rx=min(i,be_rx);be_ry=min(j,be_ry);}
               if(mp[i][j]=='G'){ g++; en_gx = max(i,en_gx);en_gy = max(j,en_gy);be_gx=min(i,be_gx);be_gy=min(j,be_gy);}
               if(mp[i][j]=='B'){ b++; en_bx = max(i,en_bx);en_by = max(j,en_by);be_bx=min(i,be_bx);be_by=min(j,be_by);}
            }
        }
        if(n*m<3){
            cout<<"NO"<<endl;return 0;}
        int num = (en_rx - be_rx+1)*(en_ry - be_ry+1);
        //cout<<num<<endl;
        //cout<<en_gx<<" "<<be_gx<<endl;
        //cout<<en_ry<<" "<<be_ry<<endl;
        if((en_rx - be_rx)==(en_gx - be_gx)&&(en_gx - be_gx)==(en_bx - be_bx)&&(en_ry - be_ry)==(en_gy - be_gy)&&(en_gy - be_gy)==(en_by - be_by)&&num==r)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
         return 0;
    }

    C. Two Seals

    题目链接:http://codeforces.com/contest/837/problem/C

    思路:

    给你几个方块,让你选两个方块放在a*b范围里,要求面积最大,方块可以转90度,直接暴力模拟就是了

    #include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    ll x[110],y[110];
    int a,b;
    ll max(ll x,ll y)
    {
        if(x>y) return x;
        return y;
    }
    bool check(int i,int j){
                ll a1=x[i]+x[j],b1=max(y[i],y[j]);
                ll a2=y[i]+x[j],b2=max(x[i],y[j]);
                ll a3=x[i]+y[j],b3=max(y[i],x[j]);
                ll a4=y[i]+y[j],b4=max(x[i],x[j]);
                if((a1<=a && b1<=b) || (a2<=a && b2<=b) || (a3<=a && b3<=b) || (a4<=a && b4<=b))
                return true;
                if((a1<=b && b1<=a) || (a2<=b && b2<=a) || (a3<=b && b3<=a) || (a4<=b && b4<=a))
                return true;
                return false;
    }
    int main()
    {
        int n,c=0,y1,x1,i,j;
        cin>>n>>a>>b;
        for(i=0;i<n;i++)
            cin>>x[i]>>y[i];
        ll ans = 0,maxx = 0;
        for(i=0;i<n-1;i++){
            for(j=i+1;j<n;j++){
                 if(check(i,j)==1){
                 ans = x[i]*y[i]+x[j]*y[j];
                //cout<<i<<" "<<j<<" "<<ans<<endl;
                maxx = max(maxx,ans);
                }
            }
        }
        cout<<maxx<<endl;
        return 0;
    }

    ps:好鸡儿菜啊,打了一年还是这么水。

  • 相关阅读:
    springboot idea新建工程Initialization failed for 'https://start.spring.io' Please check URL, network and proxy settings
    TCP的三次握手与四次挥手理解及面试题
    lambda用法
    深入理解HashMap的扩容机制
    数据库连接池性能测试对比
    SQL
    AOP实现的统一日志处理
    阿里面试1
    汇总
    如果使用association和collection实现层级查询
  • 原文地址:https://www.cnblogs.com/kls123/p/7300164.html
Copyright © 2020-2023  润新知