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

Автор macaquedev, 7 недель назад, По-английски

I hope you all enjoyed the contest! Special thanks to:

Rate the contest!

A — The 67th Integer Problem

Solution
Rate the problem!

B — The 67th 6-7 Integer Problem

Solution
Rate the problem!

C — The 67th Permutation Problem

Solution
Rate the problem!

D — The 67th OEIS Problem

Hint 1
Solution
Rate the problem!

E — The 67th XOR Problem

Hint 1
Hint 2
Solution
Bonus
Rate the problem!

F — The 67th Tree Problem

Hint 1
Hint 2
Hint 3
Solution
Rate the problem!

G — The 67th Iteration of "Counting is Fun"

Hint 1
Hint 2
Hint 3
Hint 4
Solution
Rate the problem!
Разбор задач Codeforces Round 1090 (Div. 4)
  • Проголосовать: нравится
  • +55
  • Проголосовать: не нравится

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

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

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

PS: Sorry this is late — I thought I had to wait until after open hack phase, but then was asleep when that finished...

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

It was an amazing Contest mr "macaquedev", thanks for giving this great experience, please handle the hackers... i outputted x for problem A, still it failed in system testing.. WHATS THE PROBLEMM!!!

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

brother loves 67 way too much

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

A better proof for D :

The mentioned construction is :

$$$(2i-1)\cdot(2i+1) , (2i+1)\cdot (2i+3) , (2i+3)\cdot (2i+5) , ....$$$

We claim that $$$\gcd((2i-1)\cdot(2i+1),(2i+1)\cdot(2i+3))=(2i+1)$$$ because $$$\gcd(2i-1,2i+3)=1$$$.

In fact here you don't need Euclidean algorithm to show so , the $$$\gcd$$$ is no more than $$$4$$$ (from the fact that the $$$\gcd(a,b) \le |a-b|$$$ , Here $$$a\neq b$$$) , it can never be either $$$2$$$ or $$$4$$$ since both are odd numbers , you just need to show they never both divides $$$3$$$ , if one divides $$$3$$$ then other not (because modulus $$$1$$$) and of course the other cases are redundant as one of the numbers won't be a multiple of $$$3$$$ , thus our proof is complete and the construction is valid.

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

    I have a suggestion for an answer too, Let $$$P_k$$$ be the product of the first $$$k$$$ consecutive primes.
    Then $$$\gcd(P_k, P_m) = P_{\min(k,m)}$$$, so the GCD is uniquely determined by the smaller product.
    Different pairs of such products give different GCDs, which is why the GCD behaves “uniquely” here. For example: - $$$P_2 = 2 \cdot 3 = 6$$$ - $$$P_3 = 2 \cdot 3 \cdot 5 = 30$$$ - $$$P_4 = 2 \cdot 3 \cdot 5 \cdot 7 = 210$$$

    Then: - $$$\gcd(P_2, P_3) = \gcd(6, 30) = 6 = P_2$$$
    - $$$\gcd(P_3, P_4) = \gcd(30, 210) = 30 = P_3$$$

    So $$$\gcd(P_k, P_m) = P_{\min(k,m)}$$$ always.

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

(problem G code) please don't use

            t = min(b[v] for v in (i - 1, i + 1) if v in range(n)) + 1

instead please use if-else as the one-liner might be harder to understand

Bug in explanation: Let $$$c_t$$$ be the number of people sat down at time $$$t$$$

Should be "earlier or at time $$$t$$$"

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

Why only 16 comments? And why so many cheaters :(

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

i think ABCDE is easy for me, but i am not good at to solve construction porblems just like F

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

the gcd problem was so good

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

when will the ratings update ??

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

I used a browser plugin to translate the question, and this translation plugin translated the text in question E that tries to trick AI, damn.

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

ConstructionForces Thanks for this round!

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

The out-of-bounds in problem A will haunt me in my dreams

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

Looks like people will hate this contest if it was a Div 1+2 round

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

in the first problem A just needs to output 67, I just didn’t notice that a < 67 otherwise I was outputting a + 1

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

how many constructives do you want? macaquedev: YES

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

for Question B you can negate all numbers then make one positive which is least one of them

here's my code(alternate method):- `````

include<bits/stdc++.h>

using namespace std; int main(){ int no_of_testcases; cin>>no_of_testcases;

for(int i=0;i<no_of_testcases;i++){
    vector<int>arr;
    int a;
    int sum=0;
    for(int i=0;i<7;i++){
        cin>>a;
        arr.push_back(a);
    }
    sort(arr.begin(),arr.end());
    int maxi=arr[arr.size()-1];
    for(int i=0;i<arr.size()-1;i++){
       sum+=(-1)*arr[i];
    }
    sum+=maxi;
    cout<<sum<<endl;
}
return 0;

} `````

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

question A just be alert for edge case which is 68 for rest u can print x+1;

here's my code:- ````

include<bits/stdc++.h>

using namespace std; int main(){ int no_of_testcases; cin>>no_of_testcases;

int x;
for(int i=0;i<no_of_testcases;i++){
  cin>>x;
  if(x==67){
    cout<<x<<endl;
    continue;
  }
  cout<<x+1<<endl;
}
return 0;

} ````

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

macaquedev Hi Sir,

I would like to raise a concern regarding a recent plagiarism flag on my 369693245 and submission of guy with submission id 369759595 I dont know how this guy got the code or any coincidence he started with python then c++ with my same exact code. I havent shared my code, I use usaco/ide for my submission i have no idea of him getting this solution. please have a look after this and please review my submission and is possible please reconsider the decision.

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

I would like to ask if you write more in Python or C++ for this type of competition. As a beginner, I don't quite understand.

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

I used a translation plugin to translate the problem, but the plugin translated a condition from the test AI that shouldn't have appeared in the problem description, causing my submission to be skipped. How can I handle this? This was my first AK at a competition, but it gave me such a terrible experience.

»
7 недель назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
can we construct an array a of n numbers, such that all gcd(ai,ai+1) are distinct and they should be divisors of sum number x ??

i wasted a lot of time trying to solve D this way , keeping x as some num < 1e18 which has >1e4 divisor.

i couldn't figure out a solution.

is it possible to construct such array??
»
7 недель назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

F is cool

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

    Can you explain how F is solved. I am not able to understand Editorial's solution.

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

      Okay so first of all let's say x+y is n(the number of nodes). The first thing I did was look at the tree if we just make a straight line. There would be n/2 even subtrees and (n+1)/2 odd subtrees. Then I observed that we can very simply increase the amount of odd subtrees by taking the last k nodes and just connecting them to the (n-k)th node instead of their current parent (when I get home I can draw this in paint if it's not clear). Essentially using this operation we can always get n odd subtrees or n-1 odd subtrees (this is when n is even, so the entire tree must have even nodes). Okay so now we know how to increase odd subtrees and what the max amount of odd subtrees is. Now let's go back to the line and consider how to increase the amount of even subtrees. I could not figure out an operation that would ever increase the amount of even subtrees and while doing this I observed that any even subtree has to have an odd subtree under it. Proving this was not very hard and the proof is that if an even subtree has the size k, the sum of all subtrees below it will be k-1, which is an odd number. If you want to represent an odd number as a sum of some natural numbers, atleast one of those will have to be an odd number. Then an additional thing is that since all even numbers are >=2 they will all have some subtrees below them, and atleast one of those will be odd. With this I knew that for each even subtree there is atleast one odd subtree. And coincidentally my initial construction of a line tree maximizes the amount of even subtrees. Thus I just started with a line tree which has n/2 even and (n+1)/2 odd subtrees and increased the amount of odd subtrees as needed (before this I just checked whether x and y fit into the conditions mentioned beforehand). If anything is unclear, feel free to ask. Explaining these things is kinda hard without any drawings and drawing make it much easier to visualize some of these things.

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

There is another way to construct problem D. For adjacent triangular numbers, their GCDs are mostly different, so we can construct them by brute force, starting with k=1, k*(k+1)/2, and continuously increasing k. In order to determine whether the GCD has appeared before, we can use a set to check for duplicates. MyCode

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

Overall really fun contest. Idk somehow missed problem e and slightly messed up calculations for g but fun ideas and such a great number. Yay positive delta

»
6 недель назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
Alternative solution for F
»
5 недель назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

D is similar to WUT 2025 Programming contest J, so I wrote a sieve of Eratosthenes immediately. However, later I found a simplier way:

for(int i = 1; i <= n; i ++ )
    arr[i] = (2*i-1) * (2*i+1);

DONE!

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

Is there any other solution for the problem G, I cant really understand the editorial. Thank you!

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

    Okay, I didn't go through the editorial completely but let me share my approach. Hope it will help. Firstly, we are given an array b = [b1, b2, ..., bn] which consists of all the numbers from 0 to m — 1 inclusive. We have need to find the number of all possible arrays 'a' which produce this array b using the said algorithm.

    We'll try to find all the possible values a position 'i' can hold, which will satisfy the array b. Then to get the answer we can just multiply the number of the possible values for each position.

    Since b[i] represents the time when the person i sits, if b[i] = 0 then a[i] = 0 as well since the only people sitting at time 0 are the people with 0 awkwardness. So, for b[i] = 0, a[i] has only one option. It HAS to be 0. Now, for the person i to stand up at some time greater than 0, regardless of his awkwardness, at least one of his neighbors must stand up strictly before them. That is, if b[i] > 0 then either b[i — 1] < b[i] or b[i + 1] < b[i]. If some position doesn't hold this condition, the answer will be immediately 0. (No valid array 'a').

    Now, we have at least one valid array 'a' for sure. Now, we have to count the number of valid arrays. Let's calculate the number of possible awkwardness for each position i. We need to first find out at what minimum time, at least one of its neighbors sit down. (Yeah, one of the neighbors will surely sit down before person i as we already checked). We can calculate this easily using :

    time[i] = min(b[i — 1], b[i + 1]). [Separately handle for i = 1 and i = n] Here, time[i] = Minimum time after which ith person gets a sited neighbor.

    Suppose, a person i has a sitting neighbor at b[i] — 1. That means, that person can have any awkwardness from 1 to sum of frequency of elements from 0 to b[i] — 1.

    Let's clarify this with an example. Suppose a person is expected to sit at time = 7. He can't sit before at least one of his neighbors sit, regardless of the awkwardness value. Now, we got that he gets a sited neighbor at time = 6. After time = 6, 11 persons are sitting in total(say). Now, that person can have awkwardness 11. So, he will sit at time = 7. Even if he has some small awkwardness, say 5, he will not sit before time = 7 because his neighbor sits at time = 6. So, he will sit at time = 7 for any awkwardness value from 1 to 11.

    This gives us an important hint. We need to maintain an array which will store how many people will sit in total after j seconds have passed, for each j. We can find it easily using prefix sum. Say, pref[i] = Total people sited after time i = pref[i — 1] + frequency of i in b. Now, for every i from 1 to n, if ith person gets a sited neighbor at time = b[i] — 1 then answer will be multiplied by pref[b[i] — 1].

    We are almost there. We just have another case to handle. If person i gets a sited neighbor at some time earlier than b[i] — 1, what values can a[i] have? Let's think about it. a[i] can have the number of values to equal to the number of persons sitting between time b[i] — 2 to b[i] — 1, that is, pref[b[i] — 1] — pref[b[i] — 2]. Since, the condition of sited neighbor for the ith person is completed earlier than b[i] — 1, if the person i has awkwardness value below or equal to pref[b[i] — 2], it will get sited earlier than b[i] because both the condition of neighbor and awkwardness are fulfilled before b[i]. So, in this case, a[i] can have values between pref[b[i] — 2] and pref[b[i] — 1], which is pref[b[i] — 1] — pref[b[i] — 2].

    So, for every i from 1 to n, if time[i] < b[i] — 1 then the answer will be multiplied by pref[b[i] — 1] — pref[b[i] — 2]. Tried my best to explain in easy terms. You can look into my submission if you are still baffled.

    372118309