求助,WA on #22
查看原帖
求助,WA on #22
366897
HarunluoON楼主2022/1/19 15:12

应该是第二种排序出的问题,求调

#include<iostream>
#include<cstdio>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int sco[11]={0,25,18,15,12,10,8,6,4,2,1};
int psum,n;
map<string,int> name_to_num;//名字->存储该名字的person数组下标
struct person
{
	string name,rank;//rank[i]表示得了几次第i名
    int score;
} p[1001];
void person_init()//初始化,省略
{
}
void input()//省略
{
}
bool comp1(person x,person y)
{
}
bool comp2(person x,person y)
{
	if(x.rank[1]!=y.rank[1])
    return x.rank[1]>y.rank[1];
    else
    {
    	if(x.score!=y.score)
        return x.score>y.score;
        else
        {
        	for(int i=2;i<=n;i++)
            {
            	if(x.rank[i]!=y.rank[i])
                return x.rank[i]>y.rank[i];
            }
        }
    }
}
void way1()
{
}
void way2()
{
	sort(p+1,p+psum+1,comp2);
    cout<<p[1].name<<endl;
}
int main()
{
    scanf("%d",&n);
    person_init();//初始化
    while(n--)
    input();
    way1();
    way2();
    return 0;
}

祝大佬ak ioi

2022/1/19 15:12
加载中...