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

Автор ghost1733, история, 3 года назад, По-английски

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;

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

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

Автор ghost1733, история, 4 года назад, По-английски

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.

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

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

Автор ghost1733, история, 4 года назад, По-английски

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 ?

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

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

Автор ghost1733, история, 4 года назад, По-английски

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?

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

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