//============================================================================
// Name : 4012.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <string>
using namespace std;
int getBlack(string& str) {
int re = 0;
int state = 0;
for (int i = 0; i < str.length(); i++) {
if (state == 0) {
if (str[i] == '*') {
state = 1;
re++;
}
} else if (state == 1) {
if (str[i] == '*') {
re++;
} else {
state = 2;
}
} else if (state == 2) {
if (str[i] == '*') {
return -1;
}
}
}
return re;
}
int number(int a, int b, int s) {
if (a < s || b < s) {
return 0;
}
if (a == s && b == s) {
return 1;
}
return 2;
}
int main() {
ios::sync_with_stdio(false);
int m, n, s, k;
string str;
cin >> m >> n >> s >> k >> str;
int black = getBlack(str);
int count;
if (black == 0) {
int left = k - 1;
int right = m - k;
count = number(left, n, s) + number(right, n, s);
} else if (black != s) {
count = 0;
} else {
if (s == 1 || m == s || k == 1 || k == m) {
count = 1;
} else {
count = 2;
}
}
if (count == 0)
cout << "Impossible" << endl;
else if (count == 1)
cout << "Unique" << endl;
else
cout << "Ambiguous" << endl;
return 0;
}
poj4012
最新推荐文章于 2020-03-06 15:47:33 发布