| Task: | Sanalista |
| Sender: | Skye |
| Submission time: | 2020-09-30 16:27:38 +0300 |
| Language: | C++ (C++11) |
| Status: | READY |
| Result: | 100 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 100 |
| test | verdict | time | |
|---|---|---|---|
| #1 | ACCEPTED | 0.01 s | details |
| #2 | ACCEPTED | 0.01 s | details |
| #3 | ACCEPTED | 0.01 s | details |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:51:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < chrs.size(); i++) {
~~^~~~~~~~~~~~~Code
#include <iostream>
#include <istream>
#include <list>
#include <unordered_map>
#include <string>
using namespace std;
bool check_key(unordered_map<char, int> um, char key) {
if (um.find(key) == um.end())
return false;
return true;
}
int main() {
int amountOfStrings;
string stringInput;
cin >> amountOfStrings;
list<string> stringList = {};
for (int i = 0; i < amountOfStrings; i++) {
cin >> stringInput;
stringList.push_back(stringInput);
}
unordered_map<char, int> chrs = {};
int valueBefore;
bool success;
int xcounter = 0;
for (string s : stringList) {
chrs.clear();
success = true;
for (char c : s) {
if (check_key(chrs, c)) {
auto it = chrs.find(c);
valueBefore = it->second;
chrs.erase(c);
chrs.insert({ c, valueBefore + 1 });
}
else {
chrs.insert({ c, 1 });
}
}
for (pair<char, int> e : chrs) {
for (int i = 0; i < chrs.size(); i++) {
if ((e.second % 2) == 0) {
continue;
}
else {
success = false;
break;
}
}
}
if (success) {
xcounter++;
}
}
cout << xcounter << endl;
}
Test details
Test 1
Verdict: ACCEPTED
| input |
|---|
| 1000 korvata sopimusaika nuhatartunta korttiautomaatti ... |
| correct output |
|---|
| 15 |
| user output |
|---|
| 15 |
Test 2
Verdict: ACCEPTED
| input |
|---|
| 1000 pub hansikaslokero erikoisvalmisteinen unijukka ... |
| correct output |
|---|
| 42 |
| user output |
|---|
| 42 |
Test 3
Verdict: ACCEPTED
| input |
|---|
| 1000 haapalastu toipumisaika mustalaiskieli taidelainaamo ... |
| correct output |
|---|
| 70 |
| user output |
|---|
| 70 |
