최근 글
[백준] 1026 / 보물

정렬하고 곱하기! #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int N = 0; vector vec; vector cnt; cin >> N; for (int i = 0; i > vec_cnt; cnt.push_back(vec_cnt); } for (int i = 0; i > vec_num; vec.push_back(vec_num); } sort(vec.begin(), vec.end()); sort(cnt.begin(), cnt.end(), greater()); int sum = 0..

[백준] 1012 / 유기농 배추

간단한 BFS 문제 #include using namespace std; int t = 0; //testCase int m = 0; //X int n = 0; //Y int k = 0; //BaeChu int warmCount = 0; int farmMap[51][51] = {{0,} ,}; bool isWarmSpreded[51][51] = {{false,},}; int dx[] = {1 , -1 , 0 , 0}; int dy[] = {0 , 0 , 1 , -1}; void initFarmMap(){ for(int i = 0;i < 50;i++){ for(int j = 0;j < 50;j++){ farmMap[i][j] = 0; isWarmSpreded[i][j] = 0; } } } bool isIns..

[백준] 1008 / A/B

cout은 precision을 사용하면 %.33f 와 같은 효과가 난다. #include using namespace std; int main() { cout.precision(33); int A; int B; cin>>A; cin>>B; cout

[정올] 1506 / 안전한 철판

// Preset 생략 int power, cnt; struct Line { int ymin; int ymax; int x; int idx; }; vector lines; vector ables[1005]; bool ables_[1005]; bool execpt[1005]; int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); cin >> power >> cnt; int yrmin = 1000; int yrmax = 0; for (int i = 0; i > idx >> xn >> ymin >> ymax; yrmin = min(yrmin, ymin); yrmax..

[백준] 1005 / ACM Craft

DFS를 잘 구현 하면 된다. #include #include #include #include #include using namespace std; vector paths[1001]; int delay[1001] , indeg[1001]; int t , n , k , w , x , y; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> t; while(t--){ cin >> n >> k; for(int i = 1; i delay[i]; } // get 우선순위 for(int i = 1;i > x >> y; // x first , y second indeg[y]++; paths[x].push_back(y); } cin >> w; in..

[백준] 1003 / 피보나치 함수

// preset 생략 typedef pair pipii; map memo; pipii fibonacci(int n) { if (n == 0) { return {0, {1, 0}}; } else if (n == 1) { return {1, {0, 1}}; } else { pipii f, s; if (memo.find(n - 1) != memo.end()) f = memo[n - 1]; else f = fibonacci(n - 1); if (memo.find(n - 2) != memo.end()) s = memo[n - 2]; else s = fibonacci(n - 2); f.first += s.first; f.second.first += s.second.first; f.second.second += s..

[백준] 1001 / A - B

#include using namespace std; int main() { int A; int B; cin>>A; cin>>B; cout

[정올] 2303 / [백준] 2473 / 세 용액

// preset 생략 int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); long long l[5000]; int N; cin >> N; for (int i = 0; i > l[i]; } sort(l, l + N); long long x, a, n, s, sum; sum = LLONG_MAX; for (int i = 0; i abs(temp)) { sum = ab..

[알고리즘] 큐

Queue의 정의 기본적인 자료 구조의 한가지로, 마지막에 집어 넣은 데이터가 먼저 나오는 FIFO(First In First Out)구조로 저장하는 형식을 말한다. 처음으로 Push한 값이 Pop해서 나오는 자료 구조이다. Queue 용어 Pop : Queue에 들어있는 가장 처음으로 넣어진 값을 없앤다. Push : Queue에 가장 마지막에 값을 넣는다. 백준 Queue