Submission #227872

# Submission time Handle Problem Language Result Execution time Memory
227872 2020-04-29T06:17:08 Z Vimmer Nadan (COCI18_nadan) C++14
0 / 50
30 ms 31616 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];

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

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

        cin >> 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);
        }
    }

    cout << "DA" << endl;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Incorrect 4 ms 256 KB Output isn't correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Incorrect 4 ms 384 KB Output isn't correct
5 Incorrect 5 ms 384 KB Output isn't correct
6 Incorrect 5 ms 1024 KB Output isn't correct
7 Incorrect 5 ms 384 KB Output isn't correct
8 Incorrect 5 ms 384 KB Output isn't correct
9 Incorrect 5 ms 512 KB Output isn't correct
10 Incorrect 30 ms 31616 KB Output isn't correct