21 | #define PP pair
22 | #define mod 1000000007
23 | #define MAX 100005
24 | #define s second
25 | #define f first
26 | #define newLine printf("\n")
27 | ll n,m;
28 | pair > arr[MAX];
29 | ll ADD[MAX];
30 | ll SUB[MAX];
31 | ll A[MAX];
32 | ll C;
33 |
34 | ll add(ll &x, ll y){
35 | x = (x + y) % mod;
36 | if(x < 0) x += mod;
37 | return x;
38 | }
39 |
40 | int main()
41 | {
42 | int t;
43 | si(t);
44 | while(t--){
45 | sll(n); sll(m);
46 | mem(ADD, 0);
47 | mem(SUB, 0);
48 | mem(A, 0);
49 | C = 1;
50 | rep(i, 0, m){
51 | si(arr[i].f);
52 | sll(arr[i].s.f);
53 | sll(arr[i].s.s);
54 | arr[i].s.f -= 1;
55 | arr[i].s.s -= 1;
56 | }
57 | for(int i = m-1; i >= 0; i--){
58 | add(C, ADD[i]);
59 | add(C, -1LL*SUB[i]);
60 | ADD[i] = C;
61 | if(arr[i].f == 2){
62 | if(arr[i].s.f > 0) add(SUB[arr[i].s.f-1], C);
63 | add(ADD[arr[i].s.s], C);
64 | }
65 | }
66 | mem(SUB, 0);
67 | rep(i, 0, m)
68 | if(arr[i].f == 1){
69 | if(arr[i].s.s < (n-1)) add(SUB[arr[i].s.s+1],ADD[i]);
70 | add(A[arr[i].s.f],ADD[i]);
71 | }
72 | C = 0;
73 | rep(i, 0, n){
74 | add(C, A[i]);
75 | add(C, -1*SUB[i]);
76 | A[i] = C;
77 | }
78 | rep(i,0,n) plls(A[i]);
79 | newLine;
80 | }
81 | return 0;
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/CNAME:
--------------------------------------------------------------------------------
1 | cheflib.co
--------------------------------------------------------------------------------
/CODE-OF-CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at `admin@cheflib.co`. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## How to contribute?
2 |
3 | * Have a look at the table in README.md. It contain the list of codes solved by people in CodeChef's rated contests.
4 | * Find a code for which an entry which is not yet added create an issue for it.
5 | * Make sure you are assigned for the issue before sending the PR.
6 | * Code added should follow the standard guidelines of that language, untidy codes will not be accepted.
7 | * Send a PR.
8 | * Make sure that you only send the source code not the binaries and executables in PR.
9 | * While sending a PR make sure you follow one issue per PR rule.
10 | * Link to your solution on CodeChef is mandatory.
11 |
12 |
13 |
14 |
15 | ## Code Styleguide
16 |
17 | * Code submitted should be modular.
18 | * Add the code in their respective directory only.
19 | * Filename should be same as that of the problem code.
20 | * Currently we are accepting contributions in C, C++, Java and Python but other languages may be considered after a discussion.
21 | * Meaningful comments to explain your code better are welcomed.
22 | * No profanity.
23 | * We have defined [skeleton codes](#samples) for some popular languages below. Please follow them whenever possible.
24 | * Sample skeleton codes are for showing guidelines and indentations only.
25 |
26 |
27 |
28 |
29 | ## Improving a Dish
30 |
31 | * If you feel you can improve upon any added code, feel free to open an issue discussing the improvements.
32 | * The points to be considered for improvement will be the time required by code to pass testcases, easy explanation, etc.
33 |
34 |
35 |
36 | ## Samples
37 |
38 | #### C
39 |
40 | ```c
41 | int main() {
42 | int tc;
43 | scanf("%d", &tc);
44 | while (tc--) {
45 | /*
46 | your code here;
47 | */
48 | }
49 | }
50 | ```
51 |
52 | #### C++
53 |
54 | ```c++
55 | int main() {
56 | int tc;
57 | cin >> tc;
58 | while (tc--) {
59 | /*
60 | your code here;
61 | */
62 | }
63 | }
64 | ```
65 |
66 | #### Python
67 | ```python
68 | def main():
69 | tc = int(input())
70 | while tc > 0:
71 | Your Dish here...
72 | tc -= 1
73 |
74 | if __name__ == '__main__':
75 | main()
76 | ```
77 |
78 | #### Java
79 | ```java
80 | public static void main(String[] args) {
81 | Scanner inp = new Scanner(System.in);
82 | int tc = inp.nextInt();
83 | while (tc-- != 0) {
84 | Your code goes here...
85 | }
86 | }
87 | }
88 | ```
89 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ChefLib
2 |
3 | [](https://travis-ci.org/iiitv/ChefLib)
4 | [](https://gitter.im/iiitv/ChefLib?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5 | [](https://github.com/iiitv/ChefLib/issues)
6 | [](https://github.com/iiitv/ChefLib/issues)
7 | [](https://github.com/iiitv/ChefLib/graphs/contributors)
8 | [](https://codeclimate.com/github/iiitv/ChefLib)
9 |
10 | ### Library of Sweet Dishes (codes) by Chefs (Coders).
11 |
12 | This repository is collection of CodeChef Contest Solutions.
13 | This is for educational purpose. This may help you to understand problems in better way, and since not all solutions on this repository are AC  , you can suggest changes by opening an Issue and Send a PR.
14 | You can Discuss about problems (not ones in LIVE contest) at our [Gitter Channel](https://gitter.im/iiitv/ChefLib)
15 |
16 | ## Index Of Dishes
17 |
18 | #### This is Month Wise Index Of Problem.
19 |
20 |
21 | | Month | Long | Cook-Off | Lunchtime |
22 | |:-----------------:|:-----------------:|:-----------------:|:-----------------:|
23 | | [December 2016](2016/DEC.md) | [](2016/DEC.md#long) | COOK77 [](2016/DEC.md#cook) | LTIME43 [](2016/DEC.md#ltime) |
24 | | [January 2017](2017/JAN.md) | [](2017/JAN.md#long) | COOK78 [](2017/JAN.md#cook) | LTIME44 [](2017/JAN.md#ltime) |
25 | | [February 2017](2017/FEB.md) | [](2017/FEB.md#long) | COOK79 [](2017/FEB.md#cook) | LTIME45 [](2017/FEB.md#ltime) |
26 | | [March 2017](2017/MAR.md) | [](2017/MAR.md#long) | COOK80 [](2017/MAR.md#cook) | LTIME46 [](2017/MAR.md#ltime) |
27 | | [April 2017](2017/APR.md) | [](2017/APR.md#long) | COOK81 [](2017/APR.md#cook) | LTIME47 [](2017/APR.md#ltime) |
28 | | [May 2017](2017/MAY.md) | [](2017/MAY.md#long) | COOK82 [](2017/MAY.md#cook) | `Unrated` |
29 | | [June 2017](2017/JUN.md) | [](2017/JUN.md#long) | COOK83 [](2017/JUN.md#cook) | LTIME49 [](2017/JUN.md#ltime) |
30 | | [July 2017](2017/JULY.md) | [](2017/JULY.md#long) | `Unrated` | LTIME50 [](2017/JULY.md#ltime) |
31 | | [August 2017](2017/AUG.md) | [](2017/AUG.md#long) | COOK85 [](2017/AUG.md#cook) | LTIME51 [](2017/AUG.md#ltime) |
32 | | [September 2017](2017/SEPT.md) | [](2017/SEPT.md#long) | COOK85 [](2017/SEPT.md#cook) | LTIME52 [](2017/SEPT.md#ltime) |
33 | | [October 2017](2017/OCT.md) | [](2017/OCT.md#long) | COOK86 [](2017/OCT.md#cook) | LTIME53 [](2017/OCT.md#ltime) |
34 |
35 |
36 | ## Eligible Contributors Rating
37 |
38 | ECR section in table above is for checking who are eligible for contributing to this Problem.
39 | This section will contain ★s which will represent CodeChef's ★ Rating.
40 | `For eg: If you have 3★ rating on CodeChef, you can contribute on any problem having 3 or more stars in their respective ECR column.`
41 |
42 | ## Merging Policy
43 | * Everyone should follow one commit per PR.
44 | * The first Commit message should be like:
45 | ```
46 | Added {Problem name} in {Contest name with year} [Lang]
47 | Fixes #{issue number}
48 | ```
49 | Rest of commit messages should reflect the changes done in respective commit.
50 |
51 | ## Contributing
52 | #### It is advised to first read how to contribute to this repository before [creating an issue](https://github.com/iiitv/ChefLib/issues/new).
53 | See [CONTRIBUTING.md](https://github.com/iiitv/ChefLib/blob/master/CONTRIBUTING.md).
54 |
55 | ## Adding Entry to month README
56 | #### If you are confused over how to add an entry to the month's README you can always read [this](.github/ADD_ME_IN_README.md)
57 |
58 | ## Project Maintainers
59 |
60 | * [Aashutosh Rathi](https://github.com/aashutoshrathi)
61 | * [Monal Shadi](https://github.com/Monal5031)
62 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | theme: jekyll-theme-leap-day
--------------------------------------------------------------------------------
/img/AC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/AC.png
--------------------------------------------------------------------------------
/img/CC.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/CC.png
--------------------------------------------------------------------------------
/img/GH.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/GH.png
--------------------------------------------------------------------------------
/img/RE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/RE.png
--------------------------------------------------------------------------------
/img/TLE.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/TLE.png
--------------------------------------------------------------------------------
/img/WA.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/iiitv/ChefLib/4253e07da46da81eb32a2aaf8ab11f2e04642b04/img/WA.png
--------------------------------------------------------------------------------