Submission #1093919

#TimeUsernameProblemLanguageResultExecution timeMemory
10939190pt1mus23Sob (COCI19_sob)C++14
0 / 110
20 ms34904 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int #define pb push_back #define ins insert #define endl '\n' #define putr(x) cout<<x<<endl;return; #define all(x) x.begin(),x.end() const int mod = 1e9 +7,sze = 1e5 +23,inf = INT_MAX, L = 23; void opt1z(){ int n,m; cin>>n>>m; vector<vector<pair<int,int>>> event(m+10); vector<int> ans(n,0); for(int i=0;i<n;i++){ int l = i; int r = i; for(int j=0;j<L;j++){ if(i & (1<<j)){ break; } r= i + (1<<j)-1; } l = max(m,l); r = min(m,r); // cout<<l<<" "<<r<<endl; event[l].pb({r,i}); } set<pair<int,int>> lst; for(int i=m;i<m+n;i++){ for(auto v:event[i]){ lst.ins(v); } auto it = *lst.begin(); ans[it.second]=i; lst.erase(lst.begin()); } for(int i=0;i<n;i++){ cout<<i<<" "<<ans[i]<<endl; } } signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int tt = 1; // cin>>tt; while(tt--){ opt1z(); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...