728x90
반응형

하루 1문제 챌린지/Silver2 4

백준 10971번 외판원순회2 (C++) 🚩

next_permutation은 {1,2,3,4} 가 주어지면 1,2,4,3 과 같이 다음에 넘어갈 수열이 있으면 실행 prev_permutation은 {1,2,4,3}이면 {1,2,3,4} 과 같은게 있으면 실행한다. #include #include #include using namespace std; vectorarr; int cal(vectorvisited){ visited.push_back(visited[0]); //중간에 길 끊기면 경로 아님 int cnt=0; for(int i=0;i>n; vectorvisited; arr.assign(n,vector(n,0)); visited.assign(n,0); for(int i=0;iarr[i][j]; } visited[i]=i; } //1->2->3-..

백준 18111번 마인크래프트 (C++) 🚩

https://www.acmicpc.net/problem/18111 18111번: 마인크래프트 팀 레드시프트는 대회 준비를 하다가 지루해져서 샌드박스 게임인 ‘마인크래프트’를 켰다. 마인크래프트는 1 × 1 × 1(세로, 가로, 높이) 크기의 블록들로 이루어진 3차원 세계에서 자유롭게 www.acmicpc.net 주의할점은 인벤토리 b가 중간에 마이너스가 되든 상관없다는것이다. 그건 순서의 문제니까 최종이 음수가 안되기만 되면 되는것!! #include #include #include using namespace std; vectorarr; vectorinfo; int n,m,b; long long cal(int num,int b){ long long cnt=0; for(int i=0;inum){ cnt..

백준 3085 사탕게임 C++

https://www.acmicpc.net/problem/3085 3085번: 사탕 게임 예제 3의 경우 4번 행의 Y와 C를 바꾸면 사탕 네 개를 먹을 수 있다. www.acmicpc.net #include #include using namespace std; int n; vectorarr; int check() { //최대 연속 갯수 //행,열 int cnt1 = 1; int cnt2 = 1; int maxs = 1; for (int i = 0; i < n; i++) { cnt1 = 1; cnt2 = 1; for (int j = 1; j < n; j++) { if (arr[i][j - 1] == arr[i][j]) { cnt1++; maxs = max(maxs, cnt1); } else cnt1 = ..

728x90
반응형