ABC337(A-C)

发布时间:2024年01月20日

A

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int suma=0;
  int sumb=0;
  int a,b;
  while(n--){
    cin>>a>>b;
    suma+=a;
    sumb+=b;
  }
  if(suma>sumb)cout<<"Takahashi"<<endl;
  else if(suma<sumb)cout<<"Aoki"<<endl;
  else if(suma==sumb)cout<<"Draw"<<endl;
  return 0;
}

B

#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  string s0=s;
  for(auto i:s){
    if(i!='A'&&i!='B'&&i!='C'){
        cout<<"No"<<endl;
        return 0;
    }
  }
sort(s.begin(),s.end());
if(s0==s)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}  

C

#include<bits/stdc++.h>
using namespace std;
struct people{
    int id;
    int num;
};
bool cmp(people a,people b){
    return a.num<b.num;
}
int finds(people a[],int size,int key){
    int low = 0; 
    int high = size-1; 
    int mid;
    while(low <= high)    
    {
      mid = low+(high-low>>1);     
      if(key < a[mid].num)           
          high = mid-1;            
      else if(key > a[mid].num)     
          low = mid+1;            
      else                         
          return mid;
        }
    return -1;              
}

int main()
{
    int n;
    cin>>n;
    people a[n];
    int key;
    for(int i=0;i<n;i++){
        a[i].id=i+1;
        cin>>a[i].num;
        if(a[i].num==-1)key=a[i].id;
    }
    cout<<key<<" ";
    sort(a,a+n,cmp);
    int n0=n-1;
    while(n0--){
        key=a[finds(a,n,key)].id;
        cout<<key<<" ";
    }
return 0;
}

文章来源:https://blog.csdn.net/pboaths/article/details/135722246
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。