#include <stdio.h> #include <iostream> #include <set> #include <map> #include <queue> #include <vector> #include <string> #include <math.h> #include <algorithm> using namespace std; string board; string ans; int main(void) { // freopen("B1343_input.txt", "r", stdin); cin >> board; for(int i = 0; i < board.size();) { if(board[i] == '.') { ans += '.'; i += 1; continue; } int cnt = 0; for(int j = i; j < board.size() && board[j] == 'X'; j++) { cnt++; } i += cnt; if(cnt % 2 == 1) { cout << "-1"; return 0; } while(1) { if(cnt >= 4) { ans += "AAAA"; cnt -= 4; } else if(cnt == 2) { ans += "BB"; cnt -= 2; } else { break; } } } cout << ans; return 0; } | cs |
'Baekjoon > Greedy' 카테고리의 다른 글
[백준 11047] 동전 0 (Greedy) (C/C++) (0) | 2020.03.07 |
---|