训练赛链接: http://openoj.awaysoft.com:8080/judge/contest/view.action?cid=424#overview

题目来源: The 10th Zhejiang Provincial Collegiate Programming Contest

 还是想吐嘈 ZOJ的题目描述,与模拟题的恶心程度........

   背景是ACM集训队选拔,根据OJ题数,区域赛获奖,CF/TC排名, 还有个性别,  注意的地方是CF不满三场不计算.

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;


const int N = 1010;

bool isprime(int x){
    for(int i = 2; i*i <= x; i++)
        if( x%i == 0 ) return false;
    return true;
}
int n, m;
bool cmp(int a,int b){
    return a > b;
}

map< string, int > regional;
map< int, double > tiku;
const double esp = 1e-8;
int sign(double x){
    return x < -esp ? -1 : (x >esp);
}
struct Peason{
    string name;
    string team_name;
    string sex;
    double score;
    vector<int> problem;
    vector<int> cf;
    void read(){
        // init
        problem.clear(); cf.clear();
        char tmp[50];
        int oj_num, cf_num, x;    
        scanf("%s",tmp); name = tmp;
        scanf("%s",tmp); team_name = tmp;
        scanf("%s",tmp); sex = tmp;
        scanf("%d %d",&oj_num,&cf_num );    
        for(int i = 0; i < oj_num; i++){
            scanf("%d", &x);
            problem.push_back(x);
        }    
        for(int i = 0; i < cf_num; i++){
            scanf("%d", &x);
            cf.push_back(x);
        }    
    }
    void modify(){
        score = 0;    
        if( regional.count( team_name ) ){
            int d = regional[team_name];    
            if( d == 1 ) score += 36;
            else if( d == 2 ) score += 27;
            else if( d == 3 ) score += 18;
        }     
        for(int i = 0; i < (int)problem.size(); i++){
            int d = problem[i];    
            if( tiku.count(d) != 0 ) score += tiku[d];
            else if( isprime(d) ) score += 1;
            else score += 0.3;
        }     
        if( cf.size() >= 3 ){    
            sort( cf.begin(), cf.end(), cmp );    
            int r = cf[2];
            score += max( 0.0, (r-1200)/100. )*1.5;
        }    
        if( sex == "F" ) score += 33;

    }
    bool operator < (const Peason &tmp) const{
        if( sign(score-tmp.score) != 0 ){
            return sign(score-tmp.score) == 1;    
        }    
        else return name < tmp.name;    
    } 
}p[N];


void gao(){
    scanf("%d%d", &n, &m);
    // tiku info    
    int pro_n, x;
    scanf("%d", &pro_n);
    tiku.clear();
    for(int i = 0; i < pro_n; i++){
        scanf("%d", &x);
        tiku[x] = 2.5;
    }
    scanf("%d", &pro_n);
    for(int i = 0; i < pro_n; i++){
        scanf("%d", &x);
        tiku[x] = 1.5;
    }
    // regional    
    int team_num, rank;
    char str[N];
    scanf("%d", &team_num );
    regional.clear();    
    for(int i = 0; i < team_num; i++){
        scanf("%s %d", str, &rank );
        regional[str] = rank;
    }
    //peason
    for(int i = 0; i < n; i++)
        p[i].read(), p[i].modify();

    sort( p, p+n );
    for(int i = 0; i < m; i++)
        printf("%s %.3lf\n", p[i].name.c_str(), p[i].score );
}

int main(){ 
    int T;
    scanf("%d", &T);
    while( T-- ){
        gao();
    }
    return 0;
}
View Code

相关文章:

  • 2021-11-17
  • 2022-12-23
  • 2021-05-31
  • 2021-12-08
  • 2021-07-09
  • 2021-09-01
  • 2021-09-14
  • 2021-09-27
猜你喜欢
  • 2021-11-03
  • 2022-01-21
  • 2021-12-07
  • 2021-07-19
  • 2022-02-20
  • 2021-10-23
  • 2021-06-29
相关资源
相似解决方案