栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

zoj 1444 Final Standings

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

zoj 1444 Final Standings

#include <map>  #include <cstdio>  #include <string>  #include <cstring>  #include <iostream>  #include <algorithm>  using namespace std;  #define TEAM_MAX 10005  #define PRO_MAX 105  int team_sum;bool mycmp(string a,string b) {      for(int i = 0; i < a.length(); i ++) if(a[i] > 'Z') a[i] -= 32;      for(int i = 0; i < b.length(); i ++) if(b[i] > 'Z') b[i] -= 32;      return a<b;  }  struct team_node  {      int AC;      int tol_time;      string team_name;      int problem[PRO_MAX];     bool operator<(const team_node& T)const      {          if(T.AC != AC) return AC > T.AC;        else if(tol_time != T.tol_time) return tol_time < T.tol_time;        else return mycmp(team_name,T.team_name);     }  }TEAM[TEAM_MAX];  void print()  {      int rank = 1;      if(TEAM[0].AC == 0) return ;      printf("%-10d%-30s%-10d%dn",rank,TEAM[0].team_name.c_str(),TEAM[0].AC,TEAM[0].tol_time);      for(int i = 1; i < team_sum; i ++)      {          rank++;          if(TEAM[i].AC == 0) return ;          if(TEAM[i].AC == TEAM[i-1].AC && TEAM[i].tol_time == TEAM[i-1].tol_time)        {   printf("          %-30s%-10d%dn",TEAM[i].team_name.c_str(),TEAM[i].AC,TEAM[i].tol_time);          }          else   printf("%-10d%-30s%-10d%dn",rank,TEAM[i].team_name.c_str(),TEAM[i].AC,TEAM[i].tol_time);      }  }  int main()  {        int N;      int time,pro;      string team,judge;      map<string,int>m;      team_sum = 0;    cin>>N;      while(cin>>time>>team>>pro>>judge)      {          int id;        if(m.find(team) == m.end())          {   id = team_sum++;   m[team] = id; TEAM[id].AC = TEAM[id].tol_time = 0;   TEAM[id].team_name = team;   memset(TEAM[id].problem,0,sizeof(TEAM[id].problem));          }          else id = (*m.find(team)).second;          if(judge == "AC" && TEAM[id].problem[pro] != 1)          {   TEAM[id].tol_time += time - TEAM[id].problem[pro];   TEAM[id].AC ++;   TEAM[id].problem[pro] = 1;        }          else          {   if(TEAM[id].problem[pro] == 1) continue;   TEAM[id].problem[pro] -= 20;          }      }      sort(TEAM,TEAM+team_sum);      print();      return 0;  }
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/369257.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号