-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterleave.cpp
52 lines (42 loc) · 887 Bytes
/
interleave.cpp
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
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<unordered_map>
#include<vector>
using namespace std;
int main()
{
int n;
cin>>n;
int k=1;
unordered_map<int,vector<pair<int,int>>> umap;
while(n--)
{
char s[110];
cin>>s;
int small=0;
for(int i=0;i<strlen(s);i++)
{
int num=s[i]-'0';
auto p = make_pair(k,num);
if(num>=small)
{
umap[num].push_back(p);
small=num;
}
else
{
umap[small].push_back(p);
}
}
k++;
}
for(int i=0;i<=9;i++)
{
int n=umap[i].size();
for(int j=0;j<n;j++)
{
cout<<umap[i].at(j).first<<" ";
}
}
}