Created
December 12, 2016 16:25
-
-
Save HyeonWooKim/e45909354f790943cc757fd0dc4d6eae to your computer and use it in GitHub Desktop.
BOJ 1343 폴리오미노
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<vector> | |
#include<string> | |
#include<cstring> | |
#include<algorithm> | |
using namespace std; | |
int main() | |
{ | |
ios::sync_with_stdio(false); | |
string s, ans; | |
cin >> s; | |
int len = s.length(), p = 0; | |
while (p < len) | |
{ | |
if (s[p] == '.') p++, ans += "."; | |
else | |
{ | |
int k = 0; | |
while (s[p] == 'X' && p < len)k++,p++; | |
if (k % 2 == 1) | |
{ | |
cout << "-1\n"; | |
return 0; | |
} | |
while (k) | |
{ | |
if (k >= 4) k -= 4, ans += "AAAA"; | |
else k -= 2, ans += "BB"; | |
} | |
} | |
} | |
cout << ans; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment