제출 #1188168

#제출 시각아이디문제언어결과실행 시간메모리
1188168mehdibaStone Arranging 2 (JOI23_ho_t1)C++20
60 / 100
20 ms3340 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define pb push_back #define sz(a) sizeof(a) / sizeof(a[0]) #define F first #define S second #define all(v) v.begin(), v.end() #define allr(v) v.rbegin(), v.rend() using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; int main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i]; if(n <= 2000){ for(int i = 0; i < n; i++){ int tt; // find the latest occurence of a[i] for(int j = n - 1; j >= 0; j--) if(a[j] == a[i]){ tt = j; break; } for(int j = i + 1; j < tt; j++) a[j] = a[i]; } for(int x : a) cout << x << '\n'; } else{ int f = a[0], t = 0, ot = (a[0] == 1 ? 2 : 1); for(int i = n - 1; i >= 0; i--) if(a[i] == f){ t = i; break; } for(int i = 0; i <= t; i++) cout << f << '\n'; for(int i = t + 1; i < n; i++) cout << ot << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...