ํ์ด ๋ฐฉ๋ฒ
๋ฌธ์์ด ๊ตฌํ ๋ฌธ์ ์ด๋ค.
์ฃผ์ด์ง ์ฌ๋ฌ๊ฐ์ ๋ฌธ์์ด๋ค์ ํ ๋ฌธ์์ด๋ก ํฉ์น ํ์ ๊ทธ ๋ฌธ์์ด์์๋ง ํ์ธํ๋ฉด ๋๋ ๋ฌธ์ ์๋ค.
๊ธฐ์ค ๋ฌธ์์ด์ ์ก์์ฃผ๊ณ , ๋น๊ตํ ๋ฌธ์์ด์์
? ์๋๋ฉด ์ํ๋ฒณ์ผ๋ก ์ด๋ฃจ์ด์ ธ์๊ธฐ ๋๋ฌธ์ ์ด๋ฅผ ํ์ธํ๊ณ ํฉ์ณ์ค ์ ์๋ค.
๊ทธ ํ, ์ต์ข ๋ฌธ์์ด์์ w(๊ฐ๋ก ๊ธธ์ด)๋งํผ ์ชผ๊ฐ์ ํ์ธํ๋ฉด ์ฝ๊ฒ ํด๊ฒฐํ ์ ์๋ ๋ฌธ์ ์ด๋ค.
์ฝ๋
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <limits.h>
#include <regex>
#include <sstream>
#include <tuple>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// ๋ฌธ์์ด ๋ณต์ํ๊ธฐ
int n, h, w; // ๋ฌธ์์ด ๊ธธ์ด, ์ธ๋ก ๊ธธ์ด, ๊ฐ๋ก ๊ธธ์ด
cin >> n >> h >> w;
vector <string> v; // ๋ฌธ์์ด ์ ์ฅ
string temp; // ๊ธฐ์ค ๋ฌธ์์ด
cin >> temp;
for(int i = 1; i < h; i++){ // ๋น๊ต ๋ฌธ์์ด ํ์ธ
string str;
cin >> str;
for(int j = 0; j < str.size(); j++){
if(temp[j] == '?' && str[j] != '?'){
temp[j] = str[j];
}
}
}
// cout << temp << "\n";
string ans = "";
for(int i = 0; i < n; i++){
int check = 0;
for(int j = i * w; j < i * w + w; j++){
if(temp[j] != '?'){
ans += temp[j];
check = 1;
break;
}
}
if(check == 0){
ans += '?';
}
}
cout << ans << "\n";
return 0;
}
'์๊ณ ๋ฆฌ์ฆ > [๋ฐฑ์ค]' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
BOJ_18258 : ํ 2 (C++) (0) | 2023.02.21 |
---|---|
BOJ_16208 : ๊ท์ฐฎ์ (C++) (0) | 2023.02.20 |
BOJ_14929 : ๊ท์ฐฎ์ (SIB) (C++) (0) | 2023.02.14 |
BOJ_5671 : ํธํ ๋ฐฉ ๋ฒํธ (C++) (0) | 2023.02.13 |