Submission #774654

#TimeUsernameProblemLanguageResultExecution timeMemory
774654vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
0 ms240 KiB
#include <iostream> #include <vector> #include <utility> #include <sstream> #include <climits> #include <cstring> #include <map> #define ll long long #define ld long double using namespace std; const ll mod = 1e9 + 7; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; void solve() { int n; cin >> n; map<int, int> prev_idx; vi par(n, -1); vi color(n); for (int i = 0; i < n; i++) { cin >> color[i]; if (prev_idx.find(color[i]) == prev_idx.end()) { prev_idx[color[i]] = i; } else { par[i] = prev_idx[color[i]]; prev_idx[color[i]] = i; } } for (int i = n - 1; i >= 0; i--) { if (par[i] == -1) continue; for (int j = par[i]; j < i; j++) { color[j] = color[i]; } i = par[i]; } for (int i = 0; i < n; i++) { cout << color[i] << "\n"; } } int main() { // freopen("input_text", "r", stdin); // freopen("output_text", "w", stdout); // ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t-- > 0) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...