From 652101cbfbcb90ca067316e8a4e7bf7e42d11856 Mon Sep 17 00:00:00 2001 From: sari-harin Date: Wed, 6 Sep 2023 18:32:12 +0900 Subject: [PATCH 01/14] =?UTF-8?q?[=20=EC=A0=95=EC=88=98=EB=A1=A0=20]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1735.cpp" | 35 +++++++++++ .../2840.cpp" | 59 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 "03_\354\240\225\354\210\230\353\241\240/1735.cpp" create mode 100644 "03_\354\240\225\354\210\230\353\241\240/2840.cpp" diff --git "a/03_\354\240\225\354\210\230\353\241\240/1735.cpp" "b/03_\354\240\225\354\210\230\353\241\240/1735.cpp" new file mode 100644 index 0000000..c6a8ada --- /dev/null +++ "b/03_\354\240\225\354\210\230\353\241\240/1735.cpp" @@ -0,0 +1,35 @@ + +#include + +using namespace std; + +int getGcd(int a, int b) { + int tmp; + while (b != 0) { + tmp = a % b; + a = b; + b = tmp; + } + return a; +} + + +int main() +{ + int a1, a2, b1, b2, c1, c2; + + cin >> a1 >> a2; + cin >> b1 >> b2; + + c1 = a1*b2 + a2*b1; + c2 = a2*b2; + + int gcd_c = getGcd(c1,c2); + + c1/=gcd_c; + c2/=gcd_c; + + cout << c1 << ' ' << c2; + + return 0; +} \ No newline at end of file diff --git "a/03_\354\240\225\354\210\230\353\241\240/2840.cpp" "b/03_\354\240\225\354\210\230\353\241\240/2840.cpp" new file mode 100644 index 0000000..1924af6 --- /dev/null +++ "b/03_\354\240\225\354\210\230\353\241\240/2840.cpp" @@ -0,0 +1,59 @@ +#include +#include + +using namespace std; + +int main() +{ + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, k, pt; + + cin >> n >> k; + + vector arr(n,'?'); + + for(int i=0;i> turns >> c; + + if(i==0){ + pt=i; + arr[i]=c; + continue; + } + + pt=(pt+turns)%n; + if(arr[pt]!='?' && arr[pt]!=c){ + cout << "!"; + return 0; + } + else{ + arr[pt]=c; + } + + } + + for(int i=0;i Date: Thu, 7 Sep 2023 22:07:53 +0900 Subject: [PATCH 02/14] =?UTF-8?q?[=20=EC=A0=95=EC=88=98=EB=A1=A0=20]=209?= =?UTF-8?q?=EC=9B=94=207=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../6588.cpp" | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 "03_\354\240\225\354\210\230\353\241\240/6588.cpp" diff --git "a/03_\354\240\225\354\210\230\353\241\240/6588.cpp" "b/03_\354\240\225\354\210\230\353\241\240/6588.cpp" new file mode 100644 index 0000000..ad3036d --- /dev/null +++ "b/03_\354\240\225\354\210\230\353\241\240/6588.cpp" @@ -0,0 +1,55 @@ +#include +#include +#include + +using namespace std; + +vector getPrimes(int n) { //소수 여부를 반환 + vector is_prime(n + 1, true); //소수 여부를 저장할 벡터 + is_prime[0] = is_prime[1] = false; //0과 1은 소수가 아니므로 false 저장 + for (int i = 2; i * i <= n; i++) { //n의 제곱근보다 낮은 범위에서 탐색 + if (!is_prime[i]) { //소수가 아닐 시 + continue; //처음으로 되돌아감 + } + for (int j = i * i; j <= n; j += i) { //배수는 제외 + is_prime[j] = false; //배수는 제외 + } + } + return is_prime; //결과 리턴(소수 여부가 저장된 벡터) +} + + +int goldbach(int n, vector &is_prime) { //n=a+b인 a 리턴 + for (int a = 3; a <= n / 2; a+= 2) { //3부터 홀수 중 탐색(2보다 큰 짝수 소수는 존재하지 않기 때문) + if (is_prime[a] && is_prime[n - a]) { //n=a+b에서 a와 b가 모두 소수라면 + return a; //n=a+b인 a 리턴 + } + } + return 0; //해당하는 a와 b가 없으면 0 리턴 +} + +int main() { //메인함수 + vector arr; //배열 선언 + int input; //입력값 받을 변수 + while(1) { //무한반복 + cin >> input; //입력 받기 + if (input == 0) { //사용자가 0을 입력하면 + break; //루프 끝 + } + arr.push_back(input); //벡터 끝에 입력값 넣기 + } + + int max_num = *max_element(arr.begin(), arr.end()); //배열의 처음부터 끝까지 가장 큰 수를 저장(값 참조) + vector is_prime = getPrimes(max_num); //소수 얻기 + + for (int i = 0; i < arr.size(); i++) { //배열 내에서 반복 + int a = goldbach(arr[i], is_prime); //n=a+b인 a 리턴 + + if (a != 0) { // n=a+b인 a, b가 존재하는 경우 + cout << arr[i] << " = " << a << " + " << arr[i] - a << "\n"; //결과 출력 + } else { //존재하지 않는 경우 + cout << "Goldbach's conjecture is wrong.\n"; //결과 출력 + } + } + return 0; //종료 +} \ No newline at end of file From daf12131bf2260480924db026d1f16af1566a11d Mon Sep 17 00:00:00 2001 From: sari-harin Date: Wed, 13 Sep 2023 15:44:50 +0900 Subject: [PATCH 03/14] =?UTF-8?q?[=20=EB=B8=8C=EB=A3=A8=ED=8A=B8=ED=8F=AC?= =?UTF-8?q?=EC=8A=A4=20]=209=EC=9B=94=2013=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1063.cpp" | 71 +++++++++++++++++++ .../11723.cpp" | 48 +++++++++++++ .../1436.cpp" | 32 +++++++++ 3 files changed, 151 insertions(+) create mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" create mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" create mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1436.cpp" diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" new file mode 100644 index 0000000..8fa7b70 --- /dev/null +++ "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" @@ -0,0 +1,71 @@ +#include +#include + +using namespace std; + +int main() +{ + string king, rock, dir_str; + int num, kingX, kingY, rockX, rockY, dir; + + cin >> king >> rock >> num; + + kingX='8'-king[1]; + kingY=king[0]-'A'; + rockX='8'-rock[1]; + rockY=rock[0]-'A'; + + int chessX[8]={0, 0, 1, -1, -1, -1, 1, 1}; + int chessY[8]={1, -1, 0, 0, 1, -1, 1, -1}; + + for(int i=0;i> dir_str; + if(dir_str=="R"){ + dir=0; + } + else if(dir_str=="L"){ + dir=1; + } + else if(dir_str=="B"){ + dir=2; + } + else if(dir_str=="T"){ + dir=3; + } + else if(dir_str=="RT"){ + dir=4; + } + else if(dir_str=="LT"){ + dir=5; + } + else if(dir_str=="RB"){ + dir=6; + } + else if(dir_str=="LB"){ + dir=7; + } + + int kx=kingX+chessX[dir]; + int ky=kingY+chessY[dir]; + + if (kx<0 || kx>7 || ky<0 || ky>7){ + continue; + } + if(kx==rockX && ky==rockY){ + int rx=rockX+chessX[dir]; + int ry=rockY+chessY[dir]; + if(rx<0 || rx>7 || ry<0 || ry>7){ + continue; + } + rockX=rx; + rockY=ry; + } + kingX=kx; + kingY=ky; + } + + cout << (char)(kingY+'A') << 8-kingX << '\n'; + cout << (char)(rockY+'A') << 8-rockX << '\n'; + + return 0; +} \ No newline at end of file diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" new file mode 100644 index 0000000..f91d05f --- /dev/null +++ "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" @@ -0,0 +1,48 @@ +#include + +using namespace std; + +int main(){ + + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, S=0, cmd_num; + string cmd=""; + + cin >> n; + + for(int i=0;i> cmd; + if(cmd=="add"){ + cin>>cmd_num; + S|=(1<> cmd_num; + S&= ~(1<>cmd_num; + if(S&(1<>cmd_num; + S^=(1< + +using namespace std; + +int main(){ + + int n, n_temp, count=1, num=666; + + cin >> n; + + while(count!=n){ + if(n==1){ + break; + } + + num++; + n_temp=num; + + while(n_temp!=0){ + if(n_temp%1000==666){ + count++; + break; + } + else{ + n_temp/=10; + } + } + } + + cout << num; + return 0; +} \ No newline at end of file From 56b322059e48c47753ddbaee2ea7dda061964fdf Mon Sep 17 00:00:00 2001 From: sari-harin Date: Tue, 19 Sep 2023 22:34:29 +0900 Subject: [PATCH 04/14] =?UTF-8?q?[=20=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84?= =?UTF-8?q?=20=ED=81=90=20]=209=EC=9B=94=2019=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14235.cpp" | 33 +++++++++++++++++++ .../2075.cpp" | 29 ++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" create mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" new file mode 100644 index 0000000..c11e09b --- /dev/null +++ "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" @@ -0,0 +1,33 @@ +#include +#include + +using namespace std; + +int main() +{ + int n, a, gift; + priority_queue pq; + + cin >> n; + + while(n--){ + cin >> a; + if(a==0){ + if(pq.empty()){ + cout << -1 << '\n'; + } + else{ + cout << pq.top() << '\n'; + pq.pop(); + } + } + else{ + while(a--){ + cin >> gift; + pq.push(gift); + } + } + } + + return 0; +} \ No newline at end of file diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" new file mode 100644 index 0000000..b7ac188 --- /dev/null +++ "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" @@ -0,0 +1,29 @@ +#include +#include + +using namespace std; + +int main() +{ + + ios_base::sync_with_stdio(false); + cin.tie(NULL); + cout.tie(NULL); + + int n, num; + priority_queue, greater> pq; + + cin >> n; + + for(int i=0;i> num; + pq.push(num); + if(pq.size() > n){ + pq.pop(); + } + } + + cout << pq.top(); + + return 0; +} \ No newline at end of file From 80d27a9cba939513f76e6e8d8420f2c34f74fc9f Mon Sep 17 00:00:00 2001 From: sari-harin <1303sari@gmail.com> Date: Thu, 21 Sep 2023 21:38:09 +0900 Subject: [PATCH 05/14] =?UTF-8?q?[=20=EC=9A=B0=EC=84=A0=EC=88=9C=EC=9C=84?= =?UTF-8?q?=20=ED=81=90=20]=209=EC=9B=94=2021=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2607.cpp" | 49 +++++++++++++++++++ Altu-Bitu-HarinLee | 1 + 2 files changed, 50 insertions(+) create mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" create mode 160000 Altu-Bitu-HarinLee diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" new file mode 100644 index 0000000..991d314 --- /dev/null +++ "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" @@ -0,0 +1,49 @@ +#include +#include + +using namespace std; + +const int NUM_CHARS = 26; //상수 선언 + +void countFreq(string word, vector &freq) { //각 알파벡의 개수를 센다 + for (int i = 0; i < word.length(); i++) { //받은 단어의 알파벳을 모두 돌며 + freq[word[i] - 'A']++; //받은 벡터에 각 알파벳의 개수를 센다 + } +} + +int countDiff(string word, vector original_freq) { //차이를 센다 + vector freq(NUM_CHARS, 0); //빈도(개수)를 세는 벡터 + int diff = 0; //원본 단어와의 차이를 저장할 변수 + + countFreq(word, freq); // 각 알파벳의 개수 세기 + + for (int i = 0; i < NUM_CHARS; i++) { //알파벳 개수동안 + diff += abs(original_freq[i] - freq[i]); //원본 단어와 다른 알파벳의 개수를 변수에 넣기 + } + return diff; //diff를 반환 +} + +int main() { //메인 + int N, ans=0; //입력받을 변수와 결과를 담을 변수 + string original; //원본 문자열 + + cin >> N; //입력 받기 + cin >> original; //원본 문자열 입력 받기 + vector original_freq(NUM_CHARS, 0); //기존 문자열에서 알파벳의 개수를 저장할 벡터 + + countFreq(original, original_freq); //기존 문자열의 알파벳의 개수 계산 + + for (int i = 1; i < N; i++) { //입력받은 n만큼 반복 + string word; //비교할 문자열 + cin >> word; //비교할 문자열 입력받기 + + int diff = countDiff(word, original_freq); //기존 문자열과의 차이 저장 + + if (diff == 0 || diff == 1 || diff == 2 && original.length() == word.length()) { //조건에 맞는 비슷한 단어라면 + ans++; //개수 세기 + } + } + + cout << ans; //결과 출력 + return 0; //종료 +} \ No newline at end of file diff --git a/Altu-Bitu-HarinLee b/Altu-Bitu-HarinLee new file mode 160000 index 0000000..f130cd7 --- /dev/null +++ b/Altu-Bitu-HarinLee @@ -0,0 +1 @@ +Subproject commit f130cd7f4ff148f6934d363c983778c53bb07e90 From f1c9ca51822e3d304e418639776736e0cb31067b Mon Sep 17 00:00:00 2001 From: sari-harin <1303sari@gmail.com> Date: Tue, 17 Oct 2023 00:18:05 +0900 Subject: [PATCH 06/14] =?UTF-8?q?[=20=EB=B0=B1=ED=8A=B8=EB=9E=98=ED=82=B9?= =?UTF-8?q?=20]=2010=EC=9B=94=2017=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1213.cpp" | 17 ++++++ .../14888.cpp" | 59 +++++++++++++++++++ .../15665.cpp" | 47 +++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 "06_\352\267\270\353\246\254\353\224\224/1213.cpp" create mode 100644 "09_\353\260\261\355\212\270\353\236\230\355\202\271/14888.cpp" create mode 100644 "09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" diff --git "a/06_\352\267\270\353\246\254\353\224\224/1213.cpp" "b/06_\352\267\270\353\246\254\353\224\224/1213.cpp" new file mode 100644 index 0000000..e1cf537 --- /dev/null +++ "b/06_\352\267\270\353\246\254\353\224\224/1213.cpp" @@ -0,0 +1,17 @@ +#include + +using namespace std; + +int main() +{ + string s; + int english[26]; + + cin >> s; + + for(int i=0;i + +using namespace std; + +void calculate(int n, int &maxnum, int &minnum, int result, int cnt, int nums[11], int ops[4]) +{ + if(cnt==n) + { + if(result>maxnum){ + maxnum=result; + } + if(result> n; + + for(int i=0; i> nums[i]; + } + for(int i=0; i<4; i++){ + cin >> ops[i]; + } + + calculate(n, maxnum, minnum, nums[0],1,nums,ops); + cout << maxnum << '\n' << minnum; +} \ No newline at end of file diff --git "a/09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" "b/09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" new file mode 100644 index 0000000..d5372d8 --- /dev/null +++ "b/09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" @@ -0,0 +1,47 @@ +#include +#include +#include + +using namespace std; + +void numorder(int n, int m, int num, vector nums, int (&answer)[8]){ + if(num==m){ + + for(int i=0; i nums; + int answer[8]; + + cin >> n >> m; + + for (int i=0; i> num; + nums.push_back(num); + } + + sort(nums.begin(), nums.end()); + + numorder(n, m, 0, nums, answer); + + return 0; +} \ No newline at end of file From dd90cdc05bb46d0ce5d3e11e094f13488c3009f2 Mon Sep 17 00:00:00 2001 From: sari-harin <1303sari@gmail.com> Date: Sat, 11 Nov 2023 17:33:13 +0900 Subject: [PATCH 07/14] =?UTF-8?q?[=20=ED=88=AC=ED=8F=AC=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=20]=2011=EC=9B=94=2011=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20922.cpp" | 37 ++++++++++++++++++ .../2531.cpp" | 39 +++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 "11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" create mode 100644 "11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" diff --git "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" new file mode 100644 index 0000000..66b12d4 --- /dev/null +++ "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" @@ -0,0 +1,37 @@ +#include +#include + +using namespace std; + +int main(){ + + ios::sync_with_stdio(false); + cin.tie(NULL);cout.tie(NULL); + + int n, k, start=0, end=0, answer=0; + int num[200001]; + int cnt[100001]; + + cin >> n >> k; + + for(int i=0;i> num[i]; + } + + while(startstart-end?answer:start-end; + } + + cout << answer; + + return 0; +} \ No newline at end of file diff --git "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" new file mode 100644 index 0000000..3e6b832 --- /dev/null +++ "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" @@ -0,0 +1,39 @@ +#include +#include +#include + +using namespace std; + +int main() +{ + int n, d, c, k, cnt, doubled, coupon, answer=0; + int table[30000]; + bool check[30000]; + + cin >> n >> d >> k >> c; + + for(int i=0;i> table[i]; + } + + for(int i=0;i(k-doubled+coupon)?answer:k-doubled+coupon; + memset(check, false, sizeof(check)); + } + cout << answer; + + return 0; +} \ No newline at end of file From ece377f1e242bf084fa7f54b146d9001876b6667 Mon Sep 17 00:00:00 2001 From: sari-harin <1303sari@gmail.com> Date: Tue, 21 Nov 2023 23:42:41 +0900 Subject: [PATCH 08/14] =?UTF-8?q?[=20=ED=8A=B8=EB=A6=AC=20]=2011=EC=9B=94?= =?UTF-8?q?=2021=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14503.cpp" | 86 ++++++++++++++++++ "12_\355\212\270\353\246\254/1390.cpp" | 69 ++++++++++++++ "12_\355\212\270\353\246\254/15681.cpp" | 50 +++++++++++ "12_\355\212\270\353\246\254/1967.cpp" | 54 +++++++++++ "12_\355\212\270\353\246\254/24545.cpp" | 90 +++++++++++++++++++ "12_\355\212\270\353\246\254/5639.cpp" | 42 +++++++++ 6 files changed, 391 insertions(+) create mode 100644 "11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" create mode 100644 "12_\355\212\270\353\246\254/1390.cpp" create mode 100644 "12_\355\212\270\353\246\254/15681.cpp" create mode 100644 "12_\355\212\270\353\246\254/1967.cpp" create mode 100644 "12_\355\212\270\353\246\254/24545.cpp" create mode 100644 "12_\355\212\270\353\246\254/5639.cpp" diff --git "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" new file mode 100644 index 0000000..98957a9 --- /dev/null +++ "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" @@ -0,0 +1,86 @@ +#include +#include + +using namespace std; + +const int SIZE = 50; +const int CLEAN = 2; +int n, m; //방의 크기 +int cnt = 0; //청소한 칸 개수 + +vector> board(SIZE, vector(SIZE)); //방 (0: 빈 칸, 1: 벽, 2: 청소 완료) + +//4가지 방향: { 북, 동, 남, 서 } +int dx[4] = { 0, 1, 0, -1 }; +int dy[4] = { -1, 0, 1, 0 }; + +void dfs(int row, int col, int dir) { + //1. 현재 위치 청소 + if (board[row][col] != CLEAN) { + cnt++; + board[row][col] = CLEAN; + } + + //[현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 있는가] + //3. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 있는 경우 + for (int i = 0; i < 4; i++) { //3-1. 반시계 방향으로 90º 회전 + int new_dir = (dir - i + 3) % 4; + int new_row = row + dy[new_dir], new_col = col + dx[new_dir]; + + if (board[new_row][new_col] == 0) { //3-2. 아직 청소되지 않은 빈 칸 발견 + dfs(new_row, new_col, new_dir); //한 칸 전진 + return; + } + } + + //2. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 없는 경우 + int back_dir = (dir + 2) % 4; + int back_row = row + dy[back_dir], back_col = col + dx[back_dir]; + + //[바라보는 방향을 유지한 채로 한 칸 후진할 수 있는가] + //2-2. 뒤쪽 칸이 벽이라 후진할 수 없는 경우 + if (board[back_row][back_col] == 1) { + return; + } + + //2-1. 바라보는 방향을 유지한 채로 한 칸 후진 + dfs(back_row, back_col, dir); //방향 유지한 상태로 후진 (2-3) + return; +} + +/* +[로봇 청소기 작동] +1. 현재 칸이 아직 청소되지 않은 경우, 현재 칸을 청소한다. +2. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 없는 경우, + 2-1. 바라보는 방향을 유지한 채로 한 칸 후진할 수 있다면 한 칸 후진하고 1번으로 돌아간다. + 2-2. 바라보는 방향의 뒤쪽 칸이 벽이라 후진할 수 없다면 작동을 멈춘다. +3. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 있는 경우, + 3-1. 반시계 방향으로 90º 회전한다. + 3-2. 바라보는 방향을 기준으로 앞쪽 칸이 청소되지 않은 빈 칸인 경우 한 칸 전진한다. + 3-3. 1번으로 돌아간다. +*/ + +int main() { + ios::sync_with_stdio(false); + cin.tie(NULL); cout.tie(NULL); + + int r, c, d; //로봇 청소기 정보 + + //입력 + cin >> n >> m; + cin >> r >> c >> d; + + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + cin >> board[i][j]; + } + } + + //연산 + dfs(r, c, d); + + //출력 + cout << cnt; + + return 0; +} \ No newline at end of file diff --git "a/12_\355\212\270\353\246\254/1390.cpp" "b/12_\355\212\270\353\246\254/1390.cpp" new file mode 100644 index 0000000..783d068 --- /dev/null +++ "b/12_\355\212\270\353\246\254/1390.cpp" @@ -0,0 +1,69 @@ +#include +#include + +using namespace std; + +int main(){ + + int n, x_in, y_in , k, l, cnt=0, dir=0, x=0, y=0; + char d; + + int board[101][101]; + bool visited[101][101]; + queue> snake; + int dx[4]={1, 0, -1, 0}; + int dy[4]={0, 1, 0, -1}; + + snake.push(make_pair(x, y)); + + cin >> n; + cin >> k; + + for(int i=0;i> x_in >> y_in; + board[x_in-1][y_in-1]=1; + } + + cin>>l; + + for(int i=0;i> num >> d; + + while(cnt=n||ny>=n||visited[ny][nx]){ + cout << cnt; + return 0; + } + if(board[ny][nx]==1){ + board[ny][nx]=0; + snake.push(make_pair(nx, ny)); + visited[ny][nx]=true; + } + else{ + snake.push(make_pair(nx,ny)); + visited[ny][nx]=true; + visited[snake.front().second][snake.front().first]=false; + snake.pop(); + } + + x=nx; + y=ny; + if(cnt==num){ + if(d=='D'){ + dir=(dir+1)%4; + } + else if(d=='L'){ + dir=(dir+3)%4; + } + } + } + } + return 0; +} \ No newline at end of file diff --git "a/12_\355\212\270\353\246\254/15681.cpp" "b/12_\355\212\270\353\246\254/15681.cpp" new file mode 100644 index 0000000..f75b3d1 --- /dev/null +++ "b/12_\355\212\270\353\246\254/15681.cpp" @@ -0,0 +1,50 @@ +#include +#include +#include + +using namespace std; + +vector v[100001]; +bool visited[100001]; +int num_arr[100001]; + +void dfs(int num, int upperN) { + visited[num]=true; + for(int i=0;i> n >> r >> q; + fill_n(num_arr,100001,1); + + for(int i=0;i> temp1 >> temp2; + v[temp1].push_back(temp2); + v[temp2].push_back(temp1); + } + + dfs(r, -1); + + for(int i=0;i> temp; + cout << num_arr[temp] << '\n'; + } + return 0; +} \ No newline at end of file diff --git "a/12_\355\212\270\353\246\254/1967.cpp" "b/12_\355\212\270\353\246\254/1967.cpp" new file mode 100644 index 0000000..854218c --- /dev/null +++ "b/12_\355\212\270\353\246\254/1967.cpp" @@ -0,0 +1,54 @@ +#include +#include +#include + +using namespace std; + +bool visited[100001]; +vector> board[100001]; +int endI; + +void dfs(int x, int len, int &answer){ + + if(visited[x]==true){ + return; + } + + visited[x]=true; + + if(len>answer){ + answer=len; + endI=x; + } + + for(int i=0;i> n; + + for(int i=1;i> o >> p >> q; + + board[o].push_back(make_pair(p,q)); + board[p].push_back(make_pair(o,q)); + } + + dfs(1,0,answer); + + memset(visited,false,sizeof(visited)); + + dfs(endI,0,answer); + + cout << answer; + + return 0; +} \ No newline at end of file diff --git "a/12_\355\212\270\353\246\254/24545.cpp" "b/12_\355\212\270\353\246\254/24545.cpp" new file mode 100644 index 0000000..69ed3a8 --- /dev/null +++ "b/12_\355\212\270\353\246\254/24545.cpp" @@ -0,0 +1,90 @@ +#include +#include + +using namespace std; + +vector> vec(100001, vector()); +int twoV[2]={0,0}; +int max_len=-1; +vector board(100001, 0); +bool visited[100001]; + +void dfs(int nowN, int prevN, int len, int i, int &n){ + if(max_len> n; + + for(int i=1;i<=n-1;i++){ + int temp1, temp2; + cin >> temp1 >> temp2; + vec[temp1].push_back(temp2); + vec[temp2].push_back(temp1); + } + for(int i=0;i<100001;i++){ + visited[i]=false; + } + dfs(1, 0, 0, 0, n); + max_len=-1; + dfs(twoV[0], 0, 0, 1, n); + route(twoV[0], twoV[1], 0, 0); + + for(int i=0;i<=max_len;i++){ + visited[board[i]]=true; + } + int maxInt=1; + for(int i=1;i<=max_len-1;i++){ + maxInt=max(maxInt,dfs2(board[i])); + } + cout << (maxInt==1?0:max_len+maxInt); + + return 0; +} diff --git "a/12_\355\212\270\353\246\254/5639.cpp" "b/12_\355\212\270\353\246\254/5639.cpp" new file mode 100644 index 0000000..b0ed0bc --- /dev/null +++ "b/12_\355\212\270\353\246\254/5639.cpp" @@ -0,0 +1,42 @@ +#include +#include + +using namespace std; + +vector tree; + +void searchTree(int start, int end){ + int i; + + if(start>=end){ + return; + } + if(start==end-1){ + cout << tree[start] << '\n'; + return; + } + + for(i=start+1;i> n){ + tree.push_back(n); + } + + searchTree(0,tree.size()); + + return 0; +} \ No newline at end of file From 3787196213f6200a0ab9dd75d45b8c2d8b976b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:44:08 +0900 Subject: [PATCH 09/14] =?UTF-8?q?Delete=2003=5F=EC=A0=95=EC=88=98=EB=A1=A0?= =?UTF-8?q?=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1735.cpp" | 35 ----------- .../2840.cpp" | 59 ------------------- .../6588.cpp" | 55 ----------------- 3 files changed, 149 deletions(-) delete mode 100644 "03_\354\240\225\354\210\230\353\241\240/1735.cpp" delete mode 100644 "03_\354\240\225\354\210\230\353\241\240/2840.cpp" delete mode 100644 "03_\354\240\225\354\210\230\353\241\240/6588.cpp" diff --git "a/03_\354\240\225\354\210\230\353\241\240/1735.cpp" "b/03_\354\240\225\354\210\230\353\241\240/1735.cpp" deleted file mode 100644 index c6a8ada..0000000 --- "a/03_\354\240\225\354\210\230\353\241\240/1735.cpp" +++ /dev/null @@ -1,35 +0,0 @@ - -#include - -using namespace std; - -int getGcd(int a, int b) { - int tmp; - while (b != 0) { - tmp = a % b; - a = b; - b = tmp; - } - return a; -} - - -int main() -{ - int a1, a2, b1, b2, c1, c2; - - cin >> a1 >> a2; - cin >> b1 >> b2; - - c1 = a1*b2 + a2*b1; - c2 = a2*b2; - - int gcd_c = getGcd(c1,c2); - - c1/=gcd_c; - c2/=gcd_c; - - cout << c1 << ' ' << c2; - - return 0; -} \ No newline at end of file diff --git "a/03_\354\240\225\354\210\230\353\241\240/2840.cpp" "b/03_\354\240\225\354\210\230\353\241\240/2840.cpp" deleted file mode 100644 index 1924af6..0000000 --- "a/03_\354\240\225\354\210\230\353\241\240/2840.cpp" +++ /dev/null @@ -1,59 +0,0 @@ -#include -#include - -using namespace std; - -int main() -{ - ios_base::sync_with_stdio(false); - cin.tie(NULL); - cout.tie(NULL); - - int n, k, pt; - - cin >> n >> k; - - vector arr(n,'?'); - - for(int i=0;i> turns >> c; - - if(i==0){ - pt=i; - arr[i]=c; - continue; - } - - pt=(pt+turns)%n; - if(arr[pt]!='?' && arr[pt]!=c){ - cout << "!"; - return 0; - } - else{ - arr[pt]=c; - } - - } - - for(int i=0;i -#include -#include - -using namespace std; - -vector getPrimes(int n) { //소수 여부를 반환 - vector is_prime(n + 1, true); //소수 여부를 저장할 벡터 - is_prime[0] = is_prime[1] = false; //0과 1은 소수가 아니므로 false 저장 - for (int i = 2; i * i <= n; i++) { //n의 제곱근보다 낮은 범위에서 탐색 - if (!is_prime[i]) { //소수가 아닐 시 - continue; //처음으로 되돌아감 - } - for (int j = i * i; j <= n; j += i) { //배수는 제외 - is_prime[j] = false; //배수는 제외 - } - } - return is_prime; //결과 리턴(소수 여부가 저장된 벡터) -} - - -int goldbach(int n, vector &is_prime) { //n=a+b인 a 리턴 - for (int a = 3; a <= n / 2; a+= 2) { //3부터 홀수 중 탐색(2보다 큰 짝수 소수는 존재하지 않기 때문) - if (is_prime[a] && is_prime[n - a]) { //n=a+b에서 a와 b가 모두 소수라면 - return a; //n=a+b인 a 리턴 - } - } - return 0; //해당하는 a와 b가 없으면 0 리턴 -} - -int main() { //메인함수 - vector arr; //배열 선언 - int input; //입력값 받을 변수 - while(1) { //무한반복 - cin >> input; //입력 받기 - if (input == 0) { //사용자가 0을 입력하면 - break; //루프 끝 - } - arr.push_back(input); //벡터 끝에 입력값 넣기 - } - - int max_num = *max_element(arr.begin(), arr.end()); //배열의 처음부터 끝까지 가장 큰 수를 저장(값 참조) - vector is_prime = getPrimes(max_num); //소수 얻기 - - for (int i = 0; i < arr.size(); i++) { //배열 내에서 반복 - int a = goldbach(arr[i], is_prime); //n=a+b인 a 리턴 - - if (a != 0) { // n=a+b인 a, b가 존재하는 경우 - cout << arr[i] << " = " << a << " + " << arr[i] - a << "\n"; //결과 출력 - } else { //존재하지 않는 경우 - cout << "Goldbach's conjecture is wrong.\n"; //결과 출력 - } - } - return 0; //종료 -} \ No newline at end of file From 49dd92703d5859a0c14231602b88bb32e9edd75e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:44:18 +0900 Subject: [PATCH 10/14] =?UTF-8?q?Delete=2004=5F=EB=B8=8C=EB=A3=A8=ED=8A=B8?= =?UTF-8?q?=ED=8F=AC=EC=8A=A4=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1063.cpp" | 71 ------------------- .../11723.cpp" | 48 ------------- .../1436.cpp" | 32 --------- 3 files changed, 151 deletions(-) delete mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" delete mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" delete mode 100644 "04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1436.cpp" diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" deleted file mode 100644 index 8fa7b70..0000000 --- "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/1063.cpp" +++ /dev/null @@ -1,71 +0,0 @@ -#include -#include - -using namespace std; - -int main() -{ - string king, rock, dir_str; - int num, kingX, kingY, rockX, rockY, dir; - - cin >> king >> rock >> num; - - kingX='8'-king[1]; - kingY=king[0]-'A'; - rockX='8'-rock[1]; - rockY=rock[0]-'A'; - - int chessX[8]={0, 0, 1, -1, -1, -1, 1, 1}; - int chessY[8]={1, -1, 0, 0, 1, -1, 1, -1}; - - for(int i=0;i> dir_str; - if(dir_str=="R"){ - dir=0; - } - else if(dir_str=="L"){ - dir=1; - } - else if(dir_str=="B"){ - dir=2; - } - else if(dir_str=="T"){ - dir=3; - } - else if(dir_str=="RT"){ - dir=4; - } - else if(dir_str=="LT"){ - dir=5; - } - else if(dir_str=="RB"){ - dir=6; - } - else if(dir_str=="LB"){ - dir=7; - } - - int kx=kingX+chessX[dir]; - int ky=kingY+chessY[dir]; - - if (kx<0 || kx>7 || ky<0 || ky>7){ - continue; - } - if(kx==rockX && ky==rockY){ - int rx=rockX+chessX[dir]; - int ry=rockY+chessY[dir]; - if(rx<0 || rx>7 || ry<0 || ry>7){ - continue; - } - rockX=rx; - rockY=ry; - } - kingX=kx; - kingY=ky; - } - - cout << (char)(kingY+'A') << 8-kingX << '\n'; - cout << (char)(rockY+'A') << 8-rockX << '\n'; - - return 0; -} \ No newline at end of file diff --git "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" "b/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" deleted file mode 100644 index f91d05f..0000000 --- "a/04_\353\270\214\353\243\250\355\212\270\355\217\254\354\212\244/11723.cpp" +++ /dev/null @@ -1,48 +0,0 @@ -#include - -using namespace std; - -int main(){ - - ios_base::sync_with_stdio(false); - cin.tie(NULL); - cout.tie(NULL); - - int n, S=0, cmd_num; - string cmd=""; - - cin >> n; - - for(int i=0;i> cmd; - if(cmd=="add"){ - cin>>cmd_num; - S|=(1<> cmd_num; - S&= ~(1<>cmd_num; - if(S&(1<>cmd_num; - S^=(1< - -using namespace std; - -int main(){ - - int n, n_temp, count=1, num=666; - - cin >> n; - - while(count!=n){ - if(n==1){ - break; - } - - num++; - n_temp=num; - - while(n_temp!=0){ - if(n_temp%1000==666){ - count++; - break; - } - else{ - n_temp/=10; - } - } - } - - cout << num; - return 0; -} \ No newline at end of file From e99f2dd37a1d5a60ef28352a0e119b241bdc1d9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:44:27 +0900 Subject: [PATCH 11/14] =?UTF-8?q?Delete=2005=5F=EC=9A=B0=EC=84=A0=EC=88=9C?= =?UTF-8?q?=EC=9C=84=5F=ED=81=90=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14235.cpp" | 33 ------------- .../2075.cpp" | 29 ----------- .../2607.cpp" | 49 ------------------- 3 files changed, 111 deletions(-) delete mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" delete mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" delete mode 100644 "05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" deleted file mode 100644 index c11e09b..0000000 --- "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/14235.cpp" +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include - -using namespace std; - -int main() -{ - int n, a, gift; - priority_queue pq; - - cin >> n; - - while(n--){ - cin >> a; - if(a==0){ - if(pq.empty()){ - cout << -1 << '\n'; - } - else{ - cout << pq.top() << '\n'; - pq.pop(); - } - } - else{ - while(a--){ - cin >> gift; - pq.push(gift); - } - } - } - - return 0; -} \ No newline at end of file diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" deleted file mode 100644 index b7ac188..0000000 --- "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2075.cpp" +++ /dev/null @@ -1,29 +0,0 @@ -#include -#include - -using namespace std; - -int main() -{ - - ios_base::sync_with_stdio(false); - cin.tie(NULL); - cout.tie(NULL); - - int n, num; - priority_queue, greater> pq; - - cin >> n; - - for(int i=0;i> num; - pq.push(num); - if(pq.size() > n){ - pq.pop(); - } - } - - cout << pq.top(); - - return 0; -} \ No newline at end of file diff --git "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" "b/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" deleted file mode 100644 index 991d314..0000000 --- "a/05_\354\232\260\354\204\240\354\210\234\354\234\204_\355\201\220/2607.cpp" +++ /dev/null @@ -1,49 +0,0 @@ -#include -#include - -using namespace std; - -const int NUM_CHARS = 26; //상수 선언 - -void countFreq(string word, vector &freq) { //각 알파벡의 개수를 센다 - for (int i = 0; i < word.length(); i++) { //받은 단어의 알파벳을 모두 돌며 - freq[word[i] - 'A']++; //받은 벡터에 각 알파벳의 개수를 센다 - } -} - -int countDiff(string word, vector original_freq) { //차이를 센다 - vector freq(NUM_CHARS, 0); //빈도(개수)를 세는 벡터 - int diff = 0; //원본 단어와의 차이를 저장할 변수 - - countFreq(word, freq); // 각 알파벳의 개수 세기 - - for (int i = 0; i < NUM_CHARS; i++) { //알파벳 개수동안 - diff += abs(original_freq[i] - freq[i]); //원본 단어와 다른 알파벳의 개수를 변수에 넣기 - } - return diff; //diff를 반환 -} - -int main() { //메인 - int N, ans=0; //입력받을 변수와 결과를 담을 변수 - string original; //원본 문자열 - - cin >> N; //입력 받기 - cin >> original; //원본 문자열 입력 받기 - vector original_freq(NUM_CHARS, 0); //기존 문자열에서 알파벳의 개수를 저장할 벡터 - - countFreq(original, original_freq); //기존 문자열의 알파벳의 개수 계산 - - for (int i = 1; i < N; i++) { //입력받은 n만큼 반복 - string word; //비교할 문자열 - cin >> word; //비교할 문자열 입력받기 - - int diff = countDiff(word, original_freq); //기존 문자열과의 차이 저장 - - if (diff == 0 || diff == 1 || diff == 2 && original.length() == word.length()) { //조건에 맞는 비슷한 단어라면 - ans++; //개수 세기 - } - } - - cout << ans; //결과 출력 - return 0; //종료 -} \ No newline at end of file From 3b4b9d77cb615031b6d73c3ecafe583e356fc496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:44:37 +0900 Subject: [PATCH 12/14] =?UTF-8?q?Delete=2006=5F=EA=B7=B8=EB=A6=AC=EB=94=94?= =?UTF-8?q?=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../1213.cpp" | 17 ----------------- 1 file changed, 17 deletions(-) delete mode 100644 "06_\352\267\270\353\246\254\353\224\224/1213.cpp" diff --git "a/06_\352\267\270\353\246\254\353\224\224/1213.cpp" "b/06_\352\267\270\353\246\254\353\224\224/1213.cpp" deleted file mode 100644 index e1cf537..0000000 --- "a/06_\352\267\270\353\246\254\353\224\224/1213.cpp" +++ /dev/null @@ -1,17 +0,0 @@ -#include - -using namespace std; - -int main() -{ - string s; - int english[26]; - - cin >> s; - - for(int i=0;i Date: Tue, 21 Nov 2023 23:44:47 +0900 Subject: [PATCH 13/14] =?UTF-8?q?Delete=2009=5F=EB=B0=B1=ED=8A=B8=EB=9E=98?= =?UTF-8?q?=ED=82=B9=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14888.cpp" | 59 ------------------- .../15665.cpp" | 47 --------------- 2 files changed, 106 deletions(-) delete mode 100644 "09_\353\260\261\355\212\270\353\236\230\355\202\271/14888.cpp" delete mode 100644 "09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" diff --git "a/09_\353\260\261\355\212\270\353\236\230\355\202\271/14888.cpp" "b/09_\353\260\261\355\212\270\353\236\230\355\202\271/14888.cpp" deleted file mode 100644 index 3fea78f..0000000 --- "a/09_\353\260\261\355\212\270\353\236\230\355\202\271/14888.cpp" +++ /dev/null @@ -1,59 +0,0 @@ -#include - -using namespace std; - -void calculate(int n, int &maxnum, int &minnum, int result, int cnt, int nums[11], int ops[4]) -{ - if(cnt==n) - { - if(result>maxnum){ - maxnum=result; - } - if(result> n; - - for(int i=0; i> nums[i]; - } - for(int i=0; i<4; i++){ - cin >> ops[i]; - } - - calculate(n, maxnum, minnum, nums[0],1,nums,ops); - cout << maxnum << '\n' << minnum; -} \ No newline at end of file diff --git "a/09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" "b/09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" deleted file mode 100644 index d5372d8..0000000 --- "a/09_\353\260\261\355\212\270\353\236\230\355\202\271/15665.cpp" +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -#include - -using namespace std; - -void numorder(int n, int m, int num, vector nums, int (&answer)[8]){ - if(num==m){ - - for(int i=0; i nums; - int answer[8]; - - cin >> n >> m; - - for (int i=0; i> num; - nums.push_back(num); - } - - sort(nums.begin(), nums.end()); - - numorder(n, m, 0, nums, answer); - - return 0; -} \ No newline at end of file From c87dc53388ca4057ff664a0df5190915996d1817 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=ED=95=98=EB=A6=B0?= <124681672+sari-harin@users.noreply.github.com> Date: Tue, 21 Nov 2023 23:44:57 +0900 Subject: [PATCH 14/14] =?UTF-8?q?Delete=2011=5F=ED=88=AC=ED=8F=AC=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=20directory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../14503.cpp" | 86 ------------------- .../20922.cpp" | 37 -------- .../2531.cpp" | 39 --------- 3 files changed, 162 deletions(-) delete mode 100644 "11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" delete mode 100644 "11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" delete mode 100644 "11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" diff --git "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" deleted file mode 100644 index 98957a9..0000000 --- "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/14503.cpp" +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include - -using namespace std; - -const int SIZE = 50; -const int CLEAN = 2; -int n, m; //방의 크기 -int cnt = 0; //청소한 칸 개수 - -vector> board(SIZE, vector(SIZE)); //방 (0: 빈 칸, 1: 벽, 2: 청소 완료) - -//4가지 방향: { 북, 동, 남, 서 } -int dx[4] = { 0, 1, 0, -1 }; -int dy[4] = { -1, 0, 1, 0 }; - -void dfs(int row, int col, int dir) { - //1. 현재 위치 청소 - if (board[row][col] != CLEAN) { - cnt++; - board[row][col] = CLEAN; - } - - //[현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 있는가] - //3. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 있는 경우 - for (int i = 0; i < 4; i++) { //3-1. 반시계 방향으로 90º 회전 - int new_dir = (dir - i + 3) % 4; - int new_row = row + dy[new_dir], new_col = col + dx[new_dir]; - - if (board[new_row][new_col] == 0) { //3-2. 아직 청소되지 않은 빈 칸 발견 - dfs(new_row, new_col, new_dir); //한 칸 전진 - return; - } - } - - //2. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 없는 경우 - int back_dir = (dir + 2) % 4; - int back_row = row + dy[back_dir], back_col = col + dx[back_dir]; - - //[바라보는 방향을 유지한 채로 한 칸 후진할 수 있는가] - //2-2. 뒤쪽 칸이 벽이라 후진할 수 없는 경우 - if (board[back_row][back_col] == 1) { - return; - } - - //2-1. 바라보는 방향을 유지한 채로 한 칸 후진 - dfs(back_row, back_col, dir); //방향 유지한 상태로 후진 (2-3) - return; -} - -/* -[로봇 청소기 작동] -1. 현재 칸이 아직 청소되지 않은 경우, 현재 칸을 청소한다. -2. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 없는 경우, - 2-1. 바라보는 방향을 유지한 채로 한 칸 후진할 수 있다면 한 칸 후진하고 1번으로 돌아간다. - 2-2. 바라보는 방향의 뒤쪽 칸이 벽이라 후진할 수 없다면 작동을 멈춘다. -3. 현재 칸의 주변 4칸 중 청소되지 않은 빈 칸이 있는 경우, - 3-1. 반시계 방향으로 90º 회전한다. - 3-2. 바라보는 방향을 기준으로 앞쪽 칸이 청소되지 않은 빈 칸인 경우 한 칸 전진한다. - 3-3. 1번으로 돌아간다. -*/ - -int main() { - ios::sync_with_stdio(false); - cin.tie(NULL); cout.tie(NULL); - - int r, c, d; //로봇 청소기 정보 - - //입력 - cin >> n >> m; - cin >> r >> c >> d; - - for (int i = 0; i < n; i++) { - for (int j = 0; j < m; j++) { - cin >> board[i][j]; - } - } - - //연산 - dfs(r, c, d); - - //출력 - cout << cnt; - - return 0; -} \ No newline at end of file diff --git "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" deleted file mode 100644 index 66b12d4..0000000 --- "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/20922.cpp" +++ /dev/null @@ -1,37 +0,0 @@ -#include -#include - -using namespace std; - -int main(){ - - ios::sync_with_stdio(false); - cin.tie(NULL);cout.tie(NULL); - - int n, k, start=0, end=0, answer=0; - int num[200001]; - int cnt[100001]; - - cin >> n >> k; - - for(int i=0;i> num[i]; - } - - while(startstart-end?answer:start-end; - } - - cout << answer; - - return 0; -} \ No newline at end of file diff --git "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" "b/11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" deleted file mode 100644 index 3e6b832..0000000 --- "a/11_\355\210\254\355\217\254\354\235\270\355\204\260/2531.cpp" +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include - -using namespace std; - -int main() -{ - int n, d, c, k, cnt, doubled, coupon, answer=0; - int table[30000]; - bool check[30000]; - - cin >> n >> d >> k >> c; - - for(int i=0;i> table[i]; - } - - for(int i=0;i(k-doubled+coupon)?answer:k-doubled+coupon; - memset(check, false, sizeof(check)); - } - cout << answer; - - return 0; -} \ No newline at end of file