daftcoder's blog

By daftcoder, 11 years ago, translation, In English
Problem 1. Sinking Ship.
The problem has lots of solutions. I will tell most simple which I saw.
Let's make structure {string,integer} (pair<string,int> in C++), we read the data into array of our structure, transforming rank to a priority (number). After that the necessary number of times equal to quantity of priorities (this problem - 4), we output those names from array which have the equal to cycle count priority.

Some solutions fell, who didn't consider indexes in sorting, i.e. used simply sort on a rank, instead of taking index in structure, or instead of stable_sort.

Problem 2. Settlers Training.
Let's make array A with size k+1 where Ai is a number of settlers with a rank i. After that, while exist a settler with rank lower k (A[k] not equally n), we model training activity. Finally we output the needed amount of coins.
It is necessary not to be mistaken only, in bypassing an array with ranks from left to right, though the test 2 saves us from this potential error.

Problem 3. Bulls and Cows.
We make an array with 10000 elements, mark all possible in this game number by ones. Then we eliminate these numbers by game rules for every of n input, i.e. we mark with zero the numbers from an array at which comparison with ai don't give numbers of bulls and cows bi and ci.
Finally if there is only one marked number - it's the answer, if there are several such numbers  - there is not enough information, if no one number is marked - the data is incorrect.

Problem 4. Dividing Island.
The main problem - to make areas connected.
It's possible to solve this problem so: we fill our island with a snake which moves through a column upwards-downwards and moves to a next column at its filling. Initial coordinate is (1,1) if A is even or B = 1, or (B, 1) if A is odd and B > 1.
  • Vote: I like it
  • 0
  • Vote: I do not like it

11 years ago, # |
  Vote: I like it +1 Vote: I do not like it
11 years ago, # |
  Vote: I like it 0 Vote: I do not like it
Problem C and Problem D is of which type(category)?
  • 11 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it
    Seems to be adhoc. Need to find some idea, that succeed for only that problem.