| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 994120 | vjudge1 | Rima (COCI17_rima) | C++17 | 1103 ms | 84576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
ios::sync_with_stdio(0);
cin.tie(NULL),cout.tie(NULL);
int n;
cin>>n;
map<int,vector<string>> mp;
for (int i=0;i<n;i++)
{
string s;
cin>>s;
mp[s.size()].push_back(s);
}
vector<string> v;
for (auto i:mp)
for (auto j:i.second)
v.push_back(j);
reverse(v.begin(),v.end());
map<string,int> ans;
unordered_set<string> se;
// ans.reserve(500369);
se.reserve(500369);
for (auto s:v)
se.insert(s);
while (!v.empty())
{
string s=v.back();
v.pop_back();
int mx=0,m=s.size();
string s1=s.substr(1,m-1);
if (ans.find(s1)!=ans.end())
mx=ans[s1];
s1='0'+s1;
for (int c='a';c<='z';c++)
{
s1[0]=c;
if (se.find(s1)!=se.end())
mx++;
}
ans[s]=mx;
}
int res=0;
for (auto i:ans)
res=max(res,i.second);
cout<<res<<endl;
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
