제출 #139003

#제출 시각아이디문제언어결과실행 시간메모리
139003math0_0Zalmoxis (BOI18_zalmoxis)C++11
5 / 100
584 ms47016 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pl; int main(){ ll n, k; cin >> n >> k; //all values between 1 and 30 //for k = 1 //smallest integer in input must have 2 consecutive of it, else insta solve //group and ascend? vector<pl> book[31];//book[i] stores pos of numbers i for(ll one = 0; one < 31; one++){ book[one].push_back(make_pair(-1, -1)); book[one].push_back(make_pair(n, n)); } ll tp, insidx = -1, insval = -1; ll a[n]; for(ll one = 0; one < n; one++){ cin >> tp; book[tp].push_back(make_pair(one, one)); a[one] = tp; } for(ll one = 0; one < 30; one++){ ll nums = book[one].size()-2; sort(book[one].begin(), book[one].end()); if(nums%2){ insval = one; for(ll two = 1; two <= nums; two++){ ll lb = book[one][two-1].second; ll cl = book[one][two].first; ll cr = book[one][two].second; ll rb = book[one][two+1].first; if(lb==-1 && rb==n){insidx = cr; two = nums+2; one = 31;} else if(lb==-1){ if(rb-cr!=1){insidx = cr; two = nums+2; one = 31;} } else if(rb==n){ if(cl-lb!=1){insidx = cr; two = nums+2; one = 31;} } else if(cl-lb!=1 && rb-cr!=1){insidx = cr; two = nums+2; one = 31;} } } else{ for(ll two = 1; two < nums; two+=2){ book[one+1].push_back(make_pair(book[one][two].first, book[one][two+1].second)); } } } for(ll one = 0; one < n; one++){ cout << a[one] << ' '; if(one == insidx){cout << insval << ' ';} } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...