제출 #988781

#제출 시각아이디문제언어결과실행 시간메모리
988781HienTDStone Arranging 2 (JOI23_ho_t1)C++11
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;

void solve(){
    int N; cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i ++) cin >> a[i];
    vector<int> ans(N);
    map<int, int> mp;
    for(int i = 0; i < N; i ++) mp[a[i]] = max(mp[a[i]], i);
    int curpos = 0;
    while(curpos != 0){
        int nextpos = mp[a[curpos]] + 1;
        for(int i = curpos; i < nextpos; i ++) ans[i] = a[curpos];
        curpos = nextpos;
    }
    for(int i = 0; i < n; i ++) cout << ans[i] << endl;
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    solve();
}

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:18:24: error: 'n' was not declared in this scope
   18 |     for(int i = 0; i < n; i ++) cout << ans[i] << endl;
      |                        ^