Submission #133320

# Submission time Handle Problem Language Result Execution time Memory
133320 2019-07-20T12:09:19 Z forelax Cezar (COCI16_cezar) C++14
0 / 100
3 ms 504 KB
#include<bits/stdc++.h>
using namespace std;
bool good=true;
vector<vector<bool> > dir(26,vector<bool> (26));
vector<bool> visited(26);
vector<bool> visiting(26);
vector<int> ord;
void dfs(int i){
    if(visiting[i]){
        good=false;
        return;
    }
    visiting[i]=true;
    for(int j = 0 ; j < 26 ; j ++){
        if(dir[i][j]&&!visited[j]){
            dfs(j);
        }
    }
    ord.push_back(i);
    visited[i]=true;
}
int main(){
    int n;
    cin>>n;
    vector<string> g(n),s(n);
    for(int i = 0 ; i < n ; i ++)cin>>g[i];
    for(int i = 0,j ; i < n ; i ++){
        cin>>j;
        s[i]=g[j-1];
    }
    for(int i = 0 ; i < n ; i ++){
        for(int j = i+1 ; j < n ; j ++){
            for(int k = 0 ; true ; k ++){
                if(k>s[i].length())break;
                if(k>s[j].length()){
                    cout<<"NE";
                    return 0;
                }
                if(s[i][k]==s[j][k])continue;
                dir[s[i][k]-'a'][s[j][k]-'a']=true;
                break;
            }
        }
    }
    for(int i = 25 ; i >= 0 ; i --){
        if(!visited[i]){
            dfs(i);
            if(!good){
                cout<<"NE";
                return 0;
            }
        }
    }
    cout<<"DA"<<endl;
    vector<char> rez(26);
    reverse(ord.begin(),ord.end());
    for(int i = 0 ; i < 26 ; i ++){
        rez[ord[i]]=char('a'+i);
    }
    for(int i = 0 ; i < rez.size() ; i ++)cout<<rez[i];
}

Compilation message

cezar.cpp: In function 'int main()':
cezar.cpp:34:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(k>s[i].length())break;
                    ~^~~~~~~~~~~~~~
cezar.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(k>s[j].length()){
                    ~^~~~~~~~~~~~~~
cezar.cpp:60:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < rez.size() ; i ++)cout<<rez[i];
                     ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 248 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -