Submission #1984134
Source Code Expand
#include <cstdlib> #include <algorithm> #include <iostream> #include <map> template< typename Itr, typename F > static inline void countSeq(const Itr& begin, const Itr& end, const F& f) { int cnt = 0; auto c = *begin; for (auto itr = begin; itr != end; ++itr) { if (*itr != c) { f(c, cnt); c = *itr; cnt = 1; } else { cnt++; } } f(c, cnt); } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int n; std::cin >> n; std::map<char, int> charCntMap; // init std::string s; std::cin >> s; std::sort(std::begin(s), std::end(s)); countSeq(std::cbegin(s), std::cend(s), [&charCntMap](auto c, auto cnt){ charCntMap[c] = cnt; }); for (int i = 0; i < n - 1; i++) { std::cin >> s; std::sort(std::begin(s), std::end(s)); countSeq(std::cbegin(s), std::cend(s), [&s, &charCntMap](auto c, auto cnt){ if (charCntMap.find(c) == std::cend(charCntMap)) { charCntMap[c] = 0; } else { charCntMap[c] = std::min(charCntMap[c], cnt); } }); for (auto&& e : charCntMap) { if (s.find(e.first) == std::string::npos) { e.second = 0; } } } for (const auto& e : charCntMap) { for (decltype(e.second) i = 0; i < e.second; i++) { std::cout.put(e.first); } } std::cout << std::endl; return EXIT_SUCCESS; }
Submission Info
Submission Time | |
---|---|
Task | C - Dubious Document |
User | koturn |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1454 Byte |
Status | AC |
Exec Time | 1 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt |
All | 0_000.txt, 0_001.txt, dec_half.txt, hand.txt, max.txt, max_10.txt, max_5.txt, maxx.txt, rnd.txt, single.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
dec_half.txt | AC | 1 ms | 256 KB |
hand.txt | AC | 1 ms | 256 KB |
max.txt | AC | 1 ms | 256 KB |
max_10.txt | AC | 1 ms | 256 KB |
max_5.txt | AC | 1 ms | 256 KB |
maxx.txt | AC | 1 ms | 256 KB |
rnd.txt | AC | 1 ms | 256 KB |
single.txt | AC | 1 ms | 256 KB |