Submission #774693

#TimeUsernameProblemLanguageResultExecution timeMemory
774693vjudge1Stone Arranging 2 (JOI23_ho_t1)C++17
0 / 100
1 ms1108 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define foru(i,a,b) for(int i = a; i <= b; ++i) #define ford(i,a,b) for(int i = a; i >= b; --i) #define vt vector #define endl '\n' const int N = 200005; int n; int x; int col[N]; int a[N]; int s[N]; int e[N]; int cnt; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; memset(col,-1,sizeof col); foru(i,0,n-1){ cin >> a[i]; } ford(i,n-1,0){ if(col[a[i]] == -1){ col[a[i]] = i; s[i] = i; e[i] = i; } else { s[i] = i; e[i] = col[a[i]]; col[a[i]] = i; } } int p = 0; bool ok = 0; while(p < n-1){ cnt = e[p] - s[p] + 1; if(!ok){ foru(i,1,cnt){ cout << a[p] << endl; } } else { foru(i,1,cnt-1){ cout << a[p] << endl; } } p += cnt; if(cnt > 1){ p -= 1; ok = 1; } else { ok = 0; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...