Algorithm ๐ง๐ป๐ป456 [๋ฐฑ์ค,c++] 17255๋ฒ - N์ผ๋ก ๋ง๋ค๊ธฐ ๋ฌธ์ 17255๋ฒ: N์ผ๋ก ๋ง๋ค๊ธฐ ์์ด ์๋ ์ ์ N์ด ์ฃผ์ด์ง๋ค. (0 ≤ N ≤ 10,000,000) www.acmicpc.net ์ฝ๋ #include #include #include using namespace std; string s; map visited; void dfs(int left, int right, string now, set temp){ if(now.length()>=s.length()){ if(now == s) visited[temp] = 1; return; } if(left>0){ temp.insert(s[left-1]+now); dfs(left-1, right, s[left-1]+now, temp); temp.erase(s[left-1]+now); } if(right>s; for.. 2022. 6. 20. [๋ฐฑ์ค,c++] 19537๋ฒ - ์ธ์ด๋ฒ๊ฐ๊ฐ์ดํ ๋ฌธ์ 19583๋ฒ: ์ธ์ด๋ฒ๊ฐ๊ฐ์ดํ ์ฒซ๋ฒ์งธ ์ค์๋ ๊ฐ๊ฐ์ดํ๋ฅผ ์์ํ ์๊ฐ S, ๊ฐ๊ฐ์ดํ๋ฅผ ๋๋ธ ์๊ฐ E, ๊ฐ๊ฐ์ดํ ์คํธ๋ฆฌ๋ฐ์ ๋๋ธ ์๊ฐ Q๊ฐ ์ฃผ์ด์ง๋ค. (00:00 ≤ S < E < Q ≤ 23:59) ๊ฐ ์๊ฐ์ HH:MM์ ํ์์ผ๋ก ์ฃผ์ด์ง๋ค. ๋๋ฒ์งธ ์ค๋ถํฐ๋ www.acmicpc.net ์ฝ๋ #include #include #include #include #include using namespace std; vector parsing_time(string s){ istringstream ss(s); string stringbuffer; vector v; while(getline(ss,stringbuffer, ':')){ v.push_back(stringbuffer); } return v; } vector.. 2022. 6. 20. [๋ฐฑ์ค,c++] 10546๋ฒ - ๋ฐฐ๋ถ๋ฅธ ๋ง๋ผํ ๋ ๋ฌธ์ 10546๋ฒ: ๋ฐฐ๋ถ๋ฅธ ๋ง๋ผํ ๋ ๋ง๋ผํ ๋๋ผ๋ฉด ๊ตญ์ ๊ณผ ๋์ด๋ฅผ ๋ถ๋ฌธํ๊ณ ๋๊ตฌ๋ ์ฐธ๊ฐํ๊ณ ์ถ์ดํ๋ ๋ฐฑ์ค ๋ง๋ผํค ๋ํ๊ฐ ์ด๋ฆฐ๋ค. 42.195km๋ฅผ ๋ฌ๋ฆฌ๋ ์ด ๋ง๋ผํค์ ๋ชจ๋๊ฐ ์ฐธ๊ฐํ๊ณ ์ถ์ดํ๋ ๋งํผ ๋งค๋ ๋ชจ๋๊ฐ ์์ฃผํด์๋ค. ๋จ, ํ ๋ช www.acmicpc.net ์ฝ๋ #include #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int N; cin>>N; string name; unordered_map umap; for(int i=0; i>name; umap[name]++; } for(int i=0; i>name; umap[name]--; } for(auto it = umap.begin(); it!.. 2022. 6. 19. [๋ฐฑ์ค,c++] 5430๋ฒ - AC ๋ฌธ์ 5430๋ฒ: AC ๊ฐ ํ ์คํธ ์ผ์ด์ค์ ๋ํด์, ์ ๋ ฅ์ผ๋ก ์ฃผ์ด์ง ์ ์ ๋ฐฐ์ด์ ํจ์๋ฅผ ์ํํ ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ค. ๋ง์ฝ, ์๋ฌ๊ฐ ๋ฐ์ํ ๊ฒฝ์ฐ์๋ error๋ฅผ ์ถ๋ ฅํ๋ค. www.acmicpc.net ์ฝ๋ #include #include #include #include #include #include using namespace std; void parsing(string s, deque &dq){ istringstream ss(s); string stringbuffer; while(getline(ss, stringbuffer, ',')){ dq.push_back(stoi(stringbuffer)); } } int main(){ int T; cin>>T; while(T--){ string cmd; cin>>c.. 2022. 6. 19. [๋ฐฑ์ค,c++] 18115๋ฒ - ์นด๋ ๋๊ธฐ ๋ฌธ์ 18115๋ฒ: ์นด๋ ๋๊ธฐ ์ํ์ด๋ ์นด๋ ๊ธฐ์ ์ ์ฐ์ตํ๊ณ ์๋ค. ์ํ์ด์ ์์ ๋ค๋ฆฐ ์นด๋๋ฅผ ํ๋์ฉ ๋ด๋ ค๋์ ๋ฐ๋ฅ์ ์์ผ๋ ค๊ณ ํ๋ค. ์ํ์ด๊ฐ ์ธ ์ ์๋ ๊ธฐ์ ์ ๋ค์ 3๊ฐ์ง๋ค. ์ ์ผ ์์ ์นด๋ 1์ฅ์ ๋ฐ๋ฅ์ ๋ด๋ ค๋๋๋ค. www.acmicpc.net ์ฝ๋ #include #include #include #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int N; cin>>N; vectorv(N); dequedq; for(int i=0; i>v[i]; reverse(v.begin(),v.end()); int num = 1; for(int i:v){ if(i==1) dq.push_back(num); .. 2022. 6. 19. [๋ฐฑ์ค,c++] 5397๋ฒ - ํค๋ก๊ฑฐ ๋ฌธ์ 5397๋ฒ: ํค๋ก๊ฑฐ ์ฒซ์งธ ์ค์ ํ ์คํธ ์ผ์ด์ค์ ๊ฐ์๊ฐ ์ฃผ์ด์ง๋ค. ๊ฐ ํ ์คํธ ์ผ์ด์ค๋ ํ์ค๋ก ์ด๋ฃจ์ด์ ธ ์๊ณ , ๊ฐ์ฐ์ด๊ฐ ์ ๋ ฅํ ์์๋๋ก ๊ธธ์ด๊ฐ L์ธ ๋ฌธ์์ด์ด ์ฃผ์ด์ง๋ค. (1 ≤ L ≤ 1,000,000) ๊ฐ์ฐ์ด๊ฐ ๋ฐฑ์คํ์ด์ค๋ฅผ ์ www.acmicpc.net ์ฝ๋ #include #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin>>n; while(n--){ listli; auto it = li.begin(); string s; cin>>s; for(char c: s){ if(c=='>'){ if(it!=li.end()) it++; } else if(c==' 2022. 6. 3. [๋ฐฑ์ค,c++] 1918๋ฒ - ํ์ ํ๊ธฐ์ ๋ฌธ์ 1918๋ฒ: ํ์ ํ๊ธฐ์ ์ฒซ์งธ ์ค์ ์ค์ ํ๊ธฐ์์ด ์ฃผ์ด์ง๋ค. ๋จ ์ด ์์์ ํผ์ฐ์ฐ์๋ ์ํ๋ฒณ ๋๋ฌธ์๋ก ์ด๋ฃจ์ด์ง๋ฉฐ ์์์์ ํ ๋ฒ์ฉ๋ง ๋ฑ์ฅํ๋ค. ๊ทธ๋ฆฌ๊ณ -A+B์ ๊ฐ์ด -๊ฐ ๊ฐ์ฅ ์์ ์ค๊ฑฐ๋ AB์ ๊ฐ์ด *๊ฐ ์๋ต๋๋ ๋ฑ์ www.acmicpc.net ์ฝ๋ #include #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); string s, ans; cin>>s; stackst; for(char c: s){ if(c=='(') st.push(c); else if(c==')'){ while(st.top()!='('){ cout 2022. 6. 3. [๋ฐฑ์ค,c++] 2493๋ฒ - ํ ๋ฌธ์ 2493๋ฒ: ํ ์ฒซ์งธ ์ค์ ํ์ ์๋ฅผ ๋ํ๋ด๋ ์ ์ N์ด ์ฃผ์ด์ง๋ค. N์ 1 ์ด์ 500,000 ์ดํ์ด๋ค. ๋์งธ ์ค์๋ N๊ฐ์ ํ๋ค์ ๋์ด๊ฐ ์ง์ ์์ ๋์ธ ์์๋๋ก ํ๋์ ๋น์นธ์ ์ฌ์ด์ ๋๊ณ ์ฃผ์ด์ง๋ค. ํ๋ค์ ๋์ด๋ 1 www.acmicpc.net ์ฝ๋ #include #include using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int N; cin>>N; stackst; // {ํ ๋ฒํธ, ๋์ด} for(int i=0; i>height; while(!st.empty()){ if(st.top().second>height){ cout 2022. 6. 3. [๋ฐฑ์ค,c++] 2800๋ฒ - ๊ดํธ ์ ๊ฑฐ ๋ฌธ์ 2800๋ฒ: ๊ดํธ ์ ๊ฑฐ ์ฒซ์งธ ์ค์ ์์ด ์๋ ์ ์๋ก ์ด๋ฃจ์ด์ง ์์์ด ์ฃผ์ด์ง๋ค. ์ด ์์์ ๊ดํธ๊ฐ ์ฌ๋ฐ๋ฅด๊ฒ ์ณ์ ธ์๋ค. ์ซ์, '+', '*', '-', '/', '(', ')'๋ก๋ง ์ด๋ฃจ์ด์ ธ ์๋ค. ์์์ ๊ธธ์ด๋ ์ต๋ 200์ด๊ณ , ๊ดํธ ์์ ์ ์ด๋ 1๊ฐ www.acmicpc.net ์ฝ๋ #include #include #include #include using namespace std; bool except[201]; vectorclose; stack open; set ans; string s; void dfs(int index, int delete_cnt){ if(delete_cnt >= 1){ string temp = ""; for(int i=0; is; for(int i=0; i 2022. 6. 3. ์ด์ 1 ยทยทยท 8 9 10 11 12 13 14 ยทยทยท 51 ๋ค์