๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Algorithm ๐Ÿง‘๐Ÿป‍๐Ÿ’ป456

[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - [3์ฐจ] ํŒŒ์ผ๋ช… ์ •๋ ฌ(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - [3์ฐจ] ํŒŒ์ผ๋ช… ์ •๋ ฌ ํŒŒ์ผ๋ช… ์ •๋ ฌ ์„ธ ์ฐจ๋ก€์˜ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ์™€ ๋‘ ์ฐจ๋ก€์˜ ๋ฉด์ ‘์ด๋ผ๋Š” ๊ธฐ๋‚˜๊ธด ๋ธ”๋ผ์ธ๋“œ ๊ณต์ฑ„๋ฅผ ๋ฌด์‚ฌํžˆ ํ†ต๊ณผํ•ด ์นด์นด์˜ค์— ์ž…์‚ฌํ•œ ๋ฌด์ง€๋Š” ํŒŒ์ผ ์ €์žฅ์†Œ ์„œ๋ฒ„ ๊ด€๋ฆฌ๋ฅผ ๋งก๊ฒŒ ๋˜์—ˆ๋‹ค. ์ €์žฅ์†Œ ์„œ๋ฒ„์—๋Š” ํ”„๋กœ๊ทธ๋žจ programmers.co.kr ์ฝ”๋“œ #include #include #include #include //22:13 ~ 22:50 using namespace std; struct Detail{ string head; int num; string origin; }; vector answer; bool cmp(const Detail& d1, const Detail& d2){ if(d1.head!=d2.head) return d1.head 2022. 5. 4.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ์ ํ”„์™€ ์ˆœ๊ฐ„ ์ด๋™(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ ํ”„์™€ ์ˆœ๊ฐ„ ์ด๋™ OO ์—ฐ๊ตฌ์†Œ๋Š” ํ•œ ๋ฒˆ์— K ์นธ์„ ์•ž์œผ๋กœ ์ ํ”„ํ•˜๊ฑฐ๋‚˜, (ํ˜„์žฌ๊นŒ์ง€ ์˜จ ๊ฑฐ๋ฆฌ) x 2 ์— ํ•ด๋‹นํ•˜๋Š” ์œ„์น˜๋กœ ์ˆœ๊ฐ„์ด๋™์„ ํ•  ์ˆ˜ ์žˆ๋Š” ํŠน์ˆ˜ํ•œ ๊ธฐ๋Šฅ์„ ๊ฐ€์ง„ ์•„์ด์–ธ ์ŠˆํŠธ๋ฅผ ๊ฐœ๋ฐœํ•˜์—ฌ ํŒ๋งคํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์•„์ด์–ธ ์Šˆ programmers.co.kr ์ฝ”๋“œ #include using namespace std; // ์ ํ”„: ๋ฒ ํ„ฐ๋ฆฌ ๋“ฌ, ์ˆœ๊ฐ„์ด๋™: ๋ฐฐํ„ฐ๋ฆฌ ์•ˆ๋“ฌ // ๊ฑฐ๊พธ๋กœ ๊ณ„์‚ฐ int solution(int n){ int battery = 0; while(n>2){ if(n&1){ battery++; n--; } else n/=2; } return battery+1; } ํ’€์ด ์ฒ˜์Œ์— ๋ฐฑํŠธ๋ž™ํ‚น์œผ๋กœ ์™„์ „ ํƒ์ƒ‰์„ ํ•ด๋ณผ๊นŒ ์‹ถ์—ˆ์ง€๋งŒ ๋„ˆ๋ฌด๋‚˜๋„ ํฐ ์ž…๋ ฅ๊ฐ’์— ํฌ๊ธฐํ•˜๊ณ , ๊ทœ์น™์„ ์ฐพ์•„๋ณด๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค. .. 2022. 5. 1.
[๋ฐฑ์ค€,c++] 17829๋ฒˆ - 222-ํ’€๋ง ๋ฌธ์ œ 17829๋ฒˆ: 222-ํ’€๋ง ์กฐ๊ธฐ ์กธ์—…์„ ๊ฟˆ๊พธ๋Š” ์ข…์šฑ์ด๋Š” ์š”์ฆ˜ ํ•ซํ•œ ๋”ฅ๋Ÿฌ๋‹์„ ๊ณต๋ถ€ํ•˜๋˜ ์ค‘, ์ด๋ฏธ์ง€ ์ฒ˜๋ฆฌ์— ํ”ํžˆ ์“ฐ์ด๋Š” ํ•ฉ์„ฑ๊ณฑ ์‹ ๊ฒฝ๋ง(Convolutional Neural Network, CNN)์˜ ํ’€๋ง ์—ฐ์‚ฐ์— ์˜๊ฐ์„ ๋ฐ›์•„ ์ž์‹ ๋งŒ์˜ ํ’€๋ง์„ ๋งŒ๋“ค๊ณ  ์ด๋ฅผ 22 www.acmicpc.net ์ฝ”๋“œ // 13:00 ~ 13:50 #include #include #include #include using namespace std; vectorv; int N; int dx[3] = {1,0,1}; int dy[3] = {0,1,1}; int find(int i, int k){ priority_queuepq; pq.push(v[i][k]); for(int j=0; j> p[i][j]; } } while (n > 1).. 2022. 4. 30.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ์ด์ง„ ๋ณ€ํ™˜ ๋ฐ˜๋ณตํ•˜๊ธฐ(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ด์ง„ ๋ณ€ํ™˜ ๋ฐ˜๋ณตํ•˜๊ธฐ programmers.co.kr ์ฝ”๋“œ #include #include #include // 13:35~13:47 using namespace std; int zero_cnt; int trans_cnt; string delete_zero(string s){ string bit = ""; for(char c:s){ if(c=='0') zero_cnt++; else bit+=c; } return bit; } string make_bit(string s){ trans_cnt++; int num = s.length(); string bit = ""; while(num!=0){ bit += to_string(num%2); num /= 2; } reverse(bit.beg.. 2022. 4. 26.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ๊ตฌ๋ช…๋ณดํŠธ(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ตฌ๋ช…๋ณดํŠธ ๋ฌด์ธ๋„์— ๊ฐ‡ํžŒ ์‚ฌ๋žŒ๋“ค์„ ๊ตฌ๋ช…๋ณดํŠธ๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ตฌ์ถœํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๊ตฌ๋ช…๋ณดํŠธ๋Š” ์ž‘์•„์„œ ํ•œ ๋ฒˆ์— ์ตœ๋Œ€ 2๋ช…์”ฉ ๋ฐ–์— ํƒˆ ์ˆ˜ ์—†๊ณ , ๋ฌด๊ฒŒ ์ œํ•œ๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด, ์‚ฌ๋žŒ๋“ค์˜ ๋ชธ๋ฌด๊ฒŒ๊ฐ€ [70kg, 50kg, 80kg, 5 programmers.co.kr ์ฝ”๋“œ #include #include #include #include using namespace std; int solution(vector people, int limit) { int answer = 0; priority_queue pq; // ์ตœ์†Œ ํž™ sort(people.begin(),people.end(),greater()); // ๋‚ด๋ฆผ์ฐจ์ˆœ ์ •๋ ฌ for(int i=0; i 2022. 4. 25.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ์ˆซ์ž์˜ ํ‘œํ˜„(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ˆซ์ž์˜ ํ‘œํ˜„ Finn์€ ์š”์ฆ˜ ์ˆ˜ํ•™๊ณต๋ถ€์— ๋น ์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. ์ˆ˜ํ•™ ๊ณต๋ถ€๋ฅผ ํ•˜๋˜ Finn์€ ์ž์—ฐ์ˆ˜ n์„ ์—ฐ์†ํ•œ ์ž์—ฐ์ˆ˜๋“ค๋กœ ํ‘œํ˜„ ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์—ฌ๋Ÿฌ๊ฐœ๋ผ๋Š” ์‚ฌ์‹ค์„ ์•Œ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ๋“ค์–ด 15๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด 4๊ฐ€์ง€๋กœ ํ‘œํ˜„ ํ•  programmers.co.kr ์ฝ”๋“œ #include #include using namespace std; int solution(int n) { int answer = 0; for(int i=1; i 2022. 4. 24.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ํฐ ์ˆ˜ ๋งŒ๋“ค๊ธฐ(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ํฐ ์ˆ˜ ๋งŒ๋“ค๊ธฐ programmers.co.kr ์ฝ”๋“œ #include #include #include using namespace std; string solution(string number, int k) { string answer = ""; int index = 0; for(int i=0; i 2022. 4. 24.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ๊ด„ํ˜ธ ํšŒ์ „ํ•˜๊ธฐ(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ๊ด„ํ˜ธ ํšŒ์ „ํ•˜๊ธฐ programmers.co.kr ์ฝ”๋“œ #include #include #include #include using namespace std; bool isOk(string s){ stack st; for(char c : s){ if(c==']'||c==')'||c=='}'){ if(st.empty()) return false; else if(c==']'&&st.top()=='[') st.pop(); else if(c==')'&&st.top()=='(') st.pop(); else if(c=='}'&&st.top()=='{') st.pop(); } else st.push(c); } if(st.empty()) return true; return false; } int s.. 2022. 4. 19.
[c++] ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค - ์ „๋ ฅ๋ง์„ ๋‘˜๋กœ ๋‚˜๋ˆ„๊ธฐ(Level 2) ๋ฌธ์ œ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - ์ „๋ ฅ๋ง์„ ๋‘˜๋กœ ๋‚˜๋ˆ„๊ธฐ 9 [[1,3],[2,3],[3,4],[4,5],[4,6],[4,7],[7,8],[7,9]] 3 7 [[1,2],[2,7],[3,7],[3,4],[4,5],[6,7]] 1 programmers.co.kr ์ฝ”๋“œ #include #include #include using namespace std; vectorgraph[101]; vectordivide; bool visited[101]; int group_cnt; int node_cnt[2]; void dfs(int node, pair cut){ visited[node] = 1; node_cnt[group_cnt]++; for(int i=0; i 2022. 4. 18.