이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |