Submission #85386

# Submission time Handle Problem Language Result Execution time Memory
85386 2018-11-19T15:14:36 Z DiegoGarcia Zamjena (COCI18_zamjena) C++11
28 / 70
8 ms 3924 KB
#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

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 time Memory Grader output
1 Correct 5 ms 3448 KB Output is correct
2 Correct 5 ms 3448 KB Output is correct
3 Correct 5 ms 3616 KB Output is correct
4 Correct 5 ms 3616 KB Output is correct
5 Correct 5 ms 3616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3692 KB Output is correct
2 Correct 4 ms 3692 KB Output is correct
3 Correct 4 ms 3692 KB Output is correct
4 Correct 5 ms 3692 KB Output is correct
5 Correct 5 ms 3692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3704 KB Output is correct
2 Correct 5 ms 3708 KB Output is correct
3 Correct 5 ms 3712 KB Output is correct
4 Correct 4 ms 3772 KB Output is correct
5 Correct 5 ms 3772 KB Output is correct
6 Incorrect 4 ms 3772 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 3772 KB Output is correct
2 Correct 5 ms 3880 KB Output is correct
3 Incorrect 8 ms 3880 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 3924 KB Output isn't correct
2 Halted 0 ms 0 KB -