记录编号 |
57966 |
评测结果 |
AAAAAAAAAA |
题目名称 |
歌词 |
最终得分 |
100 |
用户昵称 |
digital-T |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.031 s |
提交时间 |
2013-04-15 11:32:24 |
内存使用 |
2.97 MiB |
显示代码纯文本
- #include<fstream>
- #include<string>
- #include<algorithm>
- using namespace std;
- ifstream fi("lyric.in");
- ofstream fo("lyric.out");
- class bb
- {
- public:
- char t[7];
- string l;
- int tim;
- };
- bb lyric[2001];
- bool op(bb m,bb n)
- {
- /*if(m.t[2]=='n')return 0;
- if(n.t[2]=='n')return 1;*/
- if(m.tim<n.tim)return 0;
- if(m.tim>n.tim)return 1;
- //m.tim==n.tim
- if(m.l.length()<n.l.length())return 0;
- if(m.l.length()>n.l.length())return 1;
- if(m.l<n.l)return 0;
- return 1;
- }
- int main()
- {
- bb us;
- int n=0,check;
- while(!fi.eof())
- {n++;
- fi>>us.t[0]>>us.t[1];
- if(us.t[1]=='n')
- {
- fi>>us.t[2]>>us.t[3]>>us.t[4]>>us.t[5];
- us.tim=0;
- }//名字特判
- else
- {
- fi>>us.t[2]>>us.t[3]>>us.t[4]>>us.t[5]>>us.t[6];
- //us.tim=int(us.t[1])*1000+int(us.t[2])*100+int(us.t[4])*10+int(us.t[5])*1;
- us.tim=0;
- check=us.t[1]-48;
- us.tim+=check*1000;
- check=us.t[2]-48;
- us.tim+=check*100;
- check=us.t[4]-48;
- us.tim+=check*10;
- check=us.t[5]-48;
- us.tim+=check*1;
- }//[1][2][4][5]位存时间
- getline(fi,us.l);
- lyric[n]=us;
- }
- sort(lyric+1,lyric+n+1,op);
- int i;
- for(i=n;i>=1;i--)
- {//fo<<lyric[i].tim;
- if(lyric[i].tim==0){fo<<" "<<lyric[i].l<<endl;continue;}
- if(lyric[i-1].tim==lyric[i].tim){fo<<lyric[i].l;continue;}
- fo<<lyric[i].l<<endl;
- }
- return 0;
- }