Giter Site home page Giter Site logo

waqar-107 / codeforces Goto Github PK

View Code? Open in Web Editor NEW
178.0 6.0 88.0 1.66 MB

codeforces solutions

Home Page: http://codeforces.com/profile/_lucifer_

C++ 94.03% Java 1.04% C 0.86% Python 4.07%
competettive-programming codeforces-solutions codeforces problem-solving cplusplus cpp codeforces-problems python custom-comparator data-structures

codeforces's Introduction

Accepted problems of codeforces

handle : _lucifer_

Check out the Contribution Guidelines in case you want to contribute.

things i often forget while coding:

sorting in python3 using lambda:

assuming that x is a tuple and sorting will depend on x[0], if x[0] is equal then x[1]

data.sort(key = lambda x: (x[0], x[1]))

assuming x is a class where it has two int attributes: id, marks

data.sort(key = lambda x: (x.id, x.marks))

declaring 2D array of N * M size in python:

board = [['X' for i in range(M)] for j in range(N)]

declaring 2D empty array in python:

arr = []
for i in range(n):
  arr.append([])

priority queue with custom comparator

class comparator
{
public:
    // Type is variable type or any user defined object 
    bool operator() (Type a, Type b)
    {
        // return according to your need
    }
};

std::priority_queue<pair<int, int>, vector<pair<int, int>>, comparator> pq;

policy based data structures:

#include<iostream>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

int main(){
  ordered_set s;
  s.insert(5);
  s.insert(4);
  
  cout << s.order_of_key(6) << endl;  // this will output 2 as there are two numbers in the set that are less than 6
}

custom comparator in c#

// this goes inside the class
public int CompareTo(Node other)
{
    if (this.c == other.c) return this.value.CompareTo(other.value);
    return this.c.CompareTo(other.c);
}

codeforces's People

Contributors

aryanbhat avatar deepak-17 avatar gjaiswal108 avatar indraadhikary avatar infinity-intellect avatar parkjonggyeong18 avatar piyushkrmaurya avatar sritasngh avatar supporter09 avatar waqar-107 avatar zannatul-naim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

codeforces's Issues

Test case 9

Hello! The test cases aren't working on my account for this problem. could you help me by sending me the test case no 9? Thanks.

codeforces-987B

Hey friend, If I remove the condition
if(x==y)
{
cout<<"=";
return 0;
}

The code is not working.And what is the usage of this condition as we are comparing again in the end.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.