-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTemplate.cpp
74 lines (61 loc) · 2.12 KB
/
Template.cpp
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
#include <bits/stdc++.h>
using namespace std;
int main() {
int N = 0, M = 0;
cin >> N >> M;
string S = "";
cin >> S;
vector<int> A(N, 0);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
vector<vector<int>> B(N, vector<int>(N, 0));
int U;
int V;
for (int i = 0; i < M; i++)
{
cin >> U >> V;
U--;
V--;
way[U][V] = 1;
way[V][U] = 1;
}
A.emplace_back(5);
stack<int> st;
st.emplace(1); //st.push(1)
cout << st.top() << endl;
st.pop;
if (st.empty == true)
{
cout << "Now stack is empty" << endl;
}
queue<int> que1;
que1.emplace(1); //que.push(1)
cout << que1.front() << endl;
priority_queue<int> pque1; // <- デフォルトは降順ソートされる
priority_queue<int, vector<int>, greater<int>> pque2; // <- ここまで書くと昇順ソートにしてくれる
cout << pque1.top() << endl;
deque<int> deq;
deq.emplace_front(v); //deq.front(), deq.pop_front()
deq.emplace_back(v); //deq.back(), deq.pop_back()
cout << deq[i] << endl;
map<string, int> mp; // keyの型がstring, valueがint
mp["Hello"] = 5;
set<int> s;
s.insert(5); // setに5を格納, {5}
s.insert(9); // setに9を格納, {5, 9}
s.insert(-3); // setに-3を格納, {-3, 5, 9}
s.insert(9); // 9は既にあるので要素は変わらない, {-3, 5, 9}
auto it = s.find(5); // 5はset内にあるので,イテレータを返す
int it = *it; // v == 5,イテレータをintとして拾うには*を付ける
it = s.find(0); // 0はないので,it == s.end() となる
cout << s.count(-3); //-3はあるので、1
cout << s.count(7); //7はないので、0
it = s.lower_bound(3); //3以上で最小の値のイテレータ,今回3
it = s.upper_bound(3); //3超えで最小の値のイテレータ,今回5
it--; //イテレータは場所を示すのでインクリやデクリができる
cout << *it <<endl; //3
int ans = 0;
cout << ans <<endl;
return 0;
}