답안 #156257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
156257 2019-10-04T16:31:12 Z mdn2002 Cezar (COCI16_cezar) C++14
0 / 100
28 ms 23928 KB
#include<bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
vector<string>v,an;
vector<int>gr[1000004];
vector<char>ans;
int n,d[105],vis[30];
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++)
    {
        for(int j=i+1; j<n; j++)
        {
            int x=0;
            while(an[i][x]==an[j][x])
            {
                x++;
                if(x>=an[i].size()||x>=an[j].size())
                {
                    if(an[i].size()>an[j].size())
                    {
                        cout<<"NE";
                        return 0;
                    }
                    break;
                }
            }
            if(x<an[i].size()&&x<an[i+1].size())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];
    }
}
/*
2
abc
ab
1 2
*/

Compilation message

cezar.cpp: In function 'void dfs(int)':
cezar.cpp:14:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<gr[x].size(); i++)
                  ~^~~~~~~~~~~~~
cezar.cpp: In function 'int main()':
cezar.cpp:48:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(x>=an[i].size()||x>=an[j].size())
                    ~^~~~~~~~~~~~~~
cezar.cpp:48:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(x>=an[i].size()||x>=an[j].size())
                                     ~^~~~~~~~~~~~~~
cezar.cpp:58:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(x<an[i].size()&&x<an[i+1].size())gr[(an[i][x]-'a')+1].push_back((an[i+1][x]-'a')+1);
                ~^~~~~~~~~~~~~
cezar.cpp:58:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(x<an[i].size()&&x<an[i+1].size())gr[(an[i][x]-'a')+1].push_back((an[i+1][x]-'a')+1);
                                ~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 23928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 28 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 23928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 23928 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23804 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 22 ms 23800 KB Output isn't correct
2 Halted 0 ms 0 KB -