답안 #1044752

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1044752 2024-08-05T13:14:16 Z Esgeer Zamjena (COCI18_zamjena) C++17
0 / 70
2 ms 1884 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[i][0][0] - '0') < 10;
        bool x2 = (st[i][0][1] - '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[i][1]].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[0][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();
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 0 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 712 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 1884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -