본문 바로가기

Algorithm/Brute Force

(5)
CLOCKSYNC #include #include using namespace std; const int MAX_BUFFER_SIZE = 1024; const int SWITCH_NUM = 10; const int CLOCK_NUM = 16; const char* switches[10] = { {"oooxxxxxxxxxxxxx"}, {"xxxoxxxoxoxoxxxx"}, {"xxxxoxxxxxoxxxoo"}, {"oxxxooooxxxxxxxx"}, {"xxxxxxoooxoxoxxx"}, {"oxoxxxxxxxxxxxoo"}, {"xxxoxxxxxxxxxxoo"}, {"xxxxooxoxxxxxxoo"}, {"xoooooxxxxxxxxxx"}, {"xxxoooxxxoxxxoxx"} }; vector clockState; in..
TSP(Traveling Salesman Problem) #include #include #include using namespace std; const int MAX_BUFFER_SIZE = 1024; const int MAX_TOWN_NUM = 8; vector dist; bool visited[MAX_TOWN_NUM]; int townNum = 0; double getMinDistance(int curTown); void splitStringWithDelim(char* source, vector &result, char delim, int maxSize); int main() { int caseNum = 0; char buffer[MAX_BUFFER_SIZE] = {0, }; cin >> caseNum; for (int cIter = 0; cIter < ..
BOARDCOVER #include #include using namespace std; const int MAX_WIDTH = 20; const int coverType[4][3][2] = { {{0, 0}, {1, 0}, {1, -1}}, {{0, 0}, {0, 1}, {1, 1}}, {{0, 0}, {1, 0}, {1, 1}}, {{0, 0}, {1, 0}, {0, 1}} }; int boardHeight = 0, boardWidth = 0; int cover(vector &board); bool set(vector &board, int y, int x, int type, int flip); int main() { int caseNum = 0; string inputBuffer; char widthBuffer[MAX_..
PICNIC #include #include using namespace std; const int MAX_BUFFER_SIZE = 1024; int studentCnt = 0, pairCnt = 0; bool areFriend[10][10] = { false, }; int makePairing(bool done[10]); void splitStringWithDelim(char* source, vector &result, char delim, int maxSize); int main() { int caseNum = 0; char areFriendInput[MAX_BUFFER_SIZE]; vector areFriendInputParsed; bool done[10] = { false, }; cin >> caseNum; ..
백준 터렛 문제 (C++) 백준의 터렛 문제를 C++ 로 풀어보았다. #include #include using namespace std; int main() { int caseNum = 0; int x1 = 0, y1 = 0, x2 = 0, y2 = 0; int r1 = 0, r2 = 0; cin >> caseNum; for (int i = 0; i > x1 >> y1 >> r1 >> x2 >> y2 >> r2; double distance = sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2)); int maxR = r1 + r2, minR = abs(r1 - r2); if (x1 == x2 && y1 == y2 && r1 == r2) cout