ghost1733's blog

By ghost1733, history, 3 years ago, In English

So today I learnt a new thing, which I think will be useful for beginners. I thought that both of the lines are equivalent. However when I found out that the latter is more efficient in case of sets.

set set1;

auto ite = upper_bound(set1.begin(), set1.end(), val); // O(n) // O(log n) in case of random access container. auto ite = set1.upper_bound(val);//O(log n) // binary search, uses set property

Hope this helps; return 0;

Full text and comments »

  • Vote: I like it
  • -10
  • Vote: I do not like it

By ghost1733, history, 4 years ago, In English

I tried a question based on geometry and found an O(n) algo but still its getting TLE with time limit 1 sec. Please give suggestions to improve my code's efficiency. question: ICPC mirror problem G (https://codeforces.me/contest/1468/problem/G) my Code: https://codeforces.me/contest/1468/submission/102368471 Edit 102455572 Somehow taking input as integers and then assigning to point data structures solves my issue.

Full text and comments »

  • Vote: I like it
  • -23
  • Vote: I do not like it

By ghost1733, history, 4 years ago, In English

Problem Statement: Input Format

First line contain a no. , no. of bits in binary number. Second line contain a binary number of size .

Constraints

Output Format

Output the maximum no. that this Binary no. can result using cyclic shifts into modulo ().

Sample Input 0

5 00101 Sample Output 0

20 Explanation 0

For first case maximum is if no. is rotated to give string 10100 which is 20.

Sample Input 1

6 011010 Sample Output 1

52 Explanation 1

For second case maximum is if no. is rotated to give string 110100 which is 52.

Sample Input 2

4 1100 Sample Output 2

12

I found a solution using suffix array. but is there any simple solution ?

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

By ghost1733, history, 4 years ago, In English

I was looking submission of other user and i noticed something common in them,

#ifdef ONLINE_JUDGE

#define OJ \

freopen(file".in", "r", stdin); \

freopen(file".out", "w", stdout);

#else

#define OJ ;

#endif

I want to know how this works .Please help. And how to use it and what does it do?

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it