RE一次,WA两次,结果是因为提交错了题目。
以下是我的代码:
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
struct Type
{
Type():AC(false),tried(0) {}
bool AC;
int tried,AC_time;
};
struct Type2
{
Type2(int aa,int bb,int cc):id(aa),solved(bb),total_time(cc) {}
int id;
int solved;
int total_time;
};
bool operator<(const Type2 &a,const Type2 &b)
{
return ((a.solved>b.solved) ||
(a.solved==b.solved && a.total_time<b.total_time) ||
(a.solved==b.solved && a.total_time==b.total_time && a.id<b.id));
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("data.in","r",stdin);
#endif
int T;
scanf("%d",&T);
cin.get();cin.get();
bool first_case(true);
while(T--)
{
if(first_case)
first_case=false;
else
printf("\n");
Type r[107][17];
bool be[107]={false};
string in;
while(getline(cin,in) && !in.empty())
{
int id,prob,tm;
char state;
istringstream(in)>>id>>prob>>tm>>state;
be[id]=true;
if(state=='R' || state=='U' || state=='E' || r[id][prob].AC)
continue;
if(state=='C')
{
r[id][prob].AC=true;
r[id][prob].AC_time=tm+20*r[id][prob].tried;
}
else
r[id][prob].tried++;
}
vector<Type2> a;
for(int i=1;i<=100;i++)
if(be[i])
{
int t1(0),t2(0);
for(int j=1;j<=9;j++)
if(r[i][j].AC)
{
t1++;
t2+=r[i][j].AC_time;
}
a.push_back(Type2(i,t1,t2));
}
sort(a.begin(),a.end());
for(int i=0;i<a.size();i++)
printf("%d %d %d\n",a[i].id,a[i].solved,a[i].total_time);
}
return 0;
}
posted on 2011-09-06 14:08
lee1r 阅读(384)
评论(0) 编辑 收藏 引用 所属分类:
题目分类:基础/模拟