답안 #197857

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197857 2020-01-23T17:21:25 Z Osama_Alkhodairy Zamjena (COCI18_zamjena) C++17
42 / 70
40 ms 3064 KB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <string> a, b;

bool num(string &x){
    return '0' <= x[0] && x[0] <= '9';
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(auto &i : a) cin >> i;
    b.resize(n);
    for(auto &i : b) cin >> i;
    map <string, string> m;
    for(int itt = 0 ; itt < 2 ; itt++){
        for(int i = 0 ; i < n ; i++){
            int g = num(a[i]), h = num(b[i]);
            if(g && h){
                if(a[i] != b[i]) finish("NE");
            }
            else if(g && !h){
                if(m.count(b[i]) && m[b[i]] != a[i]) finish("NE");
                m[b[i]] = a[i];
            }
            else if(!g && h){
                if(m.count(a[i]) && m[a[i]] != b[i]) finish("NE");
                m[a[i]] = b[i];
            }
            else{
                g = m.count(a[i]);
                h = m.count(b[i]);
                if(g && h && m[a[i]] != m[b[i]]) finish("NE");
                if(!g && h) m[a[i]] = m[b[i]];
                if(g && !h) m[b[i]] = m[a[i]];
            }
        }
    }
    cout << "DA" << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 416 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 248 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Incorrect 2 ms 380 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 5 ms 760 KB Output is correct
4 Correct 8 ms 632 KB Output is correct
5 Correct 8 ms 732 KB Output is correct
6 Correct 4 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1144 KB Output is correct
2 Correct 40 ms 2948 KB Output is correct
3 Incorrect 33 ms 3064 KB Output isn't correct
4 Halted 0 ms 0 KB -