-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathahahahahaah.cpp
More file actions
54 lines (49 loc) · 940 Bytes
/
ahahahahaah.cpp
File metadata and controls
54 lines (49 loc) · 940 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 <iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
int K;
cin >>N;
cin >> K;
vector<string> v;
for(int i=0;i<N;i++)
{
string s;
cin >>s;
v.push_back(s);
}
for(int i=K;i>=1;i--)
{
vector<string> buckets[27];
for(int j=0;j<N;j++)
{
if(v[j].size()>=i)
{
buckets[v[j][i-1]-'a'].push_back(v[j]);
}
else
{
buckets[26].push_back(v[j]);
}
}
v.clear();
for(auto v1:buckets[26])
{
v.push_back(v1);
}
for(int lamda=0;lamda<26;lamda++)
{
for(auto vals:buckets[lamda])
{
v.push_back(vals);
}
}
}
for(auto elements:v)
{
cout << elements << ' ';
}
cout << endl;
}