Submission #88126

#TimeUsernameProblemLanguageResultExecution timeMemory
88126jasony123123Cezar (COCI16_cezar)C++11
30 / 100
2 ms556 KiB
#include <stdio.h> #include <queue> using namespace std; int N,P[111]; char S[111][111],ans[30]; bool f[26][26]; int d[26]; int main() { scanf ("%d",&N); for (int i=1;i<=N;i++) scanf ("%s",S[i]); for (int i=1;i<=N;i++) scanf ("%d",&P[i]); bool good = 1; for (int i=2;i<=N;i++){ for (int j=0;;j++){ if (S[P[i-1]][j] == 0) break; if (S[P[i]][j] == 0) good = 0; if (S[P[i-1]][j] != S[P[i]][j]){ f[S[P[i-1]][j]-'a'][S[P[i]][j]-'a'] = 1; break; } } } for (int i=0;i<26;i++) for (int j=0;j<26;j++) if (f[i][j]) d[j]++; queue<int> Q; for (int i=0;i<26;i++) if (d[i] == 0) Q.push(i); int c = 0; while (!Q.empty()){ int x = Q.front(); Q.pop(); ans[x] = c + 'a'; c++; for (int y=0;y<26;y++) if (f[x][y]){ if (--d[y] == 0) Q.push(y); } } if (c < 26) good = 0; if (good){ puts("DA"); puts(ans); } else{ puts("NE"); } return 0; }

Compilation message (stderr)

cezar.cpp: In function 'int main()':
cezar.cpp:10:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d",&N);
  ~~~~~~^~~~~~~~~
cezar.cpp:11:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1;i<=N;i++) scanf ("%s",S[i]);
                         ~~~~~~^~~~~~~~~~~
cezar.cpp:12:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i=1;i<=N;i++) scanf ("%d",&P[i]);
                         ~~~~~~^~~~~~~~~~~~
#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...