Facebook Hacker Cup Test Round Characters

Facebook Hacker Cup Test Round Characters

You’re interested in figuring out the number of case-insensitive unique characters in some string. This sounds simple and easily-automated, so you just decide to just go for it.

Input

Your input will consist of an integer N followed by a newline. N test cases will follow, all separated by newlines. Each test case is a string of letters containing some combination of letters (upper- and lower-case are allowed), the space character, and the characters contained in the string ?!.’$%&*:;,.

Output

Your output should consist of one integer per case, separated by whitespace, indicating the number of case-insensitive unique characters contained in the input string.

Constraints

5 ≤ N ≤ 25
Input strings will not exceed 100 characters in length.

————————————

#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <vector>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <cfloat>
#include <ctime>
#include <climits>
using namespace std;

typedef long long int64;
typedef unsigned long long uint64;

template<typename T> int size(const T& c) { return int(c.size()); }
template<typename T> T abs(T x) { return x < 0 ? -x : x; }
template<typename T> T sqr(T x) { return x*x; }
template<typename T> bool remin(T& x, const T& y) { if (x <= y) return false; x = y; return true; }
template<typename T> bool remax(T& x, const T& y) { if (x >= y) return false; x = y; return true; }

#define FOR(i, a, b) for (int i(a), _b(b); i <= _b; ++i)
#define FORD(i, a, b) for (int i(a), _b(b); i >= _b; –i)
#define REP(i, n) for (int i(0), _n(n); i < _n; ++i)
#define REPD(i, n) for (int i((n) – 1); i >= 0; –i)

int main() {
freopen(“input.txt”, “rt”, stdin);
freopen(“output.txt”, “wt”, stdout);

int t;
scanf(“%d “, &t);
while (t –> 0) {
static char buf[1<<20];
gets(buf);
set<char> s;
for (int i = 0; buf[i]; ++i)
s.insert(tolower(buf[i]));
printf(“%d\n”, size(s));
}
}

We will be happy to hear your thoughts

Leave a reply

TechEggs
Logo