본문 바로가기

C++

(226)
[BOJ] 19583번 싸이버개강총회 (C++) https://www.acmicpc.net/problem/19583 19583번: 싸이버개강총회 첫번째 줄에는 개강총회를 시작한 시간 S, 개강총회를 끝낸 시간 E, 개강총회 스트리밍을 끝낸 시간 Q가 주어진다. (00:00 ≤ S > t1 >> t2 >> t3; set first; int s =..
[BOJ] 2941번 크로아티아 알파벳 (C++) https://www.acmicpc.net/problem/2941 2941번: 크로아티아 알파벳 예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z= www.acmicpc.net #include #include using namespace std; int main() { string cro[8] = { "c=", "c-", "dz=", "d-", "lj", "nj", "s=", "z=" }; string str; cin >> str; for(int i = 0; i < 8; i++){ while(1){ int idx = str.find(..
[BOJ] 23028번 5학년은 다니기 싫어요 (C++) https://www.acmicpc.net/problem/23028 23028번: 5학년은 다니기 싫어요 2022년 1학기에는 전공 수업이 4과목, 비전공 수업이 3과목이 주어진다. 아리는 전공 2과목, 비전공 2과목을 듣게 되면 전공학점이 66학점, 총 학점이 132학점이 된다. 그래서 총 8학기 안에 졸업을 www.acmicpc.net #include using namespace std; int main() { int n, a, b, x, y; cin >> n >> a >> b; int rs = 8 - n; // 남은 학기 int rg = 66 - a; // 남은 전공 학점 int rc = 130 - b; // 남은 총 학점 for(int i = 0; i > x >> y..
[BOJ] 20291번 파일 정리 (C++) https://www.acmicpc.net/problem/20291 20291번: 파일 정리 친구로부터 노트북을 중고로 산 스브러스는 노트북을 켜자마자 경악할 수밖에 없었다. 바탕화면에 온갖 파일들이 정리도 안 된 채 가득했기 때문이다. 그리고 화면의 구석에서 친구의 메시지를 www.acmicpc.net #include #include #include using namespace std; int main() { int n; cin >> n; string str; map m; for(int i = 0; i > str; int idx = str.find('.'); str = str.substr(idx + 1); if(m.find(str) != m.end()){ m[str]++; ..
[BOJ] 18870번 좌표 압축 (C++) https://www.acmicpc.net/problem/18870 18870번: 좌표 압축 수직선 위에 N개의 좌표 X1, X2, ..., XN이 있다. 이 좌표에 좌표 압축을 적용하려고 한다. Xi를 좌표 압축한 결과 X'i의 값은 Xi > Xj를 만족하는 서로 다른 좌표의 개수와 같아야 한다. X1, X2, ..., XN에 좌 www.acmicpc.net #include #include #include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector v(n); for (int i = 0; i > v[i]; } vector tmp(v); ..
[BOJ] 10988번 팰린드롬인지 확인하기 (C++) https://www.acmicpc.net/problem/10988 10988번: 팰린드롬인지 확인하기 첫째 줄에 단어가 주어진다. 단어의 길이는 1보다 크거나 같고, 100보다 작거나 같으며, 알파벳 소문자로만 이루어져 있다. www.acmicpc.net #include #include #include using namespace std; int main() { string s1, s2; cin >> s1; s2 = s1; reverse(s1.begin(), s1.end()); if(s1 == s2) cout
[BOJ] 7576번 토마토 (C++) https://www.acmicpc.net/problem/7576 7576번: 토마토 첫 줄에는 상자의 크기를 나타내는 두 정수 M,N이 주어진다. M은 상자의 가로 칸의 수, N은 상자의 세로 칸의 수를 나타낸다. 단, 2 ≤ M,N ≤ 1,000 이다. 둘째 줄부터는 하나의 상자에 저장된 토마토 www.acmicpc.net #include #include using namespace std; #define MAX 1001 int N, M; int arr[MAX][MAX]; int dx[4] = { 1, -1, 0, 0 }; int dy[4] = { 0, 0, 1, -1 }; queue q; void bfs() { while (!q.empty()) { int x = q.front().first; int..
[BOJ] 2644번 촌수계산 (C++) https://www.acmicpc.net/problem/2644 2644번: 촌수계산 사람들은 1, 2, 3, …, n (1 ≤ n ≤ 100)의 연속된 번호로 각각 표시된다. 입력 파일의 첫째 줄에는 전체 사람의 수 n이 주어지고, 둘째 줄에는 촌수를 계산해야 하는 서로 다른 두 사람의 번호가 주어 www.acmicpc.net #include #include using namespace std; int n, m; int map[101][101]; int visit[101]; int depth[101]; void bfs(int start){ visit[start] = 1; queue q; q.push(start); while(!q.empty()){ int node = q.front(); q.pop();..