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

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

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!

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

Теги c++, c#, file
  • Проголосовать: нравится
  • -9
  • Проголосовать: не нравится

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

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

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

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

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

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

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

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

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

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)

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

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

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

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?

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

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

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

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 ?

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

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