Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 다익스트라
- ue5
- 그래프
- VR
- 유니온 파인드
- 누적 합
- Unreal Engine 5
- 정렬
- c++
- 시뮬레이션
- 다이나믹 프로그래밍
- 재귀
- 그리디 알고리즘
- 자료구조
- 구현
- 브루트포스
- 투 포인터
- 문자열
- 스택
- Team Fortress 2
- 백준
- 트리
- 수학
- 우선순위 큐
- 백트래킹
- 유니티
- 알고리즘
- XR Interaction Toolkit
- BFS
- DFS
Archives
- Today
- Total
1일1알
백준 3005번 크로스워드 퍼즐 쳐다보기 C++ 본문
https://www.acmicpc.net/problem/3005
3005번: 크로스워드 퍼즐 쳐다보기
첫째 줄에 R과 C (2 ≤ R, C ≤ 20)가 주어진다. R는 행의 개수, C는 열의 개수이다. 그 다음 R개의 줄엔 C개의 문자가 포함되어 있다. 각 문자는 영어 알파벳 소문자 또는 '#'이며, '#'인 경우에는 막혀
www.acmicpc.net
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int r, c;
vector<vector<char>> v;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> r >> c;
v = vector<vector<char>>(r, vector<char>(c));
for (int i = 0; i < r; i++) {
for (int j = 0; j < c; j++) {
cin >> v[i][j];
}
}
set<string> s;
for (int i = 0; i < r; i++) {
string str = "";
for (int j = 0; j < c; j++) {
if (v[i][j] == '#') {
if (str.length() >= 2) s.insert(str);
str = "";
continue;
}
str += v[i][j];
}
if (str.length() >= 2) s.insert(str);
}
for (int i = 0; i < c; i++) {
string str = "";
for (int j = 0; j < r; j++) {
if (v[j][i] == '#') {
if (str.length() >= 2) s.insert(str);
str = "";
continue;
}
str += v[j][i];
}
if (str.length() >= 2) s.insert(str);
}
string ans = *s.begin();
cout << ans;
}
'알고리즘' 카테고리의 다른 글
백준 17391번 무한부스터 C++ (0) | 2023.01.09 |
---|---|
백준 2785번 체인 C++ (1) | 2023.01.08 |
백준 16437번 양 구출 작전 C++ (0) | 2023.01.06 |
백준 14923번 미로 탈출 C++ (0) | 2023.01.05 |
백준 13903번 출근 C++ (0) | 2023.01.04 |