제출 #774650

#제출 시각아이디문제언어결과실행 시간메모리
774650vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
151 ms14072 KiB
/* #pragma GCC optimize("Ofast,unroll-loops") #pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt") */ #include <bits/stdc++.h> #define taskname "" #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define ll long long #define ld long double #define pb push_back #define ff first #define ss second #define pii pair<int, int> #define vi vector<int> #define vii vector<pii> #define isz(x) (int)x.size() using namespace std; const int mxN = 2e5 + 5; const int mod = 1e9 + 7; const ll oo = 1e18; int n; map<int, int> mp; vector<pair<int, pii>> cope; void solve() { cin >> n; for(int i = 1; i <= n; ++i) { int val; cin >> val; int cnt = mp[val]; if(cnt) { while(cope.back().ff != val) { --mp[cope.back().ff]; cope.pop_back(); } int l = cope.back().ss.ff; cope.pop_back(); cope.pb({val, {l, i}}); } else { mp[val]++; cope.pb({val, {i, i}}); } } for(auto tmp : cope) { for(int i = tmp.ss.ff; i <= tmp.ss.ss; ++i) cout << tmp.ff << " "; } cout << endl; } signed main() { #ifndef CDuongg if(fopen(taskname".inp", "r")) assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout)); #else freopen("bai3.inp", "r", stdin); freopen("bai3.out", "w", stdout); auto start = chrono::high_resolution_clock::now(); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); int t = 1; //cin >> t; while(t--) solve(); #ifdef CDuongg auto end = chrono::high_resolution_clock::now(); cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '='; cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl; #endif }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...