Submission #145464

# Submission time Handle Problem Language Result Execution time Memory
145464 2019-08-20T01:48:27 Z youssan_william Zamjena (COCI18_zamjena) C++14
0 / 70
10 ms 1056 KB
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
int main()
{
    int n ;
    cin >> n;
    string a[n+1],b[n+1];
    for(int i= 1; i<=n ;i++)
    {
        cin >> a[i];

    }
    for(int i= 1; i<=n ;i++)
    {
        cin >> b[i];
    }
    map<string,string>mp;
    bool first,second;
    for(int i= 1; i<=n ;i++)
    {
        first=false;
        second=false;
        if(a[i]!=b[i])
        {
            if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0)
            {
                first=true;
            }
            if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0)
            {
                second=true;
            }
            if(first&&second&&a[i]!=b[i])
            {
                cout << "NO\n";
                return 0;
            }
            if(first)
            {
                if(mp[b[i]]!="")
                {
                    cout << "NO\n";
                    return 0;
                }
                mp[b[i]]=a[i];
            }
            if(second)
            {
                if(mp[a[i]]!="")
                {
                    cout << "NE\n";
                    return 0;
                }
                mp[a[i]]=b[i];
            }
        }
    }
    for(int i = 1 ; i<=n ;i++)
    {
        first=false;
        second=false;
        if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0)
        {
            first=true;
        }
        if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0)
        {
            second=true;
        }
        if(first&&second)
            continue;
        if(first)
        {
            b[i]=mp[b[i]];
        }
        if(second)
        {
            a[i]=mp[a[i]];
        }
    }
    for(int i = 1; i <=n ;i++)
    {
        first=false;
        second=false;
        if(a[i].size()==1&&a[i][0]-'0'<=9&&a[i][0]-'0'>=0)
        {
            first=true;
        }
        if(b[i].size()==1&&b[i][0]-'0'<=9&&b[i][0]-'0'>=0)
        {
            second=true;
        }
        if(first&&second&&a[i]!=b[i])
        {
            cout << "NE\n";
            return 0;
        }
    }
    cout << "DA\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 380 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 424 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Incorrect 4 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 1056 KB Output isn't correct
2 Halted 0 ms 0 KB -