719 - Glass Beads

All about problems in Volume 7. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Tanmoy1228
New poster
Posts: 10
Joined: Sat Jul 19, 2014 2:55 am

Re: 719 - Glass Beads

Post 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;
}
ViagraFug
New poster
Posts: 1
Joined: Sun Dec 18, 2016 2:15 pm

buy tadalafil online cialis

Post by ViagraFug »

am7592 http://viagraon.top Viagra Samples af9736pg3012fu5246
Patrickzooft
New poster
Posts: 2
Joined: Mon Dec 19, 2016 7:59 pm

how much buy levitra

Post by Patrickzooft »

dt210 <a href=" http://viagraonlinea.com ">Viagra Without a Doctor Prescription</a> lf5765tx9535gi4312 pp9423wh3333
Patrickzooft
New poster
Posts: 2
Joined: Mon Dec 19, 2016 7:59 pm

buy clomid in china

Post by Patrickzooft »

xh1224 <a href=" http://viagraonlinea.com ">cheap viagra</a> wz9258tf3229nv8059 ua8083np4786
WilburBip
New poster
Posts: 2
Joined: Thu Dec 29, 2016 9:44 am

splitting cialis 20mg

Post by WilburBip »

WilburBip
New poster
Posts: 2
Joined: Thu Dec 29, 2016 9:44 am

shelf life cialis online pharmacy

Post by WilburBip »

Nathanquesy
New poster
Posts: 3
Joined: Sat Jan 07, 2017 4:28 pm

brand levitra online

Post by Nathanquesy »

sv1264 http://wwwcialison.com viagra norvasc cialis generic qm9190pc9412
Nathanquesy
New poster
Posts: 3
Joined: Sat Jan 07, 2017 4:28 pm

cheap cialis canada

Post by Nathanquesy »

cp2851 http://wwwcialison.com online cialis prescription ad2657nd9067
Nathanquesy
New poster
Posts: 3
Joined: Sat Jan 07, 2017 4:28 pm

cialis online canadian pharmacy

Post by Nathanquesy »

la1497 http://wwwcialison.com viagra suisse cialis pills oi5679nw9208
Jeffreyrem
New poster
Posts: 1
Joined: Sun Jan 08, 2017 12:39 pm

how much is viagra at walmart cialis generic

Post 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
Georgeemano
New poster
Posts: 2
Joined: Tue Jan 10, 2017 9:04 am

viagra for women

Post by Georgeemano »

dd2714 http://via24ph.com high blood pressure and viagra xj8681u
Georgeemano
New poster
Posts: 2
Joined: Tue Jan 10, 2017 9:04 am

comprare finasteride 5mg

Post by Georgeemano »

it3946 http://via24ph.com viagra lowest prices mo2721o
Post Reply

Return to “Volume 7 (700-799)”