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

Автор DrunkMaster, 5 лет назад, По-русски

Летняя олимпиада по программированию #1

Разбор в PDF:

https://drive.google.com/file/d/1idV_I1xRuPN2PgfEliYZLReB7XJ5cCGd/view?usp=sharing

329695A - Странное послание

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695B - Код от бункера

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695C - Потеря важного числа

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: Gareton

разбор
код

329695D - Загадочная ручка

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695E - Снова под огнём

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695F - Начало подготовки к походу

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: Gareton

разбор
код

329695G - Внезапное отключение

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695H - Реализация плана

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695I - Финальная битва

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Автор решения: DrunkMaster

разбор
код

329695J - Послесловие

Автор задачи: DrunkMaster

Автор перевода: MatesV13

Авторы решения: DrunkMaster, xyz.

разбор
код
  • Проголосовать: нравится
  • +14
  • Проголосовать: не нравится

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by DrunkMaster (previous revision, new revision, compare).

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Can someone please explain to me Problem C solution.I was trying to relate it to a Standard P&C problem of finding the rank of a word in a dictionary like if $$$a_i$$$ is $$$!= i$$$ then the total possible ways of arranging $$$n-i$$$ numbers is $$$(n-i)!*i$$$ and for the whole array it will be the summation of this.

  • »
    »
    5 лет назад, скрыть # ^ |
    ← Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    Okay, I'll try. Imagine that we have counted the number of permutations that are lexicographically smaller than the given one. Then the answer will be cnt + 1. We will process the permutation from left to right. From the definition of a lexicographically smaller permutation, a permutation a is less than a permutation b if the first m numbers of these permutations are the same, and the (m + 1) th number of a permutation a is less than the (m + 1) th number of b permutation. Let's say we are now at position i. Consider all the numbers of this permutation that are to the right of the current position i. Then it follows from the definition above that if we put a number Pj at position i such that Pj < Pi and j > i, this permutation will be lexicographically smaller. Then if we know the number of such Pj's, call it k, this will add k * (n — i)! to the answer, since if Pj < Pi, the arrangement of the remaining (n — i) elements is not important to us. To find k, you can use, for example, a data structure such as the Fenwick tree.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

В pdf разборе — "Задача J. Финальная битва". А здесь, "J — Послесловие". Перепуталось.

»
5 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

В H главное про лонги не забыть. Сразу забыл, потом подумал что возможно лонги, но у автора везде int'ы. Потом только заметил что у него define int int64_t!