제출 #1352104

#제출 시각아이디문제언어결과실행 시간메모리
1352104luvwinterStone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
99 ms18096 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int , int>
#define FOR(i , l , r) for(int i = (l) ; i <= (r) ; i++)
#define FOD(i , r , l) for(int i = (r) ; i >= (l) ; i--)
#define fi first
#define se second
#define endl '\n'
#define faster ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 2e5 + 5;

int a[N];
int n;

multiset<pii> s;
map<int , int> pos;
int nxt[N];



void solve (void) {
     cin >> n;
     FOR(i , 1 , n) cin >> a[i];
     FOD(i , n , 1) {
         if(pos[a[i]] == 0) {
            pos[a[i]] = i;
            nxt[i] = i;
         }
         else{
            nxt[i] = pos[a[i]];
            pos[a[i]] = i;
         }
     }
     int curr = a[1];
     int last = 0;
     FOR(i , 1 , n) {
         //cout << last << " " << i << endl;
         if(i > last) {
            cout << a[i] << endl;
            curr = a[i];
            last = nxt[i];
         }
         else{
            if(curr == a[i]) {
                last = nxt[i];
            }
            cout << curr << endl;
         }
     }

}

main() {
    faster;
    solve();


    return 0;

}

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

Main.cpp:54:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   54 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...