Submission #1091035

#TimeUsernameProblemLanguageResultExecution timeMemory
1091035vjudge1Cezar (COCI16_cezar)C++17
20 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; #define fst first #define snd second #define pb push_back #define ALL(x) x.begin(),x.end() #define SZ(x) (int)x.size() #define forn(i,a,b) for(int i = a; i < b; i++) typedef long long ll; const int MAXN = 100+5; const int MAXM = 26; ll n; string strs[MAXN]; ll ord[MAXN]; map<char,char> dic; set<char> disp; bool used[MAXM]; int main(){ cin>>n; forn(i,0,n) cin>>strs[i]; forn(i,0,n) cin>>ord[i]; forn(i,0,MAXM) disp.insert(i+'a'); //cout<<"paso\n"; forn(i,0,MAXN){ ll ind; forn(j,0,n){ ind = ord[j]-1; if(SZ(strs[ind])<=i) continue; char ch = strs[ind][i]; //cout<<ch<<" "<<ch-'a'<<'\n'; if(!used[ch-'a']){ dic[ch] = *disp.begin(); disp.erase(disp.begin()); used[ch-'a'] = true; } } } //cout<<"paso\n"; vector<pair<string,ll>> sorted; forn(j,0,n){ ll i = ord[j]-1; string str = ""; for(auto j:strs[i]) str+=dic[j]; sorted.pb({str,j}); } //forn(i,0,n){ //cout<<sorted[i].fst<<" "<<sorted[i].snd<<'\n'; //} //cout<<"paso\n"; sort(ALL(sorted)); bool good = true; forn(i,0,n){ //cout<<sorted[i].fst<<" "<<sorted[i].snd<<'\n'; if(sorted[i].snd != i) good = false; } if(!good) cout<<"NE\n"; else{ cout<<"DA\n"; forn(i,0,MAXM){ if(!used[i]){ used[i] = true; dic[i+'a'] = *disp.begin(); disp.erase(disp.begin()); } cout<<dic[i+'a']; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...