제출 #856092

#제출 시각아이디문제언어결과실행 시간메모리
856092BenmathZalmoxis (BOI18_zalmoxis)C++14
35 / 100
550 ms139480 KiB
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <bits/stdc++.h> using namespace std; int niz[1000001]; int n; int k; int vis[1000001]; vector<int>solve(int x, int y){ if (y == 1){ vector<int>ans; ans.push_back(x); return ans; }else if(y == 2){ vector<int>ans; ans.push_back(x-1); ans.push_back(x-1); return ans; }else{ if(x == 1){ vector<int>ans; ans.push_back(0); ans.push_back(0); return ans; } vector<int> ro1 = solve(x - 1, y - 1); vector<int> ro2 = solve(x - 1, y - ro1.size()); for(int i = 0; i < ro2.size();i++){ ro1.push_back(ro2[i]); } return ro1; } } using pii = pair<int,pair<int,int>>; int main() { cin >> n >> k; vector<int>v[n]; priority_queue<pii, vector<pii> , greater<pii> > pq; for(int i = 0; i < n; i++){ cin >> niz[i]; pq.push({niz[i],{i,i}}); } int t1 = 0; while(!pq.empty() and t1 < k){ pii a = pq.top(); pq.pop(); if(a.first < 30){ if(pq.empty()){ v[a.second.second].push_back(a.first); pq.push({a.first + 1, {a.second.first, a.second.second}}); t1++; }else{ pii b = pq.top(); pq.pop(); if(a.first != b.first){ v[a.second.second].push_back(a.first); pq.push({a.first + 1, {a.second.first, a.second.second}}); pq.push({b.first, {b.second.first,b.second.second}}); t1++; }else{ int prvi = a.second.second + 1; int drugi = b.second.first; if(prvi == drugi){ pq.push({a.first + 1,{a.second.first,b.second.second}}); }else{ v[a.second.second].push_back(a.first); pq.push({a.first + 1, {a.second.first, a.second.second}}); t1++; } } } } } k = k - t1; for(int i = 0; i < n; i++){ cout << niz[i] << " "; for(int j = 0;j < v[i].size(); j++){ vector<int> ro = solve(v[i][j], k + 1); for(int t = 0; t < ro.size(); t++){ cout<<ro[t]<<" "; } int velicina = ro.size(); k = k - (velicina - 1); } } }

컴파일 시 표준 에러 (stderr) 메시지

zalmoxis.cpp: In function 'std::vector<int> solve(int, int)':
zalmoxis.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int i = 0; i < ro2.size();i++){
      |                        ~~^~~~~~~~~~~~
zalmoxis.cpp: In function 'int main()':
zalmoxis.cpp:87:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   87 |         for(int j = 0;j < v[i].size(); j++){
      |                       ~~^~~~~~~~~~~~~
zalmoxis.cpp:90:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   90 |             for(int t = 0; t < ro.size(); t++){
      |                            ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...