# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
835326 | EntityPlantt | Zamjena (COCI18_zamjena) | C++14 | 6 ms | 4580 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 <iostream>
#include <map>
#include <set>
using namespace std;
int n, i;
string arr[50000], x;
map <string, int> m;
map <string, set <string>> eq;
inline const int v(const string &k) {
return isdigit(k[0]) ? stoi(k) : m[k];
}
inline const int s(const string &k, const int &i) {
m[k] = i;
string e;
while (!eq[k].empty()) {
e = *prev(eq[k].end());
eq[k].erase(prev(eq[k].end()));
s(e, i);
}
}
int main() {
ios::sync_with_stdio(); cin.tie(0); cout.tie(0);
cin >> n;
for (i = 0; i < n; i++) cin >> arr[i];
for (i = 0; i < n; i++) {
cin >> x;
if (arr[i] == x);
else if (v(arr[i]) && v(x)) {
if (v(arr[i]) != v(x)) {
cout << "NE";
return 0;
}
}
else if (v(arr[i])) s(x, v(arr[i]));
else if (v(x)) s(arr[i], v(x));
else {
eq[arr[i]].insert(x);
eq[x].insert(arr[i]);
}
}
cout << "DA";
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... |