题解 AT836 【UTPC】
STL大法好
map不好吗
map也是打表,但最好的一点在于只要存圈圈为1和2的7个,因为map没有赋值的自动设为0,与题意一样
注意这个题目是这样的,并不是只是圈圈数于UTPC一样,每一位也要一样,这就是为什么有人过不了#21的原因
代码:
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
map<char, int> mp;
char ch;
int main()
{
mp['A'] = mp['D'] = mp['O'] = mp['P'] = mp['Q'] = mp['R'] = 1;
mp['B'] = 2;
int sum = 0, cnt = 1;
while(scanf("%c", &ch) != EOF)
{
if(cnt == 1 || cnt == 2 || cnt == 4)
{
if(mp[ch])
{
cout << "no\n";
return 0;
}
}
else if(cnt == 3)
{
if(!mp[ch] || mp[ch] == 2)
{
cout << "no\n";
return 0;
}
}
sum += mp[ch];
if(sum >= 2)
{
cout << "no\n";
return 0;
}
cnt++;
}
cout << "yes\n";
return 0;
}

浙公网安备 33010602011771号