From 6b0a993d8038c9d0feac33ba1cb45ee81c424061 Mon Sep 17 00:00:00 2001 From: Manikantan Narasimhan Date: Sat, 8 Oct 2016 14:56:14 +0530 Subject: [PATCH] Problem YODANESS from SPOJ --- YODANESS.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 YODANESS.cpp diff --git a/YODANESS.cpp b/YODANESS.cpp new file mode 100644 index 0000000..bcfa814 --- /dev/null +++ b/YODANESS.cpp @@ -0,0 +1,51 @@ +// Problem : YODANESS from SPOJ + +#include +using namespace std; + +void update(int BIT[], int v, int n){ + for(;v<=n;v+=(v&(-v)))BIT[v]++; +} + +int query(int BIT[], int v){ + int ans = 0; + for(;v>0;v-=(v&(-v)))ans+=BIT[v]; + return ans; +} + +void solve(){ + int n,i; + string s; + unordered_map Hash; + cin>>n; + int a[n]; + + for(i=0;i>s; + Hash[s] = i+1; + } + + for(i=0;i>s; + a[i] = Hash[s]; + } + + int BIT[n+1],res; + for(i=1;i<=n;i++)BIT[i] = 0; + + res = 0; + + for(i=0;i>t; + while(t--)solve(); +} \ No newline at end of file