This repository has been archived on 2022-06-22. You can view files and clone it, but cannot push or open issues or pull requests.
usaco-guide/content/models.ts

47 lines
1.9 KiB
TypeScript
Raw Normal View History

2020-06-24 21:11:48 +00:00
const sources = {
"AC": "https://atcoder.jp/",
2020-06-24 21:11:48 +00:00
"CC": "https://www.codechef.com/problems/",
"CSA": "https://csacademy.com/contest/archive/task/",
"DMOJ": "https://dmoj.ca/problem/",
"SPOJ": "https://www.spoj.com/problems/",
"YS": "https://judge.yosupo.jp/problem/",
"CF": "https://codeforces.com/",
2020-06-24 21:28:57 +00:00
"Bronze": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
"Silver": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
"Gold": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
2020-06-24 23:08:16 +00:00
"Old Bronze": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
"Old Silver": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
"Old Gold": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
2020-06-24 21:28:57 +00:00
"Plat": "http://www.usaco.org/index.php?page=viewproblem2&cpid=",
2020-06-24 21:11:48 +00:00
"Kattis": "https://open.kattis.com/problems/",
"CSES": "https://cses.fi/problemset/task/",
2020-06-25 01:38:05 +00:00
"LC": "https://leetcode.com/problems/",
"ojuz": "https://oj.uz/problem/view/",
"HR": "https://www.hackerrank.com/",
2020-06-24 21:11:48 +00:00
};
2020-06-24 20:52:45 +00:00
export class Problem {
2020-06-24 21:11:48 +00:00
public url: string;
2020-07-06 21:21:40 +00:00
public difficulty: 'Very Easy' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard' | 'Insane';
2020-06-29 23:26:26 +00:00
public isIntro: boolean;
2020-06-24 21:11:48 +00:00
2020-06-24 20:52:45 +00:00
constructor(
2020-06-24 21:11:48 +00:00
public source: string,
2020-06-24 20:52:45 +00:00
public name: string,
2020-06-24 21:11:48 +00:00
public id: string,
2020-07-06 21:21:40 +00:00
labels?: 'Very Easy' | 'Easy' | 'Normal' | 'Hard' | 'Very Hard' | 'Insane' | 'Intro|Very Easy' | 'Intro|Easy' | 'Intro|Normal' | 'Intro|Hard' | 'Intro|Very Hard' | 'Intro|Insane',
2020-06-24 21:28:57 +00:00
public starred?: boolean,
2020-06-24 20:52:45 +00:00
public tags?: string[],
2020-06-24 21:11:48 +00:00
public sketch?: string,
) {
2020-07-03 21:13:26 +00:00
this.isIntro = labels && labels.includes("Intro|");
if (labels) labels = labels.replace("Intro|", "") as any;
2020-06-29 23:26:26 +00:00
this.difficulty = labels as any;
2020-06-25 02:09:35 +00:00
if (!id.startsWith("http")) {
if (source in sources) {
this.url = sources[source] + id;
} else throw `URL ${id} is not valid. Did you make a typo in the problem source (${source}), or in the URL? Problem name: ${name}`
} else this.url = id;
2020-06-24 20:52:45 +00:00
}
2020-06-24 21:11:48 +00:00
}