Submission #46987

#TimeUsernameProblemLanguageResultExecution timeMemory
46987diegogrcCezar (COCI16_cezar)C++17
0 / 100
2 ms748 KiB
// Copyright © 2018 Diego Garcia Rodriguez del Campo. All rights reserved. #include<bits/stdc++.h> #define MAX 105 #define ALPHA 30 #define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0); using namespace std; typedef long long i64; int N, tot; string word[MAX]; int in[MAX]; int ord[MAX]; int ady[ALPHA][ALPHA]; vector < int > adyy[MAX]; queue < int > q; queue < int > ans; int main() { optimiza_io cin >> N; for( int i = 1; i <= N; i ++ ) cin >> word[i]; for( int i = 1; i <= N; i ++ ) cin >> ord[i]; for( int i = 1; i <= N; i ++ ) for( int j = i + 1; j <= N; j ++ ) { int a = ord[i], b = ord[j]; int idx = 0; while( idx < word[a].size() && idx < word[b].size() && word[a][idx] == word[b][idx] ) idx++; if( idx < word[a].size() && idx < word[b].size() ) ady[word[a][idx] - 'a' + 1][word[b][idx] - 'a' + 1] = 1; } for( int i = 1; i <= 26; i ++ ) for( int j = 1; j <= 26; j ++ ) if( ady[i][j] ) { in[j]++; adyy[i].push_back( j ); } for( int i = 1; i <= 26; i ++ ) if( ! in[i] ) { q.push( i ); tot++; } while( ! q.empty() ) { int x = q.front(); q.pop(); ans.push( x ); for( auto v : adyy[x] ) { in[v]--; if( ! in[v] ) { tot++; q.push( v ); } } } if( tot != 26 ) cout << "NE\n"; else { cout << "DA\n"; while( ! ans.empty() ) { char a = ans.front() + 'a' - 1; cout << a; ans.pop(); } } return 0; }

Compilation message (stderr)

cezar.cpp: In function 'int main()':
cezar.cpp:32:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while( idx < word[a].size() && idx < word[b].size() && word[a][idx] == word[b][idx] ) idx++;
                    ~~~~^~~~~~~~~~~~~~~~
cezar.cpp:32:48: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             while( idx < word[a].size() && idx < word[b].size() && word[a][idx] == word[b][idx] ) idx++;
                                            ~~~~^~~~~~~~~~~~~~~~
cezar.cpp:33:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if( idx < word[a].size() && idx < word[b].size() )
                 ~~~~^~~~~~~~~~~~~~~~
cezar.cpp:33:45: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if( idx < word[a].size() && idx < word[b].size() )
                                         ~~~~^~~~~~~~~~~~~~~~
#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...