Last active
July 26, 2018 03:18
-
-
Save EkiXu/9e1ce88e0e2e34363014846479234494 to your computer and use it in GitHub Desktop.
「THUPC 2017」体育成绩统计
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cstdio> | |
#include<cstdlib> | |
#include<cstring> | |
#include<algorithm> | |
#define MAXN 5000 | |
template <typename Num> | |
inline void Read(Num &x) { | |
x=0;int p=1;char c=getchar(); | |
for(; !('0'<=c&&c<='9'); c=getchar()) if(c=='-') p=-1; | |
for(;'0'<=c&&c<='9';c=getchar()) x=x*10+c-'0'; | |
x*=p; | |
return ; | |
} | |
struct Record { | |
double distance; | |
int date; | |
int begin,end,pause,steps; | |
Record():distance(0),date(0),begin(0),end(0),pause(0),steps(0){} | |
Record(double _distance,int _date,int _begin,int _end,int _pause,int _steps):distance(_distance),date(_date),begin(_begin),end(_end),pause(_pause),steps(_steps){} | |
}; | |
char levelTable[12][4]= {"","A","A-","B+","B","B-","C+","C","C-","D+","D","F"}; | |
int levelStandard[12]= {0,95,90,85,80,77,73,70,67,63,60,0}; | |
char runCntTable[9]= {0,10,9,8,7,6,4,2,0}; | |
char runCntStandard[9]= {0,21,19,17,14,11,7,3,0}; | |
char planCntStandard[7]= {0,18,15,12,9,6,0}; | |
struct Student { | |
int isMale; | |
int id; | |
int score; | |
int campCnt,runCnt; | |
Record lastRecord; | |
Student(){} | |
Student(int _id,int _isMale,int _score,int _campCnt):id(_id),isMale(_isMale),score(_score),campCnt(_campCnt),runCnt(0){} | |
friend bool operator < (Student _a,Student _b) { | |
return _a.id<_b.id; | |
} | |
inline void Calc(){ | |
int ret=0,p=1; | |
while(runCnt<runCntStandard[p]) p++; | |
ret+=runCntTable[p]; | |
ret+=5;p=1; | |
while(runCnt+campCnt<planCntStandard[p]) ret--,p++; | |
score+=ret; | |
return ; | |
} | |
inline int GetLevel() { | |
int ret=1; | |
while(score<levelStandard[ret]) ret++; | |
return ret; | |
} | |
inline void Print() { | |
printf("%d %d %s\n",id,score,levelTable[GetLevel()]); | |
return ; | |
} | |
} stu[MAXN+10]; | |
inline int Minute(char *str) { | |
int p=0; | |
int m=0,s=0; | |
for(; '0'<=str[p]&&str[p]<='9'; p++) m=m*10+str[p]-'0'; | |
while(!('0'<=str[p]&&str[p]<='9')) p++; | |
for(; '0'<=str[p]&&str[p]<='9'; p++) s=s*10+str[p]-'0'; | |
return m*60+s; | |
} | |
inline void ReadMinute(int &x) { | |
char minute[10]=""; | |
scanf("%s",minute); | |
x=Minute(minute); | |
return ; | |
} | |
inline int Hour(char *str) { | |
int p=0; | |
int h=0,m=0,s=0; | |
for(; '0'<=str[p]&&str[p]<='9'; p++) h=h*10+str[p]-'0'; | |
while(!('0'<=str[p]&&str[p]<='9')) p++; | |
for(; '0'<=str[p]&&str[p]<='9'; p++) m=m*10+str[p]-'0'; | |
while(!('0'<=str[p]&&str[p]<='9')) p++; | |
for(; '0'<=str[p]&&str[p]<='9'; p++) s=s*10+str[p]-'0'; | |
return h*3600+m*60+s; | |
} | |
inline void ReadHour(int &x) { | |
char hour[15]=""; | |
scanf("%s",hour); | |
x=Hour(hour); | |
return ; | |
} | |
int runStandard[2][11]= {{0,6*60+40,6*60+57,7*60+14,7*60+31,7*60+50,8*60+5,8*60+20,8*60+35,8*60+50,9*60+40}, | |
{0,12*60+30,13*60,13*60+30,14*60,14*60+30,15*60+10,15*60+50,16*60+30,17*60+10,18*60}}; | |
inline int GetRunScore(int isMale,int runTime) { | |
int ret=20,p=1; | |
while(runStandard[isMale][p]<runTime) p++,ret-=2; | |
return ret; | |
} | |
inline bool isVaild(Student u,Record r) { | |
if((u.isMale and r.distance<3.0) or (!u.isMale and r.distance<1.5)) return false; | |
if(r.distance*1000>5.0*(r.end-r.begin) or r.distance*1000<2.0*(r.end-r.begin)) return false; | |
if(r.pause>4*60+30) return false; | |
if(r.distance*1000>1.5*r.steps) return false; | |
if(u.lastRecord.date!=0 and (u.lastRecord.date==r.date and r.begin-u.lastRecord.end<6*60*60)) return false; | |
return true; | |
} | |
int n; | |
inline int Find(int id){ | |
int l=1,r=n,mid; | |
while(l<=r){ | |
mid=l+r>>1; | |
if(id<stu[mid].id) r=mid-1; | |
else if(id==stu[mid].id) return mid; | |
else l=mid+1; | |
} | |
return 0; | |
} | |
int main() { | |
freopen("std.in","r",stdin); | |
freopen("std.out","w",stdout); | |
Read(n); | |
char c; | |
for(int i=1,id,isMale,PEScore,runScore,testScore,planScore,campCnt,runTime; i<=n; i++) { | |
Read(id); | |
do {c=getchar();} while(c!='M' and c!='F'); | |
isMale=(c=='M')?1:0; | |
Read(PEScore); | |
ReadMinute(runTime); | |
runScore=GetRunScore(isMale,runTime); | |
do {c=getchar();} while(c!='P' and c!='F'); | |
testScore=(c=='P')?10:0; | |
Read(planScore); | |
Read(campCnt); | |
stu[i]=Student(id,isMale,PEScore+runScore+testScore+planScore,campCnt); | |
} | |
std::sort(stu+1,stu+n+1); | |
int m; | |
Read(m); | |
double distance; | |
for(int i=1,id,date,begin,end,pause,steps; i<=m; i++) { | |
Read(date); | |
Read(id); | |
ReadHour(begin); | |
ReadHour(end); | |
scanf("%lf",&distance); | |
ReadMinute(pause); | |
Read(steps); | |
if(isVaild(stu[Find(id)],Record(distance,date,begin,end,pause,steps))) stu[Find(id)].runCnt++,stu[Find(id)].lastRecord=Record(distance,date,begin,end,pause,steps); | |
} | |
for(int i=1; i<=n; i++) stu[i].Calc(),stu[i].Print(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment