| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1333224 | herissonwoww | Stone Arranging 2 (JOI23_ho_t1) | C++20 | 0 ms | 0 KiB |
#include <iostream>
using namespace std;
int main()
{
int n; cin >> n;
int stones[n];
bool flag = true;
if(n<=2000){
for(int i = 0; i < n; i++){
int color; cin >> color;
stones[i] = color;
int lastc = -1;
for(int j = 0; j < i; j++){
if(stones[j] == color)
lastc = j;
}
if(lastc==-1)
continue;
for(int j = lastc; j < i; j++){
stones[j] = color;
}
}
for(int i : stones)
cout << i << '\n';
return 0;
}
for(int i = 0; i < n; i++){
int color; cin >> color;
stones[i] = color;
if(color > 2)
flag = false;
}
if(flag){
last1 = -1;
last2 = -1;
for(int i = 0; i < n; i++){
int color = stones[i];
if(color==1){
if(last1 == -1){
last1 = i;
continue;
}
else{
for(int j = last1; j < i; j++){
stones[j] = color;
}
last1 = i;
continue;
}
}
else{
if(last2 == -1){
last2 = i;
continue;
}
else{
for(int j = last2; j < i; j++){
stones[j] = color;
}
last2 = i;
continue;
}
}
}
}
return 0;
}
