-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbwtinverse.cpp
More file actions
executable file
·48 lines (45 loc) · 969 Bytes
/
bwtinverse.cpp
File metadata and controls
executable file
·48 lines (45 loc) · 969 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
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000000000000
#define endll "\n"
#define pb push_back
#define forn(i,n) for(i=0;i<n;i++)
#define forab(i,a,b) for(i=a;i<=b;i++)
#define vpll vector<pair<ll,ll>>
#define pll pair<ll,ll>
#define vll vector<ll>
#define ff first
#define ss second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define test ll t;cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void inverseBWT(string s)
{
ll l=s.length();
ll i,j;
vector<pair<char,ll>> v;
for(i=0;i<l;i++)
v.pb({s[i],i});
sort(v.begin(),v.end());
pair<char,ll> x;
x=v[0];
for(i=0;i<l;i++)
{
x=v[x.ss];
cout<<x.ff;
}
}
int main()
{
fast_io;
string s;
cin>>s;
inverseBWT(s);
return 0;
}