diff --git a/Sikca/M_2024_05/Week_1/P_4928/README.md b/Sikca/M_2024_05/Week_1/P_4928/README.md new file mode 100644 index 0000000..de6395d --- /dev/null +++ b/Sikca/M_2024_05/Week_1/P_4928/README.md @@ -0,0 +1,40 @@ + +--- + +## ๐Ÿ”– ๋ฌธ์ œ ์„ค๋ช… + +- ๊ด„ํ˜ธ, ๋ฌธ์ž, ์ˆซ์ž๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ๊ทธ์— ๋งž๋Š” ๋ฌธ์ž์—ด์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ +- `link` : [`click`](https://www.acmicpc.net/problem/4928) + +--- + +## ๐Ÿณ ์Šค์Šค๋กœ ์ƒ๊ฐํ•œ ์ ‘๊ทผ ๋ฐฉ์‹ + +๊ด„ํ˜ธ์•ˆ์— ๋ฌธ์ž์™€ ์ˆซ์ž๊ฐ€ ์ฃผ์–ด์ง€๋ฉด ์ˆซ์ž์˜ ๊ฐœ์ˆ˜ ๋งŒํผ ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅํ•ด์•ผ ํ•˜๋Š”๋ฐ ์ด์™€ ๋น„์Šทํ•œ ๋ฐฑ์ค€ '๊ด„ํ˜ธ' ๋ผ๋Š” ๋ฌธ์ œ๋ฅผ ํ‘ผ ๊ธฐ์–ต์ด ์žˆ๊ธฐ์— ์Šคํƒ์„ ์‚ฌ์šฉํ•˜๋ฉด ํ’€๋ฆด๊ฒƒ ๊ฐ™์•˜๋‹ค. + +--- + + +## โ— ํ‹€๋ฆฐ ์ด์œ  ์„ค๋ช… + +๋ฌธ์ œ์—์„œ ์ˆจ๊ฒจ์ง„ ์˜ˆ์™ธ ์ผ€์ด์Šค์ธ ์ˆซ์ž๊ฐ€ ์—ฐ๋‹ฌ์•„ ๋‚˜์˜ฌ๋•Œ๋ฅผ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ–ˆ๋‹ค. + +--- + + +## โœ… ์˜ฌ๋ฐ”๋ฅธ ์ ‘๊ทผ ๋ฐฉ์‹ ๋ฐ ํ•ด๊ฒฐ ๋ฐฉ์‹ + +์ˆซ์ž๊ฐ€ ๋‚˜์˜ฌ๋•Œ ๊นŒ์ง€ ์Šคํƒ์œผ๋กœ ์ž…๋ ฅ๋ฐ›์•„ ์ฒ˜๋ฆฌํ–ˆ๋‹ค/ + +--- + +## ๐Ÿ›  ์ž์‹ ์˜ ํ’€์ด์—์„œ ๊ฐœ์„ ํ•  ๋ถ€๋ถ„ + +์˜ฌ๋ฐ”๋ฅธ ํ’€์ด ์ธ๊ฒƒ ๊ฐ™๋‹ค. + +--- + +## Reference + +--- + diff --git a/Sikca/M_2024_05/Week_1/P_4928/image.png b/Sikca/M_2024_05/Week_1/P_4928/image.png new file mode 100644 index 0000000..57af50e Binary files /dev/null and b/Sikca/M_2024_05/Week_1/P_4928/image.png differ diff --git a/Sikca/M_2024_05/Week_1/P_4928/solution.cpp b/Sikca/M_2024_05/Week_1/P_4928/solution.cpp new file mode 100644 index 0000000..9d1e1b0 --- /dev/null +++ b/Sikca/M_2024_05/Week_1/P_4928/solution.cpp @@ -0,0 +1,60 @@ +#include +#include +#define sz(x) (int)x.size() +using namespace std; +string a; +stack s; +stack ans; +int main(void) { + ios::sync_with_stdio(false); + cin.tie(nullptr); + cout.tie(nullptr); + //ํ™•์‹คํ•œ ์ƒ๊ฐ๊ณผ ๊ณ„ํš ์ฝ”๋“œ + while(1){ + getline(cin,a); + if (a == "$") return 0; + s = {}; + for (int i = 0; i < (int)a.size(); i++){ + if (a[i] == '('){ + s.push('('); + }else if (isdigit(a[i])){ + s.push(a[i]); + }else if (isalpha(a[i])){ + s.push(a[i]); + }else if (a[i] == ')'){ + int len = 0; + string temp; + int k = 1; + len += s.top()-'0'; + s.pop(); + while(isdigit(s.top())){ + len += 10*k * (s.top() -'0'); + k *= 10; + s.pop(); + } + while(s.top() != '('){ + temp += s.top(); + s.pop(); + } + reverse(temp.begin(),temp.end()); + s.pop(); + + for (int j = 0; j < len; j++){ + for (auto w : temp){ + s.push(w); + } + } + } + } + while(!s.empty()){ + ans.push(s.top()); + s.pop(); + } + while(!ans.empty()){ + cout << ans.top(); + ans.pop(); + } + cout << '\n'; + } + return 0; +} \ No newline at end of file