Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
1b80c8d
test
BlueStaxks Jun 29, 2022
16d90cd
test over
BlueStaxks Jun 29, 2022
a76eac7
Merge branch 'W-CodeTest-Study:main' into main
BlueStaxks Jul 8, 2022
b406d48
week1 upload
BlueStaxks Jul 8, 2022
286f3cf
week1 upload
BlueStaxks Jul 8, 2022
a2c9d85
Update 1-3.cpp
BlueStaxks Jul 8, 2022
753eb13
Update 1-4.cpp
BlueStaxks Jul 8, 2022
1d09278
upload
BlueStaxks Jul 8, 2022
4256f84
update
BlueStaxks Jul 8, 2022
7a8d761
update
BlueStaxks Jul 8, 2022
cecf084
Update 1-7.cpp
BlueStaxks Jul 10, 2022
ee7134c
Update 1-7.cpp
BlueStaxks Jul 10, 2022
91f890d
Update 1-4.cpp
BlueStaxks Jul 10, 2022
d372a5a
Update 1-4.cpp
BlueStaxks Jul 10, 2022
d671f1e
update
BlueStaxks Jul 10, 2022
d4a7213
Update 1-7.cpp
BlueStaxks Jul 10, 2022
abcc619
Update 1-4.cpp
BlueStaxks Jul 10, 2022
a177008
Update 1-4.cpp
BlueStaxks Jul 13, 2022
18796ce
Update 1-4.cpp
BlueStaxks Jul 13, 2022
8b81e6f
week2 upload
BlueStaxks Jul 15, 2022
f68b455
Merge branch 'W-CodeTest-Study:main' into main
BlueStaxks Jul 15, 2022
bed61e4
week2 upload
BlueStaxks Jul 15, 2022
ff33a68
Update 2-4.cpp
BlueStaxks Jul 15, 2022
9cbfa7b
Update 2-4.cpp
BlueStaxks Jul 15, 2022
083af5a
description edit
BlueStaxks Jul 16, 2022
2b4a9cc
update week2
BlueStaxks Jul 16, 2022
99f30be
var name change
BlueStaxks Jul 16, 2022
3788ea0
Update 2-7.cpp
BlueStaxks Jul 16, 2022
93e5a8a
Update 2-7.cpp
BlueStaxks Jul 16, 2022
dc9d59f
Update 2-7.cpp
BlueStaxks Jul 16, 2022
ff62d83
Update 2-7.cpp
BlueStaxks Jul 16, 2022
82bdc08
Update 2-7.cpp
BlueStaxks Jul 16, 2022
ebdbbbd
Update 2-4.cpp
BlueStaxks Jul 16, 2022
9fc19bc
Update 2-5.cpp
BlueStaxks Jul 18, 2022
006ed7c
Update 2-6.cpp
BlueStaxks Jul 18, 2022
708bd84
Update 2-7.cpp
BlueStaxks Jul 18, 2022
4a6fba5
Week4 Upload
BlueStaxks Jul 22, 2022
ca77641
Update 3-1.cpp
BlueStaxks Jul 22, 2022
92aec72
name change
BlueStaxks Jul 22, 2022
993af19
Week 3 update
BlueStaxks Jul 25, 2022
993883b
Update 3-7 징검다리.cpp
BlueStaxks Jul 26, 2022
bd41f7f
Update 3-5 이중우선순위큐.cpp
BlueStaxks Jul 27, 2022
ef5c30e
Merge branch 'main' of https://github.com/BlueStaxks/22S-CodeTest-Study
BlueStaxks Jul 27, 2022
b7ad09f
Update 3-6 입국심사.cpp
BlueStaxks Jul 27, 2022
ee9147a
Week4 upload
BlueStaxks Jul 29, 2022
5e98677
Merge branch 'main' of https://github.com/BlueStaxks/22S-CodeTest-Study
BlueStaxks Jul 29, 2022
9b42eaf
UPDATE
BlueStaxks Jul 29, 2022
0363d3e
Update 4-1 N으로표현.cpp
BlueStaxks Jul 31, 2022
a2049e8
아기상어 의사코드
BlueStaxks Aug 3, 2022
e2981a9
description update
BlueStaxks Aug 3, 2022
9362b87
3-1 update
BlueStaxks Aug 11, 2022
0719426
3-1 solution
BlueStaxks Aug 11, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
| 1주차 (07.07~07.10) | [단어정렬](https://www.acmicpc.net/problem/1181) | [다트게임](https://school.programmers.co.kr/learn/courses/30/lessons/17682) | [파일명정렬](https://school.programmers.co.kr/learn/courses/30/lessons/17686) | [매칭점수](https://school.programmers.co.kr/learn/courses/30/lessons/42893) | [키패드](https://school.programmers.co.kr/learn/courses/30/lessons/67256) | [양궁대회](https://school.programmers.co.kr/learn/courses/30/lessons/92342) | [외벽점검](https://school.programmers.co.kr/learn/courses/30/lessons/60062) |
| 2주차 (07.14~07.17) | | | | | | | |
| 3주차 (07.21~07.24) | | | | | | | |
| 4주차 (07.28~07.31) | | | | | | | |
| 4주차 (07.28~07.31) | | | | | | | |
32 changes: 32 additions & 0 deletions Week1/BlueStaxks/1-1 단어정렬.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
bool comp(string a, string b)
{
if (a.length() == b.length()) //길이가 같으면 사전순으로 정렬
return a < b;
return a.length() < b.length(); //길이가 다르면 긴 순서대로 정렬
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL); // 빠른 입출력을 위한 코드 3줄
int n, i;
cin >> n;
string t;
vector<string> v;
for (i = 0; i < n; ++i)
{
cin >> t;
v.push_back(t);
} //여기까지 그냥 입력
sort(v.begin(), v.end(), comp); //정렬함수
v.erase(unique(v.begin(), v.end()), v.end()); //중복 제거 함수
for (i = 0; i < v.size(); ++i)
cout << v[i] << '\n';
return 0;
}
59 changes: 59 additions & 0 deletions Week1/BlueStaxks/1-2 다트게임.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <string>
#include <math.h>
#include <vector>
using namespace std;
int solution(string dartResult)
{
int i = 0, s = (int)dartResult.length();
dartResult += '('; //문자열 bad_excess 방지용 문자 추가(i+1 이런 식으로 탐색할 때 문제가 없어짐)
int m = 1, d = 1, c = 0;
vector<int> v;
for (i = 0; i < s; ++i)
{
if (dartResult[i] == '#')
{
d *= -1;
v.push_back(c * d * m);
d = m = 1;
}
else if (dartResult[i] == '*')
{
m *= 2;
v.push_back(c * d * m);
d = m = 1;
if (v.size() > 1)
v[v.size() - 2] *= 2;
}
else if ('0' <= dartResult[i] && dartResult[i] <= '9')
{
if (i && dartResult[i - 1] != '*' && dartResult[i - 1] != '#')
v.push_back(c * d * m);
c = dartResult[i] - '0';
if (c == 1 && dartResult[i + 1] - '0' == 0)
{
c = 10;
i++;
}
}
else if (dartResult[i] == 'D') //S는 아무것도 안해도 됨
c = pow(c, 2);
else if (dartResult[i] == 'T')
c = pow(c, 3);
//printf("%d ", i);
}
if (dartResult[s - 1] != '#' && dartResult[s - 1] != '*')
v.push_back(c * d * m);
int su = 0;
for (i = 0; i < v.size(); ++i)
su += v[i];
return su;
}// * 3 T / # 9 D ~


