Submission #1333225

#TimeUsernameProblemLanguageResultExecution timeMemory
1333225herissonwowwStone Arranging 2 (JOI23_ho_t1)C++20
25 / 100
20 ms1092 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){
        int last1 = -1;
        int 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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...