Submission #158206

# Submission time Handle Problem Language Result Execution time Memory
158206 2019-10-15T13:33:10 Z GoldNextYear Cezar (COCI16_cezar) C++14
Compilation error
0 ms 0 KB
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;
const ll mod2=998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
int n;
    string s[109],ss[109];
    vi v[29];
    int done[29],deg[29],ans[29],yes[29];
    void dfs(int node){
            done[node]=1;
            for(auto u:v[node]){
                    if(done[u]==2)C;
                    if(done[u]==1)cout<<"NE"<<endl,exit(0);
                    dfs(u);
            }
            done[node]=2;
    }
    void make(string a,string b){
            int z=0;
            for(int i=0;i<min((int) a.size(),(int) b.size());i++){
                    if(a[i]==b[i])C;
                    z=1;
                    v[a[i]-'a'].pb(b[i]-'a');
                    deg[b[i]-'a']++;
                break;
            }
    }
int pre(string x,string xx){
        if(x.size()>xx.size())return 0;
        int z=0;
        for(int i=0;i<x.size();i++){
                if(x[i]!=xx[i])z=1;
        }
        return !z;
}
    int main(){
            cin>>n;
            for(int i=0;i<n;i++)cin>>ss[i];
            for(int i=0;i<n;i++){
                    int x;cin>>x;
                    x--;
                    s[i]=ss[x];
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<i;j++){
                if(pre(s[j],s[i])){
                                cout<<"NE"<<endl;
                                exit(0);
                        }
                }
            }
            for(int i=0;i<n-1;i++){
                    if(pre(s[i],s[i+1]))C;
                    make(s[i],s[i+1]);
            }
            for(int i=0;i<26;i++){
                    if(done[i]==0)dfs(i);
            }
            queue<int>q;
            for(int i=0;i<26;i++)
                    if(deg[i]==0)q.push(i),yes[i]=1;
            int last=(int) 'a';
            while(q.size()){
                    int node=q.front();q.pop();
                    ans[node]=last++;
                    for(auto u:v[node]){
                            if(yes[u])C;
                            deg[u]--;
                            if(deg[u]==0)q.push(u),yes[u]=1;
                    }
            }
      cout<<"DA"<<endl;
            for(int i=0;i<26;i++)cout<<(char)ans[i];
            cout<<endl;
    }

Compilation message

cezar.cpp:10:9: error: 'pair' does not name a type
 typedef pair<int,int> pi;
         ^~~~
cezar.cpp:11:9: error: 'pair' does not name a type
 typedef pair<ll,ll> pll;
         ^~~~
cezar.cpp:12:9: error: 'vector' does not name a type
 typedef vector<int> vi;
         ^~~~~~
cezar.cpp:13:9: error: 'vector' does not name a type
 typedef vector<ll> vll;
         ^~~~~~
cezar.cpp:14:9: error: 'vector' does not name a type
 typedef vector<pi> vpi;
         ^~~~~~
cezar.cpp:15:9: error: 'vector' does not name a type
 typedef vector<pll> vpll;
         ^~~~~~
cezar.cpp:19:14: error: 'acos' was not declared in this scope
 const ld pai=acos(-1);
              ^~~~
cezar.cpp:21:5: error: 'string' does not name a type; did you mean 'struct'?
     string s[109],ss[109];
     ^~~~~~
     struct
cezar.cpp:22:5: error: 'vi' does not name a type
     vi v[29];
     ^~
cezar.cpp: In function 'void dfs(int)':
cezar.cpp:26:24: error: 'v' was not declared in this scope
             for(auto u:v[node]){
                        ^
cezar.cpp:28:35: error: 'cout' was not declared in this scope
                     if(done[u]==1)cout<<"NE"<<endl,exit(0);
                                   ^~~~
cezar.cpp:28:47: error: 'endl' was not declared in this scope
                     if(done[u]==1)cout<<"NE"<<endl,exit(0);
                                               ^~~~
cezar.cpp:28:47: note: suggested alternative: 'enum'
                     if(done[u]==1)cout<<"NE"<<endl,exit(0);
                                               ^~~~
                                               enum
cezar.cpp:28:52: error: 'exit' was not declared in this scope
                     if(done[u]==1)cout<<"NE"<<endl,exit(0);
                                                    ^~~~
cezar.cpp: At global scope:
cezar.cpp:33:15: error: variable or field 'make' declared void
     void make(string a,string b){
               ^~~~~~
cezar.cpp:33:15: error: 'string' was not declared in this scope
cezar.cpp:33:15: note: suggested alternative: 'struct'
     void make(string a,string b){
               ^~~~~~
               struct
cezar.cpp:33:24: error: 'string' was not declared in this scope
     void make(string a,string b){
                        ^~~~~~
cezar.cpp:33:24: note: suggested alternative: 'struct'
     void make(string a,string b){
                        ^~~~~~
                        struct
cezar.cpp:43:9: error: 'string' was not declared in this scope
 int pre(string x,string xx){
         ^~~~~~
cezar.cpp:43:9: note: suggested alternative: 'struct'
 int pre(string x,string xx){
         ^~~~~~
         struct
cezar.cpp:43:18: error: 'string' was not declared in this scope
 int pre(string x,string xx){
                  ^~~~~~
cezar.cpp:43:18: note: suggested alternative: 'struct'
 int pre(string x,string xx){
                  ^~~~~~
                  struct
cezar.cpp:43:27: error: expression list treated as compound expression in initializer [-fpermissive]
 int pre(string x,string xx){
                           ^
cezar.cpp: In function 'int main()':
cezar.cpp:52:13: error: 'cin' was not declared in this scope
             cin>>n;
             ^~~
cezar.cpp:52:13: note: suggested alternative: 'main'
             cin>>n;
             ^~~
             main
cezar.cpp:53:38: error: 'ss' was not declared in this scope
             for(int i=0;i<n;i++)cin>>ss[i];
                                      ^~
cezar.cpp:57:21: error: 's' was not declared in this scope
                     s[i]=ss[x];
                     ^
cezar.cpp:57:26: error: 'ss' was not declared in this scope
                     s[i]=ss[x];
                          ^~
cezar.cpp:61:24: error: 's' was not declared in this scope
                 if(pre(s[j],s[i])){
                        ^
cezar.cpp:61:33: error: 'pre' cannot be used as a function
                 if(pre(s[j],s[i])){
                                 ^
cezar.cpp:62:33: error: 'cout' was not declared in this scope
                                 cout<<"NE"<<endl;
                                 ^~~~
cezar.cpp:62:45: error: 'endl' was not declared in this scope
                                 cout<<"NE"<<endl;
                                             ^~~~
cezar.cpp:62:45: note: suggested alternative: 'enum'
                                 cout<<"NE"<<endl;
                                             ^~~~
                                             enum
cezar.cpp:63:33: error: 'exit' was not declared in this scope
                                 exit(0);
                                 ^~~~
cezar.cpp:68:28: error: 's' was not declared in this scope
                     if(pre(s[i],s[i+1]))C;
                            ^
cezar.cpp:68:39: error: 'pre' cannot be used as a function
                     if(pre(s[i],s[i+1]))C;
                                       ^
cezar.cpp:69:26: error: 's' was not declared in this scope
                     make(s[i],s[i+1]);
                          ^
cezar.cpp:69:21: error: 'make' was not declared in this scope
                     make(s[i],s[i+1]);
                     ^~~~
cezar.cpp:69:21: note: suggested alternative: 'main'
                     make(s[i],s[i+1]);
                     ^~~~
                     main
cezar.cpp:74:13: error: 'queue' was not declared in this scope
             queue<int>q;
             ^~~~~
cezar.cpp:74:19: error: expected primary-expression before 'int'
             queue<int>q;
                   ^~~
cezar.cpp:76:34: error: 'q' was not declared in this scope
                     if(deg[i]==0)q.push(i),yes[i]=1;
                                  ^
cezar.cpp:78:19: error: 'q' was not declared in this scope
             while(q.size()){
                   ^
cezar.cpp:81:32: error: 'v' was not declared in this scope
                     for(auto u:v[node]){
                                ^
cezar.cpp:87:7: error: 'cout' was not declared in this scope
       cout<<"DA"<<endl;
       ^~~~
cezar.cpp:87:19: error: 'endl' was not declared in this scope
       cout<<"DA"<<endl;
                   ^~~~
cezar.cpp:87:19: note: suggested alternative: 'enum'
       cout<<"DA"<<endl;
                   ^~~~
                   enum