Submission #1044761

# Submission time Handle Problem Language Result Execution time Memory
1044761 2024-08-05T13:21:16 Z vjudge1 Zamjena (COCI18_zamjena) C++17
56 / 70
57 ms 8788 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long 
#define vi vector<int>
#define vvi vector<vi>
#define sp << " " <<
#define F(i, s, e) for(int i = s; i < e; i++)
#define pb push_back
#define pii pair<int, int>
#define fi first
#define se second
#define vb vector<bool>
#define Tree tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update>

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    string st[2][n];

    F(i, 0, 2) {
        F(j, 0, n) cin >> st[i][j];
    }

    map<string, string> var;

    F(i, 0, n) {
        bool x1 = (st[0][i][0] - '0') < 10;
        bool x2 = (st[1][i][0] - '0') < 10;

        if(x1 && x2) {
            if(st[0][i] != st[1][i]) {
                cout << "NE" << endl;
                return;
            }
        }
    }
    F(i, 0, n) {
        bool x1 = (st[0][i][0] - '0') < 10;
        bool x2 = (st[1][i][0] - '0') < 10;

        if(x1 && !x2) {
            if(var[st[1][i]].length() && var[st[1][i]] != st[0][i]) {
                cout << "NE" << endl;
                return;
            } else var[st[1][i]] = st[0][i];
        }
        if(!x1 && x2) {
            if(var[st[0][i]].length() && var[st[0][i]] != st[1][i]) {
                cout << "NE" << endl;
                return;
            } else var[st[0][i]] = st[1][i];
        }
    }

    F(repeat, 0, 2) {
    F(i, 0, n) {
        bool x1 = (st[0][i][0] - '0') < 10;
        bool x2 = (st[1][i][0] - '0') < 10;

        if(!x1 && !x2) {
            bool e1 = var[st[0][i]].length();
            bool e2 = var[st[1][i]].length();

            if(e1 && e2) {
                if(var[st[0][i]] != var[st[1][i]]) {
                    cout << "NE" << endl;
                    return;
                }
            } else if(e1 && !e2) {
                var[st[1][i]] = var[st[0][i]];
            } else if(!e1 && e2) {
                var[st[0][i]] = var[st[1][i]];
            }
        }
    }
    }

    cout << "DA" << endl;
}

int32_t main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    #ifdef Local
        freopen("io.in", "r", stdin);
        freopen("io.out", "w", stdout);
    #endif

    int t = 1;
    //cin >> t;
    while(t--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 2 ms 860 KB Output is correct
5 Correct 3 ms 860 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1624 KB Output is correct
2 Correct 20 ms 3164 KB Output is correct
3 Correct 28 ms 5200 KB Output is correct
4 Correct 24 ms 5700 KB Output is correct
5 Correct 56 ms 8788 KB Output is correct
6 Correct 57 ms 6156 KB Output is correct