제출 #774770

#제출 시각아이디문제언어결과실행 시간메모리
774770vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
363 ms21164 KiB
// ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠉⠉⠉⠉⠉⠉⠉⠙⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⠿⠛⠛⠛⠿⠃⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⣿⣿⣿
// ⣿⣿⣿⡿⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠹⣿⣿⣿⣿⣿
// ⣿⣿⠏⠁⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠈⢻⣿⣿⣿
// ⣿⠟⠄⠄⠄⠄⠄⢀⣀⣀⣠⣠⣤⣄⣀⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠹⣿⣿
// ⡏⠄⠄⠄⠄⠄⣠⣿⣿⣿⣿⣿⣿⣿⣿⣷⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠙⣿
// ⡇⠄⠄⠄⠄⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢸
// ⠄⠄⠄⠄⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣆⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄
// ⠄⠄⠄⠄⠄⠄⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀
// ⡆⠄⠄⠄⠄⢀⣿⣿⣿⠿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠛⠛⠃⠄⠄⢠⡀⠄⠄⠄⠄⠄⢸
// ⣿⡄⠄⠄⠄⢸⣿⠋⣠⣄⣀⣀⣀⣈⣿⣿⣿⡏⢀⣤⣤⣤⡤⠄⡈⠻⠆⠄⠄⠄⠄⢸
// ⣿⣿⡀⠄⠄⠘⠩⣽⣟⣃⣀⣀⣀⣤⡍⣉⣉⠄⠠⣠⣤⣀⡀⠄⣀⣠⡀⡄⠄⠄⢀⣿
// ⣿⣿⣷⡀⠄⢠⣤⣸⣿⣿⣿⣿⣵⣷⣦⣿⣿⠄⢠⣾⣿⣷⣶⣶⣷⣿⣻⡇⠄⠄⢸⣿
// ⣿⣿⣿⣧⠄⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇⠛⢿⣿⣿⣿⣿⣿⣿⣿⡇⠄⠘⣼⣿
// ⣿⣿⣿⣿⣧⠄⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠾⠇⠹⣿⣿⣿⠿⠉⠟⢱⡀⢧⣿⣿
// ⣿⣿⣿⣿⣿⣵⣿⣿⣿⡿⠏⣸⣿⣯⣉⣉⠁⠄⠄⠄⠄⠄⠄⢀⡀⠄⠄⠈⡆⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⣾⣿⣿⣷⣰⡿⣿⣿⠿⠿⠿⠟⠓⠛⠄⠄⠄⣼⡇⠄⠄⢀⢹⣿⣿⣿
// ⣿⣿⣿⣿⣿⣿⣷⠹⣿⣿⣿⣿⣦⣶⣶⠶⠷⠶⠞⡂⠄⠄⠄⣻⠁⠄⠄⠄⠈⠻⣿⣿
// ⣿⣿⣿⣿⣿⣿⣿⣷⡌⠻⣿⣿⣿⣿⣿⡻⠿⠟⠋⠁⠄⢀⣴⠁⠄⠄⠄⠄⠄⠄⠹⣿
// ⣿⣿⣿⣿⣿⣿⣿⣿⡿⢄⠸⣿⣿⣿⣿⣶⣤⣤⣴⣶⣶⡿⠏⠄⠄⠄⠄⠄⠄⠄⠄⠺
// ⣿⣿⣿⣿⣿⣿⡿⡿⠅⠘⣧⣌⠛⠻⠿⠿⠟⠛⠛⠋⠁⠄⠄⠄⠄⠄⠄⠄⠄⡀⣄⣔
// ⣿⣿⣿⣿⢯⠇⠄⣶⠄⠄⢹⣿⣷⣦⡀⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⠄⢀⣼⣿⣿⡟

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using type=ll;
#define taskname "table"
// for Orac
#define tasknamein "table"
#define tasknameout "table"
#define fi first
#define se second
#define sz(v) ((type)(v).size())
#define all(v) (v).begin(), (v).end()
typedef pair<type, type> ii;      
typedef vector<ii> vii;      
typedef vector<type> vi;   
typedef vector<vector<type>> vvi;
//for FFT     
using cd = complex<double>;
const double PI = acos(-1);
const type MN=2e5+10;
const type oo=1e18;
const type llmax=0x3f3f3f3f3f3f;

type n, a[MN];
map<type, type> mp;
vector<pair<type, ii>> v;

void read() {
	cin >> n;
	for(int i=1; i<=n; i++) {
		cin >> a[i];
        mp[a[i]]=i;
	}
    // for(int i=1; i<=n; i++) {
    //     cout << mp[i] << " ";
    // }
    // cout << endl;
}

void sol(){
	type i=1;
	while(i<=n) {
        //cout << a[i] << " " << i << " " << mp[a[i]] << endl;
		if(mp[a[i]]>i) {
			v.emplace_back(make_pair(a[i], make_pair(i, mp[a[i]])));
		}
		else {
			v.emplace_back(make_pair(a[i], make_pair(i, i)));
		}
		i=mp[a[i]]+1;
	}
	for(auto i:v) {
		for(type j=i.se.fi; j<=i.se.se; j++) {
			cout << i.fi << endl;
		}
	}  
}

signed main() {
    //freopen(taskname".inp", "r", stdin);
    //freopen(taskname".out", "w", stdout);
    //for Orac
    /*
    ifstream in("tasknamein.txt");
    ofstream out("tasknameout.txt");
    */
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    type t;
    // cin >> t;
    t=1;
    while(t--) {
    	read();  
    	sol();
    	cout << endl;
    }  
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...