답안 #145466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145466 2019-08-20T01:54:38 Z youssan_william Zamjena (COCI18_zamjena) C++14
14 / 70
16 ms 1528 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]]!=""&&mp[b[i]]!=a[i])
                {
                    cout << "NO\n";
                    return 0;
                }
                mp[b[i]]=a[i];
            }
            if(second)
            {
                if(mp[a[i]]!=""&&mp[a[i]]!=b[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)
        {
            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;
}
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Incorrect 2 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 3 ms 504 KB Output is correct
3 Incorrect 6 ms 760 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 1528 KB Output isn't correct
2 Halted 0 ms 0 KB -