60分求调,悬关!

P1781 宇宙总统

@[lucy2012](/user/1252442) 我记得字符串可以直接排序的吧
by 2022cxy @ 2024-03-02 15:21:09


@[lucy2012](/user/1252442) 你可以直接改成这样 ```cpp bool sum(zong a,zong b){ if(a.p.size()!=b.p.size())return a.p.size()>b.p.size(); return a.p>b.p; }
by 2022cxy @ 2024-03-02 15:24:25


```cpp #include<bits/stdc++.h> using namespace std; struct node { int id; string x; }k[100005]; bool cmp(node q,node h) { if(q.x.size()!=h.x.size()) return q.x.size()>h.x.size(); else if(q.x!=h.x) return q.x>h.x; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>k[i].x; k[i].id=i; } sort(k+1,k+1+n,cmp); cout<<k[1].id<<endl<<k[1].x; return 0; } ```
by 违规用户名971024 @ 2024-03-02 15:29:47


@[lucy2012](/user/1252442) 你可以直接改成这样
by 违规用户名971024 @ 2024-03-02 15:30:02


@[2022cxy](/user/809248) @[feizhukkksc03](/user/971024) ok,谢谢!
by lucy2012 @ 2024-03-03 16:52:08


|