Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Eulers_Formula.mdx #4801

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Update Eulers_Formula.mdx #4801

wants to merge 4 commits into from

Conversation

inmbtr
Copy link

@inmbtr inmbtr commented Sep 25, 2024

Gave Introduction and modified the examples.

Place an "x" in the corresponding checkbox if it is done or does not apply to this pull request.

  • [X ] I have tested my code.
  • [X ] I have added my solution according to the steps here.
  • [ X] I have followed the code conventions mentioned here.
    • I understand that if it is clear that I have not attempted to follow these conventions, my PR will be closed.
    • If changes are requested, I will re-request a review after addressing them.
  • [X ] I have linked this PR to any issues that it closes.

Gave Introduction and modified the examples.
<Resources>
<Resource
source="MIT"
title=" MIT Course Notes"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weird formatting

@@ -11,19 +11,215 @@ frequency: 1

## Introduction

<IncompleteSection />
A planar graph is a graph that can be drawn on a plane without any edges crossing. In other words, it can be embedded in the plane such that no two edges intersect except at their endpoints. Planar graphs can be represented in a two-dimensional space without overlaps between edges.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

third sentence is redundant


Euler's Formula states that any correct embedding of a connected planar graph satistfies:-

<center><h1>V − E + F = 2</h1></center>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use double dollar signs for latex


<center><h1>V − E + F = 2</h1></center>

Where V is the no of vertices, E is the number of edges and F is the number of faces.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use latex for these variables

**Memory Complexity:** $\mathcal{O}(N \log N)$

```cpp
#include "rainbow.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rainbow.h?

```cpp
#include "rainbow.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no macros

#define FOR(i, x, y) for (int i = x; i < y; i++)
using namespace std;

const int MAXN = 2e5, MAXSEG = (6e5 + 9) * 19 + 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maxseg?

Comment on lines 197 to 202
int E =
edges_horiz.query(ar + 1, br, ac, bc) + edges_vert.query(ar, br, ac + 1, bc);
int V = vertices.query(ar + 1, br, ac + 1, bc);
int R = rivers.query(ar, br, ac, bc);
int C = (ar >= mn_r || br <= mx_r || ac >= mn_c || bc <= mx_c ? 1 : 2);
return E - V + C - R;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use lowercase variable names


## Example 2

<Problems problems="e2" />

<IncompleteSection />
# Explanation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this h1

content/6_Advanced/Eulers_Formula.mdx Outdated Show resolved Hide resolved
inmbtr and others added 2 commits September 25, 2024 21:22
Made changes according to your advice.
Comment on lines +44 to +50
<center> $$ V − E + F = 2 $$ </center>

$$ V = Vertices $$

$$ E = Edges $$

$$ F = Faces $$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you...check how this looks in the markdown renderer

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I will change it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any other changes?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll see

Copy link
Member

@ryanchou-dev ryanchou-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for your contribution!

Comment on lines +59 to +63
In this problem, we're asked to count the number of contiguous areas of cells on
several flat rectangles. Such areas are separated by river segments and
rectangle boundaries.

Where else do we count the number of areas on a flat surface?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this problem, we're asked to count the number of contiguous areas of cells on
several flat rectangles. Such areas are separated by river segments and
rectangle boundaries.
Where else do we count the number of areas on a flat surface?
In this problem, we're given a 2D grid with a river segment (path) running through it. Our task is to count the number of contiguous areas of non-river cells on $Q$ subrectangles in this grid.
That's the definition of a planar graph! How can we calculate the number of segments on this plane?

wording is confusing on this part. it might be better to not restate the problem at all

Comment on lines +93 to +106
Finding $E$, $V$, and $R$ is a lot more complicated though.

### Finding $E$, $V$, and $R$

To find $E$, $V$, and $R$, we can use a data structure that can handle 2D range
queries efficiently.

However, the coordinates of the grid can get very large, so a simple 2D BIT or
segment tree won't work here.

To work around this, we can either use a 2D BIT with coordinate compression or a
persistent segment tree. See the sections on
[offline 2D sum queries](/plat/2DRQ#2d-offline-sum-queries) or
[persistent segment trees](/adv/persistent) for more details.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be useful to tell the user why we need 2d range queries.

also you don't need to split this into another section.


<IncompleteSection />
**Memory Complexity:** $\mathcal{O}(N \log N)$
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Memory Complexity:** $\mathcal{O}(N \log N)$


```cpp

const int MAXN = 2e5, MAXSEGMENT = (6e5 + 9) * 19 + 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate with underscore: MAX_N


int cnt = 1, segtree[MAXSEGMENT], left_c[MAXSEGMENT], right_c[MAXSEGMENT];

struct Segtree {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you use the one from the module & codesnip it?


**Time Complexity:** $\mathcal{O}(N^2 \log N)$

**Memory Complexity:** $\mathcal{O}(N^2)$

```cpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok this entire code block needs to be rewritten -- we want the code to be as readable /easy-to-understand as possible. so this means removing templates/macros

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants