为什么我只有80分?

学术版

```cpp #include<bits/stdc++.h> using namespace std; int n,maxn=0,sum=0,tot=0,kkk[10005]; string s[1005],sos,maxs; struct node{ int pas; int name; }a[10005]; bool cmd(node x,node y) { if(x.pas==y.pas) return x.name<y.name; return x.pas>=y.pas; } int main() { //freopen("save.in","r",stdin); //freopen("save.out","w",stdout); cin>>n; for(int i=1;i<=n;i++) { cin>>s[i]>>sos; a[i].name=i; sum=0; while(sos.size()) { if(sos.find("sos")==0) sum++; sos.erase(0,1); } tot++; //cout<<sum<<endl; a[tot].pas=sum; } tot=1; sort(a+1,a+n+1,cmd); maxn=a[1].pas; while(tot<=n&&a[tot].pas==maxn) { kkk[a[tot].name]=1; tot++; } for(int i=1;i<=n;i++) { if(kkk[i]==1) cout<<s[i]<<" "; } cout<<endl<<maxn<<endl; return 0; } ```
by cxh315 @ 2020-05-24 20:59:24


我改了一下cmd函数就好了,sort之后不保证原来信息中靠前的人名靠前,遇到多解的情况会出错
by cxh315 @ 2020-05-24 21:00:58


~~另外不应该叫cmp吗~~
by cxh315 @ 2020-05-24 21:01:52


@[cxh315](/user/189505) 淦,我也是一样的问题QwQ
by Yansuan_HCl @ 2020-05-24 22:32:25


@[cxh315](/user/189505) 早知道用stable_sort了QwQ
by Yansuan_HCl @ 2020-05-24 22:32:41


@[cxh315](/user/189505) 谢大佬
by Yellow_Lemon_Tree @ 2020-05-25 16:44:30


|