TTMMM's blog

By TTMMM, history, 3 years ago, In English

Can someone please convert this short piece of C code to C# code.

int main(int argc) {
    
    FILE* f = fopen("xyz", "rb");
    uint32_t offset = 0;
    fseek(f, 0x3c, SEEK_SET);
    fread(&offset, sizeof(offset), 1, f);
    fseek(f, offset + 4, SEEK_SET);
    uint16_t machine = 0;
    fread(&machine, sizeof(machine), 1, f);
    printf("Machine: 0x%.4x\n", machine);
}

Thanks in advance!

Full text and comments »

Tags c++, c#, file
  • Vote: I like it
  • -9
  • Vote: I do not like it

By TTMMM, history, 5 years ago, In English

Many a times i have heard people saying there's no point in practicing Greedy questions. If you have a good day, you'll solve the question based on greedy else not. So we shall save the time and rather spend on practicing DP. Please express your viewpoint.

In contests, I am generally not able to solve 1800-rated Greedy questions. My Rating: 1630

Full text and comments »

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

By TTMMM, history, 5 years ago, In English

Submission ID: 66585414 Problem : 1201/C C. Maximum Median

I am first calculating that for median to be ar[i], can we go there by swapping? Once done, all elements in second half of array are equal and i am still left with k, its easy to increase median by increasing all elements by 1 each. Please tell if this approach is fine or not, Getting WA at test case 6

Full text and comments »

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

By TTMMM, history, 5 years ago, In English

MIKE AND INFINITE GRID Mike and his friend are playing a game in the first quadrant of x-y plane. They have a toy car, which is initially placed at position (a, b). A player who can place it at position (p, q), where p<a and q<b, will win the game. In a move, a player can move this car from position (x, y) to:

A position (x',y), such that p <= x' < x. A position (x,y'), such that q <= y' < y. A position (x-k,y-k), such that 0 < k <= min(x-p,y-q).

Mike starts the game and both the players play optimally. Find the winner of the game.

I understand the question reduces to two piles with A,B coins and players can remove any number of coins from individual stack and can remove k coins from both where k<=min(A,B)

Full text and comments »

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

By TTMMM, history, 5 years ago, In English

How important is lazy propagation in competitive programming? It takes me a lot of time to implement it. How do i get to know weather it is required or not by looking at the constraints? I mean, what is the complexity of a algorithm with and without it?

Full text and comments »

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

By TTMMM, history, 5 years ago, In English

When we have question to find a number given a condition between L,R we do fun(R)-fun(L). When we need to find a number with a max number between L,R we maintain 2 tight conditions. What do we do when we need to find kth largest between L,R given a condition? How do i account for that K ?

Full text and comments »

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