Submission #1214060

#TimeUsernameProblemLanguageResultExecution timeMemory
1214060NeltHieroglyphs (IOI24_hieroglyphs)C++20
3 / 100
160 ms16236 KiB
#include "hieroglyphs.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T, typename key = less<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;

std::vector<int> ucs(std::vector<int> a, std::vector<int> b)
{
    ll n = a.size(), m = b.size();
    set<ll> sa, sb;
    vector<int> ans;
    for (ll i : a) sa.insert(i);
    for (ll i : b) sb.insert(i);
    {
        vector<int> nv;
        for (ll i : a) if (sb.count(i)) nv.push_back(i);
        a = nv;
        nv.clear();
        for (ll i : b) if (sa.count(i)) nv.push_back(i);
        b = nv;
        nv.clear();
        for (ll i : a) if (nv.empty() or nv.back() != i) nv.push_back(i);
        a = nv;
        nv.clear();
        for (ll i : b) if (nv.empty() or nv.back() != i) nv.push_back(i);
        b = nv;
    }
    if (a != b) return {-1};
    set<ll> s;
    for (ll i : a) s.insert(i);
    if (a.size() != s.size()) return {-1};
    return a;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...