전체 글(331)
-
[BOJ] 1149번 : RGB거리
1. problem : https://www.acmicpc.net/problem/1149 2. solution 1:#include using namespace std;int n;int d[1005][3];int r[1005];int g[1005];int b[1005];int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i = 1; i > r[i] >> g[i] >> b[i]; d[1][0] = r[1]; d[1][1] = g[1]; d[1][2] = b[1]; for (int i = 2; i source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/bl..
2024.08.31 -
[BOJ] 9095번 : 1,2,3 더하기
1. problem : https://www.acmicpc.net/problem/9095 2. solution 1 :#include using namespace std;int t;int board[12];int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> t; while (t--) { int n; cin >> n; board[0] = 1, board[1] = 1, board[2] = 2; for (int i = 3; i
2024.08.31 -
[BOJ] 1463번 : 1로 만들기
1. problem : https://www.acmicpc.net/problem/1463 2. solution 1:// Authored by : BaaaaaaaaaaarkingDog// Co-authored by : -// http://boj.kr/161694ef04f04d8dbe826e253622c1cb#include using namespace std;int d[1000005];int n;int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; d[1] = 0; for(int i = 2; i source code 출처 : https://github.com/encrypted-def/basic-algo-lecture/blob/master/..
2024.08.30 -
[C++] 구조체
1. 사용법 #include using namespace std;int main(void) { ios::sync_with_stdio(0); cin.tie(0); struct position { int xpos; int ypos; }; struct position pos; pos.xpos = 1; pos.ypos = 2; cout 정확하지는 않지만, 비유를 해보면 , position이라는 클래스의 이름에 객체를 생성한다. 이때 객체의 이름은 pos다. 각각의 메서드에 접근하기 위해서는. 을 이용해 멤버변수에 접근한다. (그냥 내가 이해하기 쉽도록 작성) 구조체를 정의 후 선언하는 방법; #include using namespace std;int main(void) { ios::sync_wi..
2024.08.30 -
[BOJ] 7795번 : 먹을 것인가 먹힐 것인가
1. problem : https://www.acmicpc.net/problem/7795 2. solution 1:#include using namespace std;int t;vector> vc;void mergeSort(vector>& v1, vector>& v2) { vector> temp; int v1idx = 0, v2idx = 0; for (int i = 0; i > t; for (int i = 0; i > va; vector> vb; cin >> n >> m; for (int i = 0; i > x; va.push_back(make_pair(x,'A')); } for (int i = 0; i > x; vb.push_back(make_pair(x, 'B')); } //..
2024.08.30 -
[BOJ] 2910번 : 빈도 정렬
1. problem : https://www.acmicpc.net/problem/2910 2. solution 1 :#include using namespace std;vector> nums; // {숫자, 순서, 빈도} 초기값 {0,0,0}int n, c; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> c; for (int i = 0; i > x; auto it = find_if(nums.begin(), nums.end(), [x](const tuple& t) { return get(t) == x; }); if (it != nums.end()) { get(*it)++; // 이미 vector에 존재하는 경우, 빈도..
2024.08.30