Submission #774781

#TimeUsernameProblemLanguageResultExecution timeMemory
774781vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
100 / 100
128 ms13272 KiB
#include<bits/stdc++.h> using namespace std; #define taskname "template" #define ll long long #define ld double #define fi first #define se second #define vi vector<int> #define pii pair<int,int> #define vii vector<pii> #define vvi vector<vi> #define pb push_back #define eb emplace_back #define PI acos((ld)-1) typedef complex<ld> base; typedef vector<base> vb; mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count()); const int MN=2e5+5; int n; int arr[MN],near[MN]; map<int,int> mp; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); /* freopen(taskname".inp","r",stdin); freopen(taskname".out","w",stdout); */ cin>>n; for(int i=1;i<=n;++i){ near[i]=-1; cin>>arr[i]; } for(int i=1;i<=n;++i){ if(mp.find(arr[i])!=mp.end()) near[mp[arr[i]]]=i; mp[arr[i]]=i; } // for(int i=1;i<=n;++i){ // cout<<near[i]<<' '; // }cout<<'\n'; for(int i=1;i<=n;++i){ cout<<arr[i]<<'\n'; if(near[i]<0) continue; int idx=i+1; while(idx<near[i]){ cout<<arr[i]<<'\n'; ++idx; } --idx; // cout<<"Case "<<i<<": "<<idx+1<<'\n'; i=idx; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...