记录编号 57966 评测结果 AAAAAAAAAA
题目名称 歌词 最终得分 100
用户昵称 Gravatardigital-T 是否通过 通过
代码语言 C++ 运行时间 0.031 s
提交时间 2013-04-15 11:32:24 内存使用 2.97 MiB
显示代码纯文本
  1. #include<fstream>
  2. #include<string>
  3. #include<algorithm>
  4. using namespace std;
  5. ifstream fi("lyric.in");
  6. ofstream fo("lyric.out");
  7. class bb
  8. {
  9. public:
  10. char t[7];
  11. string l;
  12. int tim;
  13. };
  14. bb lyric[2001];
  15. bool op(bb m,bb n)
  16. {
  17. /*if(m.t[2]=='n')return 0;
  18. if(n.t[2]=='n')return 1;*/
  19. if(m.tim<n.tim)return 0;
  20. if(m.tim>n.tim)return 1;
  21. //m.tim==n.tim
  22. if(m.l.length()<n.l.length())return 0;
  23. if(m.l.length()>n.l.length())return 1;
  24. if(m.l<n.l)return 0;
  25. return 1;
  26. }
  27. int main()
  28. {
  29. bb us;
  30. int n=0,check;
  31. while(!fi.eof())
  32. {n++;
  33. fi>>us.t[0]>>us.t[1];
  34. if(us.t[1]=='n')
  35. {
  36. fi>>us.t[2]>>us.t[3]>>us.t[4]>>us.t[5];
  37. us.tim=0;
  38. }//名字特判
  39. else
  40. {
  41. fi>>us.t[2]>>us.t[3]>>us.t[4]>>us.t[5]>>us.t[6];
  42. //us.tim=int(us.t[1])*1000+int(us.t[2])*100+int(us.t[4])*10+int(us.t[5])*1;
  43. us.tim=0;
  44. check=us.t[1]-48;
  45. us.tim+=check*1000;
  46. check=us.t[2]-48;
  47. us.tim+=check*100;
  48. check=us.t[4]-48;
  49. us.tim+=check*10;
  50. check=us.t[5]-48;
  51. us.tim+=check*1;
  52. }//[1][2][4][5]位存时间
  53. getline(fi,us.l);
  54. lyric[n]=us;
  55. }
  56. sort(lyric+1,lyric+n+1,op);
  57. int i;
  58. for(i=n;i>=1;i--)
  59. {//fo<<lyric[i].tim;
  60. if(lyric[i].tim==0){fo<<" "<<lyric[i].l<<endl;continue;}
  61. if(lyric[i-1].tim==lyric[i].tim){fo<<lyric[i].l;continue;}
  62. fo<<lyric[i].l<<endl;
  63. }
  64. return 0;
  65. }