답안 #227874

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227874 2020-04-29T06:20:19 Z Vimmer Nadan (COCI18_nadan) C++14
0 / 50
43 ms 62976 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("fast-math")
//#pragma GCC optimize("no-stack-protector")

#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define M ll(1e9 + 7)

using namespace std;

//using namespace __gnu_pbds;

typedef long double ld;

typedef long long ll;

typedef short int si;

//typedef tree<int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


map <string, string> mp;

bool gd(string s)
{
    for (int i = 0; i < sz(s); i++)
        if (s[i] - '0' > 9 || s[i] - '0' < 0) return 0;

    return 1;
}

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n;

    cin >> n;

    string s[n], t[n];

    for (int i = 0; i < n; i++) cin >> s[i];

    for (int i = 0; i < n; i++)
    {
        string str;

        cin >> str;

        t[i] = str;

        bool fr = gd(s[i]), sc = gd(str);

        if (sc && fr)
        {
            if (str == s[i]) continue;

            cout << "NE" << endl;

            exit(0);
        }

        if (!fr && !sc)
        {
            if (mp.find(str) == mp.end() && mp.find(s[i]) == mp.end()) continue;

            if (mp.find(str) != mp.end() && mp.find(s[i]) != mp.end())
            {
                if (mp[str] == mp[s[i]]) continue;

                cout << "NE" << endl;

                exit(0);
            }

            if (mp.find(str) != mp.end()) {mp[s[i]] = mp[str]; continue;}
              else {mp[str] = mp[s[i]]; continue;}
        }

        if (fr && !sc)
        {
            if (mp.find(str) == mp.end() || mp[str] == s[i])
            {
                mp[str] = s[i];

                continue;
            }

            cout << "NE" << endl;

            exit(0);
        }

        if (!fr && sc)
        {
            if (mp.find(s[i]) == mp.end() || mp[s[i]] == str)
            {
                mp[s[i]] = str;

                continue;
            }

            cout << "NE" << endl;

            exit(0);
        }
    }

    for (int i = 0; i < n; i++)
    {
        string str = t[i];

        bool fr = gd(s[i]), sc = gd(str);

        if (sc && fr)
        {
            if (str == s[i]) continue;

            cout << "NE" << endl;

            exit(0);
        }

        if (!fr && !sc)
        {
            if (mp.find(str) == mp.end() && mp.find(s[i]) == mp.end()) continue;

            if (mp.find(str) != mp.end() && mp.find(s[i]) != mp.end())
            {
                if (mp[str] == mp[s[i]]) continue;

                cout << "NE" << endl;

                exit(0);
            }

            if (mp.find(str) != mp.end()) {mp[s[i]] = mp[str]; continue;}
              else {mp[str] = mp[s[i]]; continue;}
        }

        if (fr && !sc)
        {
            if (mp.find(str) == mp.end() || mp[str] == s[i])
            {
                mp[str] = s[i];

                continue;
            }

            cout << "NE" << endl;

            exit(0);
        }

        if (!fr && sc)
        {
            if (mp.find(s[i]) == mp.end() || mp[s[i]] == str)
            {
                mp[s[i]] = str;

                continue;
            }

            cout << "NE" << endl;

            exit(0);
        }
    }

    cout << "DA" << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Incorrect 4 ms 384 KB Output isn't correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Incorrect 5 ms 384 KB Output isn't correct
5 Incorrect 4 ms 384 KB Output isn't correct
6 Incorrect 5 ms 1792 KB Output isn't correct
7 Incorrect 5 ms 384 KB Output isn't correct
8 Incorrect 4 ms 384 KB Output isn't correct
9 Incorrect 5 ms 640 KB Output isn't correct
10 Incorrect 43 ms 62976 KB Output isn't correct