RT,0分挂掉了,但是样例过了()
跑这组hack的时候挂掉了,第二个人的成绩输出了 86。但是没有找到哪里假掉了……
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
#include<ctime>
#include<iomanip>
#include<sstream>
using namespace std;
int gett1(const string &s){
int a,b;
sscanf(s.c_str(),"%d'%d\"",&a,&b);
return a*60+b;
}
int monthdats[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
time_t gett2(const string &date,const string &s){
tm tt;
// sscanf(s.c_str(),"%d:%d:%d",&tt.tm_hour,&tt.tm_min,&tt.tm_sec);
// tt.tm_mday=((date[4]-'0')*10+(date[5]-'0'));
// tt.tm_mon=((date[6]-'0')*10+(date[7]-'0'));
istringstream sin(date+" "+s);
sin >> get_time(&tt,"%Y%m%d %H:%M:%S");
return mktime(&tt);
}
struct student{
long long p;
bool sex;//M(false)男F(true)女
int s;//体育课专项成绩
int t1;//期末长跑成绩
bool pf;//是否通过体质测试
int f;//期末检测成绩
int c;//班级训练营次数
int sunrun_cnt;//阳光长跑合法次数
}a[10001];
map<long long,int> idp;//key=编号 second=学生id
map<long long,time_t> lasttime;//上条合法记录结束时间
constexpr int sc[2][114]={
{12*60+30,13*60+0,13*60+30,14*60+0,14*60+30,15*60+10,15*60+50,16*60+30,17*60+10,18*60+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+0}
};
constexpr int sunsc[15]={//分数在[sunsc[i],sunsc[i+1])之间的,得i分
0,0,3,7,7,11,11,14,17,19,21,1145141919
};
constexpr int sunsc2[12]={//分数在[sunsc2[i],sunsc2[i+1])之间的,得i分
0,6,9,12,15,18
};
int score(student &t){
int res=t.s;
// cout << "体育专项成绩: " << t.s << " 分。\n";
for(int i=0;i<100;i++){
if(t.t1<=sc[t.sex][i]){
res+=20-i*2;
// cout << "期末长跑成绩:" << 20-i*2 << " 分。\n";
break;
}
}
for(int i=10;i>=2;i--){
if(t.sunrun_cnt>=sunsc[i]){
// cout << "阳光长跑合法次数得分:" << i << " 分。\n";
res+=i;
break;
}
}
if(t.sunrun_cnt<3){
// cout << "阳光长跑合法次数得分:" << 0 << "分。\n";
}
res+=(t.pf?10:0);
// cout << "体质测试成绩:" << (t.pf?10:0) << "分。\n";
int csum=t.sunrun_cnt+t.c;
for(int i=5;i>=1;i--){
if(csum>=sunsc2[i]){
// cout << "出勤次数得分:" << i << "分。\n";
res+=i;
break;
}
}
if(csum<6){
// cout << "出勤次数得分:" << 0 << "分。\n";
}
res+=t.f;
// cout << "期末检测成绩:" << t.f << "分。\n";
return res;
}
pair<int,string> pt_sc[114]={
make_pair(95,"A"),
make_pair(90,"A-"),
make_pair(85,"B+"),
make_pair(80,"B"),
make_pair(77,"B-"),
make_pair(73,"C+"),
make_pair(70,"C"),
make_pair(67,"C-"),
make_pair(63,"D+"),
make_pair(60,"D"),
make_pair(0,"F")
};
string tostr(int sc){
for(int i=0;;i++){
if(sc>=pt_sc[i].first){
return pt_sc[i].second;
}
}
}
int n,m;
string tmp,date;
char ch;
long long pid;
struct wsy{
int stuid;
int stop,steps;
time_t st,ed;
int rdis;
bool operator<(const wsy &rhs) const{
return ed==rhs.ed?st<rhs.st:ed<rhs.st;
}
}records[150001];
map<string,int> order;
int main(){
cin >> n;
for(int i=1;i<=n;i++){
cin >> a[i].p;
idp[a[i].p]=i;
order[to_string(a[i].p)]=i;
cin >> ch;
if(ch=='M'){
a[i].sex=false;
} else{
a[i].sex=true;
}
cin >> a[i].s;
cin >> tmp;
a[i].t1=gett1(tmp);
cin >> ch;
if(ch=='P'){
a[i].pf=true;
} else{
a[i].pf=false;
}
cin >> a[i].f;
cin >> a[i].c;
}
cin >>m;
for(int i=1;i<=m;i++){
double dis1;
cin >> date;
cin >> pid;
records[i].stuid=idp[pid];
cin >> tmp;
records[i].st=gett2(date,tmp);
cin >> tmp;
records[i].ed=gett2(date,tmp);
cin >> dis1;
records[i].rdis=dis1*1000;
cin >> tmp;
records[i].stop=gett1(tmp);
cin >> records[i].steps;
}
sort(records+1,records+m+1);
for(int i=1;i<=m;i++){
student &t=a[records[i].stuid];
int stop=records[i].stop,steps=records[i].steps;
time_t st=records[i].st,ed=records[i].ed;
int rdis=records[i].rdis;//按米计算的
bool flag=true;
if(rdis<(t.sex==false?3000:1500)){
flag=false;
} else{
time_t delay=ed-st;
//运动距离>=(结束时间-开始时间)*2
//运动距离<=(结束时间-开始时间)*5
if(rdis<delay*2 || rdis>delay*5){
flag=false;
} else{
if(stop>4*60+30){
flag=false;
} else{
if(rdis>steps*1.5){
flag=false;
} else if(lasttime.find(pid)!=lasttime.end()){
if(ed-lasttime[pid]<6*3600){
flag=false;
}
}
}
}
}
if(flag){
t.sunrun_cnt++;
lasttime[pid]=ed;
}
}
for(auto &it:order){
int i=it.second;
int x=score(a[i]);
cout << a[i].p << " " << x << " " << tostr(x) << '\n';
}
return 0;
}