bugfixes
This commit is contained in:
parent
47e908d9e6
commit
3f1082e3ae
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -70,4 +70,6 @@ yarn-error.log
|
|||
|
||||
|
||||
# Other
|
||||
.idea
|
||||
.idea
|
||||
# Local Netlify folder
|
||||
.netlify
|
|
@ -7,6 +7,16 @@ prerequisites:
|
|||
description: You should already be familiar with the concept of binary searching for a number in a sorted array. However, binary search can be extended to binary searching on the answer itself.
|
||||
---
|
||||
|
||||
import { Problem } from "../models";
|
||||
|
||||
export const metadata = {
|
||||
problems: {
|
||||
problems: [
|
||||
new Problem("CSES", "Factory Machines", "1620", "Intro"),
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
When we binary search on the answer, we start with a search space of size $N$ which we know the answer lies in. Then, each iteration of the binary search cuts the search space in half, so the algorithm tests $O(\log N)$ values. This is efficient and much better than testing each possible value in the search space.
|
||||
|
||||
Let's say we have a function `check(x)` that returns true if the answer of $x$ is possible, and false otherwise. Usually, in such problems, we'll want to find the maximum or minimum value of $x$ such that `check(x)` is true. Similarly to how binary search on an array only works on a sorted array, binary search on the answer only works if the answer function is [monotonic](https://en.wikipedia.org/wiki/Monotonic_function), meaning that it is always non-decreasing or always non-increasing.
|
||||
|
@ -149,6 +159,4 @@ int main() {
|
|||
- [Packmen](http://codeforces.com/contest/847/problem/E) [](57)
|
||||
- [Office Keys](http://codeforces.com/problemset/problem/830/A) [](60)
|
||||
|
||||
<problems-list>
|
||||
<problem name="Factory Machines" cses="1620" difficulty="Intro" />
|
||||
</problems-list>
|
||||
<problems-list problems={metadata.problems.problems} />
|
|
@ -12,7 +12,7 @@ import {Problem} from "../models"
|
|||
export const metadata = {
|
||||
problems: {
|
||||
practice: [
|
||||
new Problem.USACO("Lemonade Line", "835")
|
||||
new Problem("Silver", "Lemonade Line", "835")
|
||||
]
|
||||
}
|
||||
};
|
||||
|
|
|
@ -32,7 +32,7 @@ export class Problem {
|
|||
this.url = sources[source] + id;
|
||||
} else {
|
||||
if (!id.startsWith("http")) {
|
||||
throw "URL of problem not valid. Did you make a typo in the problem source, or in the URL?"
|
||||
throw `URL ${id} is not valid. Did you make a typo in the problem source (${source}), or in the URL? Problem name: ${name}`
|
||||
}
|
||||
this.url = id;
|
||||
}
|
||||
|
|
|
@ -131,29 +131,7 @@ const components = {
|
|||
<div className="px-4 pt-5 pb-2 sm:p-6 sm:pb-2">{children}</div>
|
||||
</div>
|
||||
),
|
||||
'problems-list': ({ children, problems }) => {
|
||||
if (problems) return <ProblemsListComponent problems={problems} />;
|
||||
console.log('New problem list');
|
||||
return <div>{children}</div>;
|
||||
},
|
||||
problem: ({ name, difficulty, tags, children, ...other }) => {
|
||||
console.log(
|
||||
`new Problem("${Object.keys(other)[0]}", "${name}", "${
|
||||
Object.values(other)[0]
|
||||
}", "${difficulty}", false, ${JSON.stringify(tags)}, "${
|
||||
children || ''
|
||||
}"),`
|
||||
);
|
||||
return null;
|
||||
},
|
||||
// problem: ({ name, difficulty, tags, children, ...other }) => {
|
||||
// console.log(
|
||||
// `new Problem("${Object.keys(other)[0]}", "${name}", "${
|
||||
// Object.values(other)[0]
|
||||
// }", "${difficulty}", false, ${JSON.stringify(tags)}),`
|
||||
// );
|
||||
// return null;
|
||||
// },
|
||||
'problems-list': ProblemsListComponent,
|
||||
table: props => <table {...props} className="text-base border-gray-600" />,
|
||||
th: props => <th {...props} className="border py-1 px-3" />,
|
||||
td: props => <td {...props} className="border py-1 px-3" />,
|
||||
|
|
Reference in a new issue