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

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

Thank you for participating!

1850A - To My Critics

Idea: mesanu

Tutorial
Solution

1850B - Ten Words of Wisdom

Idea: flamestorm

Tutorial
Solution

1850C - Word on the Paper

Idea: flamestorm

Tutorial
Solution

1850D - Balanced Round

Idea: SlavicG

Tutorial
Solution

1850E - Cardboard for Pictures

Idea: flamestorm

Tutorial
Solution

1850F - We Were Both Children

Idea: mesanu & SlavicG

Tutorial
Solution

1850G - The Morning Star

Idea: flamestorm

Tutorial
Solution

1850H - The Third Letter

Idea: SlavicG

Tutorial
Solution
Разбор задач Codeforces Round 886 (Div. 4)
  • Проголосовать: нравится
  • +78
  • Проголосовать: не нравится

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

It feels like Problem A was directed at someone 😶

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

Thanks to authors! The problemset was very cool

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

This competition is the best for me.

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

For E wasn't it worth mentioning O(1) solution with quadratic formula if we ignore time for taking input

https://mirror.codeforces.com/contest/1850/submission/214907399 or https://mirror.codeforces.com/contest/1850/submission/214911845

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

For anyone using JAVA , never ever use Arrays.sort even after shuffling the array, I got unnecessary TLE and rectified using Collections.sort. The tests were designed carefully.

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

What is a failed test case for this solution for D?

214942704

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

Editorial published during open hacking phase?!

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

G Problem is kind of impossible with python

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

Hello! This is my first contest and I submitted the problem A. I was registered but I do not see an increase in my rating, can someone tell me when will I get them?

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

can someone try to hack my solutions?

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

I used binary search for problem-E but it has some error which I am unable to figure out. Can anyone please help me find error in my binary search logic for my submission 214950555. ? edit : when i set r = 1e10 the sample test-cases passed but on submission it fails again on some test case.

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

Why this solution TLE in problem F because It does unnecessary work when we have more occurrences of one elment. I think the TC Is exactly the same as the one proposed by the editorial in the end. Also if we have the test case 1,2,3....,2e5. The solution posted does the same number of operations as the one of the editorial. Am I wrong thinking that this has the same TC as editorial?

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

maybe f can be hacked, consider case {1,1,1...} * 10^5

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

I liked problem H . Before reading editorial, i didn't though it will turn that easy.

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

can someone explain why my E solution is accepted here:
https://mirror.codeforces.com/contest/1850/submission/214991383

but it is failing here:
https://mirror.codeforces.com/contest/1850/submission/214991353

the only difference is in my accepted version, i did (sizes[i] + w * 2) * (sizes[i] + w * 2)
but in the failing version, i did pow((sizes[i] + w * 2), 2)

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

In this contest can my E be WA, G be TL?

My submission in E in contest: 214829184. I don't know how it's passed pretests. In code wrongly I did: x = s[i] + 2 * md + 1 and printed l but x should be s[i] + 2 * md and printed l — 1. Like this code: 214997775 which I submitted after contest. Please let me know if it's hackable.

My submission in G in contest: 214869824. Can it be TL or ML? It passed pretests with 1668 ms 76900 KB(Time limit is 2s). After contest I optimized it (removed set) and passed pretests with 904 ms 39300 KB(214997753). Please let me know it's hackable.

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

During the contest,I misunderstand Problem F,I think each second we can place a trap,so in this case,can we also calculate the maximum number of the frogs we can catch?I need help,thanks.

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

Can anyone help me my code has resulted in TLE in system testing?, it is having similar complexity as of author O(nlogn)

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

The solution of F was already available on geeks for geeks and other various websites , seems to be a quite popular problem

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

I used an unordered map on F. I will never use an unordered map again.

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

Why does that give TLE if unordered_map is used instead of the normal map in C++? Can anyone tell me when to use unordered_map and normal map?

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

Can anyone explaine how Wrapper function works? This is my hacked submission: https://mirror.codeforces.com/contest/1850/submission/214906792 And then i fixed it by Wrapper function which make my submisson accept https://mirror.codeforces.com/contest/1850/submission/214984466 *sorry for bad english

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

can someone tell why Question 'G' Fails for an Unordered map, but runs absolutely fine for ordered map

void mr_kamran(){

ll n; cin>>n; ll ans = 0; unordered_map<ll,ll>m1,m2,m3,m4; for(int i = 0;i<n;++i) { ll x,y; cin>>x>>y; m1[x]++; m2[y]++; m3[y-x]++; m4[y+x]++; } for(auto it : m1) { ans+=(it.second*(it.second-1)); } for(auto it : m2) { ans+=(it.second*(it.second-1)); } for(auto it : m3) { ans+=(it.second*(it.second-1));
} for(auto it : m4) { ans+=(it.second*(it.second-1)); } cout<<ans<<an;

}

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

Solved problem H using Union Find.

215052919

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

1850E - Cardboard for Pictures

Can someone Explain Why my code gives WA? For Some Test Cases it the While Loop Breaks and prints 1 which I used for Checking.

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

why F is nlog(n)? if there are 2e5 1 than is n*n

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

why in problem G it gives TLE error if we use unordered_map<int,int> instead of map<int,int>. The time complexity of unordered_map is O(1) whereas operations on map take O(log n) time.

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

Hey guys! Can somebody help me please why in task E — Cardboard for Pictures we should use mid = l + (r — l) / 2? I am new at this and would appreciate any answer)

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

SlavicG Can you explain why u also pushed negative edges in the last problem

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

Can we solve H using different approach?: For all loops found in graph, I check if "cnt" of the loop is equal to 0. "cnt" of the loop is sum of all (-d)s for all adjacent vertexes in the loop. For example, if we have loop

(a, b, d)

1 2 1

2 3 2

3 1 -3

cnt of this loop is 0. (-1-2-(-3) = 0). If cnt of the loop is not zero, it means that every soldier in the loop belongs to 2 different camps. My code gives WA3: 216588864

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

can we do F by checking for cycle ?

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

Comment on G implementation

If you want to calculate $$$n(n-1)$$$, you can instead calculate $$$2(1+2+...+(n-1))$$$.

By using this, you can avoid the second calculation pass and have a cleaner solution (https://mirror.codeforces.com/contest/1850/submission/221488328)

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

can anybody please tell me a counter test case for F problem according to my code? please

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

    Your code is overcounting, say for 4 you have contributions from 1,2,4 as multiples but 2 has contributions from 2 as well as from 1. So, eventually your answer for 4 counts the contributions from 1 twice. To avoid this you can start from n and go till 1 and do the same process, it would pass then

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

I wonder why the G question times out with unordered_map

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

Why when I didn't add the edge b[i] to a[i] with weight −di, it gave the wrong answer, but when I did, it was Accepted? My solution https://mirror.codeforces.com/contest/1850/submission/304616401

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

This is come text. In G I write this code: This is some text. ~~~~~ // this is code from collections import defaultdict for _ in range(int(input())): n = int(input()) coor = [[] for i in range(n)] for i in range(n): coor[i]=(list(map(int,input().split()))) counter = [dict() for i in range(4)] ans = 0 for x,y in coor: t=counter[0][x]= counter[0].get(x,0)+ 1 ans += (t-1)*2 t=counter[1][y]=counter[1].get(y,0) + 1 ans += (t-1)*2 t=counter[2][x+y]=counter[2].get(x+y,0)+1 ans += (t-1)*2 t = counter[3][x-y]=counter[3].get(x-y,0)+ 1 ans += (t-1)*2 print(ans) ~~~~~ It gives me time limit exceeded how can I improve it?

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

Could someone give me a python solution for G,please?