| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1284051 | Bui_Quoc_Cuong | Stone Arranging 2 (JOI23_ho_t1) | C++20 | 148 ms | 15860 KiB | 
#include <bits/stdc++.h>
using namespace std;
#define MASK(i) (1LL << (i))
#define BIT(mask, i) (((mask) >> (i)) & 1)
#define all(v) (v).begin(), (v).end()
#define sz(a) (int)a.size()
#define FOR(i, a, b) for (int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for (int i = a; i >= (int)b; i--) 
#define fi first
#define se second
template <class T1, class T2> bool maximize(T1 &a, T2 b){if (a < b) {a = b; return true;}return false;}
template <class T1, class T2> bool minimize(T1 &a, T2 b){if (a > b) {a = b; return true;}return false;}
const int N = 2e5 + 5;
int n;
int a[N];
map <int, int> last_val;
map <int, vector <int>> pos_val;
int ans[N];
void solve()
{
	cin >> n;
	stack <pair <int, int>> st;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if(last_val[a[i]])
		{
			int cnt = 1;
			while(!st.empty() && st.top().first != a[i])
			{
				cnt+= st.top().second;
				last_val[st.top().first] = false;
				st.pop();
			}
			st.push({a[i], cnt});
		}  else
		{
			st.push({a[i], 1});
			last_val[a[i]] = true;
		}
	}
	vector <pair <int, int>> res;
	while(!st.empty()) 
	{
		res.push_back(st.top());
		st.pop();
	}
	reverse(all(res));
	for(auto x : res)
	{
		for(int j = 1; j <= x.second; j++) cout << x.first << "\n";
	}
}	
signed main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #define koa "kieuoanh"
    if(fopen(koa".inp", "r")) 
    {
        freopen(koa".inp", "r", stdin); 
        freopen(koa".out", "w", stdout);
    }
    solve();
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
