Submission #85386

#TimeUsernameProblemLanguageResultExecution timeMemory
85386DiegoGarciaZamjena (COCI18_zamjena)C++11
28 / 70
8 ms3924 KiB
#include <map> #include <string> #include <iostream> #define ft first #define sd second using namespace std; const int MAXN = 5e4 + 3; int n,x,y; string A[MAXN], B[MAXN]; map < string, int > keys; map < string, int > :: iterator it,it2; int toInt( string s ) { int ret = 0; for( int i=0; i<s.size(); i++ ){ ret = ret*10 + (int)(s[i] - '0'); } //cout << ret << "\n"; return ret; } int main() { //cin para strings ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n; for( int i=0; i<n; i++ ) cin >> A[i]; for( int i=0; i<n; i++ ) cin >> B[i]; for( int i=0; i<n; i++ ) { x = 0; y = 0; if( A[i][0] >= '0' && A[i][0] <= '9' ) x = toInt(A[i]); if( B[i][0] >= '0' && B[i][0] <= '9' ) y = toInt(B[i]); if( x > 0 && y > 0 ) { if( x != y ) { cout << "NE"; return 0; } continue; } else if( x > 0 ) { it = keys.find(B[i]); if( it == keys.end() ) { keys[B[i]] = x; continue; } else if( it->sd != x ) { cout << "NE"; return 0; } } else if( y > 0 ) { it = keys.find(A[i]); if( it == keys.end() ) { keys[A[i]] = y; continue; } else if( it-> sd != y ) { cout << "NE"; return 0; } } } for( int i=0; i<n; i++ ) { if(A[i][0] >= 'a' && A[i][0] <= 'z' && B[i][0] >= 'a' && B[i][0] <= 'z' ) { if( A[i] != B[i] ) { it = keys.find(A[i]); it2 = keys.find(B[i]); if( it == keys.end() || it2 == keys.end() ) continue; if( it->sd == it2->sd ) continue; cout << "NE"; return 0; } } } cout << "DA"; return 0; }

Compilation message (stderr)

zamjena.cpp: In function 'int toInt(std::__cxx11::string)':
zamjena.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i=0; i<s.size(); 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...