#include <iostream> #include <vector> #include <string> #include <map> using namespace std; vector<string> split (string s, string delimiter) { size_t pos_start = 0, pos_end, delim_len = delimiter.length(); string token; vector<string> res; while ((pos_end = s.find (delimiter, pos_start)) != string::npos) { token = s.substr (pos_start, pos_end - pos_start); pos_start = pos_end + delim_len; res.push_back (token); } res.push_back (s.substr (pos_start)); return res; } int main(){ int n; cin >> n; map<string, int> counts; string line; for(int i = 0; i < n; i++){ cin >> line; counts[line] ++; } if(counts.size() == 15 and counts["5A"] >= 2 and counts["5B"] >= 2 and counts["5C"] >= 2){ cout << "TAK" << std::endl; } else { cout << "NIE" << std::endl; } }
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 | #include <iostream> #include <vector> #include <string> #include <map> using namespace std; vector<string> split (string s, string delimiter) { size_t pos_start = 0, pos_end, delim_len = delimiter.length(); string token; vector<string> res; while ((pos_end = s.find (delimiter, pos_start)) != string::npos) { token = s.substr (pos_start, pos_end - pos_start); pos_start = pos_end + delim_len; res.push_back (token); } res.push_back (s.substr (pos_start)); return res; } int main(){ int n; cin >> n; map<string, int> counts; string line; for(int i = 0; i < n; i++){ cin >> line; counts[line] ++; } if(counts.size() == 15 and counts["5A"] >= 2 and counts["5B"] >= 2 and counts["5C"] >= 2){ cout << "TAK" << std::endl; } else { cout << "NIE" << std::endl; } } |