이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vei;
typedef vector<vei> vevei;
#define coa \
for (auto i : a) { \
cout << i << ' '; \
} \
cout << '\n';
#define cia \
for (auto& i : a) { \
cin >> a; \
}
#define cna \
int n; \
cin >> n; \
vector<int> a(n); \
for (int i = 0; i < n; i++) { \
cin >> a[i]; \
}
#define cnka \
int n, k; \
cin >> n >> k; \
vector<int> a(n); \
for (int i = 0; i < n; i++) { \
cin >> a[i]; \
}
#define cnab \
int n; \
cin >> n; \
vector<int> a(n); \
for (int i = 0; i < n; i++) { \
cin >> a[i]; \
} \
vector<int> b(n); \
for (int i = 0; i < n; i++) { \
cin >> b[i]; \
}
#define all(a) (a).begin(), (a).end()
#define sz(a) (int) a.size()
#define con cout << "NO\n"
#define coe cout << "YES\n";
#define str string
#define pb push_back
#define ff first
#define sc second
#define pii pair<int, int>
#define mxe max_element
#define mne min_element
#define stf shrink_to_fit
#define f(i, l, r) for (int i = (l); i < (r); i++)
#define double ld
void solve() {
int n; cin >> n;
vector<int> a(n);
for (auto& u : a) cin >> u;
map<int, vector<int>> pos;
f(i, 0, n) pos[a[i]].pb(i);
int ind = 0;
while (true) {
if (ind == n) break;
int bc = pos[a[ind]].back();
for (int j = 0; j < bc - ind + 1; j++) cout << a[ind] << '\n';
ind = bc + 1;
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int tt = 1; // cin >> tt;
while (tt--) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |