# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
284981 | shrek12357 | Rima (COCI17_rima) | C++14 | 1095 ms | 41276 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
bool comp(string a, string b) {
return a.size() < b.size();
}
int main() {
int n;
cin >> n;
vector<string> words;
map<string, int> count;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
words.push_back(s);
}
sort(words.begin(), words.end(), comp);
int best = 0;
for (int i = 0; i < words.size(); i++) {
count[words[i]] = count[words[i].substr(1)] + 1;
count[words[i].substr(1)]++;
best = max(best, max(count[words[i]], count[words[i].substr(1)]));
}
cout << best << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |