-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsol.cpp
More file actions
executable file
·54 lines (41 loc) · 917 Bytes
/
Copy pathsol.cpp
File metadata and controls
executable file
·54 lines (41 loc) · 917 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <bits/stdc++.h>
using namespace std;
bool containsDoubleChar(string s)
{
unordered_map<char, int> M;
for (char c : s)
{
++M[c];
if (M[c] > 1)
return true;
}
return false;
}
int main()
{
int n;
cin >> n;
vector<string> candidates;
while (n--)
{
string tmp;
cin >> tmp;
if (tmp.length() < 5)
continue;
if (containsDoubleChar(tmp))
continue;
candidates.push_back(tmp);
}
sort(candidates.begin(), candidates.end(), [](const string &a, const string &b) -> bool
{
if (a.length() < b.length())
return true;
else
return (a.length() <= b.length() && a > b);
});
if (candidates.size())
cout << candidates[0] << endl;
else
cout << "neibb!" << endl;
return 0;
}