제출 #774660

#제출 시각아이디문제언어결과실행 시간메모리
774660vjudge1Stone Arranging 2 (JOI23_ho_t1)C++14
0 / 100
1 ms468 KiB
#include<bits/stdc++.h> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #define int long long #define f first #define s second #define pii pair<int,int> #define piii pair<int,pair<int,int>> #define vii vector<vector<int>> #define vi vector<int> #define cd complex<double> #define endl '\n' //#define multipletest using namespace std; const int LIM=2e5; const int INF = 1e18; const string name="template"; int n,m,q; int a[LIM+5]; map<int,int> mp; void solve(){ //CODE GOES HERE cin>>n; for(int i=1;i<=n;++i){ cin>>a[i]; } for(int i=1;i<=n;++i){ if(mp.count(a[i])==0){ mp[a[i]]=i; } else{ for(int j=mp[a[i]];j<=i;++j){ if(a[j]!=a[i]){ auto it = mp.find(a[j]); mp.erase(it); } a[j]=a[i]; } auto it=mp.find(a[i]); mp.erase(it); } } for(int i=1;i<=n;++i){ cout<<a[i]<<endl; } } signed main(){ // freopen((name+".inp").c_str(),"r",stdin); // freopen((name+".out").c_str(),"w",stdout); // ifstream cin(".txt"); // ofstream cout(".txt"); //ifstream cin((name +".inp")); //ofstream cout((name +".ans")); ios_base::sync_with_stdio(false); cin.tie(NULL); int test; test=1; #ifdef multipletest cin>>test; #endif while(test--){ solve(); #ifdef DEBUG cerr << "Runtime is: " << clock() * 1.0 / CLOCKS_PER_SEC << endl; #endif } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...