Here is the link to the editorial. Feel free to discuss problems and ask me questions. I'll be glad to improve the editorial with your comments.
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 156 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Here is the link to the editorial. Feel free to discuss problems and ask me questions. I'll be glad to improve the editorial with your comments.
Hi, Codeforces community.
Today is the first day of the Persian new year (1399), we call it Nowruz. I wish everyone bug-less codes, high ratings, branded T-shirts, and, successful hacks. Also, I hope no one gets failed on system testing, no hacks after locking, and no tiredness of coding.
I'd like to finish the post with a poem:
برآمد باد صبح و بوی نوروزبه کام دوستان و بخت پیروز
نکویی کن که دولت بینی از بخت
مبر فرمان بدگوی بدآموز
Translation:
The morning breeze and Nowrooz (new year) scent have started to blow,
Onto the friends' desire and the triumphant fortune,
Do good deeds to get goods from the world,
Don't obey malicious people.
Here is the link to the editorial. Feel free to discuss problems and ask me questions. I'll be glad to improve the editorial with your comments.
Here is the link to the editorial. Feel free to discuss problems and ask me questions. I'll be glad to improve the editorial with your comments.
Hi.
Here is the link to the editorial. Feel free to discuss problems here and ask me questions.
Hi.
Here is the link to the editorial. Feel free to discuss problems here and ask me questions.
UPDATE: I'm no longer contest coordinator at HackerEarth, contact [email protected] for proposing problems
Hi.
Check this blog at the first. We've modified our problem selection process. Now you can use this form to submit ideas. If you submitted a problem on Ninja-Setters, send it again through this form, I can't access Ninja-Setters anymore.
Still, we need approximation problems (although it doesn't mean we don't need other problems), please submit them if you have any.
If you have questions, please send an email to me ([email protected]) or ask in the comments. Please do not message me here.
Hi!
I'm here to introduce a new series of contests on HackerEarth, Data Structures and Algorithms (DSA) coding challenge! In this series, you will have to solve 3 problems in 1.5 hours.
The problems are classic and educational as against being creative and challenging. So, if you're learning new things, don't miss the DSA contests. These contests are similar to Codeforces Educational rounds.
We have hard problems and easy problems in this contest. After the contest, don't forget to upsolve! This will help you a lot.
The next DSA contest is on September 14, 4 AM UTC.
Authors are Devarshi (devarshi09) Khanna, Prakash (forgotter) Jha, and, Aditya (aditya123garg) Garg. I'm the tester of the round.
GL & HF!
UPDATE: I'm no longer contest coordinator at HackerEarth, contact [email protected] for proposing problems
Please read this blog as an update.
Hi everyone.
I want to describe the process to become a problem setter on HackerEarth. I'm eager to see new problem setters want to prepare contests. It's a great experience for every coder to hold a contest at least once. The first time when I prepared a contest (I was fifteen at that time, a high schooler student!) it was so sweet for me that I continued preparing problems on Codeforces, CodeChef, HackerEarth, Quera, Iran Olympiad of Informatics Finals and several more. Then I worked for 1.5 years in Quera as the contest coordinator, which was great. I'm continuing my job — Contest Coordinating — on HackerEarth from January.
We have three algorithmic contest every month, here is the table:
Contest | Number of problems | Approximate Difficulty | Length | Comments |
---|---|---|---|---|
Easy | 6 | Like Codeforces Div. 2 | 3 Hours | |
DS and Algo challenge | 3 | Easy to Medium-Hard | 1.5 Hour | |
Circuits | 8 | One approximate problem and 7 algorithmic, from Very-Easy to Hard | 9 Days | More educational, less competitive, we could use classical problems |
As you can see, we need a lot of problems every month. To propose a problem, follow this instruction:
Our proposal queue is almost empty, so if you propose a problem today, with a high probability, your problem will be used in August contests. Here is the compensation table:
S. No. | Difficulty level | Indian setters (INR) | International setters (USD) |
1 | Very Easy | 1600 | 23 |
2 | Easy | 2300 | 35 |
3 | Easy-Medium | 3000 | 45 |
4 | Medium | 4700 | 70 |
5 | Medium-Hard | 6000 | 90 |
6 | Hard | 8000 | 120 |
7 | Approx. | 8000 | 120 |
P. S. You don't need to prepare the whole contest. A contest may have many setters, so even if you send one problem, it's welcomed.
P. S. We need an approximation problem every month. Propose it if you have some. Check the last Circuits contest for an example.
Update. It's not needed to send me a message when you register on Ninja Setters, just wait for several days, I'll add you to group such that you can start proposing problems.
Update. Users with rating less than 1600 can propose problems but the probability of acceptance is low.
Hello everyone!
Another long and exciting contest is here, June Circuits '19, a challenging challenge with 8 amazing problems, should be solved in 9 days. The contest will start on June 21, 15:30 PM UTC.
Thanks to problem setters for doing such a fantastic job, we have 7 setters involved this time (!):
I'm tester of the round, I'm completely sure that you'll enjoy too!
To make the challenge more interesting, we will add problems to the contest in this order:
As usual, there will be some sweet prizes for the top five competitors:
Hope to see you on the leaderboard!
Hi all!
Happy Eid Fitr to all Muslims in the Codeforces community.
Hello!
Welcome to June Easy '19, from our easy and educational contest series. It's a 3-hour competition with six algorithmic tasks. We are going to hold it on Sunday at 16:00 GMT. Check contest page for more details.
I helped Danylo Danylo99 Mocherniuk, Mohammad-Mahdi Kerpoo Taheri, and, Dishant Dishant_18 Trivedi setting this round. AmirHossein amsen Pashaee and I are testers of the contest. As usual, here are the prizes for the top three contestants:
Note that prizes and T-shirts are given to top participants with ratings < 1600 (beginners).
GL & HF.
Let's discuss the problems after the contest!
P. S. Sorry for problems occurred. Now everything fixed.
Hello everyone!
Another long and exciting contest is here, May Circuits '19, a challenging challenge with 8 amazing problems, should be solved in 10 days. The contest will start on May 24, 15:30 PM UTC.
Thanks to problem setters for doing such a fantastic job, we have:
Also, I helped them by adding three problems.
I, Danial Danial Erfanian, and, Javad javaD Karimi were the testers of the round, and we enjoyed solving problems, we're entirely sure that you'll enjoy too!
To make the challenge more interesting, we will add problems to the contest in this order:
As usual, there will be some sweet prizes for the top five competitors:
Hope to see you at the scoreboard!
Hello!
I'm honored to invite you to April Easy '19; it's a 3-hour competition with 6 algorithmic tasks. We are going to hold it on Saturday (Today) at 16:00 GMT (you can check your timezone here). Check contest page for more details about in-contest schedule and rules.
AghaTizi is the setter of this round and Aryan is the tester of problems. As usual, here are the prizes for the top three contestants:
Note that prizes and T-shirts are given to top participants with ratings < 1600 (beginners).
GL & HF.
Let's discuss the problems after the contest!
P.S. Sorry for the late announcement.
Hello everyone!
As the new contest coordinator in HackerEarth, I'm honored to announce, we're here with the new version of circuits contests, March Circuits '19, a challenging challenge with 8 amazing problems, should be solved in 10 days. The contest will start on March 22, 15:30 PM UCT.
This time setters around the world helped us make this round possible. We have:
I was the tester of the round and enjoyed solving problems, I'm sure that you'll enjoy too!
To make the challenge more interesting, problems added to the contest in this order:
As usual, there will be some nice prizes for the top five competitors:
Hope to see you at the scoreboard!
Good Luck & Have Fun ;)
Hello!
As the new Contest Coordinator at HackerEarth, I'm honored to invite you to HackerEarth HourStorm #8; it's a 1-hour competition with 3 traditional (but nice) algorithmic tasks. We are going to hold it on Friday at 14:30 GMT (you can check the time here.
For traditional algorithmic tasks, you will receive points for every test case your solution passes, so you can get some points with partial solutions as well. Check contest page for more details about in-contest schedule and rules.
MazzForces is the setter of this round and I'm the tester of problems. Prepared problems were interesting and I enjoyed solving them, I hope you find them interesting too. As usual, here are the prizes for the top three contestants:
In addition, the top 5 will win HackerEarth t-shirts.
GL & HF.
Let's discuss the problems after the contest!
P.S. I'm sorry for the problem occurred on problem B (A counting problem). I was the tester of this contest; the problem was Anand has changed test cases and didn't run my solution on test cases again and his solution has a little bug, so test cases 17-29 were wrong. We apologize for this problem. Now rejudge is done.
Here are the winners:
Hello, We would like to invite the Codeforces community to the CodeChef November Lunchtime 2018 sponsored by Sharechat — a contest you will surely enjoy competing in. This is a 3-hour contest with 5 problems to work on and it’s open to programmers across the globe.
The contest problems will be available in English, Hindi, Bengali, Russian, Mandarin and Vietnamese. In addition, there are some exciting job opportunities from ShareChat — India’s fastest growing social network for programmers across the globe. For more details, you may visit the November Lunchtime contest page.
I hope you will join your fellow programmers and enjoy the contest problems. Joining me on the problem setting panel are:
(For those who have not yet got their previous winning, please send an email to [email protected])
Good Luck!
Hope to see you participating!!
Happy Programming!!
P.S. As tester, I encourage you to participate in the contest, nice problems are prepared.
Hi!
Thanks to all of you participates, who made this contest possible. And thanks to Lewin and Arterm, also to the great coordinator, Nikolay KAN Kalinin, zemen, WHITE2302, and for sure MikeMirzayanov.
Test data and code solutions. It's the original packages from polygon, you can find pretests, tests, generators, validators, etc in it.
Div.2 A: Take a look at notes section.
Div.2 B: Create a circle with these points.
Div.1 B: Fix the gcd.
Div.1 C: Tag: Grundy number.
Div.1 C
I want to thank my grand teacher Mojtaba moji FayazBakhsh here. Who was my teacher not only for coding but also a teacher for my life. Thanks Mojtaba! Thanks to you and all of other good teachers in the world.
Author: Arpa
Author: Arpa
Author: Lewin
Thanks to Lewin, the writer of this tutorial.
Author: Arpa
Author: Arpa
Author: Arterm
Thanks to WHITE2302, the writer of this tutorial. I translated this tutorial to English.
Author: Arterm
Thanks to Arterm, the writer of this tutorial.
Author: Lewin
Thanks to Lewin, the writer of this tutorial.
I’d like to finish the editorial with the below poem by Hatef Esfahani:
Translation: What can lover (Farhad) do with the power of love? He has no choice but to hurt himself by ax because he feels jealousy to Khosrow. More information about Khosrow and Shirin story.
Good luck and see you soon ;)
Hi!
I'm honored to invite you to Codeforces Round #432, it will be held on 4th September 14:35 UTC. There will be 5 problems for each division, as usual, you have 2:30 to solve the problems. The contest was prepared by Lewin Lewin Gan, Artsem Arterm Zhuk and me.
The IndiaHacks Final Round will be held on 3rd September 12:30. Finalist must not discuss the problems after their contest.
The stories of my problems will be about Arpa, although in one problem you'll see Mojtaba moji FayazBakhsh, my great teacher.
I'd like to thank Lewin, Artsem and myself (:P) at first, then Konstantin zemen Semenov and WHITE2302 for testing the problems, Nikolay KAN Kalinin for helping us in moving the contest to codeforces and Mike MikeMirzayanov Mirzayanov for the great Codeforces and Polygon platforms.
The scoring distribution will be announced later.
Obviously, if you are interested in if the round is rated or not, ask in comments and get a lot of down votes.
UPD. There will be 5 problems for div.2 and 6 problems for div.1.
UPD2. Scoring Distribution: div.1: 500-1000-1250-1750-2000-2500, div.2: 500-1000-1500-2000-2500.
UPD3. Editorial is partially ready. I'll complete it soon.
Congratulations to winners:
Div.1:
1 . BaconLi
2 . dreamoon_love_AA
3 . sd0061
4 . W4yneb0t
5 . Um_nik
Div.2:
1 . miaom
2 . fzzzq2002
3 . lzy960601
4 . Lucas97 and Szymanski_w (WoW !!)
Hi!
A: Tag: Greedy!
B: Tag: Greedy!
C: For each vertex like v find exv, the expected length of their journey if they start from v.
D: Tag: Inclusion exclusion.
E: Find the maximum clique.
NikaraBika's solution: 29458745.
P.S. Please notify me if there is any problem.
Hi!
A: Let Cost(k) the answer if we compress the image with k, find min Cost(k).
B: Solve the problem without first query.
C: Let the frequencies of the characters be a1, a2, ..., ak. Alice loses if and only if is odd and n is even.
D: Consider adding an extra seat, and the plane is now circular.
E: Let dpi, j be the longest path given that we've included segment i, j in our solution, and we are only considering points to the right of ray i, j (so dpi, j and dpj, i may be different).
F: We want to compute dpi, j: expected value given we have seen i red balls and j black balls.
P.S. Please notify me if there are any problems.
Hi !
About one month ago I asked Xu Han (admin of the Virtual judge) if it's possible to add my own problems (that aren't present in any online judge) to some contest in Virtual judge, and we worked together to find a way to do this, and here is it, you can now add your own problems to Virtual judge. Let's see how to do.
To see an example, here is my added problem to Virtual judge: Arpa as an ARPA :P (Hard, Fixed).
P.S. Deleting problem is not available now, but Xu Han said that he will make it available soon.
Hi.
We have a graph, we want to save it (and maybe run DFS on it for example); simple? Yes, but I want to show different methods for this, you can choose any of them depending on problem.
Simple, if graph is not weighted, save in G[v][u] if there is an edge between v and u or not.
If graph is weighted, if there is an edge between v and u save it’s weight in G[v][u], save - 1 otherwise (if weight can be negative, use inf instead of - 1).
Memory usage : .
Overall time complexity : (for running dfs).
// God & me
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 17;
int n, m;
bool G[maxn][maxn], mark[maxn];
void dfs(int v){
if(mark[v]) return ;
mark[v] = 1;
for(int u = 0; u < n; u++)
if(G[v][u])
dfs(u);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++){
int v, u;
cin >> v >> u;
G[v][u] = G[u][v] = 1;
}
return 0;
}
It's the most common method for saving graph. For each vertex keep a vector of it’s edges, now for each edge just save it in related vectors. Use pair (or another struct) for saving weighted graph. It works similar for directed graph.
Memory usage : (Note that vector uses more memory than you need).
Overall time complexity : (for running dfs).
// God & me
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 17;
int n, m;
bool mark[maxn];
vector<int> G[maxn];
void dfs(int v){
if(mark[v]) return ;
mark[v] = 1;
for(auto u : G[v]) dfs(u);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++){
int v, u;
cin >> v >> u;
G[v].push_back(u);
G[u].push_back(v);
}
return 0;
}
This method is rarely used. For each vertex count edges connected to it at first, then allocate a enough space for each vertex to save it’s adjacency-list. Note that this method is Offline.
Memory usage : .
Overall time complexity : (for running dfs).
// God & me
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 17;
int n, m;
bool mark[maxn];
int *G[maxn], sz[maxn];
pair<int, int> edge[maxn];
void dfs(int v){
if(mark[v]) return ;
mark[v] = 1;
for(int i = 0; i < sz[v]; i++)
dfs(G[v][i]);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++){
int v, u;
cin >> v >> u;
sz[v]++, sz[u]++;
edge[i] = {v, u};
}
for(int i = 1; i <= n; i++){
G[i] = new int[ sz[i] ];
sz[i] = 0;
}
for(int i = 0; i < m; i++){
int v = edge[i].first, u = edge[i].second;
G[v][ sz[v]++ ] = u;
G[u][ sz[u]++ ] = v;
}
return 0;
}
This method is used when id of edges are important and works only for directed graphs (or if you can convert the undirected graph to directed). We use array for saving edges. Then, for each vertex we keep index of last added edge and for each edge consider it’s from Fromi to Toi, we keep the index of last edge before this edge that Fromindex = Fromi and name it prvi. Then we can use headv and prv array to find adjacency-list.
Memory usage : .
Overall time complexity : (for running dfs).
// God & me
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 17;
int n, m, from[maxn], to[maxn], head[maxn], prv[maxn];
bool mark[maxn];
void dfs(int v){
if(mark[v]) return ;
mark[v] = 1;
for(int e = head[v]; e != -1; e = prv[e])
dfs(to[e]);
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
fill(head, head + n, -1);
for(int i = 0; i < m; i++){
int v, u;
cin >> v >> u;
from[i] = v, to[i] = u;
prv[i] = head[v];
head[v] = i;
}
return 0;
}
Application: Solving flow network problems. Wikipedia: Maximum flow problem.
void add_edge(int v, int u, int vu, int uv = 0){
to[ecnt] = u, prv[ecnt] = head[v], cap[ecnt] = vu, head[v] = ecnt++;
to[ecnt] = v, prv[ecnt] = head[u], cap[ecnt] = uv, head[u] = ecnt++;
}
int dfs(int v, int flow = inf){
if(v == sink || flow == 0) return flow;
if(mark[v]) return 0;
mark[v] = 1;
for(int e = head[v]; e != -1; e = prv[e])
if(cap[e]){
int x = dfs(to[e], min(flow, cap[e]));
if(x)
return cap[e] -= x, cap[e ^ 1] += x, x;
}
return 0;
}
int maxflow(){
int ans = 0;
for(int tmp; (tmp=dfs(so)); ans += tmp)
memset(mark, 0, sizeof mark);
return ans;
}
void add_edge(int v, int u, int vu, int uv = 0){
to[ecnt] = u, prv[ecnt] = head[v], cap[ecnt] = vu, head[v] = ecnt++;
to[ecnt] = v, prv[ecnt] = head[u], cap[ecnt] = uv, head[u] = ecnt++;
}
bool bfs(int source, int sink){
memset(dis, 63, sizeof dis);
dis[source] = 0;
int h = 0, t = 0;
q[t++] = source;
while(h < t){
int v = q[h++];
for(int e = head[v]; e != -1; e = prv[e])
if(cap[e] && dis[ to[e] ] > dis[v] + 1){
dis[ to[e] ] = dis[v] + 1, q[t++] = to[e];
if(to[e] == sink) return 1;
}
}
return 0;
}
int dfs(int v, int sink, int flow = inf){
if(v == sink || flow == 0) return flow;
int ret = 0;
for(int &e = ptr[v]; e != -1; e = prv[e])
if(dis[v] == dis[ to[e] ] - 1){
int x = dfs(to[e], sink, min(flow, cap[e]));
flow -= x, ret += x;
cap[e] -= x, cap[e ^ 1] += x;
if(flow == 0) break;
}
return ret;
}
int max_flow(int source, int sink){
int ans = 0;
while(bfs(source, sink)){
memcpy(ptr, head, sizeof ptr);
ans += dfs(source, sink);
}
return ans;
}
Usage of this method in above codes are where we use cap[e] -= x, cap[e ^ 1] += x
. Because of special adding edge method, it is guaranteed that if edge e is from v to u, is its pair and it’s from u to v.
Related submission : 23115110.
This method is used when index of edges is important (i.e. in queries we need to change something about edges, i.e. change weight, delete edge). Keep index of edges related to each vertex in its vector, and for each edge keep the vertices connecting with this edge (see code below).
Note that index keeping is possible and maybe easier using map (or unordered_map), but it is faster using this method. Also note that dynamic array method could be used here as well.
Memory usage : (Note that vector uses more memory than you need).
Overall time complexity : (for running dfs).
// God & me
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 17;
int n, m;
int first[maxn], second[maxn];
vector<int> g[maxn];
void dfs(int v){
if(mark[v]) return ;
mark[v] = 1;
for(auto e : g[v]){
int u = first[e] == v ? second[e] : first[e]; // or simply first[e] + second[e] - v, or first[e] ^ second[e] ^ v;
dfs(u);
}
}
int main(){
ios::sync_with_stdio(0), cin.tie(0);
cin >> n >> m;
for(int i = 0; i < m; i++){
int v, u;
cin >> v >> u;
g[v].push_back(i);
g[u].push_back(i);
first[i] = v, second[i] = u;
}
return 0;
}
Example: Consider you need to change weight of edges online, this is simple using index keeping method, but it isn’t possible with other methods (at least it will be harder). Related submission : 20776118.
Application: Finding Euler tour. Wikipedia : Eulerian path. Blocking edges is easier with this method, that’s what we need in Euler tour finding. Related submissions : 21395473, 21636007.
I used Codeforces polygon for comparing and generated 16 random graphs:
#1 to #4 : n = 106, m = 106
#5 to #4 : n = 105, m = 106
#9 to #8 : n = 104, m = 106
#13 to #16 : n = 103, m = 106
# | dynamic array | linked list | vector |
---|---|---|---|
1 | OK 1637 / 44 | OK 1123 / 29 | OK 1606 / 39 |
2 | OK 1637 / 44 | OK 1247 / 29 | OK 1559 / 39 |
3 | OK 1590 / 44 | OK 1107 / 29 | OK 1560 / 39 |
4 | OK 1669 / 44 | OK 1169 / 29 | OK 1622 / 39 |
5 | OK 1060 / 29 | OK 1060 / 31 | OK 1169 / 36 |
6 | OK 1106 / 29 | OK 1045 / 31 | OK 1123 / 36 |
7 | OK 1060 / 30 | OK 1029 / 31 | OK 1122 / 36 |
8 | OK 1091 / 29 | OK 1044 / 31 | OK 1169 / 36 |
9 | OK 1029 / 26 | OK 1013 / 29 | OK 1044 / 29 |
10 | OK 982 / 26 | OK 998 / 29 | OK 1013 / 29 |
11 | OK 1013 / 26 | OK 982 / 29 | OK 1201 / 29 |
12 | OK 1123 / 26 | OK 1029 / 29 | OK 1029 / 29 |
13 | OK 998 / 26 | OK 951 / 29 | OK 982 / 27 |
14 | OK 935 / 26 | OK 982 / 29 | OK 950 / 27 |
15 | OK 951 / 26 | OK 951 / 29 | OK 982 / 27 |
16 | OK 966 / 26 | OK 1060 / 29 | OK 1013 / 27 |
Σ | 16 | 16 | 16 |
max. | 1669ms / 44MB | 1247ms / 31MB | 1622ms / 39MB |
It's really strange for me that vector uses less memory than dynamic array while testing, can someone explain the reason? Here is the link to codes and generator.
UPD: I found the answer, I missed that in dynamic array method we are saving edges in pairs, and keeping the sz
array in addition (thanks to ATofighi).
As usual I’d like to finish the post with a poem:
بی سبب هرگز نمیگردد کسی یار کسی یار بسیار است تا گرم است بازار کسی
By: Parto biza’ee arani.
Translation: No one becomes friend with another one without reason. People are like shops, a shop is full of customers while it has goods.
P.S. Kindly write in comments (or use private chat in case of necessary) if something is wrong.
Hi!
I've recently found Spoj ToolKit. It's features:
Let's help this website by adding more correct solutions to its database.
Название |
---|