'알고리즘 모음집' 카테고리의 글 목록 (29 Page)
본문 바로가기
728x90
반응형

알고리즘 모음집307

2021년09월02일_3190-뱀 #include #include #include using namespace std; #define SIZE 101 // 보드의 최대 크기 int N, K, L;//입력으로 주어지는 보드크기,사과의 개수, 뱀의 방향 변환 횟수 int board[SIZE][SIZE]; int dy[] = { 0,1,0,-1 };//방향 int dx[] = { 1,0,-1,0 }; void init(); void play();//게임 시작 struct info { int y, x, size, dir; }snake; int main(void) { int testCase = 1; for (int tc = 1; tc 2021. 9. 2.
13460_구슬탈출2 #include #include #include #include #include #define NMSIZE 11 using namespace std; char board[NMSIZE][NMSIZE];// 구슬과 구멍 맵그려지는 곳 int chk[NMSIZE][NMSIZE][NMSIZE][NMSIZE];// 구슬 위치 체크하는 배열 int N, M;//가로 세로 크기입력 변수 int ret;//결과값 저장 int dy[] = { 0,1,0,-1 };// 상하좌우 이동 위한 배열 int dx[] = { 1,0,-1,0 }; void init();//초기화 void play();//시뮬레이션 시작 struct ballXY { int ry, rx;//빨간공 y,x int by, bx;//파란공 y,x int c.. 2021. 9. 1.
2021년08월04일_16953-A->B #include #include #include #include #include #include using namespace std; struct Data { long long int number; int cnt; }; int A, B, ret;//A: 시작, B: 만들어야하는 숫자, ret: 결과값 void init() { A = B = 0; ret = 0x7fffffff; scanf("%d %d", &A, &B); } void AtoB() { mapvisit;// 방문 체크 맵 queueq; q.push({ A,1 }); visit[A] = 1; while (!q.empty()) { Data current = q.front(); q.pop(); if (current.number > B || curre.. 2021. 8. 7.
2021년08월04일_11724-연결요소의개수 #include #include #include using namespace std; #define NS 1001 int N, M;//정점의 개수, 간선의 개수 int ret;//결과 값 vectorG[NS]; void init(); void search(); int main() { int testCase = 1; //scanf("%d", &testCase); for (int tc = 1; tc 2021. 8. 4.
728x90
반응형