Submission #774668

#TimeUsernameProblemLanguageResultExecution timeMemory
774668vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
231 ms14356 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; vi color(n); map<int, int> last_idx; for (int i = 0; i < n; i++) { cin >> color[i]; last_idx[color[i]] = i; } for (int i = 0; i < n; i++) { if (last_idx.find(color[i]) == last_idx.end()) continue; int last_i = last_idx[color[i]]; for (int j = i; j <= last_i; j++) { color[j] = color[i]; } i = last_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...