# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
182409 |
2020-01-09T18:22:38 Z |
XmtosX |
Rima (COCI17_rima) |
C++17 |
|
5 ms |
504 KB |
#include <bits/stdc++.h>
using namespace std;
int n,ans;
string s[20];
vector <int> v[20];
bool vis[20];
bool check (string s1,string s2)
{
int x=max(s1.size(),s2.size())-1;
return s1.substr(0,x)==s2.substr(0,x);
}
int dfs (int x)
{
vis[x]=true;
int maxx=0;
for (int i=0;i<v[x].size();i++)
{
if (!vis[v[x][i]])
maxx=max(maxx,dfs(v[x][i])+1);
}
vis[x]=false;
return maxx;
}
int main()
{
cin >>n;
for (int i=0;i<n;i++)
{
cin >>s[i];
reverse(s[i].begin(),s[i].end());
}
for (int i=0;i<n;i++)
{
for (int j=i+1;j<n;j++)
{
if (check(s[i],s[j]))
{
v[i].push_back(j);
v[j].push_back(i);
}
}
}
for (int i=0;i<n;i++)
ans=max(ans,dfs(i)+1);
cout <<ans;
return 0;
}
Compilation message
rima.cpp: In function 'int dfs(int)':
rima.cpp:16:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i=0;i<v[x].size();i++)
~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
5 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
5 |
Runtime error |
4 ms |
504 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
7 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
8 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
2 ms |
376 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
2 ms |
380 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |