# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
167233 | 2019-12-06T21:22:36 Z | PedroBigMan | Cezar (COCI16_cezar) | C++14 | 3 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[i].ff=cur; } sort(s.begin(),s.end()); 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; REP(i,0,26) {cout<<((char) (ans[i]+'a'));} cout<<endl; return 0; }
Compilation message
# | 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 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | 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 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
# | 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 | 3 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 | - |