Skip to content

Commit b672dbc

Browse files
committed
Lv3_캠핑 수정
1 parent f2e44ec commit b672dbc

File tree

4 files changed

+22
-105
lines changed

4 files changed

+22
-105
lines changed

Programmers/Lv3/Lv3_캠핑.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,22 @@ int solution104(int n, vector<vector<int>> data) {
2727
int end_up = start_y;
2828
int end_up_x = start_x;
2929
int end_down = start_y;
30-
int uc = 0;
31-
int dc = 0;
32-
set<pair<int, int>>::iterator temp1;
33-
for (temp1 = iter; temp1 != s.end(); temp1++) { // 위쪽 한계선 설정
34-
if (temp1->first != start_x && end_up < temp1->second) {
35-
end_up = temp1->second;
36-
end_up_x = temp1->first;
37-
break;
30+
set<pair<int, int>>::iterator temp;
31+
for (temp = iter; temp != s.end(); temp++) { // 한계선 설정
32+
if (end_up == start_y && temp->first != start_x && end_up < temp->second) {
33+
end_up = temp->second;
34+
end_up_x = temp->first;
3835
}
39-
}
4036

41-
set<pair<int, int>>::iterator temp2;
42-
for (temp2 = iter; temp2 != s.end(); temp2++) { // 아래쪽 한계선 설정
43-
if (temp2->first != start_x && end_down > temp2->second) {
44-
end_down = temp2->second;
45-
break;
37+
if (end_down == start_y && temp->first != start_x && end_down > temp->second) {
38+
end_down = temp->second;
4639
}
40+
41+
if (end_up != start_y && end_down != start_y)
42+
break;
4743
}
48-
4944

50-
int prev_end_up = end_up;
51-
int temp_x = end_up_x;
45+
int prev_end_up = INT_MAX;
5246
set<pair<int, int>>::iterator iter2;
5347
for (iter2 = iter; iter2 != s.end(); iter2++) {
5448
int end_x = iter2->first;
@@ -59,15 +53,15 @@ int solution104(int n, vector<vector<int>> data) {
5953

6054
if (end_y > start_y) {
6155
if (end_up >= end_y) {
62-
prev_end_up = end_up;
56+
if (end_up != end_y) {
57+
prev_end_up = end_up;
58+
end_up_x = end_x;
59+
}
6360
end_up = end_y; // 새로운 위쪽 한계선 갱신
64-
temp_x = end_x;
6561
answer++;
6662
}
6763
else {
68-
if (end_x == end_up_x)
69-
answer++;
70-
else if (end_x == temp_x && end_y <= prev_end_up)
64+
if (end_x == end_up_x && end_y <= prev_end_up)
7165
answer++;
7266
}
7367
}

Programmers/Lv3_캠핑.cpp

Lines changed: 0 additions & 81 deletions
This file was deleted.

Programmers/Programmers.vcxproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
<ClCompile Include="Lv3\Lv3_브라이언의고민.cpp" />
111111
<ClCompile Include="Lv3\Lv3_섬연결하기.cpp" />
112112
<ClCompile Include="Lv3\Lv3_순위.cpp" />
113+
<ClCompile Include="Lv3\Lv3_숫자게임.cpp" />
113114
<ClCompile Include="Lv3\Lv3_여행경로.cpp" />
114115
<ClCompile Include="Lv3\Lv3_예산.cpp" />
115116
<ClCompile Include="Lv3\Lv3_이중우선순위큐.cpp" />
@@ -119,9 +120,9 @@
119120
<ClCompile Include="Lv3\Lv3_줄서는방법.cpp" />
120121
<ClCompile Include="Lv3\Lv3_짝지어제거하기.cpp" />
121122
<ClCompile Include="Lv3\Lv3_카카오프렌즈컬러링북.cpp" />
123+
<ClCompile Include="Lv3\Lv3_캠핑.cpp" />
122124
<ClCompile Include="Lv3\Lv3_타일장식물.cpp" />
123125
<ClCompile Include="Lv3\Lv3_하노이의탑.cpp" />
124-
<ClCompile Include="Lv3_캠핑.cpp" />
125126
<ClCompile Include="Lv4\Lv4_카드게임.cpp" />
126127
<ClCompile Include="실전모의고사2회\배열회전.cpp" />
127128
<ClCompile Include="실전모의고사2회\가로등.cpp" />

Programmers/Programmers.vcxproj.filters

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,10 @@
333333
<ClCompile Include="Lv3\Lv3_배달.cpp">
334334
<Filter>소스 파일</Filter>
335335
</ClCompile>
336-
<ClCompile Include="Lv3_캠핑.cpp">
336+
<ClCompile Include="Lv3\Lv3_숫자게임.cpp">
337+
<Filter>소스 파일</Filter>
338+
</ClCompile>
339+
<ClCompile Include="Lv3\Lv3_캠핑.cpp">
337340
<Filter>소스 파일</Filter>
338341
</ClCompile>
339342
</ItemGroup>

0 commit comments

Comments
 (0)