제출 #1221242

#제출 시각아이디문제언어결과실행 시간메모리
1221242Theo830상형문자열 (IOI24_hieroglyphs)C++20
0 / 100
24 ms8264 KiB
#include <bits/stdc++.h> using namespace std; typedef int ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training #include "hieroglyphs.h" vector<int> ucs(std::vector<int> a, std::vector<int> b){ vector<int>ans; vector<int>ex[200005]; f(i,0,b.size()){ ex[b[i]].pb(i); } f(i,0,200005){ reverse(all(ex[i])); } ll posi = 0; for(auto x:a){ while(!ex[x].empty() && ex[x].back() < posi){ ex[x].pop_back(); } if(!ex[x].empty() && ex[x][0] >= posi){ posi = ex[x][0] + 1; ans.pb(x); } } bool ok = 1; ll pos = 0; for(auto x:a){ if(pos < ans.size() && ans[pos] == x){ pos++; } } ok &= pos == (ll)ans.size(); pos = 0; for(auto x:b){ if(pos < ans.size() && ans[pos] == x){ pos++; } } ok &= pos == (ll)ans.size(); if(!ok){ ans.clear(); ans.pb(-1); } return ans; }
#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...