# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
957676 | 2024-04-04T07:47:23 Z | VinhLuu | Stone Arranging 2 (JOI23_ho_t1) | C++17 | 10 ms | 27232 KB |
#include <bits/stdc++.h> #define int long long #define ll long long #define fi first #define se second #define pb push_back #define all(lmao) lmao.begin(), lmao.end() using namespace std; typedef pair<int,int> pii; typedef tuple<int,int,int> tp; const int N = 1e6 + 5; const int mod = 1e9 + 7; const int oo = 2e18; int n, a[N], b[N], t, p[N]; vector<int> vr[N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "v" if(fopen(task ".inp","r")){ freopen(task ".inp","r",stdin); freopen(task ".out","w",stdout); } cin >> n; set<int> s; for(int i = 1; i <= n; i ++){ cin >> a[i]; s.insert(a[i]); } for(auto j : s) p[++t] = j; for(int i = 1; i <= n; i ++) a[i] = lower_bound(p + 1, p + t + 1, a[i]) - p; vector<int> cur; for(int i = 1; i <= n; i ++){ if(!vr[a[i]].empty()){ int u = vr[a[i]].back(); int v = i; while(!cur.empty() && cur.back() > u){ int tmp = cur.back(); vr[a[tmp]].pop_back(); cur.pop_back(); } } vr[a[i]].pb(i); cur.pb(i); } for(int i = 1; i <= t; i ++){ if(!vr[p[i]].empty()){ b[vr[p[i]][0]] = p[i]; for(int j = vr[p[i]][0]; j <= vr[p[i]].back(); j ++) b[j] = p[i]; } } for(int i = 1; i <= n; i ++) cout << b[i] << "\n"; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 27228 KB | Output is correct |
2 | Correct | 7 ms | 27232 KB | Output is correct |
3 | Correct | 6 ms | 27224 KB | Output is correct |
4 | Correct | 6 ms | 27228 KB | Output is correct |
5 | Correct | 7 ms | 27228 KB | Output is correct |
6 | Correct | 6 ms | 27228 KB | Output is correct |
7 | Incorrect | 6 ms | 27228 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 27224 KB | Output is correct |
2 | Correct | 6 ms | 27228 KB | Output is correct |
3 | Correct | 6 ms | 27228 KB | Output is correct |
4 | Correct | 6 ms | 27228 KB | Output is correct |
5 | Correct | 6 ms | 27228 KB | Output is correct |
6 | Incorrect | 6 ms | 27228 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 27228 KB | Output is correct |
2 | Correct | 7 ms | 27232 KB | Output is correct |
3 | Correct | 6 ms | 27224 KB | Output is correct |
4 | Correct | 6 ms | 27228 KB | Output is correct |
5 | Correct | 7 ms | 27228 KB | Output is correct |
6 | Correct | 6 ms | 27228 KB | Output is correct |
7 | Incorrect | 6 ms | 27228 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |