# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
85386 | DiegoGarcia | Zamjena (COCI18_zamjena) | C++11 | 8 ms | 3924 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 <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)
# | 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... |