Submission #167244

# Submission time Handle Problem Language Result Execution time Memory
167244 2019-12-06T23:49:20 Z PedroBigMan Cezar (COCI16_cezar) C++14
0 / 100
2 ms 380 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF ((ll) pow(2,63) -1)
#define si signed
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    vector<vector<bool> > adj; 
    vector<bool> xx; REP(i,0,26) {xx.pb(false);}
    REP(i,0,26) {adj.pb(xx);}
    ll N; cin>>N; 
    vector<pair<ll,string> > s;
    REP(i,0,N) {s.pb(mp(0,""));}
    string str; ll cur;
    REP(i,0,N) 
    {
        cin>>str;
        s[i].ss=str;
    }
    REP(i,0,N) 
    {
        cin>>cur;
        s[cur-1].ff=i;
    }
    sort(s.begin(),s.end());
    REP(i,0,N) {cout<<s[i].ss<<endl;}
    string a,b;
    REP(i,0,N-1)
    {
        a=s[i].ss; b=s[i+1].ss;
        bool done=false;
        REP(j,0,min(a.size(),b.size()))
        {
            if(a[j]!=b[j])
            {
                adj[(ll) (a[j]-'a')][(ll) (b[j]-'a')]=true;
                done=true;
                break;
            }
        }
        if(!done && a.size()>b.size()) {cout<<"NE"<<endl; return 0;}
    }
    vector<ll> ans;
    vector<bool> visited; REP(i,0,26) {visited.pb(false);}
    while(ans.size()<26)
    {
        bool al=false;
        REP(i,0,26)
        {
            if(visited[i]) {continue;}
            bool ok=true;
            REP(j,0,26)
            {
                if(j==i || visited[j]) {continue;}
                if(adj[j][i]) {ok=false;}
            }
            if(ok)
            {
                ans.pb(i);
                visited[i]=true;
                al=true;
                break;
            }
        }
        if(!al) {cout<<"NE"<<endl; return 0;}
    }
    cout<<"DA"<<endl;
    vector<ll> corr; REP(i,0,26) {corr.pb(0);}
    REP(i,0,26)
    {
        corr[ans[i]]=i;
    }
    REP(i,0,26) {cout<<((char) ((ll) ('a')+corr[i]));}
    cout<<endl;
    return 0;
}

Compilation message

cezar.cpp: In function 'void Out(std::vector<long long int>)':
cezar.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
cezar.cpp:20:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
cezar.cpp:20:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
cezar.cpp: In function 'int main()':
cezar.cpp:10:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
cezar.cpp:50:13:
         REP(j,0,min(a.size(),b.size()))
             ~~~~~~~~~~~~~~~~~~~~~~~~~~
cezar.cpp:50:9: note: in expansion of macro 'REP'
         REP(j,0,min(a.size(),b.size()))
         ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 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 -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -