D can be solved using Binary search as well, which is also a common technique to use when dealing with intervals. from bisect import bisect_right n=int(input()) q = sorted([list(map(int,input().split())) for _ in range(n)]) a = [x for x,y in q] print(sum(bisect_right(a,q[i][1],i+1,n)-i-1 for i in range(n)))
For problem B, I don't get why I need to do C = A + B instead of just working directly on a sorted A list. I just need to check if every element of A is equal to the next element right ? The following code passes all test cases except one, and I don't understand why (I can't find the test cases online). Does someone have an idea what is wrong ? N, M = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) A.sort() for i in range(N - 1): if A[i]+1 == A[i+1]: print("Yes") exit() print("No") Thank you for your video.
> I just need to check if every element of A is equal to the next element right ? No. For example, if A = [1, 3] and B = [4], the answer is Yes. I suggest reading the problem statement again. (It is surprising that your code passed almost all test cases.)
A はsetなんか使わなくてもa != bの時に6-a-bすればO(1)で求まります
a==b?-1:6-a-b 使えば楽勝
賢すぎる...
感動した
Every beginner contest ever:
> solve ABCD in 40 min
> Stare at E for 1 hour
same
how can c pass in n*t i wasted time in bitwise implementation
The difficulty gap between green and cyan/blue is too large
なんか海外の人に人気だし、動画出すの早すぎませんか!?たすかります
この人問題出してる側なので早いんじゃないですかね?
前に動画内で言ってた気が…
I hope every single editorial could be as good as this
E問題BFSなのやば、、、
グラフっぽくない問題がグラフの問題のときやっぱdiffあがるよなぁ
先週の反省を活かし、困ったらソートを考える精神で初の4完できました!
eはともかく、fは解けそうだったのでこの調子で頑張ります💪
おめでとうございます!正直なところFはDとそこまでの差はないと思います(Eと順番が逆ならもっと解かれていたでしょう)。
ありがとうございます!
頑張ります。
In problem a if A != B anawer is 6 - (A + B)
👍
Dの問題、緑色に塗られている区間の下に[5,6]と書かれていますが、[7,9]だと思います。
ご指摘ありがとうございます。はい、その通りです。
(こういったあからさまなミスの検出は驚くほど難しいです……。)
D can be solved using Binary search as well, which is also a common technique to use when dealing with intervals.
from bisect import bisect_right
n=int(input())
q = sorted([list(map(int,input().split())) for _ in range(n)])
a = [x for x,y in q]
print(sum(bisect_right(a,q[i][1],i+1,n)-i-1 for i in range(n)))
could you do it in c++?
@@adriano4fk
void sovle() {
int n;
cin >> n;
node a[n + 1];
rep(i, 1, n) {
cin >> a[i].l >> a[i].r;
}
sort(a + 1, a + 1 + n, [](node x, node y){
return x.l < y.l;
});
long long res = 0;
rep(i, 1, n) {
int l = i, r = n;
while(l < r) {
int mid = (l + r + 1) >> 1;
if(a[mid].l
B問題は黒鍵と白鍵の並びがモチーフですね
それは考えましたが、違う気がしています。
(それなら数列が2つある必要はなく、白鍵または黒鍵のうち一方の位置のみ与えれば十分だと思います……でないと白鍵でも黒鍵でもないものがあることになりそうです。)
しかし、他になさそうでもあります。
@@evimalab 「白鍵として設置したい周波数」「黒鍵として設置したい周波数」の列がそれぞれ与えられた時に、白鍵が連続する箇所があるか?という問題であると捉えると自然であると感じました。
なるほど周波数ですか、制約の
Can you expand more on how bfs has to be applied in E?
Thank You!
Hey evima!!!
Can you give me some resources and problem on plan sweep technique to practice.
Thank you 🤍
我想知道场均4题对标codeforces的rating是多少?
我觉得应该没办法
Are you preferring python over c++?
How the hell do u even think of E being a graph problem , Jeez......
ABCDF5完!
Eは引き算までは気付いたけどBFSに気付けず…(ABC238Eの要領でできたのに
For problem B, I don't get why I need to do C = A + B instead of just working directly on a sorted A list.
I just need to check if every element of A is equal to the next element right ?
The following code passes all test cases except one, and I don't understand why (I can't find the test cases online). Does someone have an idea what is wrong ?
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A.sort()
for i in range(N - 1):
if A[i]+1 == A[i+1]:
print("Yes")
exit()
print("No")
Thank you for your video.
> I just need to check if every element of A is equal to the next element right ?
No. For example, if A = [1, 3] and B = [4], the answer is Yes. I suggest reading the problem statement again.
(It is surprising that your code passed almost all test cases.)
"two consecutive elements" refers to c[i] and c[i+1], not a[i] and a[i+1]
Thanks for the answers, I misunderstood the problem.
3:03
first view!
congrats