답안 #94540

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
94540 2019-01-20T05:21:04 Z YamiDust Zamjena (COCI18_zamjena) C++14
70 / 70
346 ms 12020 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

vector < string > S(50010),T(50010);

map <string , string > parent;

string busca (string A) {
    if (parent[A]=="" || parent[A]==A) {
        parent[A]=A;
        return parent[A];
    }
    parent[A] = busca(parent[A]);
    return parent[A];
}

bool NUM (string K) {
    return (K[0]>='0' && K[0]<='9');
}

bool comp (string A, string B){
    //cout << "-----------\n" << A << " " << B << endl;
    if (A==B) {
        return true;
    }
    if (NUM(A) && NUM(B)) {
        return false;
    }
    string p1=busca(A);
    string p2=busca(B);
    //cout << p1 << " " << p2 << endl;
    if (NUM(p2) && NUM(A)) {
        if (p2!=A) {
            return false;
        }
        else {
            return true;
        }
    }
    if (p1!=p2) {
        if (NUM(p1) && NUM(p2))
            return false;
        if (NUM(p1)) {
            parent[p2] = p1;
        }
        else {
            parent[p1] = p2;
        }
    }
    return true;
}

int main () {
    int N;
    scanf("%d",&N);
    vector < string > S(N+1),T(N+1);
    for (int i=0;i<N;i++) {
        cin >> S[i];
    }
    for (int i=0;i<N;i++) {
        cin >> T[i];
    }
    for (int i=0;i<N;i++){
        if (!comp(min(S[i],T[i]),max(S[i],T[i]))) {
            printf("NE\n");
            return 0;
        }
    }
    printf("DA\n");
    return 0;
}

Compilation message

zamjena.cpp: In function 'int main()':
zamjena.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&N);
     ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3448 KB Output is correct
2 Correct 4 ms 3448 KB Output is correct
3 Correct 4 ms 3448 KB Output is correct
4 Correct 4 ms 3448 KB Output is correct
5 Correct 4 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3448 KB Output is correct
2 Correct 4 ms 3448 KB Output is correct
3 Correct 4 ms 3448 KB Output is correct
4 Correct 4 ms 3448 KB Output is correct
5 Correct 4 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3448 KB Output is correct
2 Correct 4 ms 3440 KB Output is correct
3 Correct 4 ms 3448 KB Output is correct
4 Correct 4 ms 3448 KB Output is correct
5 Correct 5 ms 3448 KB Output is correct
6 Correct 5 ms 3448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 3576 KB Output is correct
2 Correct 7 ms 3576 KB Output is correct
3 Correct 11 ms 3836 KB Output is correct
4 Correct 14 ms 3960 KB Output is correct
5 Correct 14 ms 3960 KB Output is correct
6 Correct 11 ms 3832 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 4764 KB Output is correct
2 Correct 86 ms 6392 KB Output is correct
3 Correct 137 ms 8140 KB Output is correct
4 Correct 99 ms 8660 KB Output is correct
5 Correct 346 ms 12020 KB Output is correct
6 Correct 256 ms 9248 KB Output is correct