-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[브루트포스] 9월 27일 #6
base: main
Are you sure you want to change the base?
The head ref may contain hidden characters: "\uBE0C\uB8E8\uD2B8\uD3EC\uC2A4"
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2. 코드가 깔끔하네요. 전체적으로 잘 풀어주셨어요!! 👍 20055번은 가독성 면에서 훨씬 좋게 바꿀 수 있어서 수정을 추천드려요~! 수정하시고 저 다시 리뷰어로 호출해주세요! 수고하셨습니다!
int triangle(int t, int* tri){ | ||
|
||
for(int i=0; i<45; i++){ | ||
for(int j=0; j<45; j++){ | ||
for(int k=0; k<45; k++){ | ||
if(tri[i] + tri[j] + tri[k] == t) | ||
return 1; | ||
} | ||
} | ||
} | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3. 0 또는 1만 반환하네요! 무슨 자료형이 더 적합할까요?
int start = 1; | ||
int tri[45]; | ||
for(int i=2; i<47; i++){ | ||
tri[i-2] = start; | ||
start += i; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3. n까지의 합이라는 걸 활용해서 삼각수 잘 구해주셨어요! 👍👍👍 tri[1] = 1을 넣고, i를 지금처럼 2부터 tri[i] += tri[i-1] + i 로 구현하면 코드가 더 깔끔해질 것 같아요!
void moveRobot(vector<int> &durab, int up, int down, vector<bool> &robot, int n){ | ||
if(down>up){ | ||
for(int i=down-1; i>up; i--){ | ||
if(durab[i+1] > 0 && robot[i] && !robot[i+1]){ | ||
robot[i] = false; | ||
robot[i+1] = true; | ||
durab[i+1]--; | ||
} | ||
robot[down] = false; | ||
} | ||
} | ||
else if(down<up){ | ||
for(int i=down-1; i>=0; i--){ | ||
if(durab[i+1] > 0 && robot[i] && !robot[i+1]){ | ||
robot[i] = false; | ||
robot[i+1] = true; | ||
durab[i+1]--; | ||
} | ||
robot[down] = false; | ||
} | ||
for(int i=2*n-1; i>up; i--){ | ||
if(i==2*n-1){ | ||
if(durab[0] > 0 && robot[i] && !robot[0]){ | ||
robot[i] = false; | ||
robot[0] = true; | ||
durab[0]--; | ||
} | ||
} | ||
else if(durab[i+1] > 0 && robot[i] && !robot[i+1]){ | ||
robot[i] = false; | ||
robot[i+1] = true; | ||
durab[i+1]--; | ||
} | ||
robot[down] = false; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2. 같은 연산이 많이 중복되고 있네요!! 지금 up, down 관계가 여러 경우가 있어서 이렇게 해 주신 것 같아요. 하지만 이 부분은 하나의 반복문으로 합칠 수 있어요. moveBelt 함수에서 인덱스를 관리해주신 것처럼 접근할 수 있지 않을까요? 반복문은 꼭 for문만 있는 건 아니죠.
for(int i=0; i<8001; i++){ | ||
if(mode[i] > k){ | ||
k = mode[i]; | ||
index = i; | ||
count = 0; | ||
} | ||
else if(mode[i] == k && count<1){ | ||
count++; | ||
index = i; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍👍
if(t > max) | ||
max = t; | ||
if(t < min) | ||
min = t; | ||
mid[i] = t; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p3. 아래서 mid배열의 정렬이 이루어지네요! 그럼 꼭 max, min값 따로 변수로 구해야 할까요?
l = area/i; | ||
} | ||
int temp = (w-1)*2+(l-1)*2; | ||
if(temp == r && area-temp == b){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p2. 앞의 조건을 만족시킨다면, 뒤의 조건은 무조건 어떻게 되나요?
No description provided.