최근 글
[정올] 1570 / 중앙값

#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; int main(){ cin.tie(0); cout.tie(0); priority_queue minq , maxq; int n , mid; cin >> n >> mid; cout a >> b; if(a < mid) maxq.push(a); else minq.push(-a); if(b < mid) maxq.push(b); else minq..

[정올] 1544 / [백준] 2660 / 회장뽑기

#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned long ull; typedef pair pii; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int n; int r[51]; int d[51][51]; int main() { cin.tie(0); cout.tie(0); cin >> n; for (int i = 0; i f >> t; if (f == -1 || t == -1) break; d[f][t] = 1; d[t][f] ..

[정올] 1457 / [백준] 2583 / 영역 구하기

#include #include #include using namespace std; int m, n, k; int c; int arrCount = 0; int map[110][110]; int arr[10000]; int moveX[4] = { 0, 1, 0, -1 }; int moveY[4] = { 1, 0, -1, 0 }; void DFS(int a, int b) { if (map[a][b] == 0) { map[a][b] = 1; ++c; for (int l = 0; l = 0 && y >= 0 && x < m && y < n) { DFS(x, y); } } } } int main(in..

[정올] 1440 / 가까운 공통 조상 찾기

#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; #define s second; #define l first int dx[] = {0 , 0 , 1 , -1}; int dy[] = {1 , -1 , 0 , 0}; vi path[10005]; int n; int uping[10005]; int main(){ cin.tie(0); cout.tie(0); cin >> n; for(int i = 0;i < n - 1;i++) { int par , chi; ci..

[정올] 1409 / [백준] 2666 / 벽장문의 이동

#include using namespace std; typedef long long ll; typedef pair pii; int n; int wo[25] , woc; int findLCost(int woidx , int oa , int ob){ if(woidx >= woc) { return 0; } int nowo = wo[woidx]; int tc1 = abs(oa - nowo) + findLCost(woidx + 1 , nowo , ob); // 왼쪽으로 밀기 int tc2 = abs(ob - nowo) + findLCost(woidx + 1 , oa , nowo); // 오른쪽으로 return min(tc1 , tc2); } int main(){ cin.tie(0); cout.tie(0); in..

[정올] 1405 / 하노이3(4기둥)

#include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; int dx[] = {0, 0, 1, -1}; int dy[] = {1, -1, 0, 0}; int N; int moveK[22]; int moveCnt(int n) { if (n N; int ans = moveCnt(N); cout

[정올] 1370 / [백준] 1931 / 회의실 배정

#include using namespace std; struct Meet { int st; int ed; int id; }; bool sort_func(Meet a, Meet b) { if (a.ed == b.ed) { return a.st > n; vector meets; for (int i = 0; i > a.id >> a.st >> a.ed; meets.push_back(a); } sort(meets.begin(), meets..

[정올] 1341 / 구구단2

#include int main(){ while(1){ int a , b; scanf("%d %d" , &a , &b); if(a 9 || b 9) { printf("INPUT ERROR!\n"); continue; } if(a < b){ for(int i = a;i

[정올] 1335 / [백준] 2630 / 색종이 만들기(영역구분)

#include using namespace std; typedef long long ll; typedef pair pii; const int NOTHING = 0; const int ALLWHIT = 1; const int ALLBLUE = 2; const int WHITEPA = 0; const int BLUEPAI = 1; int n; // board[y][x] int board[130][130]; int ansWhite = 0; int ansBlue = 0; int allSomeThing(int stX , int stY , int edX , int edY){ bool allWhite = true; bool allBlue = true; for(int i = stY;i