int data = 100;
string st = to_string(data)
string st = "100";
int data = stoi(st);
int data = 9;
char ch = (char)(data + '0');
#include <algorithm>
필요!!!#include <climits>
에 선언됨INT_MAX
, INT_MIN
, LONG_MIN
, LONG_MAX
, LLONG_MIN
, LLONG_MAX
우선순위 큐는 내림차순 정렬(큰 수가 먼저옴) 이다.
priority_queue<int,vector<int>,greater<int>>
: 오름차순으로 정렬priority_queue<pair<int, pair<int,int>>, vector<pair<int, pair<int,int>>>, greater<pair<int, pair<int,int>>> > pq;
pq.push({heights[0][0], {0,0}});
while (!pq.empty()) {
int val = pq.top().first;
int y = pq.top().second.first;
int x = pq.top().second.second;
pq.pop();
queue 에는 top이 아니라 front였다는걸 까먹음..
queue<pair<int, int>> q 의 원소를 찾아갈땐 q.front().first, q.front().second.. 이런식으로 가야함.
vector<vector<int>> v;
vector<int> tmp;
tmp.push_back(3);
v.push_back(tmp);
tmp.clear();
tmp.push_back(9);
tmp.push_back(20);
v.push_back(tmp);
이런식으로 가야 [3],[9,20]... 이렇게 쌓임.
vector<pair<int, int>> v;
v.push_back({1,2}) // 이렇게 넣고
v[0].first, v[0].second // 이렇게 뺀다.
// int n = 초기화될 갯수
vector<int> vect(n, 10);
// nm 배열 초기화
vector<vector<int>> vec(n , vector<int> (m, 0));
vector<int> dp;
dp = vector<int>(1000, -1);
vector<int> v;
v.assign(tmp);
삽입, 삭제, 찾기 (insert, erase, find), count: O(logN)
map<int, int, greater<int>> m; // 이렇게 선언하고 넣으면
// {4, 19}
// {3, 10}
// {-1, 3}
// ... 이런식으로 들어간다.
대괄호([,]) 사용하여 value 데이터에 접근할 수 있다.
map<int, int> prices;
prices[key] 하면 value 값이 나옴
반복문 데이터 접근 (first, second)
for (auto iter = m.begin() ; iter != m.end(); iter++)
{
cout << iter->first << " " << iter->second << endl;
}
#include <set>
필요! <multiset>
이 아님을 유의!!#include<map>
mm.begin();
mm.end();
mm.rbegin();
mm.rend();
mm.clear();
mm.count(key);
mm.empty();
mm.insert(pair < >); // pair 객체입니다.
mm.erase(start, end);
mm.find(key);
mm2.swap(mm1);
mm.value_comp();
mm.key_comp();
mm.max_size();
mm.size();