#include <stdio.h>
int main()
{
string s = "1T2D3D#";
printf("%d", solution(s));
return 0;
}
54 changes: 54 additions & 0 deletions Week1/BlueStaxks/1-3 파일명정렬.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#include <string>
#include <vector>
using namespace std;
bool comp(string &a, string &b)
{
//printf("*");
int i = 0, j = 0, t1 = 0, t2 = 0;
char t;
string s1 = "", s2 = "";
while (!('0' <= a[i] && a[i] <= '9')) //헤드 파트
{
t = a[i];
if ('A' <= t && t <= 'Z')
t += 32;
s1 += t;
i++;
}
while (!('0' <= b[j] && b[j] <= '9'))
{
t = b[j];
if ('A' <= t && t <= 'Z')
t += 32;
s2 += t;
j++;
}
if (s1 != s2)
return s1 < s2;
while (('0' <= a[i] && a[i] <= '9')) //숫자 파트
{
t1 *= 10;
t1 += a[i] - '0';
i++;
}
while (('0' <= b[j] && b[j] <= '9'))
{
t2 *= 10;
t2 += b[j] - '0';
j++;
}
return t1 <= t2;
}
vector<string> solution(vector<string> files)
{
string t;
for (int i = 0; i < files.size(); ++i) //버블 정렬
for (int j = 0; j < files.size() - 1 - i; ++j)
if (!comp(files[j], files[j + 1]))
{
t = files[j];
files[j] = files[j + 1];
files[j + 1] = t;
}
return files;
}
111 changes: 111 additions & 0 deletions Week1/BlueStaxks/1-4 매칭점수.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
unordered_map<string, int> um;
string exOG(string& a) //page의 오리지널 주소 반환
{
int p1, p2;
p1 = a.find("<meta property=\"og:url\" content=\"");
p2 = a.find("\"/>\n", p1 + 33);
return a.substr(p1 + 33, p2 - (p1 + 33));
}
void down(string& a) //소문자로 바꾸기
{
int i;
for (i = 0; i < a.length(); ++i)
if ('A' <= a[i] && a[i] <= 'Z')
a[i] += 32;
}
int solution(string word, vector<string> pages)
{
int i, j, p, p1, p2, p3, c;
int n[20] = {}; //기본 점수
int ol[20] = {}; //외부 링크 개수
double s[20] = {}; //최종 점수
vector<string> pl;
vector<int> v[20];
down(word);
for (i = 0; i < pages.size(); ++i)
{
pl.push_back(exOG(pages[i])); //pl의 인덱스가 주소 string을 가지고 있음
um[pl.back()] = i; //um에 string(주소)를 넣으면 그 인덱스가 나옴
}
for (i = 0; i < pages.size(); ++i)
{
c = 0;
p1 = pages[i].find("/>\n</head> \n<body>\n");
string t = pages[i].substr(p1 + 20, pages[i].length() - 16 - (p1 + 20)); //t는 내용
down(t);
t += '*'; //bad_excess를 막기 위해 문자 추가 //찾는 값이 맨 뒤에 있을 수 없게 됨
p1 = t.find(word);
if (!p1 && !('a' <= t[p1 + word.length()] && t[p1 + word.length()] <= 'z')) //t의 시작부터 찾는 단어가 나올 수 있기에 따로 분류(아래에서 p1-1을 하는데 p1이 0이면 안됨)
c++;
p1 = t.find("<a href=\""); //t의 시작부터 외부 링크가 나올 수 있음
if (!p1)
{
p1 = t.find("\">", 10);
ol[i]++;
if (um.count(t.substr(9, p1 - 9)))
if (um[t.substr(9, p1 - 9)] != i) //i는 um[pl[i]]와 동일함
v[um[t.substr(9, p1 - 9)]].push_back(um[pl[i]]);
}
for (j = 1; j < t.length() - 1; ++j) //t(body)에서 단어와 외부 링크를 동시에 검색
{
if (j <= t.length() - word.length())
{
p1 = t.substr(j, word.length()).find(word); //p1은 제로 스케일
if (!p1) //찾는 단어가 j에 딱 있으면 걸림, 그때 p1은 0
if (!('a' <= t[j - 1] && t[j - 1] <= 'z') && !('a' <= t[j + word.length()] && t[j + word.length()] <= 'z')) //단어 앞 뒤로 알파벳이 있으면 안됨
{
c++;
j += word.length() - 1; //찾으면 j 점프
}
}
if (j <= t.length() - 9)
{
p1 = t.substr(j, 9).find("<a href=\"");
if (!p1)
{
p2 = t.find("\">", j + 10); //p2는 t 스케일
ol[i]++;
if (um.count(t.substr(j + 9, p2 - j - 9))) //unordered_map의 특성상 없는 key를 검색하면 0으로 나오기 때문에 v[0]이 되는 것을 막기 위해 먼저 key가 있는지 확인
if (um[t.substr(j + 9, p2 - j - 9)] != i)
v[um[t.substr(j + 9, p2 - j - 9)]].push_back(um[pl[i]]); //v[page에 써있는 외부 링크]에 지금 page의 주소를 추가 //이래야 나중에 검색이 쉬움
p3 = t.find("</a>", p2 + 2);
j = p3 + 2; //외부 링크 처리가 끝나면 j 점프
}
}
}
n[i] = c; //기본 점수
}
double td, ms = -1; //여기부턴 점수 집계
int ri;
for (i = 0; i < pages.size(); ++i)
{
s[i] = (double)n[i]; //먼저 기본 점수로 맞춰두기
td = 0;
for (j = 0; j < v[i].size(); ++j) //v[i]에는 i로 가는 j들이 있음
td += (double)n[v[i][j]] / (double)ol[v[i][j]];
s[i] += td;
if (s[i] > ms)
{
ms = s[i];
ri = i;
}
}
return ri;
}



#include <iostream>
int main()
{
vector<string> t;
t.push_back("<html lang=\"ko\" xml:lang=\"ko\" xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <meta charset=\"utf-8\">\n <meta property=\"og:url\" content=\"https://a.com\"/>\n</head> \n<body>\nBlind Lorem Blind ipsum dolor Blind test sit amet, consectetur adipiscing elit. \n<a href=\"https://b.com\"> Link to b </a>\n</body>\n</html>");
t.push_back("<html lang=\"ko\" xml:lang=\"ko\" xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <meta charset=\"utf-8\">\n <meta property=\"og:url\" content=\"https://b.com\"/>\n</head> \n<body>\nSuspendisse potenti. Vivamus venenatis tellus non turpis bibendum, \n<a href=\"https://a.com\"> Link to a </a>\nblind sed congue urna varius. Suspendisse feugiat nisl ligula, quis malesuada felis hendrerit ut.\n<a href=\"https://c.com\"> Link to c </a>\n</body>\n</html>");
t.push_back("<html lang=\"ko\" xml:lang=\"ko\" xmlns=\"http://www.w3.org/1999/xhtml\">\n<head>\n <meta charset=\"utf-8\">\n <meta property=\"og:url\" content=\"https://c.com\"/>\n</head> \n<body>\nUt condimentum urna at felis sodales rutrum. Sed dapibus cursus diam, non interdum nulla tempor nec. Phasellus rutrum enim at orci consectetu blind\n<a href=\"https://a.com\"> Link to a </a>\n</body>\n</html>");
cout << solution("BLIND", t);
return 0;
}
67 changes: 67 additions & 0 deletions Week1/BlueStaxks/1-5 키패드누르기.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#include <string>
#include <vector>
#include <math.h>
using namespace std;
pair<int, int> nown(int a)
{
if (a == 1) return { 1,4 };
if (a == 2) return { 2,4 };
if (a == 3) return { 3,4 };
if (a == 4) return { 1,3 };
if (a == 5) return { 2,3 };
if (a == 6) return { 3,3 };
if (a == 7) return { 1,2 };
if (a == 8) return { 2,2 };
if (a == 9) return { 3,2 };
if (a == 0) return { 2,1 };
}
int dis(pair<int, int> a, pair<int, int> b) //거리 구하기
{
return abs(a.first - b.first) + abs(a.second - b.second);
}
string solution(vector<int> numbers, string hand)
{
string answer = "";
int i;
pair<int, int> L = { 1,1 }, R = { 3,1 }, n;
for (i = 0; i < numbers.size(); ++i)
{
n = nown(numbers[i]);
if (numbers[i] == 1 || numbers[i] == 4 || numbers[i] == 7) //예외
{
answer += 'L';
L = n;
continue;
}
if (numbers[i] == 3 || numbers[i] == 6 || numbers[i] == 9) //예외
{
answer += 'R';
R = n;
continue;
}
if (dis(n, L) > dis(n, R)) //2,5,8,0일 때 더 가까운 거리 구하기
{
answer += 'R';
R = n;
}
else if (dis(n, L) < dis(n, R))
{
answer += 'L';
L = n;
}
else //거리가 같으면 자기 메인 손으로 누르기
{
if (hand[0] == 'r')
{
answer += 'R';
R = n;
}
else
{
answer += 'L';
L = n;
}
}
}
return answer;
}
Loading