Submission #1085448

#TimeUsernameProblemLanguageResultExecution timeMemory
1085448I_am_Polish_GirlStone Arranging 2 (JOI23_ho_t1)C++14
100 / 100
244 ms32340 KiB
#pragma target("arch=icelake-server") #include <iostream> #include <vector> #include <algorithm> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <stack> #include <queue> #include <cmath> #include <random> #include <chrono> #include <iomanip> #include <bitset> using namespace std; #define int long long typedef long long ll; typedef long double ld; int log_ = 21; int inf = 4000000007000000007; long long mod = 998244353; int p = 499; int NADIYA = 39; signed main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; vector <int> a(n); map<int, int> mp; set <pair <pair <int, int>, int>> s; for (int i = 0; i < n; i++) { cin >> a[i]; if (mp[a[i]] == 0) { mp[a[i]]++; s.insert({ {i , i} , a[i] }); continue; } pair <pair <int, int>, int> p = *s.rbegin(); while (p.second != a[i]) { mp[p.second]--; s.erase(p); p = *s.rbegin(); } s.erase(p); p.first.second = i; s.insert(p); } vector <int> ans(n , -1); for (auto i : s) { int l = i.first.first; int r = i.first.second; int x = i.second; for (int j = l; j <= r; j++) { ans[j] = x; } } for (int i = 0; i < n; i++) cout << ans[i] << "\n"; } /*5 1 2 1 2 3 1 2 4 1 1 5 4 */

Compilation message (stderr)

Main.cpp:1: warning: ignoring '#pragma target ' [-Wunknown-pragmas]
    1 | #pragma target("arch=icelake-server")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...