zoukankan      html  css  js  c++  java
  • Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2)

    https://codeforces.com/contest/976

    A

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define IT set<ll>::iterator
     6 #define sqr(x) ((x)*(x))
     7 #define pb push_back
     8 #define eb emplace_back
     9 #define maxn 200005
    10 #define eps 1e-8
    11 #define pi acos(-1.0)
    12 #define rep(k,i,j) for(int k=i;k<j;k++)
    13 typedef long long ll;
    14 typedef pair<int,int> pii;
    15 typedef pair<ll,ll>pll;
    16 typedef pair<ll,int> pli;
    17 typedef pair<pair<int,string>,pii> ppp;
    18 typedef unsigned long long ull;
    19 const long long MOD=998244353;
    20 const double oula=0.57721566490153286060651209;
    21 using namespace std;
    22 
    23 
    24 
    25 int main(){
    26     std::ios::sync_with_stdio(false);
    27     int n;
    28     string str;
    29     cin>>n>>str;
    30     if(str=="0") cout<<0<<endl;
    31     else {
    32         int co=0;
    33         for(int i=0;i<str.length();i++){
    34             if(str[i]=='0') co++;
    35         }
    36         cout<<1;
    37         for(int i=0;i<co;i++){
    38             cout<<0;
    39         }
    40         cout<<endl;
    41     }
    42 }
    View Code

    B

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define IT set<ll>::iterator
     6 #define sqr(x) ((x)*(x))
     7 #define pb push_back
     8 #define eb emplace_back
     9 #define maxn 200005
    10 #define eps 1e-8
    11 #define pi acos(-1.0)
    12 #define rep(k,i,j) for(int k=i;k<j;k++)
    13 typedef long long ll;
    14 typedef pair<int,int> pii;
    15 typedef pair<ll,ll>pll;
    16 typedef pair<ll,int> pli;
    17 typedef pair<pair<int,string>,pii> ppp;
    18 typedef unsigned long long ull;
    19 const long long MOD=998244353;
    20 const double oula=0.57721566490153286060651209;
    21 using namespace std;
    22 
    23 
    24 int main(){
    25     std::ios::sync_with_stdio(false);
    26     ll n,m,k;
    27     cin>>n>>m>>k;
    28     if (k<n) {
    29         cout<<k+1<<" "<<1<<endl;
    30         return 0;
    31     }
    32     k-=n-1;
    33     if (k==0) {
    34         cout<<n<<" "<<1;
    35         return 0;
    36     }
    37     k-=1;
    38     ll l=k/(m-1);
    39     k%=(m-1);
    40     if((n-l)%2==0) cout<<n-l<<" "<< k+2<<endl;
    41     else cout<<n-l<<" "<<m-k<<endl;
    42 }
    View Code

    C

    题意:是否存在一条线段是否包含另一条线段,有的话就输出其中一个解

    思路:sort排序下即可

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define IT set<ll>::iterator
     6 #define sqr(x) ((x)*(x))
     7 #define pb push_back
     8 #define eb emplace_back
     9 #define maxn 200005
    10 #define eps 1e-8
    11 #define pi acos(-1.0)
    12 #define rep(k,i,j) for(int k=i;k<j;k++)
    13 typedef long long ll;
    14 typedef pair<int,int> pii;
    15 typedef pair<ll,ll>pll;
    16 typedef pair<ll,int> pli;
    17 typedef pair<pair<int,string>,pii> ppp;
    18 typedef unsigned long long ull;
    19 const long long MOD=998244353;
    20 const double oula=0.57721566490153286060651209;
    21 using namespace std;
    22 
    23 
    24 vector<pair<int,pair<int,int> > >ve;
    25 
    26 bool cmp(pair<int,pair<int,int> > a,pair<int,pair<int,int> > b){
    27     if(a.second.first==b.second.first) return a.second.second>b.second.second;
    28     return a.second.first<b.second.first;
    29 }
    30 
    31 int main(){
    32     std::ios::sync_with_stdio(false);
    33     int n;
    34     cin>>n;
    35     int x,y;
    36     for(int i=1;i<=n;i++){
    37         cin>>x>>y;
    38         ve.pb({i,{x,y}});
    39     }
    40     sort(ve.begin(),ve.end(),cmp);
    41     int L=ve[0].second.first,R=ve[0].second.second,pos=ve[0].first;
    42     int flag=0;
    43     for(int i=1;i<ve.size();i++){
    44         if(L<=ve[i].second.first&&R>=ve[i].second.second){
    45             cout<<ve[i].first<<" "<<pos<<endl;
    46             return 0;
    47         }
    48         L=ve[i].second.first,R=ve[i].second.second,pos=ve[i].first;
    49     }
    50     if(!flag){
    51         cout<<-1<<" "<<-1<<endl;
    52     }
    53 }
    View Code

    D

    题意:

    给你一个长度为 n 的正整数序列 d1,d2,,dn (d1<d2<<dn )。要求你构造一个满足以下条件的无向图:

    1. 有恰好 dn+1 个点。
    2. 没有自环。
    3. 没有重边。
    4. 总边数不超过 10^6。
    5. 它的度数集合等于 dd 。

    点从 1标号至 dn+1 。

    图的度数序列是一个长度与图的点数相同的数组 a,其中 ai 是第 i 个顶点的度数(与其相邻的顶点数)。图的度数集合是度数序列排序后去重的结果。

    思路:把前d[1]个点向所有点连接一条边后,就会出现有d[1]个度为d[n]的点,剩下的点度都为d[1],然后我们可以继续构造(d[2]-d[1],d[3]-d[1],d[4]-d[1]....d[n-1]-d[1])的点,不断缩小子问题

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define IT set<ll>::iterator
     6 #define sqr(x) ((x)*(x))
     7 #define pb push_back
     8 #define eb emplace_back
     9 #define maxn 200005
    10 #define eps 1e-8
    11 #define pi acos(-1.0)
    12 #define rep(k,i,j) for(int k=i;k<j;k++)
    13 typedef long long ll;
    14 typedef pair<int,int> pii;
    15 typedef pair<ll,ll>pll;
    16 typedef pair<ll,int> pli;
    17 typedef pair<pair<int,string>,pii> ppp;
    18 typedef unsigned long long ull;
    19 const long long MOD=998244353;
    20 const double oula=0.57721566490153286060651209;
    21 using namespace std;
    22 
    23 
    24 vector<pii>ve;
    25 int d[305];
    26 
    27 int main(){
    28     std::ios::sync_with_stdio(false);
    29     int n;
    30     cin>>n;
    31     for(int i=1;i<=n;i++) cin>>d[i];
    32     int L=1,R=n;
    33     int co=0;
    34     while(L<=R){
    35         for(int i=d[L-1]+1;i<=d[L];i++){
    36             for(int j=i+1;j<=d[R]+1;j++){
    37                 ve.pb({i,j});
    38                 co++;
    39             }
    40         }
    41         L++;
    42         R--;
    43     }
    44     cout<<co<<endl;
    45     for(int i=0;i<ve.size();i++){
    46         cout<<ve[i].first<<" "<<ve[i].second<<endl;
    47     }
    48 }
    View Code

    E

    题意:你有n个小兵,每个小兵都有血条和攻击力,你可以使用a种1操作,b种2操作,是小兵们的攻击力之和最大。1操作:是一个小兵当前血量翻倍 。2操作:把一个小兵当前的血量值赋值给攻击力。

    思路:容易想到,把a操作的都给集中给一个小兵是最好的,所以我们可以先按血量-攻击力的差值从大到小排序,然后不断分情况枚举a给谁最好。

     1 #include<bits/stdc++.h>
     2 using namespace std;
     3 #define lson l,mid,rt<<1
     4 #define rson mid+1,r,rt<<1|1
     5 #define IT set<ll>::iterator
     6 #define sqr(x) ((x)*(x))
     7 #define pb push_back
     8 #define eb emplace_back
     9 #define maxn 200005
    10 #define eps 1e-8
    11 #define pi acos(-1.0)
    12 #define rep(k,i,j) for(int k=i;k<j;k++)
    13 typedef long long ll;
    14 typedef pair<int,int> pii;
    15 typedef pair<ll,ll>pll;
    16 typedef pair<ll,int> pli;
    17 typedef pair<pair<int,string>,pii> ppp;
    18 typedef unsigned long long ull;
    19 const long long MOD=998244353;
    20 const double oula=0.57721566490153286060651209;
    21 using namespace std;
    22 
    23 ll n,a,b;
    24 vector<pll>ve;
    25 
    26 bool cmp(pll a,pll b){
    27     return a.first-a.second>b.first-b.second;
    28 }
    29 
    30 int main(){
    31     std::ios::sync_with_stdio(false);
    32     ll x,y;
    33     cin>>n>>a>>b;
    34     b=min(b,n);
    35     for(int i=1;i<=n;i++){
    36         cin>>x>>y;
    37         ve.pb({x,y});
    38     }
    39     sort(ve.begin(),ve.end(),cmp);
    40     ll sum=0;
    41     for(int i=0;i<b;i++){
    42         sum+=max(ve[i].first,ve[i].second);
    43     }
    44     for(int i=b;i<n;i++){
    45         sum+=ve[i].second;
    46     }
    47     ll ans=sum;
    48     for(int i=0;i<b;i++){
    49         ans=max(ans,sum-max(ve[i].first,ve[i].second)+(ve[i].first<<a));
    50     }
    51     sum-=max(ve[b-1].first,ve[b-1].second)-ve[b-1].second;
    52     if(b){
    53         for(int i=b;i<n;i++){
    54             ans=max(ans,sum-ve[i].second+(ve[i].first<<a));
    55         }
    56     }
    57     cout<<ans<<endl;
    58 }
    View Code

    F

    待补

  • 相关阅读:
    HNU 12906 Battleship
    codeforces 261 D
    HDU 4939 Stupid Tower Defense(dp)
    HDU 4941 Magical Forest(map映射+二分查找)杭电多校训练赛第七场1007
    HDU 4902 Nice boat 2014杭电多校训练赛第四场F题(线段树区间更新)
    【转载】使用Pandas对数据进行筛选和排序
    【转载】使用pandas进行数据清洗
    【转载】VC维的来龙去脉
    Python-时间操作
    Pandas-数据导入
  • 原文地址:https://www.cnblogs.com/Fighting-sh/p/10639254.html
Copyright © 2011-2022 走看看