| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1091674 | vjudge1 | Cezar (COCI16_cezar) | C++17 | 1 ms | 600 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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++)
const int MAXN = 100;
const int MAXL = 26;
struct Word{
string str;
ll ord;
Word(ll ord, string str) : ord(ord), str(str) {}
};
bool cmp(const Word &a, const Word &b) {
if(a.ord<b.ord) return true;
return false;
}
ll n;
string strs[MAXN];
ll ord[MAXN];
bool menor[MAXL][MAXL]; // menor[i][j] = true -> si i < j
int main(){
cin>>n;
forn(i,0,n) cin>>strs[i];
forn(i,0,n) cin>>ord[i];
vector<Word> sorted;
forn(i,0,n) sorted.pb(Word(i,strs[ord[i]-1]));
sort(ALL(sorted),cmp);
forn(i,0,n){
forn(j,i+1,n){
string a,b; a = sorted[i].str; b = sorted[j].str;
//cout<<a<<" "<<b<<'\n';
forn(h,0,SZ(a)){
if(h>=SZ(b)){
cout<<"NE\n";
return 0;
}
if(a[h]==b[h]) continue;
menor[a[h]-'a'][b[h]-'a']=true;
//cout<<a[h]<<" "<<b[h]<<'\n';
if(menor[b[h]-'a'][a[h]-'a']){
cout<<"NE\n";
return 0;
}
break;
}
}
}
vector<bool> used(MAXL,false);
vector<char> dicc(MAXL);
forn(i,0,MAXL){
forn(j,0,MAXL){
bool puede = true;
if(used[j]) puede = false;
forn(h,0,MAXL){
if(menor[h][j]) puede = false;
}
if(puede){ dicc[j]=i+'a'; used[j]=true; forn(h,0,MAXL){menor[j][h]=false;} break; }
else if(!used[j]){
//cout<<j<<" no pudo en "<<i<<'\n';
}
}
}
cout<<"DA\n";
forn(i,0,SZ(dicc)) cout<<dicc[i]; cout<<'\n';
return 0;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
