<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      書山有徑勤為路>>>>>>>>

      <<<<<<<<學海無涯苦作舟!

      vector的小小應用,大大功能

      Description

      As a contestant, you must be familiar with the rules of ACM-ICPC. Teams are ranked according to the most problems solved. Teams who solve the same number of problems are ranked by least total time. The total time is the sum of the time consumed for each problem solved. The time consumed for a solved problem is the time elapsed from the beginning of the contest to the submittal of the accepted run plus 20 penalty minutes for every rejected run for that problem regardless of submittal time. There is no time consumed for a problem that is not solved. Teams who solve the same number of problems and the same total time are ranked by their names in alphabetical order. 

      Any submit of a problem by those teams who has solved this problem before would be ignored!

      Caspar (a coach of SCPC) wants to know when the rank of his students’ team changed. He makes a curve to show the rank’s changes of his students’ team. Now, give you the information of every submission. Your problem is to calculate the changing points of a giving team. 

      Input

       

      There is ONLY ONE TESTCASE.

      The first line is an integer N (1<=N<=200) which indicates the number of submissions, and the number of teams is less than 20.

      Each of the following N lines has four operations A (indicating the Name of the team who submitted this code, no more than 20 characters), B(an integer indicating the submitted time), C (indicating the ID of problem, only one uppercase character), D (indicating the result of this run, ‘Y’ means accepted and ‘N’ means not accepted).

      Then an integer M followed in one line.

      Each of the following M lines has only one string indicating the team name which Caspar wants to check its curve.

      We promise that there is at most one submit in the same time and each of those teams Caspar want to check has at least one submit in this competition.

      Output

      For each team that Caspar wants to check its curve. You should output the changing points of the team in several lines. Each line has two number T, R indicating the time when the rank has been changed and rank. You should output as this format “time:T rank:R”. There is a blank line followed.

      After that, you should output the final rank of all teams.

      Sample Input

      16
      TEAM1 1 A Y
      TEAM2 2 A N
      TEAM2 3 A Y
      Dream 4 A Y
      TEAM3 5 A Y
      TEAM3 6 B Y
      TEAM4 7 A Y
      TEAM4 8 B Y
      TEAM4 9 C Y
      Dream 10 B Y
      Dream 11 C Y
      TEAM3 12 C Y
      TEAM1 13 B Y
      TEAM1 14 C Y
      TEAM1 15 D Y
      Dream 16 D Y
      2
      Dream
      TEAM1
      

      Sample Output

      time:4 rank:2
      time:6 rank:3
      time:8 rank:4
      time:10 rank:3
      time:11 rank:2
      time:12 rank:3
      time:15 rank:4
      time:16 rank:1
      
      time:1 rank:1
      time:6 rank:2
      time:8 rank:3
      time:10 rank:4
      time:15 rank:1
      time:16 rank:2
      
      Dream
      TEAM1
      TEAM3
      TEAM4
      TEAM2
      
      
      沒有用vector的做法,采用的是另外的兩個二維數組
      一個用來記時間,一個用來記排名。此外,還用了一個一
      維數組,來統計有多少次改動。
      然而,所有這些,用一個vector就可以搞定了。
      先貼出沒有用vector的代碼。
      #include "iostream"
      #include "cstring"
      #include "algorithm"
      #include "string"
      #include "map"
      using namespace std;
      #define sz 21
      #define ca 201
      int tm[sz][ca], rk[sz][ca], wg[sz][ca];
      bool AC[sz][ca];
      struct submit
      {
      string na;
      int ti;
      char pr, sb;
      }s[ca];
      struct team
      {
      string na;
      int an, at, ra;
      }t[sz], tt[sz];
      bool check(team a, team b)
      {
      if(a.an > b.an) return true;
      if(a.an==b.an && a.at<b.at) return true;
      if(a.an==b.an && a.at==b.at && a.na<b.na) return true;
      return false;
      }
      int main()
      {
      int n, k1 = 0, k2 = 0, flag1, flag2, df[sz], who, whi, nowtime;
      string ne;
      map<string, int> nm; //name
      map<char, int> pm; //probelm
      for(int i=0; i<21; i++)
      {
      t[i].an = 0; t[i].at = 0;
      t[i].ra = 0; df[i] = 0;
      }
      memset(tm, 0, sizeof(tm)); memset(rk, 0, sizeof(rk));
      memset(wg, 0, sizeof(wg)); memset(AC, false, sizeof(AC));
      cin>>n;
      for(int i=0; i<n; i++)
      {
      flag1 = 1; flag2=1;
      cin>>s[i].na>>s[i].ti>>s[i].pr>>s[i].sb;
      nowtime = s[i].ti;
      for(int j=0; j<i; j++)
      {
      if(s[i].na==s[j].na) flag1=0;
      if(s[i].pr==s[j].pr) flag2=0;
      }
      if(flag1)
      {
      t[k1].na = s[i].na; //存入姓名
      nm[s[i].na]=k1; k1++;
      }
      if(flag2)
      {
      pm[s[i].pr]=k2;
      k2++;
      }
      who = nm[s[i].na]; whi = pm[s[i].pr];
      if(s[i].sb=='N') wg[who][whi]++;
      else if(AC[who][whi]==false)
      {
      AC[who][whi]=true;
      t[who].an++;
      t[who].at+=(nowtime+20*wg[who][whi]);
      }
      for(int i=0; i<k1; i++)
      tt[i] = t[i];
      sort(tt, tt+k1, check);
      for(int j=0; j<k1; j++)
      {
      who = nm[tt[j].na];
      if(t[who].ra!=(j+1)) //j+1是現在的排名
      {
      t[who].ra = j+1; df[who]++;
      tm[who][df[who]]=nowtime; //記錄提交時的時間
      rk[who][df[who]]=j+1;
      }
      }
      }
      cin>>n;
      while(n--)
      {
      cin>>ne;
      for(int i=1; i<=df[nm[ne]]; i++)
      cout<<"time:"<<tm[nm[ne]][i]<<" rank:"<<rk[nm[ne]][i]<<endl;
      cout<<endl;
      }
      for(int i=0; i<k1; i++)
      cout<<tt[i].na<<endl;
      }
      
      
      下面給出用了vector的代碼。
      #include <string>
      #include <vector>
      #include <algorithm>
      #include <iostream>
      using namespace std;
      struct Info
      {
      int iTime;
      int iRank;
      };
      struct Team
      {
      int Problems[36]; //小于0表示已經AC,大于0表示WA次數,等于0表示還沒提交
      int AcCount;
      int total_time;
      string name;
      int rank;
      vector<Info> curve; //將結構體Info放入vector中,這個用法比較新
      };
      bool Cmp(Team t1,Team t2)
      {
      if(t1.AcCount > t2.AcCount)return true;
      if(t1.AcCount < t2.AcCount)return false;
      if(t1.total_time < t2.total_time)return true;
      if(t1.total_time > t2.total_time)return false;
      return t1.name < t2.name;
      }
      int N,M;
      Team Teams[20];
      int Team_Count = 0;
      int GetID(string str) //將字符串映射到數字,便于用計算機處理,其實可以用map來實現
      {
      int i;
      for(i=0;i<Team_Count;i++)
      if(str == Teams[i].name) return i;//已經存在了,就返回他的number
      Teams[Team_Count].name = str; //不存在,加入Teams中
      Team_Count++;
      return Team_Count-1;
      }

      void Init()
      {
      int i,j;
      for(i=0;i<20;i++)
      {
      for(j=0;j<36;j++)
      Teams[i].Problems[j] = 0;
      Teams[i].AcCount = 0;
      Teams[i].name = "";
      Teams[i].rank = 21;
      Teams[i].total_time = 0;
      }
      }
      int main()
      {
      Init();
      int i,j, NID, PID;
      string teamName;
      char results,ProblemID;
      int SubTime;
      cin>>N;
      for(i=1;i<=N;i++)
      {
      cin>>teamName>>SubTime>>ProblemID>>results;
      NID = GetID(teamName); PID = ProblemID-'A';
      if( Teams[NID].Problems[PID] < 0 )continue; //忽略已經AC的題目
      if(results == 'Y')
      {
      Teams[NID].total_time += (SubTime+20*Teams[NID].Problems[PID]);
      Teams[NID].Problems[PID] = -1;
      Teams[NID].AcCount++;
      }
      else
      Teams[NID].Problems[PID]++;
      sort(Teams,Teams+Team_Count,Cmp);
      for(j=0;j<Team_Count;j++)
      {
      if(Teams[j].rank != j)
      {
      Info TMP;
      TMP.iRank = 1+j;
      TMP.iTime = SubTime;
      Teams[j].rank = j;
      Teams[j].curve.push_back(TMP); //將變化的排名存入Teams[j]的vector中
      }
      }
      }
      cin>>M;
      while(M--)
      {
      cin>>teamName;
      int xb = GetID(teamName);
      for(i=0;i<Teams[xb].curve.size();i++)
      cout<<"time:"<<Teams[xb].curve[i].iTime<<" rank:"<<Teams[xb].curve[i].iRank<<endl;
      cout<<endl;
      }
      for(i=0;i<Team_Count;i++)
      cout<<Teams[i].name<<endl;
      }

      總結:
      在一個結構體中放入一個vector來可以統計結構體
      以外的內容,省去了用多個數組才能實現的麻煩。
      
      

      posted on 2011-11-23 13:14  More study needed.  閱讀(273)  評論(0)    收藏  舉報

      導航

      書山有徑勤為路>>>>>>>>

      <<<<<<<<學海無涯苦作舟!

      主站蜘蛛池模板: 亚洲成人av一区二区| 亚洲av无码精品色午夜蛋壳| 亚洲精品久久国产高清小说| 人妻精品中文字幕av| 日韩全网av在线| 公天天吃我奶躁我的在线观看| 国产91精品调教在线播放| 91中文字幕一区二区| 婷婷亚洲综合五月天小说| 精品国产乱码久久久人妻| 精品亚洲国产成人av在线| 精品国内自产拍在线观看| 亚洲成人av在线高清| 欧美成人www免费全部网站| 精精国产XXX在线观看| 少妇愉情理伦片丰满丰满午夜| 国产精品中文字幕日韩| 四虎精品永久在线视频| 久久精品国产精品第一区| 国产愉拍91九色国产愉拍| 岛国岛国免费v片在线观看| 自拍视频在线观看成人| 久久99精品中文字幕在| 日韩中文字幕人妻一区| 久久久久青草线蕉亚洲| 亚洲国产成人久久综合野外 | 日韩高清免费一码二码三码| 国产精品不卡一区二区在线| 亚洲色婷婷一区二区| 精品久久久无码中文字幕 | 亚洲岛国成人免费av| 久久精品噜噜噜成人av| 人人妻碰人人免费| 精品亚洲国产成人痴汉av| 欧美老熟妇乱子伦牲交视频| 亚洲一区二区三区丝袜| 亚洲中文字幕精品第一页| 国产精品人成视频免| 日本免费人成视频在线观看| 亚洲天码中文字幕第一页| 国产成人无码性教育视频|