# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
895922 | niter | Stone Arranging 2 (JOI23_ho_t1) | C++14 | 140 ms | 16312 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define loop(i,a,b) for(int i = (a); i < (b); i ++)
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define ff first
#define ss second
#define op(x) cerr << #x << " = " << x << endl;
#define opa(x) cerr << #x << " = " << x << ", ";
#define spac cerr << ' ';
#define entr cerr << endl;
#define STL(x) cerr << #x << " : "; for(auto &qwe:x) cerr << qwe << ' '; cerr << endl;
#define ARR(x, nnn) cerr << #x << " : "; loop(qwe,0,nnn) cerr << x[qwe] << ' '; cerr << endl;
using namespace std;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
ostream& operator<<(ostream& os, pii A){ os << "[" << A.ff << ", " << A.ss << "]"; }
struct P{
int st, ed, col;
};
ostream& operator<<(ostream& os, P A){ os << "\n[" << A.st << ", " << A.ed << "], color = " << A.col; }
int main(){
ios::sync_with_stdio(false); cin.tie(0);
int n; cin >> n;
vector<P> v;
map<int,int> pos;
loop(i,0,n){
int now; cin >> now;
if(pos.count(now)){
int ind = pos[now];
while(v.size() > ind + 1){
pos.erase(v.back().col);
v.pop_back();
}
v.back().ed = i;
}
else{
pos[now] = v.size();
v.pb({i, i, now});
}
// STL(v)
}
for(auto &i:v){
loop(j,0,i.ed - i.st + 1){
cout << i.col << '\n';
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |