Submission #835328

# Submission time Handle Problem Language Result Execution time Memory
835328 2023-08-23T13:09:00 Z EntityPlantt Zamjena (COCI18_zamjena) C++14
70 / 70
172 ms 14668 KB
#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 void 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;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1876 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1748 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1748 KB Output is correct
4 Correct 1 ms 1748 KB Output is correct
5 Correct 1 ms 1748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1876 KB Output is correct
2 Correct 1 ms 1748 KB Output is correct
3 Correct 1 ms 1876 KB Output is correct
4 Correct 1 ms 1748 KB Output is correct
5 Correct 1 ms 1868 KB Output is correct
6 Correct 1 ms 1876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2260 KB Output is correct
2 Correct 2 ms 2004 KB Output is correct
3 Correct 4 ms 2260 KB Output is correct
4 Correct 7 ms 2644 KB Output is correct
5 Correct 5 ms 2388 KB Output is correct
6 Correct 4 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 3284 KB Output is correct
2 Correct 37 ms 5040 KB Output is correct
3 Correct 66 ms 8268 KB Output is correct
4 Correct 44 ms 7392 KB Output is correct
5 Correct 172 ms 14668 KB Output is correct
6 Correct 81 ms 7200 KB Output is correct