-
Notifications
You must be signed in to change notification settings - Fork 0
/
cout.h
86 lines (79 loc) · 2.04 KB
/
cout.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
Debugging cout override created by naoya_t.
http://topcoder.g.hatena.ne.jp/n4_t/20081204
*/
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
ostream& operator<<(ostream &s, vector<string> v)
{
int cnt = v.size();
s << "[ ";
for (int i=0; i<cnt; i++) {
if (i > 0) s << ", ";
s << '"' << v[i] << '"';
}
return s << " ] // " << cnt << " item" << (cnt >= 2 ? "s" : "");
}
template <typename T> ostream& operator<<(ostream &s, vector<T> v)
{
int cnt = v.size();
s << "[ ";
for (int i=0; i<cnt; i++) {
if (i > 0) s << ", ";
s << v[i];
}
return s << " ] // " << cnt << " item" << (cnt >= 2 ? "s" : "");
}
template <typename T> ostream& operator<<(ostream &s, list<T> ls)
{
int cnt = 0;
s << "( ";
for (typeof(ls.begin()) it=it.begin(); it!=it.end(); it++) {
if (it != it.begin()) s << ", ";
s << *it;
cnt++;
}
return s << " ) // " << cnt << " item" << (cnt >= 2 ? "s" : "");
}
template <typename T> ostream& operator<<(ostream &s, deque<T> st)
{
int cnt = st.size();
s << "[ ";
for (typeof(st.begin()) it=st.begin(); it!=st.end(); it++) {
if (it != st.begin()) s << ", ";
s << *it;
}
return s << " ] // " << cnt << " item" << (cnt >= 2 ? "s" : "");
}
template <typename T1, typename T2> ostream& operator<<(ostream &s, map<T1,T2> m)
{
int cnt = m.size();
s << "{ ";
for (typeof(m.begin()) it=m.begin(); it!=m.end(); it++) {
if (it != m.begin()) s << ", ";
s << it->first << " => " << it->second;
}
return s << " } // " << cnt << " item" << (cnt >= 2 ? "s" : "");
}
template <typename T> ostream& operator<<(ostream &s, set<T> st)
{
int cnt = st.size();
s << "[ ";
for (typeof(st.begin()) it=st.begin(); it!=st.end(); it++) {
if (it != st.begin()) s << ", ";
s << *it;
}
return s << " ] // " << cnt << " item" << (cnt >= 2 ? "s" : "");
}
template <typename T1, typename T2> ostream& operator<<(ostream &s, pair<T1,T2> p)
{
return s << "(" << p.first << "," << p.second << ")";
}