Skip to content
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

7-oesnuj #24

Merged
merged 5 commits into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions oesnuj/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@
| 1์ฐจ์‹œ | 2024.03.26 | ์Šคํƒ | [ํ›„์œ„ํ‘œ๊ธฐ์‹2](https://www.acmicpc.net/problem/1935) | [#4](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/4) |
| 2์ฐจ์‹œ | 2024.03.29 | ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ | [์—๋””ํ„ฐ](https://www.acmicpc.net/problem/1406) | [#8](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/8) |
| 3์ฐจ์‹œ | 2024.04.02 | ๋ฑ | [์นด๋“œ ๋†“๊ธฐ](https://www.acmicpc.net/problem/18115) | [#11](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/11) |
| 4์ฐจ์‹œ | 2024.04.06 | ์Šคํƒ | [์˜ฅ์ƒ ์ •์› ๊พธ๋ฏธ๊ธฐ](https://www.acmicpc.net/problem/6198) | [#14](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/14) |
| 5์ฐจ์‹œ | 2024.04.13 | ์ด๋ถ„ํƒ์ƒ‰ | [๋“ฃ๋ณด์žก](https://www.acmicpc.net/problem/1764) | [#20](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/20) |
| 6์ฐจ์‹œ | 2024.05.06 | ๊ธฐํ•˜ํ•™ | [์ •์‚ฌ๊ฐํ˜•](https://www.acmicpc.net/problem/1485) | [#22](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/22) |
| 7์ฐจ์‹œ | 2024.05.08 | ๋ฑ | [queuestack](https://www.acmicpc.net/problem/24511) | [#24](https://github.com/AlgoLeadMe/AlgoLeadMe-10/pull/24) |
---
53 changes: 53 additions & 0 deletions oesnuj/๊ธฐํ•˜/1485.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

struct Point
{
int x, y;
};

int calcDistance(Point a, Point b)
{
return pow(a.x - b.x, 2) + pow(a.y - b.y, 2);
}

bool compareInfo(Point &a, Point &b)
{
if(a.x == b.x)
return a.y < b.y;
return a.x < b.x;
}

int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);

int n;
cin >> n;

while (n--)
{
vector <Point> v(4);
for (int i = 0; i < 4; i++) {
cin >> v[i].x >> v[i].y;
}
sort(v.begin(), v.end(),compareInfo);
//2 3
//0 1
int s1 = calcDistance(v[0], v[1]); //์„ ๋ถ„
int s2 = calcDistance(v[0], v[2]);
int s3 = calcDistance(v[1], v[3]);
int s4 = calcDistance(v[2], v[3]);

int dia1 = calcDistance(v[0], v[3]); //๋Œ€๊ฐ์„ 
int dia2 = calcDistance(v[1], v[2]);
if (s1 == s2 && s2 == s3 && s3 == s4 && dia1 == dia2) //๋„ค๋ณ€์˜ ๊ธธ์ด๊ฐ€ ๊ฐ™๊ณ  ๋Œ€๊ฐ์„ ์˜ ๊ธธ์ด๊ฐ€ ๊ฐ™๋‹ค.
cout << 1 << '\n';
else
cout << 0 << '\n';
}
return 0;
}
35 changes: 35 additions & 0 deletions oesnuj/๋ฑ/24511.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include <iostream>
#include <deque>
#include <vector>
using namespace std;

int main()
{
ios::sync_with_stdio(false); cin.tie(NULL);
int n;
cin >> n;
vector <int> dataStructure(n); //์Šคํ…์ธ์ง€ ํ์ธ์ง€ ์ž…๋ ฅ๋ฐ›๊ธฐ
for (auto& i : dataStructure){
cin >> i;
}

deque <int> queuestack;
for (int i = 0; i < n; i++)
{
int x;
cin >> x;
if (dataStructure.at(i) == 0) //ํ์ธ ๊ฒฝ์šฐ์—๋งŒ ์ฒ˜๋ฆฌ, ์Šคํƒ์€ ๋ฌด์กฐ๊ฑด ์ž…๋ ฅ๊ฐ’์ด ๋‚˜์˜ค๊ธฐ์— ์—†๋‹ค๊ณ  ๋ณด๋ฉด๋จ
queuestack.push_back(x);
}
int m;
cin >> m;
for (int i = 0; i < m; i++)
{
int x;
cin >> x;
queuestack.push_front(x);
cout << queuestack.back() << " ";
queuestack.pop_back();
}
return 0;
}
44 changes: 44 additions & 0 deletions oesnuj/์Šคํƒ/6198.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#include <iostream>
#include <vector>

using namespace std;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);

int n;
cin >> n; //๋นŒ๋”ฉ ๊ฐœ์ˆ˜ ์ž…๋ ฅ

vector <int> v(n); //๋นŒ๋”ฉ ๋†’์ด๋ฅผ ๋ฐ›์„ ๋ฒกํ„ฐ ์„ ์–ธ
vector <int> s; //๋นŒ๋”ฉ ๋†’์ด๋“ค์„ ์ ์ ˆํ•˜๊ฒŒ ๋„ฃ์„ ์Šคํƒ ์„ ์–ธ
for (auto& i : v)
cin >> i; //๊ฐ ๋นŒ๋”ฉ ๋†’์ด ์ž…๋ ฅ

long long int count = 0; //count๊ฐ€ intํ˜•์„ ๋„˜์–ด์„œ๊ธฐ์— long long int type์œผ๋กœ ๋‘ 
for (const auto& height : v) // ๋ชจ๋“  ๋นŒ๋”ฉ ๋†’์ด๋ฅผ ํ•˜๋‚˜์”ฉ ์ˆœํšŒํ•œ๋‹ค.
{
while (true)
{
if (s.empty()) //์Šคํƒ์ด ๋น„์—ˆ๋‹ค๋ฉด ํ˜„์žฌ ๋นŒ๋”ฉ ๋†’์ด ์Šคํƒ์— push
{
s.push_back(height);
break;
}
if (height < s.back()) //ํ˜„์žฌ ๋นŒ๋”ฉ ๋†’์ด๊ฐ€ ์Šคํƒ์˜ top๋ณด๋‹ค ๋†’์€ ๋นŒ๋”ฉ์ด๋ผ๋ฉด(๋ณผ ์ˆ˜ ์žˆ๋Š” ๋นŒ๋”ฉ์ด๋ผ๋ฉด)
{
count += s.size();
//์Šคํƒ์—๋Š” ํ˜„์žฌ ๋นŒ๋”ฉ๋ณด๋‹ค ๋†’์€ ๋นŒ๋”ฉ ๋ฐ–์— ์—†์œผ๋‹ˆ ์Šคํƒ์˜ ํฌ๊ธฐ = ํ˜„์žฌ ๋นŒ๋”ฉ์„ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๋นŒ๋”ฉ ์ˆ˜
s.push_back(height);
break;
}
s.pop_back(); //ํ˜„์žฌ ๋นŒ๋”ฉ์ด ์Šคํƒ์˜ top๋ณด๋‹ค ๋†’๋‹ค๋ฉด(์–ด์งœํ”ผ ๋‚˜๋ฅผ ๋ณผ ์ˆ˜ ์—†๋Š” ๋นŒ๋”ฉ์ด๋‹ˆ) ์ „๋ถ€ pop
//์Šคํƒ์ด ๋น„๊ฑฐ๋‚˜ ํ˜„์žฌ ๋นŒ๋”ฉ๋ณด๋‹ค ๋†’์€ top์ด ๋‚˜์˜ฌ๋•Œ๊นŒ์ง€ popํ•œ๋‹ค.
// ์–ธ์ œ๊นŒ์ง€ pop ํ• ๊นŒ?
//case 1. ์Šคํƒ์ด ๋น„๋ฉด ๋‚˜๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๋นŒ๋”ฉ์€ ์—†๋‹ค๋Š” ๋œป์ด๋‹ˆ ์Šคํƒ์— push
//case 2. ๋‚˜๋ณด๋‹ค ๋†’์€ ๋นŒ๋”ฉ์ด ๋‚˜์˜จ๋‹ค๋ฉด ๊ทธ๋•Œ ์Šคํƒ์˜ ํฌ๊ธฐ = ๋‚˜๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋Š” ๋นŒ๋”ฉ ์ˆ˜ ๋ฅผ count์— ์ถ”๊ฐ€
}
}
cout << count;
return 0;
}
53 changes: 53 additions & 0 deletions oesnuj/์ด๋ถ„ํƒ์ƒ‰/1764.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;


bool binarySearch(vector <string> &v, string str) //์ด๋ถ„ํƒ์ƒ‰
{
int left = 0;
int right = v.size() - 1;
while (left <= right)
{
int middle = (left + right) / 2;
if (str > v[middle])
left = middle + 1;
else if (str < v[middle])
right = middle - 1;
else
return true;

}
return false;
}


int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, m;
cin >> n >> m;
vector <string> v(n); //๋“ฃ๋„ ๋ชปํ•œ ์‚ฌ๋žŒ ์ž…๋ ฅ
for (auto& i : v){
cin >> i;
}
sort(v.begin(), v.end()); //์ด๋ถ„ ํƒ์ƒ‰์„ ์œ„ํ•ด ์ •๋ ฌ
vector <string> result;
for (int i = 0; i < m; i++)
{
string word;
cin >> word; //๋ณด๋„ ๋ชปํ•œ ์‚ฌ๋žŒ ์ž…๋ ฅ
if (binarySearch(v, word)){ //๋ณด๋„ ๋ชปํ•œ ์‚ฌ๋žŒ์ด ๋“ฃ๋„ ๋ณด๋‹ค ๋ชปํ•œ ์‚ฌ๋žŒ์—๋„ ํฌํ•จ๋˜๋ฉด
result.push_back(word);
}
}
sort(result.begin(), result.end()); //๋งˆ์ง€๋ง‰ ์‚ฌ์ „์ˆœ ์ •๋ ฌ์„ ์œ„ํ•ด ์ •๋ ฌ

cout << result.size() << "\n";
for (const auto& word : result) {
cout << word << "\n";
}
return 0;
}