到Noip就只有半年了写个日志激励激励自己吧

争取日更

Ivan the Fool VS Gorynych the Dragon 尚未AC

/*
    http://codeforces.com/problemset/problem/48/E
    Ivan the Fool VS Gorynych the Dragon
*/
#include <bits/stdc++.h>

using namespace std;

int h,t,r,n,m;
int times = 1,max_dis = -1;
int graph[256][256];
queue <int> task;
struct tasks{
    int head,tail;
}tasks[512];
struct head{
    int head,tail;
}head[256];
struct tail{
    int head,tail;
}tail[256];

void dp(){
    int x,y;
    while(!task.empty()){
        x = tasks[task.front()].head;
        y = tasks[task.front()].tail;
        task.pop();
        for(int i = 1;i<=n;i++){
            if(i>x){
                break;
            }
            if(graph[x+head[i].head][y+head[i].tail]==-1||graph[x+head[i].head][y+head[i].tail]>graph[x][y]+1){
                graph[x+head[i].head][y+head[i].tail] = graph[x][y]+1;
                if(x+head[i].head+y+head[i].tail<=r){
                    task.push(times);
                    tasks[times].head = x+head[i].head;
                    tasks[times].tail = y+head[i].tail;
                    times++;
                }
                else{
                    max_dis = max(max_dis,graph[x+head[i].head][y+head[i].tail]);
                }
            }
        }
        for(int i = 1;i<=m;i++){
            if(i>y){
                break;
            }
            if(graph[x+tail[i].head][y+tail[i].tail]==-1||graph[x+tail[i].head][y+tail[i].tail]>graph[x][y]+1){
                graph[x+tail[i].head][y+tail[i].tail] = graph[x][y]+1;
                if(x+tail[i].head+y+tail[i].tail<=r){
                    task.push(times);
                    tasks[times].head = x+tail[i].head;
                    tasks[times].tail = y+tail[i].tail;
                    times++;
                }
                else{
                    max_dis = max(max_dis,graph[x+tail[i].head][y+tail[i].tail]);
                }
            }
        }
    }
    return;
}

void where_he_die(){
    if(max_dis!=-1){
        cout<<"Zmey"<<endl<<max_dis;
    }
    else{
        cout<<"Draw";
    }
    return;
}

int main(){
    cin>>h>>t>>r;
    cin>>n;
    for(int i = 1;i<=n;i++){
        cin>>head[i].head>>head[i].tail;
        head[i].head = head[i].head-i;
    }
    cin>>m;
    for(int i = 1;i<=m;i++){
        cin>>tail[i].head>>tail[i].tail;
        tail[i].tail = tail[i].tail-i;
    }
    memset(graph,-1,sizeof(graph));
    graph[h][t] = 0;
    task.push(0);
    tasks[0].head = h;
    tasks[0].tail = t;
    dp();
    if(graph[0][0]!=-1){
        cout<<"Ivan"<<endl<<graph[0][0];
    }
    else{
        where_he_die();
    }
    return 0;
}

 

Sum AC

#include <bits/stdc++.h>

using namespace std;

int position(char num){
  if(num>57){
    return (num&31)+10;
  }
  return num-48;
}

int cover(char a[1000],int dec){
  int sum = 0,wei = 1;
  /*for(int i = 0;i<strlen(a);i++){
    sum += wei*position(a[i]);
    wei *= dec;
  }*/
  for(int i = strlen(a)-1;i>=0;i--){
    sum += wei*position(a[i]);
    wei *= dec;
  }
  return sum;
}

int back(int total,int dec){
  int sum = 0;
  while(total){
    sum ++;
    total /= dec;
  }
  return sum;
} 

int main(){
  char a[1000],b[1000];
  int total;
  int m = 0;
  cin>>a>>b;
  for(int i = 0;i<strlen(a);i++){
    m = max(position(a[i]),m);
  }
  for(int i = 0;i<strlen(b);i++){
    m = max(position(b[i]),m);
  }
  m++;
  total = cover(a,m) + cover(b,m);
  cout<<back(total,m);
  return 0;
}

Winner AC

#include<bits/stdc++.h>
using namespace std;
map<string,int> mp,mpp;
int n,a[100001],maxn=-99999999;
string s[100001],s1;
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        cin>>s[i]>>a[i];
        mp[s[i]]+=a[i];
    }
    for(int i=1;i<=n;i++){
        maxn=max(maxn,mp[s[i]]);
    }
    for(int i=1;i<=n;i++){
        mpp[s[i]]+=a[i];
        if(mp[s[i]]==maxn&&mpp[s[i]]>=maxn){
            s1=s[i];
            break;
        }
    }
    cout<<s1<<endl;
    return 0;
}

打赏 赞(1)
微信二维码图片

微信扫描二维码打赏

发表评论

电子邮件地址不会被公开。

Scroll Up