| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1340986 | doantaolaaidi | Cezar (COCI16_cezar) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define AC "test"
#define foru(i, l, r) for (int i = (l); i <= (r); i++)
#define ford(i, l, r) for (int i = (l); i >= (r); i--)
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vii;
typedef vector<ll> vll;
const ll inf = 1e9 + 7;
const ll linf = 1e18 + 7;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 7;
const int base = 31;
void fastIO(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
}
ll mul(ll a, ll b){
a%=mod;
ll res = 0;
while (b){
if (b%2) res = (res + a)%mod;
a = (a + a)%mod;
b/=2;
}
return res;
}
ll Pow(ll a, ll b){
ll ans = 1;
while (b){
if (b % 2) ans = mul(ans, a);
a = mul(a, a);
b/=2;
}
return ans;
}
stack<int> topo;
ll n, res, visited[28], x, been[maxn];
vii g[105];
string t[105], s[105];
void dfs(int u){
if (res == -1) return;
visited[u] = 1;
for (int v : g[u]){
if (visited[v] == 1){
res = -1;
return;
}
if (!visited[v]) dfs(v);
}
visited[u] = 2;
topo.push(u);
}
void solve(){
cin >> n;
foru(i, 1 ,n){
cin >> t[i];
}
foru(i, 1, n){
cin >> x;
s[x] = t[i];
}
foru(i, 1, n - 1){
int found = 0;
foru(k, 0, min(s[i].size(), s[i + 1].size()) - 1){
if (s[i][k] != s[i + 1][k]){
found = 1;
g[s[i][k] - 'a' + 1].pb(s[i + 1][k] - 'a' + 1);
break;
}
}
if (!found && s[i].size() > s[i + 1].size()){
cout << "NE";
return;
}
}
ford(i, 26, 1){
if(!visited[i]) dfs(i);
}
if (res == -1){
cout << "NE" << "\n";
return;
}
cout << "DA" << "\n";
while (!topo.empty()){
cout << char(topo.top() + 'a' - 1);
topo.pop();
}
}
int main(){
fastIO();
if (fopen(AC".inp", "r")){
freopen(AC".inp", "r", stdin);
freopen(AC".out", "w", stdout);
}
solve();
}
컴파일 시 표준 에러 (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... | ||||
