Created
February 24, 2016 15:28
-
-
Save akouryy/bd96e8e78e11b5775ea7 to your computer and use it in GitHub Desktop.
競プロテンプレート(2016/2/25)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define lambda [&] | |
#define tmpA template<class A> | |
#define tmpB template<class A, class B> | |
#define tmpX template<class X, class ...Y> | |
tmpA using V = vector<A>; tmpA using W = V<V<A>>; tmpA using VW = V<W<A>>; tmpA using WW = W<W<A>>; | |
tmpB using P = pair<A, B>; tmpA using PP = P<A, A>; | |
tmpA using S = set<A>; | |
tmpB using M = map<A, B>; tmpA using MM = M<A, A>; | |
#define int long long | |
#define double long double | |
using VI = V<int>; using WI = W<int>; using VWI = VW<int>; using WWI = WW<int>; | |
using PI = PP<int>; using VPI = V<PI>; using WPI = W<PI>; using VWPI = VW<PI>; using WWPI = WW<PI>; | |
using SI = S<int>; using VSI = V<SI>; using WSI = W<SI>; using VWSI = VW<SI>; using WWSI = WW<SI>; | |
using MI = MM<int>; using VMI = V<MI>; using WMI = W<MI>; using VWMI = VW<MI>; using WWMI = WW<MI>; | |
using VD = V<double>; using WD = W<double>; using VWD = VW<double>; using WWD = WW<double>; | |
using PD = PP<double>; using VPD = V<PD>; using WPD = W<PD>; using VWPD = VW<PD>; using WWPD = WW<PD>; | |
using SD = S<double>; using VSD = V<SD>; using WSD = W<SD>; using VWSD = VW<SD>; using WWSD = WW<SD>; | |
using MD = MM<double>; using VMD = V<MD>; using WMD = W<MD>; using VWMD = VW<MD>; using WWMD = WW<MD>; | |
using VC = V<char>; using WC = W<char>; using VWC = VW<char>; using WWC = WW<char>; | |
using PC = PP<char>; using VPC = V<PC>; using WPC = W<PC>; using VWPC = VW<PC>; using WWPC = WW<PC>; | |
using SC = S<char>; using VSC = V<SC>; using WSC = W<SC>; using VWSC = VW<SC>; using WWSC = WW<SC>; | |
using MC = MM<char>; using VMC = V<MC>; using WMC = W<MC>; using VWMC = VW<MC>; using WWMC = WW<MC>; | |
using VS = V<string>; using WS = W<string>; using VWS = VW<string>; using WWS = WW<string>; | |
using PS = PP<string>; using VPS = V<PS>; using WPS = W<PS>; using VWPS = VW<PS>; using WWPS = WW<PS>; | |
using SS = S<string>; using VSS = V<SS>; using WSS = W<SS>; using VWSS = VW<SS>; using WWSS = WW<SS>; | |
using MS = MM<string>; using VMS = V<MS>; using WMS = W<MS>; using VWMS = VW<MS>; using WWMS = WW<MS>; | |
using PID = P<int, double>; using VPID = V<PID>; using WPID = W<PID>; using VWPID = VW<PID>; using WWPID = WW<PID>; | |
using PIC = P<int, char>; using VPIC = V<PIC>; using WPIC = W<PIC>; using VWPIC = VW<PIC>; using WWPIC = WW<PIC>; | |
using PIS = P<int, string>; using VPIS = V<PIS>; using WPIS = W<PIS>; using VWPIS = VW<PIS>; using WWPIS = WW<PIS>; | |
using PDI = P<double, int>; using VPDI = V<PDI>; using WPDI = W<PDI>; using VWPDI = VW<PDI>; using WWPDI = WW<PDI>; | |
using PDC = P<double, char>; using VPDC = V<PDC>; using WPDC = W<PDC>; using VWPDC = VW<PDC>; using WWPDC = WW<PDC>; | |
using PDS = P<double, string>; using VPDS = V<PDS>; using WPDS = W<PDS>; using VWPDS = VW<PDS>; using WWPDS = WW<PDS>; | |
using PCI = P<char, int>; using VPCI = V<PCI>; using WPCI = W<PCI>; using VWPCI = VW<PCI>; using WWPCI = WW<PCI>; | |
using PCC = P<char, char>; using VPCC = V<PCC>; using WPCC = W<PCC>; using VWPCC = VW<PCC>; using WWPCC = WW<PCC>; | |
using PCS = P<char, string>; using VPCS = V<PCS>; using WPCS = W<PCS>; using VWPCS = VW<PCS>; using WWPCS = WW<PCS>; | |
using PSI = P<string, int>; using VPSI = V<PSI>; using WPSI = W<PSI>; using VWPSI = VW<PSI>; using WWPSI = WW<PSI>; | |
using PSD = P<string, double>; using VPSD = V<PSD>; using WPSD = W<PSD>; using VWPSD = VW<PSD>; using WWPSD = WW<PSD>; | |
using PSC = P<string, char>; using VPSC = V<PSC>; using WPSC = W<PSC>; using VWPSC = VW<PSC>; using WWPSC = WW<PSC>; | |
using MID = M<int, double>; using VMID = V<MID>; using WMID = W<MID>; using VWMID = VW<MID>; using WWMID = WW<MID>; | |
using MIC = M<int, char>; using VMIC = V<MIC>; using WMIC = W<MIC>; using VWMIC = VW<MIC>; using WWMIC = WW<MIC>; | |
using MIS = M<int, string>; using VMIS = V<MIS>; using WMIS = W<MIS>; using VWMIS = VW<MIS>; using WWMIS = WW<MIS>; | |
using MDI = M<double, int>; using VMDI = V<MDI>; using WMDI = W<MDI>; using VWMDI = VW<MDI>; using WWMDI = WW<MDI>; | |
using MDC = M<double, char>; using VMDC = V<MDC>; using WMDC = W<MDC>; using VWMDC = VW<MDC>; using WWMDC = WW<MDC>; | |
using MDS = M<double, string>; using VMDS = V<MDS>; using WMDS = W<MDS>; using VWMDS = VW<MDS>; using WWMDS = WW<MDS>; | |
using MCI = M<char, int>; using VMCI = V<MCI>; using WMCI = W<MCI>; using VWMCI = VW<MCI>; using WWMCI = WW<MCI>; | |
using MCC = M<char, char>; using VMCC = V<MCC>; using WMCC = W<MCC>; using VWMCC = VW<MCC>; using WWMCC = WW<MCC>; | |
using MCS = M<char, string>; using VMCS = V<MCS>; using WMCS = W<MCS>; using VWMCS = VW<MCS>; using WWMCS = WW<MCS>; | |
using MSI = M<string, int>; using VMSI = V<MSI>; using WMSI = W<MSI>; using VWMSI = VW<MSI>; using WWMSI = WW<MSI>; | |
using MSD = M<string, double>; using VMSD = V<MSD>; using WMSD = W<MSD>; using VWMSD = VW<MSD>; using WWMSD = WW<MSD>; | |
using MSC = M<string, char>; using VMSC = V<MSC>; using WMSC = W<MSC>; using VWMSC = VW<MSC>; using WWMSC = WW<MSC>; | |
tmpA using viter = typename V<A>::iterator; | |
tmpA using vciter = typename V<A>::const_iterator; | |
tmpA using remove_const_t = typename remove_const <A>::type; | |
tmpA using remove_reference_t = typename remove_reference<A>::type; | |
#define times(n, i) uptil(0, n, i) | |
#define rtimes(n, i) downto((n) - 1, 0, i) | |
#define upto(f, t, i) for(int i##__count = (f), i = i##__count, i##__goal = (t); i <= i##__goal; i = ++i##__count) | |
#define uptil(f, t, i) for(int i##__count = (f), i = i##__count, i##__goal = (t); i < i##__goal; i = ++i##__count) | |
#define downto(f, t, i) for(int i##__count = (f), i = i##__count, i##__goal = (t); i >= i##__goal; i = --i##__count) | |
#define downtil(f, t, i) for(int i##__count = (f), i = i##__count, i##__goal = (t); i > i##__goal; i = --i##__count) | |
#define timesB(n, i) uptilB(0, n, i) | |
#define rtimesB(n, i) downtoB((n) - 1, 0, i) | |
#define uptoB(f, t, i) for(int i = (f); i <= (t); ++i) | |
#define uptilB(f, t, i) for(int i = (f); i < (t); ++i) | |
#define downtoB(f, t, i) for(int i = (f); i >= (t); --i) | |
#define downtilB(f, t, i) for(int i = (f); i > (t); --i) | |
#define unless(c) if(!(c)) | |
#define until(c) while(!(c)) | |
#define loop while(true) | |
struct nout{ tmpA const nout& operator<<(const A& a) const { return *this; } } nout; | |
#ifdef debug | |
#define debug 1 | |
#define dout cout | |
#define ln << endl | |
#define dsp << "\t" | |
#else | |
#define debug 0 | |
#define dout nout | |
#define ln << "\n" | |
#define dsp << " " | |
#endif | |
#define tb << " " | |
#define sp << " " | |
tmpA inline istream& operator>>(istream& in, vector<A>& v) { times(v.capacity(), i) in >> v[i]; return in; } | |
tmpA inline ostream& operator<<(ostream& out, const vector<A>& v) { times(v.size(), i) out << (i ? " " : "") << v[i]; return out; } | |
tmpB inline istream& operator>>(istream& in, pair<A, B>& p) { A a; B b; in >> a >> b; p = {a, b}; return in; } | |
tmpB inline ostream& operator<<(ostream& out, const pair<A, B>& p) { out << p.first sp << p.second; return out; } | |
tmpX inline X next(istream& in, const Y&... y) { X x(y...); in >> x; return x; } | |
tmpX inline X next( const Y&... y) { return next<X>(cin, y...); } | |
inline string nextLine(istream& in = cin) { string s; getline(in, s); return move(s); } | |
tmpA A pow (A x, A n) { int ans = 1; while(n) { if(n & 1) ans *= x; x *= x; n /= 2; } return ans; } | |
tmpA A powM (A x, A n, A mod) { int ans = 1; while(n) { if(n & 1) { ans *= x; ans %= mod; } x *= x; x %= mod; n /= 2; } return ans; } | |
tmpA inline A divMP(A d, A r, A modP) { return d * powM(r, modP - 2, modP) % modP; } | |
#define size(v) ((signed)((v).size())) | |
#define all(v) begin(v), end(v) | |
tmpA A sum (const vector<A>& v) { A ans = A(); for(const A& a : v) ans += a; return ans; } | |
tmpA A sumM (const vector<A>& v, A mod) { A ans = A(); for(const A& a : v) ans = (ans + a) % mod; return ans; } | |
tmpA A product (const vector<A>& v) { A ans = A(); for(const A& a : v) ans *= a; return ans; } | |
tmpA A productM(const vector<A>& v, A mod) { A ans = A(); for(const A& a : v) ans = (ans * a) % mod; return ans; } | |
tmpA inline A min (const vector<A>& v) { return *min_element(all(v)); } | |
tmpA inline A minI (const vector<A>& v) { return distance(begin(v), min_element(all(v))); } | |
tmpA inline A max (const vector<A>& v) { return *max_element(all(v)); } | |
tmpA inline A maxI (const vector<A>& v) { return distance(begin(v), max_element(all(v))); } | |
tmpA inline void sort (const vector<A>& v) { sort(all(v)); } | |
tmpA inline vector<A> sorted (const vector<A>& v) { vector<A> x = v; sort(x); return x; } | |
tmpA inline pair<A, A> maxmin(const vector<A>& v) { return pair<A, A>(max(v), min(v)); } | |
tmpA inline bool cmax (A& a, const A& v) { if(a < v) { a = v; return true; } return false; } | |
tmpA inline bool cmaxE(A& a, const A& v) { if(a <= v) { a = v; return true; } return false; } | |
tmpA inline bool cmin (A& a, const A& v) { if(a > v) { a = v; return true; } return false; } | |
tmpA inline bool cminE(A& a, const A& v) { if(a >= v) { a = v; return true; } return false; } | |
tmpA inline bool smax (A& a, A& b) { if(a < b) { swap(a, b); return true; } else return false; } | |
tmpA inline bool smaxE(A& a, A& b) { if(a <= b) { swap(a, b); return true; } else return false; } | |
tmpA inline bool smin (A& a, A& b) { if(a > b) { swap(a, b); return true; } else return false; } | |
tmpA inline bool sminE(A& a, A& b) { if(a >= b) { swap(a, b); return true; } else return false; } | |
tmpA inline pair<A, A> maxmin(const A& a, const A& b) { return a > b ? pair<A, A>(a, b) : pair<A, A>(b, a); } | |
signed main() { | |
ios::sync_with_stdio(0); | |
cin.tie(0); | |
WI v = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9, 10}, next<VI>(next<int>())}; | |
cout << v ln << maxmin(v) ln; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment