Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <math.h>
- #include <iostream>
- #include <string>
- #include <set>
- #include <map>
- #include <vector>
- #include <queue>
- #include <typeinfo>
- using namespace std;
- typedef unsigned int uint;
- typedef unsigned long long ull;
- typedef long long ll;
- typedef long double llf;
- typedef double lf;
- typedef float sf;
- typedef pair<ull,ull> para;
- #define forn(i,n) for(auto i=(n)-(n);i<(n);++i)
- #define forab(i,a,b) for(auto i=(a)+(b)-(b);i<(b);++i)
- #define fornd(i,n) for(auto i=(n);i--;)
- #define _tc(x,y) (typeid(x)==typeid(y) || typeid(x)==typeid(const y) || typeid(x)==typeid(y*) || typeid(x)==typeid(const y*))
- template<typename T>
- inline static const string fmtget(T x){
- if(_tc(x,int)){
- return "%i";
- }else if(_tc(x,uint)){
- return "%u";
- }else if(_tc(x,long)){
- return "%li";
- }else if(_tc(x,unsigned long)){
- return "%lu";
- }else if(_tc(x,ll)){
- return "%lli";
- }else if(_tc(x,ull)){
- return "%llu";
- }else if(_tc(x,sf)){
- return "%f";
- }else if(_tc(x,lf)){
- return "%lf";
- }else if(_tc(x,llf)){
- return "%Lf";
- }else{
- return "error";
- }
- }
- class fmt{
- public:
- template <typename T,typename... Args>
- fmt(const string& sp,const string& el,const T& x,const Args... args){s=fmtget(x)+sp+fmt(sp,el,args...).s;}
- fmt(const string& sp,const string& el){s=el;}
- string s;
- };
- #define pr(...) printf(fmt(" ","\n",__VA_ARGS__).s.c_str(),__VA_ARGS__)
- #define sc(...) scanf(fmt("","",__VA_ARGS__).s.c_str(),__VA_ARGS__)
- #define scn(a,n) forn(_read_index,(n)){sc((a)+_read_index);}
- #define scnn(a,n,type) uint n; sc(&(n)); type* (a)=new type[(n)]; scn(a,n);
- #define prn(a,n) forn(_write_index,n){pr(a[_write_index]);}
- template <typename T>
- int cmp_num(const void* a,const void* b){
- return (*(T)a>*(T)b)-(*(T)a<*(T)b);
- }
- #define sqsort(a,n) qsort(a,n,sizeof(*a),cmp_num<decltype(a)>)
- #define tqsort(a,n,type) qsort(a,n,sizeof(*a),cmp_num<type*>)
- #define fqsort(a,n,func) qsort(a,n,sizeof(*a),func);
- #define sbsearch(key,a,n) (decltype(a))bsearch(&key,a,n,sizeof(*a),cmp_num<decltype(a)>)
- #define tbsearch(key,a,n,type) (decltype(a))bsearch(&key,a,n,sizeof(*a),cmp_num<type*>)
- #define fbsearch(key,a,n,func) (decltype(a))bsearch(&key,a,n,sizeof(*a),func)
- int main(){
- #ifdef noacm
- freopen("input.txt","r",stdin);
- //freopen("output.txt","w",stdout);
- #endif
- scnn(a,n,uint);
- sqsort(a,n);
- prn(a,n);
- #ifdef noacm
- fclose(stdin);
- //fclose(stdout);
- for(;;);
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment