Medeali's blog

By Medeali, history, 6 months ago, In English

I am trying to solve this problem https://www.spoj.com/problems/KQUERY/ but i keep getting WA. Here is my code https://ideone.com/8Gknva My idea is for eacch query (l,r) answer the query for (l,n) and then for (r,n) without including r in the second one and then the answer would be difference Now for (l,n) i sort queries in terms of increasing l and at each point i keep updating occurences and sum occurences of elements greater than k using segment tree. For (r,n) same thing but i sort in terms of increasing r. Could someone help me spot the issue with my code.

Full text and comments »

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

By Medeali, history, 6 months ago, In English

i am trying to sort an array of structs but i am getting compiling error this is my code https://ideone.com/mQPPxI could someone help me solve the issue please

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

By Medeali, history, 8 months ago, In English

i am trying to solve this problem https://codeforces.net/edu/course/2/lesson/4/2/practice/contest/273278/problem/C this is my code https://ideone.com/uXfHJJ i got WA on test 6 however i cannot spot the issue can someone help please ??

Full text and comments »

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

By Medeali, history, 8 months ago, In English

i am trying to solve this problem https://codeforces.net/edu/course/2/lesson/4/2/practice/contest/273278/problem/B this is my code https://ideone.com/T1U9z5 i got WA on test 16 but i cannot spot the mistake i made

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By Medeali, history, 9 months ago, In English

i was trying to solve the edu segtree step 1 C problem but i fail on testcase 21 https://codeforces.net/edu/course/2/lesson/4/1/practice/contest/273169/submission/245570564 i am confident my code is working i still don't know what is the problem can anyone help please.

Full text and comments »

  • Vote: I like it
  • -17
  • Vote: I do not like it

By Medeali, history, 10 months ago, In English

` ~~~~~

include <bits/stdc++.h>

using namespace std; typedef long long ll;

define pb push_back

define F first

define S second

void file(){ freopen("input.txt.txt","r",stdin); freopen("output.txt.txt","w",stdout); } int maxer(int a,int b,int c){ return max(a,max(b,c)); } void setio(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); }

void dfs(int u,vectorgraph[],bool visited[],int colors[],bool &flag){ if(visited[u])return; visited[u]=true; colors[u]=flag+1; flag=!flag; for(auto s:graph[u]){ dfs(s,graph,visited,colors,flag); } } void solve(){ int n,m; cin>>n>>m; vectorgraph[n+1]; vector<pair<int,int>>vp; while(m--){ int a,b; cin>>a>>b; graph[a].pb(b); graph[b].pb(a); vp.pb({a,b}); } bool visited[n+1]; for(int i=1;i<=n;i++) visited[i]=false; int colors[n+1];

} int main() { // file(); solve(); return 0;}

~~~~~

`i am trying to solve this problem https://cses.fi/problemset/task/1668/

My strategy is for each node color its neighbours with different colour ofc every node coloured is counted as visited, i don't know why i got WA.

Full text and comments »

  • Vote: I like it
  • -10
  • Vote: I do not like it

By Medeali, history, 11 months ago, In English

Hello Codeforces,as you all know tommorow starts 2024,i would like everyone to share their goals for 2023, did they make them or not, and then what do they want to do in 2023.I will start, personally this year has been a mix of good and bad events for me well mainly the beginning of 2023 was not the best for me, i made some poor decisions which led to me not doing bad on a maths olympiad round, i had lost hope of qualifying so i did not really prepare however i got qualified for the second time i was not prepared and i did bad after i came back home, the round was in summer i decided this time to prepare as hard as possible in both cp and maths olympiad, i clang to the hope of qualifying in spite of my bad performance the summer went on and my level in both cp and maths skyrocketed in comparison to before because i did not use to prepare before at all, and the day before my last day in holidays(litterally my last day tomorrow is school) results got announced i did not make it,it was hard moment i was relying on a another good luck i was in good level and preparing ready to take down the rounds, anyways days went on and i reapplied to olympiad as my last chance for participation, and this time i ignored anything else than M.O and cp i did not want to make the year before mistakes and i kept working and fighting, i took first maths olympiad round and the after it cp round i qualified i both and then i took second round of M.O(cp still), if i qualify i will join those who qualified last year. I still don't know why am i sharing this story but i want this to be a reminder for anyone having a bad performance or struggling these days it will get better i still don't know the results of M.O round up to this moment but i can say that this struggle has really given me push to get better and really better in cp and maths olympiad and has made me discover how much i love both of those subjects and how much i am willing to give it.i hope this blog inspires anyone having a hard time you need to realize that this golden chance that you feel very bad when losing might not be the best opportunity you get in life and that maybe there is much better one you just need to keep working and not lose hope.as for 2024 i hope i get to IOI team of this year and keep qualifying in maths rounds, and why not make CM in codeforces. Your turn now tell us about your goals for 2023 and whether you made it or not,and then your goals for 2024 i hope you show some reactions to this blog(please upvote)

Full text and comments »

  • Vote: I like it
  • +7
  • Vote: I do not like it

By Medeali, history, 12 months ago, In English

In today's contest i finally reached pupil after more than 3 months of doing competitive programming,and times when i was so close but then had a bad contest i am still glad i hadn't reached pupil at that time i was not that good anyways and did not deserve it(please upvote).

Full text and comments »

  • Vote: I like it
  • +13
  • Vote: I do not like it

By Medeali, history, 13 months ago, In English

