Submission #1091035

# Submission time Handle Problem Language Result Execution time Memory
1091035 2024-09-19T14:39:31 Z vjudge1 Cezar (COCI16_cezar) C++17
20 / 100
1 ms 348 KB
#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 time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -