Skip to content

Instantly share code, notes, and snippets.

@arafatkatze
Created August 9, 2016 17:55
Show Gist options
  • Save arafatkatze/91e66f473b14b3f7fcd810fa34318d63 to your computer and use it in GitHub Desktop.
Save arafatkatze/91e66f473b14b3f7fcd810fa34318d63 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
#define inf INFINITY
#define bitcount __builtin_popcount // counts 1 eg- 1101 has value 3
/*
const clock_t begin_time = clock();
// do something
cout << float( clock () - begin_time ) / CLOCKS_PER_SEC;
Read from a file
freopen("input.in","r",stdin);
freopen("output.out","w",stdout);
*/
void r(){};
template<typename T,typename... Args>
void r(T &a, Args&... args) { cin>>a ; r(args...); }
void p(){cout <<"\n";};
template<typename T,typename... Args>
void p(T &a, Args&... args) { cout << a << " " ; p(args...); }
template<class T> T gcd(T a, T b) { return a ? gcd (b % a, a) : b; }
template<class T> T lcm(T a, T b) { return ((a*b)/gcd (b % a, a)); }
template<class T> T binpow(T number, T power) { T result = 1; while(power) { if(power & 1) result *= number; number *= number;power /= 2;}return result;}
template<class T> T absa(T a) {if(a > 0) return a; return -a;}
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// Useful container manipulation / traversal macros
#define fa(i, begin, end) for (auto i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define fe(v, c) for(auto v :c)
#define all(a) a.begin(), a.end()
#define in(a,b) ( (b).find(a) != (b).end())
#define pb emplace_back // this will work almost always
#define fill(a,v) memset(a, v, sizeof a)
#define sz(a) ((auto)(a.size()))
#define mt make_tuple
// comparision Guys
#define maX(a,b) ( (a) > (b) ? (a) : (b))
#define miN(a,b) ( (a) < (b) ? (a) : (b))
#define checkbit(n,b) ( (n >> b) & 1)
#define DREP(a) sort(all(a)); a.erase(unique(all(a)),a.end()) //deletes repeat
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
// The bit standard guys
#define bit(x,i) (x&(1<<i)) //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define higbit(x) (1 << ( auto) log2(x) )
// The vectors and pairs
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int>pa;
#define ft first
#define sd second
#define pq priority_queue
// the data types
#define ll long long
#define st string
#define ld long double
struct comp {
bool operator() (const tuple<char, int , string> a, const tuple<char, int , string> b) const {
return get<1>(a) > get<1>(b);
}
};
std::map<tuple<char, int , string>, double, comp> v;
main()
{
boost;
v[mt('a',534,"train")] = 343.325;
v[mt('b',143,"ring")] = 123.325;
v[mt('c',642,"string")] = 623.325;
fe(i,v)p(get<0>(i.ft), get<1>(i.ft), get<2>(i.ft), i.sd);
}
@arafatkatze
Copy link
Author

arafatkatze commented Aug 9, 2016

Result

c 642 string 623.325 
a 534 train 343.325 
b 143 ring 123.325 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment