Skip to content

Commit f7e46e3

Browse files
authored
Update show.h
1 parent 00deab2 commit f7e46e3

File tree

1 file changed

+45
-32
lines changed

1 file changed

+45
-32
lines changed

0000.test_project/show.h

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <map>
99
#include <unordered_set>
1010
#include <set>
11+
#include <bitset>
1112
#include <iostream>
1213
using namespace std;
1314

@@ -37,7 +38,7 @@ void show(vector<vector<T>> answer)
3738
int single_answer_size;
3839
cout << "-------" << endl;
3940
cout << "size=" << answer.size() << endl
40-
<< "~~~~" << endl;
41+
<< "~~~~" << endl;
4142
for (int i = 0; i < answer_size; ++i)
4243
{
4344
single_answer_size = answer.at(i).size();
@@ -47,33 +48,33 @@ void show(vector<vector<T>> answer)
4748
}
4849
cout << "-------" << endl;
4950
}
50-
template <typename T>
51-
void show(vector<T> answer)
51+
void show(vector<pair<int,int>> answer)
5252
{
5353
cout << "----" << endl;
5454
int answer_size = answer.size();
5555
cout << "size=" << answer.size() << endl
56-
<< "~~~~" << endl;
56+
<< "~~~~" << endl;
5757
for (int i = 0; i < answer_size; ++i)
58-
cout << answer.at(i) << endl;
58+
cout << answer.at(i).first << ' ' << answer.at(i).second << endl;
5959
cout << "----" << endl;
6060
}
61-
void show(vector<pair<int,int>> answer)
61+
template <typename T>
62+
void show(vector<T> answer)
6263
{
6364
cout << "----" << endl;
6465
int answer_size = answer.size();
6566
cout << "size=" << answer.size() << endl
66-
<< "~~~~" << endl;
67+
<< "~~~~" << endl;
6768
for (int i = 0; i < answer_size; ++i)
68-
cout << answer.at(i).first << ' ' << answer.at(i).second << endl;
69+
cout << answer.at(i) << endl;
6970
cout << "----" << endl;
7071
}
7172
template <typename T>
7273
void show(list<T> answer)
7374
{
7475
cout << "----" << endl;
7576
cout << "size=" << answer.size() << endl
76-
<< "~~~~" << endl;
77+
<< "~~~~" << endl;
7778
for (auto p=answer.begin();p!=answer.end();++p)
7879
cout << *p << endl;
7980
cout << "----" << endl;
@@ -93,7 +94,7 @@ void show(unordered_map<K,V> answer)
9394
{
9495
cout << "----" << endl;
9596
cout << "size=" << answer.size() << endl
96-
<< "~~~~" << endl;
97+
<< "~~~~" << endl;
9798
for (auto p=answer.begin();p!=answer.end();++p)
9899
cout << p->first << ' ' << p->second << endl;
99100
cout << "----" << endl;
@@ -103,7 +104,7 @@ void show(map<K,V> answer)
103104
{
104105
cout << "----" << endl;
105106
cout << "size=" << answer.size() << endl
106-
<< "~~~~" << endl;
107+
<< "~~~~" << endl;
107108
for (auto p=answer.begin();p!=answer.end();++p)
108109
cout << p->first << ' ' << p->second << endl;
109110
cout << "----" << endl;
@@ -113,7 +114,7 @@ void show(unordered_set<T> answer)
113114
{
114115
cout << "----" << endl;
115116
cout << "size=" << answer.size() << endl
116-
<< "~~~~" << endl;
117+
<< "~~~~" << endl;
117118
for (auto p=answer.begin();p!=answer.end();++p)
118119
cout << *p << endl;
119120
cout << "----" << endl;
@@ -123,7 +124,7 @@ void show(set<T> answer)
123124
{
124125
cout << "----" << endl;
125126
cout << "size=" << answer.size() << endl
126-
<< "~~~~" << endl;
127+
<< "~~~~" << endl;
127128
for (auto p=answer.begin();p!=answer.end();++p)
128129
cout << *p << endl;
129130
cout << "----" << endl;
@@ -133,29 +134,41 @@ void show(multimap<K,V> answer)
133134
{
134135
cout << "----" << endl;
135136
cout << "size=" << answer.size() << endl
136-
<< "~~~~" << endl;
137+
<< "~~~~" << endl;
137138
for (auto p=answer.begin();p!=answer.end();++p)
138139
cout << p->first << ' ' << p->second << endl;
139140
cout << "----" << endl;
140141
}
141-
142-
143-
int base=1e9+7;
144-
int quick_pow(int a,int n)
142+
void show_in_binary(int x)
145143
{
146-
//a^n
147-
if (a==0)
148-
return 0;
149-
if (n==0)
150-
return 1;
151-
a%=base;
152-
if ((n&1)==1)
153-
return a*quick_pow(a,n-1)%base;
154-
else
155-
{
156-
int half=quick_pow(a,n/2);
157-
return (long long)half*half%base;
158-
}
144+
cout << "----" << endl;
145+
cout << bitset<32>(x).to_string() << endl;
146+
cout << "----" << endl;
147+
}
148+
template <typename T>
149+
void show(priority_queue<T> answer)
150+
{
151+
cout << "----" << endl;
152+
cout << "size=" << answer.size() << endl
153+
<< "~~~~" << endl;
154+
while (!answer.empty())
155+
{
156+
cout << answer.top() << endl;
157+
answer.pop();
158+
}
159+
cout << "----" << endl;
160+
}
161+
template <typename A,typename B>
162+
void show(priority_queue<pair<A,B>> answer)
163+
{
164+
cout << "----" << endl;
165+
cout << "size=" << answer.size() << endl
166+
<< "~~~~" << endl;
167+
while (!answer.empty())
168+
{
169+
cout << answer.top().first << ' ' << answer.top().second << endl;
170+
answer.pop();
171+
}
172+
cout << "----" << endl;
159173
}
160-
161174
#endif

0 commit comments

Comments
 (0)