답안 #855686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
855686 2023-10-01T16:25:26 Z vjudge1 Zamjena (COCI18_zamjena) C++17
14 / 70
2 ms 860 KB
//author: Ahmet Alp Orakci
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

bool check(string &a) {
    bool ans = true;
    for(char &ch : a)
        ans &= ('0' <= ch && ch <= '9');

    return ans;
}

#define ONLINE_JUDGE
void solve() {
    int n;
    cin >> n;

    vector <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 ans = true;
    for(int i = 1; i <= n; i++) {
        if(check(a[i])) {
            if(check(b[i])) {
                if(a[i] != b[i]) {
                    return cout << "NE", void();
                }
            } else {
                if(mp.count(b[i])) {
                    if(mp[b[i]] != a[i]) {
                        return cout << "NE", void();
                    } 
                } else {
                    mp[b[i]] = a[i];
                }
            }
        } else if(check(b[i])) {
            swap(a[i], b[i]);
            if(check(b[i])) {
                if(a[i] != b[i]) {
                    return cout << "NE", void();
                }
            } else {
                if(mp.count(b[i])) {
                    if(mp[b[i]] != a[i]) {
                        return cout << "NE", void();
                    } 
                } else {
                    mp[b[i]] = a[i];
                }
            }
        }
    }

    cout << "DA";

    return;
}

signed main() {
    #ifndef ONLINE_JUDGE
        freopen(".in", "r", stdin);
        freopen(".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int t = 1; //cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }

    return 0;
}

Compilation message

zamjena.cpp: In function 'void solve()':
zamjena.cpp:27:10: warning: unused variable 'ans' [-Wunused-variable]
   27 |     bool ans = true;
      |          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 416 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 604 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 860 KB Output isn't correct
2 Halted 0 ms 0 KB -