Блог пользователя _kryptonyte_

Автор _kryptonyte_, история, 9 лет назад, По-английски

I am having problem with this problem. link

Here is my solution , link

I don't know why it gives me WA on test case 36. the test case is big so i can't debug it. Can anybody tell me what's the problem. I am using Z algorithm.

The Idea is, (two string is concatenated with '\x7F' hexadecimal value)

  • Calculate z value for b+a ==> value goes to zba[]

  • Calculate z value for a+reverse(b) ==> value goes to zarb[]

  • Calculate z value for reverse(a)+b ==> value goes to zrab[]

then iterate through zba( from b.size()+1 to the end ) Calculate (i,j) stated in the problem. Check (0...i) string from zarb[] and check (j..n-1) from zrab[].

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор _kryptonyte_, история, 10 лет назад, По-английски

The problem is simple. You are given N point and M query. Each query will provide 4 points. you need to create two segments with first two point and second two point. And add their intersecting point to the tail of the given list of point. query will be always valid. You have to ans in which query the intersecting point is (0,0).

Here is the problem statement : http://poj.org/problem?id=3429 Here is my code: http://ideone.com/2jMgAj

My idea is just to do the simulation. I used this geometry library many time to get AC. I don't know if there is any problem? Some description of my geometry library for you better understanding,

  1. Vec -is a point/vector.
  2. Line — is a line segement.
  3. L1.LineAndLineIntersection2D( line L2 , double t , double s ) — For intersecting two line. t denotes the parametric t of the L1 and s denotes the parametric s of the line L2.
  4. L1.atPos(t) — returns the point on the Line L1 according to parametric t.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор _kryptonyte_, история, 10 лет назад, По-английски

Problem Link : http://poj.org/problem?id=3277 The full code, http://ideone.com/RF1JfE

This is a very straight forward segment tree problem( if I don't miss anything ) , but unfortunately it just don't get AC. Obviously I miss something. Can anybody help. I try to build a seg tree with minimum 2 range sized leaf nodes by following code where Tree[nd] holds the height of the range.

void build( int nd , int st , int en ) {
    Tree[nd] = 0 ;
    if( st+1 == en )return ;
    build( (nd<<1) , st , (st+en)>>1 );
    build( (nd<<1)+1 , (st+en)>>1 , en );
} 

Then I update like following manner, here l,r is the index of the value given in the problem,

void update( int nd , int st , int en ) {
    propagate(nd,st,en) ;
    if( st == en ) return  ;
    if( st > r || en < l ) return ;
    if( st>=l && en <= r ) {
        Tree[nd] = max( Tree[nd] , h ) ;
        return ;
    }
    if( st+1 == en ) return  ;
    update( (nd<<1) , st , (st+en)>>1 );
    update( (nd<<1)+1 , (st+en)>>1 , en );
}

And finally run the query,

long long query( int nd , int st , int en ) {
    propagate(nd,st,en) ;
    if( st == en ) return 0 ;
    if( en-st == 1 ) {
        long long ans = (V[en]-V[st])*Tree[nd] ;
        return ans ;
    }

    return query( (nd<<1) , st , (st+en)>>1 )
           +query( (nd<<1)+1 , (st+en)>>1 , en );
}

Полный текст и комментарии »

  • Проголосовать: нравится
  • +8
  • Проголосовать: не нравится

Автор _kryptonyte_, 10 лет назад, По-английски

Problem Link

My approach for solving this problem is to form a new source from given multiple sources based on the capacity of the sources. And also for the given multiple sink, form a new sink whose edge's weight is the capacity of the given (multiple) sinks. My default source and sink is 0 and 250.

In case of a node which is not source or sink, I connect a new node with that given node( adding 120 ) having a edge weights the capacity of the given node.

Then I run Flow.

My code gives Runtime error. I would be very happy with some help.

UPD:ACed it. Got some problem in implementation.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

Автор _kryptonyte_, 11 лет назад, По-английски

Can anyone help me to understand the solve of this problem? http://mirror.codeforces.com/contest/304/problem/D I am new to this type of problem. So easy explanation will be very helpful.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится