Submission #1333224

#TimeUsernameProblemLanguageResultExecution timeMemory
1333224herissonwowwStone Arranging 2 (JOI23_ho_t1)C++20
Compilation error
0 ms0 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;
}

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:36:9: error: 'last1' was not declared in this scope
   36 |         last1 = -1;
      |         ^~~~~
Main.cpp:37:9: error: 'last2' was not declared in this scope
   37 |         last2 = -1;
      |         ^~~~~