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;
#define ll long long
#define ar array
int n;
string a[50000], b[50000];
map<string, int> mp;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 0; i < n; ++i)
cin >> a[i];
for (int i = 0; i < n; ++i)
cin >> b[i];
for (int i = 0; i < n; ++i) {
if (a[i] == b[i])
continue;
if (isdigit(a[i][0]) && isdigit(b[i][0])) {
cout << "NE";
return 0;
}
else if (isdigit(a[i][0]) && isalpha(b[i][0])) {
int x = stoi(a[i]);
auto it = mp.find(b[i]);
if (it == mp.end())
mp[b[i]] = x;
else if (it->second ^ x) {
cout << "NE";
return 0;
}
}
else if (isalpha(a[i][0]) && isdigit(b[i][0])) {
int x = stoi(b[i]);
auto it = mp.find(a[i]);
if (it == mp.end())
mp[a[i]] = x;
else if (it->second ^ x) {
cout << "NE";
return 0;
}
}
}
for (int i = 0; i < n; ++i)
if (isalpha(a[i][0]) && isalpha(b[i][0]) && a[i] != b[i] && mp[a[i]] != mp[b[i]]) {
cout << "NE";
return 0;
}
cout << "DA";
return 0;
}
# | 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... |