Page 3 of 3

Re: 719 - Glass Beads

Posted: Fri Sep 25, 2015 10:25 am
by Tanmoy1228
Verdict: WA
can not get the problem..
please help......

Code: Select all

#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll Rank[109][200009];
struct info
{
    ll idx,tup[2];
    bool operator< (const info &a) const
    {
        if(tup[0]==a.tup[0])
            return tup[1]<a.tup[1];
        else
            return tup[0]<a.tup[0];
    }
};

info arr[200005];

void Suffix_Array(string s)
{
    ll n,i,a,b,step,jump;
    n=s.size();
    s=s+s;
    s[n+n]='\0';

    for(i=0; i<n; i++)
    {
        Rank[0][i]=s[i]-'a'+1;

        arr[i].tup[0]=0;
        arr[i].tup[1]=0;
    }

    for(step=1,jump=1; jump<=n; step++,jump=jump*2)
    {
        for(i=0; i<n; i++)
        {
            a=Rank[step-1][i];

            b=Rank[step-1][(i+jump)%n];

            arr[i].idx=i;
            arr[i].tup[0]=a;
            arr[i].tup[1]=b;
        }
        sort(arr,arr+n);

        Rank[step][arr[0].idx]=0;
        for(i=1; i<n; i++)
        {
            if(arr[i].tup[0]==arr[i-1].tup[0] && arr[i].tup[1]==arr[i-1].tup[1])
                Rank[step][arr[i].idx]=Rank[step][arr[i-1].idx];
            else
                Rank[step][arr[i].idx]=i;
        }
    }
}

int main()
{
    ll t,n,m,i,j;
    string s;
    cin>>t;
    while(t--)
    {
        cin>>s;
        n=s.size();
        Suffix_Array(s);
        cout<<arr[0].idx+1<<endl;
    }
    return 0;
}

buy tadalafil online cialis

Posted: Mon Dec 19, 2016 2:42 am
by ViagraFug
am7592 http://viagraon.top Viagra Samples af9736pg3012fu5246

how much buy levitra

Posted: Mon Dec 19, 2016 11:42 pm
by Patrickzooft
dt210 <a href=" http://viagraonlinea.com ">Viagra Without a Doctor Prescription</a> lf5765tx9535gi4312 pp9423wh3333

buy clomid in china

Posted: Tue Dec 20, 2016 7:22 am
by Patrickzooft
xh1224 <a href=" http://viagraonlinea.com ">cheap viagra</a> wz9258tf3229nv8059 ua8083np4786

splitting cialis 20mg

Posted: Thu Dec 29, 2016 9:44 pm
by WilburBip

shelf life cialis online pharmacy

Posted: Fri Dec 30, 2016 5:20 am
by WilburBip

brand levitra online

Posted: Sun Jan 08, 2017 9:34 pm
by Nathanquesy
sv1264 http://wwwcialison.com viagra norvasc cialis generic qm9190pc9412

cheap cialis canada

Posted: Mon Jan 09, 2017 8:59 am
by Nathanquesy
cp2851 http://wwwcialison.com online cialis prescription ad2657nd9067

cialis online canadian pharmacy

Posted: Mon Jan 09, 2017 7:45 pm
by Nathanquesy
la1497 http://wwwcialison.com viagra suisse cialis pills oi5679nw9208

how much is viagra at walmart cialis generic

Posted: Mon Jan 09, 2017 9:35 pm
by Jeffreyrem
cn7999 http://wwwcialison.com cialis 5mg for sale yl6925es5832bm6204 un2484 Cialis online so1559hd6182pb5306 ue2440ms3069 <a href=" http://wwwcialison.com/#sporanox-msds-cialis-pills ">Cialis Coupons</a> ub6342pn8330pe8647

viagra for women

Posted: Tue Jan 10, 2017 9:49 pm
by Georgeemano
dd2714 http://via24ph.com high blood pressure and viagra xj8681u

comprare finasteride 5mg

Posted: Wed Jan 11, 2017 10:32 am
by Georgeemano
it3946 http://via24ph.com viagra lowest prices mo2721o