제출 #1298953

#제출 시각아이디문제언어결과실행 시간메모리
1298953tuandqStone Arranging 2 (JOI23_ho_t1)C++20
100 / 100
85 ms17192 KiB
#include <bits/stdc++.h> using namespace std ; typedef long long ll ; typedef long double ld ; typedef pair<int, int> pii ; typedef pair<int, long long> pil ; typedef pair<long long, int> pli ; typedef pair<long long, long long> pll ; #define bitc(n) (__builtin_popcountll(n)) #define clz(n) (__builtin_clzll(n)) #define ctz(n) (__builtin_ctzll(n)) #define lgi(n) (31 - __builtin_clz(n)) #define lgl(n) (63 - __builtin_clzll(n)) #define MASK(k) (1ll << (k)) #define getbit(n, k) ((n) >> (k) & 1) #define flipbit(n, k) ((n) ^ (1ll << (k))) #define ton(n, k) ((n) | (1ll << (k))) #define toff(n, k) ((n) & ~(1ll << (k))) #define fi first #define se second #define mp make_pair #define eb emplace_back #define lwb lower_bound #define upb upper_bound #define sz(x) (int)(x.size()) #define all(x) x.begin(),x.end() #define taskname "input" template<class X, class Y> bool maximize(X &x, const Y &y) { if(x < y) { return x = y, true ; } return false ; } template<class X, class Y> bool minimize(X &x, const Y &y) { if(x > y) { return x = y, true ; } return false ; } template<class X> void removeDup(vector<X> &ve) { sort(ve.begin(), ve.end()) ; ve.resize(unique(ve.begin(), ve.end()) - ve.begin()) ; } const ll INF = 1e18 ; const int inf = 1e9 ; const int mod = 1e9 + 7 ; const int N = 2e5 + 5, LG = 17 ; /* Some Peach Tea Is Great ;-; */ /* Author : Tuandq */ int a[N], n ; vector<int> diff ; vector<pii> col[N] ; vector<pair<pii, int>> lst ; int cpr(const int &x) { return upb(all(diff), x) - diff.begin() ; } void kittncool() { cin >> n ; for(int i = 1; i <= n; i ++) { cin >> a[i] ; diff.emplace_back(a[i]) ; } removeDup(diff) ; for(int i = 1; i <= n; i ++) { a[i] = cpr(a[i]) ; } for(int i = 1; i <= n; i ++) { int &x = a[i] ; if(col[x].empty()) { col[x].emplace_back(i, i) ; lst.emplace_back(mp(i, i), x) ; // for(auto cur : lst) cerr << cur.fi.fi << ' ' << cur.fi.se << ' ' << cur.se << endl ; // cerr << endl ; continue ; } pii &cur = col[x].back() ; while(!lst.empty() && lst.back().fi.fi > cur.fi) { col[lst.back().se].pop_back() ; lst.pop_back() ; } cur.se = i ; lst.pop_back() ; lst.emplace_back(cur, x) ; // for(auto cur : lst) cerr << cur.fi.fi << ' ' << cur.fi.se << ' ' << cur.se << endl ; // cerr << endl ; } for(int i = 0; i < sz(lst); i ++) { for(int j = lst[i].fi.fi; j <= lst[i].fi.se; j ++) { cout << diff[lst[i].se - 1] << '\n' ; } } } signed main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0) ; if(fopen(taskname".inp", "r")) { freopen(taskname".inp", "r", stdin) ; freopen(taskname".out", "w", stdout) ; } int t = 1 ; //cin >> t ; while(t --) { kittncool() ; } }

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

Main.cpp: In function 'int main()':
Main.cpp:117:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  117 |         freopen(taskname".inp", "r", stdin) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:118:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  118 |         freopen(taskname".out", "w", stdout) ;
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...