# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156250 | mdn2002 | Cezar (COCI16_cezar) | C++14 | 3 ms | 632 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<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
vector<string>v,an;
vector<int>gr[10004];
vector<char>ans;
int n,d[105],vis[10004];
bool dt[30];
void dfs(int x)
{
ans.push_back('a'+(x-1));
dt[x-1]=true;
vis[x]=1;
for(int i=0; i<gr[x].size(); i++)
{
int u=gr[x][i];
if(vis[u]==1)
{
cout<<"NE";
exit(0);
}
else if(vis[u]==0)dfs(u);
}
vis[x]=2;
}
int main()
{
cin>>n;
for(int i=0; i<n; i++)
{
string s;
cin>>s;
v.push_back(s);
}
for(int i=0; i<n; i++)
{
cin>>d[i];
an.push_back(v[d[i]-1]);
}
for(int i=0; i<n-1; i++)
{
int x=0;
while(an[i][x]==an[i+1][x])x++;
gr[(an[i][x]-'a')+1].push_back((an[i+1][x]-'a')+1);
}
dfs(an[0][0]-'a'+1);
cout<<"DA"<<endl;
for(int i=0;i<26;i++)
{
if(dt[i]==false)ans.push_back('a'+i);
}
for(int i=0;i<26;i++)cout<<ans[i];
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |