-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathICPC_Balloons.cpp
40 lines (37 loc) · 1002 Bytes
/
ICPC_Balloons.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Problem statement:
In an ICPC contest, balloons are distributed as follows:
Whenever a team solves a problem, that team gets a balloon.
The first team to solve a problem gets an additional balloon.
A contest has 26 problems, labelled A, B, C, ..., Z. You are given the order of solved problems in the contest, denoted as a string s,
where the i-th character indicates that the problem si has been solved by some team. No team will solve the same problem twice.
Determine the total number of balloons that the teams recieved. Note that some problems may be solved by none of the teams.
*/
#include<iostream>
#include<string>
#include<set>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n;
cin >> n;
string s;
cin >> s;
set<char> mySet;
int count = 0;
for (int i = 0; i < s.length(); i++) {
if (!mySet.insert(s[i]).second) {
count += 1;
}
else
{
mySet.insert(s[i]);
count += 2;
}
}
cout << count << endl;
}
return 0;
}