P1781 宇宙总统


题目传送门

#include 

using namespace std;
int n;
const int N = 30;

struct Node {
    string x;
    int num;
} a[N];

bool cmp(const Node &A, const Node &B) {
    if (A.x.size() != B.x.size()) return A.x.size() > B.x.size();
    return A.x > B.x;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i].x;
        a[i].num = i + 1;
    }
    sort(a, a + n, cmp);
    cout << a[0].num << endl;
    cout << a[0].x << endl;
    return 0;
}