skate1512's blog

By skate1512, history, 4 years ago, In English

The problem
I tried writing a generator script but that didn't help.
Submission Link.

Code explanation: In the problem, we are given an array/list and we have to check if we can form 1 square and 1 rectangle with those elements(planks). Only possible values are 8, 6 6, 6 2, 4 4, 4 2 2. I tried to count the numbers of 2s, 4s, 6s and 8s. And with every query, their value is incremented or decremented. In the end, I check if the values form any of the possible values and print Yes or No according to it. If anything is greater than 8 then I count it as 8.

Edit: I was missing 6 4 in my possible values. Accepted Solution.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can u explain the problem & your solution?

  • »
    »
    4 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    In the problem we are given an array/list and we have to check if we can form 1 square and 1 rectangle with those elements(planks). Only possible values are 8, 6 6, 6 2, 4 4, 4 2 2. I tried to count the numbers of 2s, 4s, 6s and 8s. And with every query, their value is incremented or decremented. In the end I check if the values form any of the possible values and print Yes or No according to it.

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      what if something is 17 times not 2, 4, 6, 8 times in the array.

    • »
      »
      »
      4 years ago, # ^ |
      Rev. 3   Vote: I like it 0 Vote: I do not like it

      There is also a case when two >= 4

      • »
        »
        »
        »
        4 years ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        But that will not form a square, we need a minimum of 4.

        • »
          »
          »
          »
          »
          4 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Ah, forgot this Anyway, you can also construct it with sixes and fours