Submission #580253

#TimeUsernameProblemLanguageResultExecution timeMemory
580253AlperenTZalmoxis (BOI18_zalmoxis)C++17
0 / 100
358 ms96460 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e6 + 5; int n, k, x; vector<pair<int, int>> v, v2; vector<int> nums[N], vec; int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); cin >> n >> k; for(int i = 0; i < n; i++){ cin >> x; nums[i].push_back(x); v.push_back({x, i}); } for(int num = 1; num <= 29; num++){ swap(v, v2); v.clear(); for(auto p : v2){ if(v.empty()) v.push_back(p); else{ if(v.back().first == num){ if(p.first == num){ v.back().first = num + 1; v.back().second = p.second; } else{ v.back().first = num + 1; nums[v.back().second].push_back(num); v.push_back(p); } } else v.push_back(p); } } if(v.back().first == num){ v.back().first = num + 1; nums[v.back().second].push_back(num); } } for(int i = 0; i < n; i++){ for(auto j : nums[i]){ vec.push_back(j); } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...