Submission #1313180

#TimeUsernameProblemLanguageResultExecution timeMemory
1313180TymondHieroglyphs (IOI24_hieroglyphs)C++20
0 / 100
273 ms23756 KiB
#include "hieroglyphs.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define fi first #define se second #define vi vector<int> #define vll vector<long long> #define pii pair<int, int> #define pll pair<long long, long long> #define pb push_back #define mp make_pair #define eb emplace_back #define all(x) (x).begin(), (x).end() #define sz(x) (int)(x).size() mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); mt19937_64 rng64(chrono::high_resolution_clock::now().time_since_epoch().count()); inline int rand(int l,int r){return uniform_int_distribution<int>(l, r)(rng);} inline ll rand(ll l,ll r){return uniform_int_distribution<ll>(l, r)(rng64);} #ifdef DEBUG auto&operator<<(auto&o,pair<auto,auto>p){return o<<"("<<p.first<<", "<<p.second<<")";} auto operator<<(auto&o,auto x)->decltype(x.end(),o){o<<"{";int i=0;for(auto e:x)o<<","+!i++<<e;return o<<"}";} #define debug(X...)cerr<<"["#X"]: ",[](auto...$){((cerr<<$<<"; "),...)<<endl;}(X) #else #define debug(...){} #endif vi ucs(vi A, vi B){ int n = sz(A); int m = sz(B); vi ret = {-1}; ret = {}; //znajdź wynik set<int> ind = {}; map<int, vi> posA; map<int, vi> posB; map<int, int> cntA; map<int, int> cntB; for(int i = n - 1; i >= 0; i--){ posA[A[i]].pb(i); cntA[A[i]]++; } for(int i = m - 1; i >= 0; i--){ posB[B[i]].pb(i); cntB[B[i]]++; } int mx = -1; for(int i = 0; i < n; i++){ if(cntA[A[i]] > cntB[A[i]]){ continue; } while(sz(posB[A[i]]) && posB[A[i]].back() <= mx){ posB[A[i]].pop_back(); } ind.insert(i); mx = posB[A[i]].back(); posB[A[i]].pop_back(); } mx = -1; for(int i = 0; i < m; i++){ if(cntB[B[i]] >= cntA[B[i]]){ continue; } while(sz(posA[B[i]]) && posA[B[i]].back() <= mx){ posA[B[i]].pop_back(); } ind.insert(posA[B[i]].back()); mx = posA[B[i]].back(); posA[B[i]].pop_back(); } for(auto ele : ind){ ret.pb(A[ele]); } return ret; }
#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...