Submission #748493

#TimeUsernameProblemLanguageResultExecution timeMemory
748493TrunktySob (COCI19_sob)C++14
39 / 110
132 ms113836 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define int ll int n,m,l,r,curr; vector<vector<int>> ans; vector<int> a; vector<int> b[3000005]; signed main(){ //ios::sync_with_stdio(false); //cin.tie(NULL); cin >> n >> m; for(int i=0;i<=n-1;i++){ a.push_back(i); } for(int i=m;i<=m+n-1;i++){ b[i].push_back(i); } for(int j=20;j>=0;j--){ while(a.size()>0 and a.back()&(1<<j)){ int x = a.back(); a.pop_back(); int y; if(b[x].size()==0){ for(int k=1;k<=2e6;k++){ if(b[x&k].size()>0){ y = b[x&k].back(); b[x&k].pop_back(); break; } } } else{ y = b[x].back(); b[x].pop_back(); } ans.push_back({x,y}); } for(int i=(1<<j);i<(1<<(j+1));i++){ for(int k:b[i]){ b[i-(1<<j)].push_back(k); } b[i].clear(); } } ans.push_back({a.back(),b[0][0]}); for(vector<int> i:ans){ cout << i[0] << " " << i[1] << "\n"; } return 0; }

Compilation message (stderr)

sob.cpp: In function 'int main()':
sob.cpp:39:32: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |             ans.push_back({x,y});
      |                                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...