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

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

I'm facing a problem while trying to write a code that'll give the vertices of the inner polygon if the Outer polygon's vertices are given along with the "setback values" of each face.

in the example above, we'll be given the outer polygon vertices and the setback values a, b, c where a = distance from face A of the outer polygon to face A' of the inner polygon, b = distance from face A of the outer polygon to face B' and so on...

What's an optimal way to find the vertices of the inner polygon?

I tried to solve it but I'm unable to find the correct vertices while the slope value is > 0.

The number of vertices will be from 1 to 100 and the area of the polygon will not exceed 10^6.

Your help will be much appreciated :)

Thank you

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

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

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

Hi guys. I tried implementing sieve today (I have done it 50+ times before), and my code was giving Runtime error :(

I tried to find out the error in my code but I don't know what is wrong.


#include<bits/stdc++.h> using namespace std; bool vis[1000002]; int main(){ int i,j; for(i=2;i<=100000;i++) vis[i]=true; for(i=2;i<=100000;i++){ if(!vis[i]) continue; for(j=i*i;j<=100000;j+=i){ vis[j]=false; } //cerr<<i<<" "; } return 0; }

If I change j+=i to j++, it does not show runtime error!(& the code will obviously be wrong & TLE)

UPDATE : Found my mistake(updated in comment section).

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

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

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

Hi guys. I was trying to solve this problem but couldn't arrive with a working solution . We have to find the maximum xor contiguous sub-sequence . I have no idea how to start (I know we have to use trie , but don't know how to can find the max xor contiguous sub-sequence ).

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

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

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

Hi guys.

#include <stdio.h>
  int main()
   {
   	   if (sizeof(int) > -1)
           printf("True");
       else
           printf("False");
   return 0;
   }

This outputs False. If I give any negative value , the output is False.

I don't understand why.

Shouldn't it be 4>-1 ?

If I replace -1 with 0,1,2 or 3, The output is True.

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

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

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

Note : I am posting this question because the problem link has been removed . ****

If we are given a tree and asked to pick a node as the 'root' node such that the distance between the root and all leaf node is minimum , how do we pick the root ?

We should just print the distance from the root to leaf .

EG : 0->1->2 , we should pick 1 because the distance from 1 to 0 = 1 and distance from 1 to 2 = 1 . We can't pick 0 or 2 because the diatance will be 2 .

Constrains : number of nodes : 100000 value of each node 1<=ai<=100000

Input format : The first line contains N , the number of edges , the following N lines contains two numbers x and y denoting an edge from x to y .

Input : 4

1 2

2 3

2 4

3 4

Output: 2

My wrong solution

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

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

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

Hi guys , my team has been selected for ACM-ICPC Amritapuri , India onsite round . We are requested to submit the paper form ( algorithm templates ) on or before December 10th . What kind of algorithms should we include ?

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

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

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

How do I solve This problem efficiently ?

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

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