# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94539 | YamiDust | Zamjena (COCI18_zamjena) | C++14 | 61 ms | 4692 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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) {
parent[p2]=p1;
}
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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |