Skip to content

Instantly share code, notes, and snippets.

@jason790228
Last active July 26, 2017 10:56
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 jason790228/c4d00ae37dabbb96f35e1f6fb4837390 to your computer and use it in GitHub Desktop.
Save jason790228/c4d00ae37dabbb96f35e1f6fb4837390 to your computer and use it in GitHub Desktop.
10415
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <bitset>
using namespace std;
static const map<char, bitset<10>> ori =
{
{ 'c', bitset<10>("0111001111") },
{ 'd', bitset<10>("0111001110") },
{ 'e', bitset<10>("0111001100") },
{ 'f', bitset<10>("0111001000") },
{ 'g', bitset<10>("0111000000") },
{ 'a', bitset<10>("0110000000") },
{ 'b', bitset<10>("0100000000") },
{ 'C', bitset<10>("0010000000") },
{ 'D', bitset<10>("1111001110") },
{ 'E', bitset<10>("1111001100") },
{ 'F', bitset<10>("1111001000") },
{ 'G', bitset<10>("1111000000") },
{ 'A', bitset<10>("1110000000") },
{ 'B', bitset<10>("1100000000") }
};
static const map<char, bitset<10>> not_ori =
{
{ 'c', bitset<10>("1000110000") },
{ 'd', bitset<10>("1000110001") },
{ 'e', bitset<10>("1000110011") },
{ 'f', bitset<10>("1000110111") },
{ 'g', bitset<10>("1000111111") },
{ 'a', bitset<10>("1001111111") },
{ 'b', bitset<10>("1011111111") },
{ 'C', bitset<10>("1101111111") },
{ 'D', bitset<10>("0000110001") },
{ 'E', bitset<10>("0000110011") },
{ 'F', bitset<10>("0000110111") },
{ 'G', bitset<10>("0000111111") },
{ 'A', bitset<10>("0001111111") },
{ 'B', bitset<10>("0011111111") }
};
void count_r(const bitset<10> &t, vector<size_t> &r)
{
for (size_t j = 0; j < 10; j++)
{
if (t[j]) r[j]++;
}
}
void run(const string& s)
{
vector<size_t> record(10, 0);
if (!s.empty())
{
count_r(ori.at(s[0]), record);
for (size_t i = 1; i < s.length(); i++)
{
count_r((not_ori.at(s[i - 1]) & ori.at(s[i])), record);
}
}
for (int i = record.size() - 1; i > 0; i--)
{
cout << record[i] << " ";
}
cout << record[0] << endl;
}
int main()
{
int a;
cin >> a;
cin.ignore(1, '\n');
for (int i = 0; i < a; i++)
{
string s;
getline(cin, s);
run(s);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment