Skip to content

Instantly share code, notes, and snippets.

@HyeonWooKim
Created December 12, 2016 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HyeonWooKim/e45909354f790943cc757fd0dc4d6eae to your computer and use it in GitHub Desktop.
Save HyeonWooKim/e45909354f790943cc757fd0dc4d6eae to your computer and use it in GitHub Desktop.
BOJ 1343 폴리오미노
#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