I am trying to solve this problem https://lightoj.com/problem/conquering-keokradong i applied binary search and i think my code is fine but i got WA this is my code https://lightoj.com/problem/conquering-keokradong can anyone tell me what is wrong?

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it

By Medeali, history, 14 months ago, In English

I have started doing cp for 2months now(i registered on codeforces before but i was only discovering at that time) my dream is to make my country IOI team. I can feel the improvememnt a bit(by the way what do you think of my rating graph) however i am always doubting my practice efficiency because i am not using a roadmap or something just random practice and whenever i encounter a new topic on a problem i learn it and pratcie some basic problems to grasp i also tried that ultimate topic list but still everytime i feel there is something wrong and i don't even know dsa or anything so should i learn it first or what however i know that in spite of my lack of experinec i really love cp and OI and am willing to do anything to improve i also tried the USACO guide which i tought would be amazing however the statements were very long and usually they did not require any thinking just heavy implementation in the beginner bronze problems.So i am now asking for help and advice and i hope to get answers unlike other blogs i had posted so please i want help on practice and on my progress whether is it good or not.Thanks again for this wonderful community and this amazing website which is my favourite one for practice.

Full text and comments »

  • Vote: I like it
  • -2
  • Vote: I do not like it

By Medeali, history, 15 months ago, In English

I am trying to solve this problem https://www.spoj.com/problems/NDIV/ this is my code https://www.ideone.com/c9uEMT i got SIGKILL but i am confused what is wrong with my code

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it

By Medeali, history, 15 months ago, In English

i was solving this problem and i got WAbut i am very confused why it said 29th number in testcases https://codeforces.net/contest/1849/problem/B i wrote a program to stop accepting at 29th numbers testcase to spot it but when i tried it had right ouput can you help here's my code https://www.ideone.com/v0tCla i even checked the editorial and i found the same idea as mine but still don't know why WA please help

Full text and comments »

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

By Medeali, history, 15 months ago, In English

hey i was solving this problem https://codeforces.net/contest/754/problem/A and i implemented this code https://www.ideone.com/ but got wrong answer on test 1 however it outputs exactly the same for test 1 as the one in the editorial(i read the editorial but decide to do the implementation on my own) which got accepted i am really confused i checked if i had printed some extra spaces but everything was fine please i need help

Full text and comments »

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

By Medeali, history, 15 months ago, In English

I am high school student interested in Olympiad of Informatics and want to be part of my IOI team . So for my preparation i use codeforces of course but also i try to focus on usaco guide since it has learning ressources sorted with problems like kind of roadmap but i was always wondering is it useful for me although i am not from USA and if yes what other ressources should i include too?? by the way i have been doing cp for 1month you might see me registered 11months ago but my first contest was 1month ago.Anyways i hope you answer my question.

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By Medeali, history, 15 months ago, In English

https://arena.moi/problem/moi21qualnones this is my code #include

include

using namespace std;

int main() { int t; cin>>t; while(t--){ string n; long long a; cin>>n>>a; long long o=0,s=0; for(char i : n){ if(i=='1') s++; if(s==a){ o++; s=0; } } cout<<o<<endl; } return 0; } i am struggling in finding the issue

Full text and comments »

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

By Medeali, history, 15 months ago, In English

I am high school student, I love both maths olympiad and INformatics Olympiad.My dream is to go to both IMO and IOI. I still have 3 years of high school, i know some people who have gone to both of these prestigious competitions but htey have started early preparing at lesat earlier than me(by the way i am already in maths olympiad and still qualifying to rounds so my level is not the worst).I just would love to know if there are some ressources that could help me combine both, I also wanna know whether i should give up on one of them(my goal is only to be in team not gold medal or some high result) or it is still possible for me to make both of them.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By Medeali, history, 15 months ago, In English

I am gray coder and i just solved a div 1 A problem with 1600 rating.I just started competitive programming amonth now and i solved the problem in about 2 hours.Do you think this is an improvement sign or not here's the problem by the way. https://codeforces.net/contest/559/problem/A if you look at the editorial the solution is trivial but it was hard for me to think about it.

Full text and comments »

  • Vote: I like it
  • +8
  • Vote: I do not like it

By Medeali, history, 15 months ago, In English

i was solving this problem "https://codeforces.net/problemset/problem/629/A" but i did not understand the 2nd testcase i think the output should be 8 not 9

Full text and comments »

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

By Medeali, history, 15 months ago, In English

I am high school student from morocco. I am fascinated by algorithms and cp. I have doing cp for a while i know sortings and search. I am really overwhelmed by all the ressources on internet and i would love some help. I am mastering all c++ basics also, I would love some help on ressources or roadmap so i can be prepared for next year's selections in our country.I know it is hard to do it in a year and i will need hardwork and real practice and i am ready to give it everything i just need help onwhat ressources to use or problems to solve because sometimes i keep solvig easy problems like 900 or 1000.I hope to see some answers i really need it this is important for me.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By Medeali, history, 15 months ago, In English

my code :

include

using namespace std; int subsum(int A[],int n,int index,int sum,int x){ if(sum==x && index!=0) return 1; if(index==n) return 0; return subsum(A,n,index+1,sum+A[index],x)+subsum(A,n,index+1,sum,x);

} int main() { int n,x; cin>>n>>x; int A[n]; for(int i=0;i<n;i++) cin>>A[i]; int b=subsum(A,n,0,0,x); if(x==0) b++; cout<<b; return 0; } Given an array A of N elements and an integer K , we want you to calculate the number of subsets of A whose sum of elements is equal to K .

B is a subset of A if B can be obtained by removing zero or more elements from A .

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it