This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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);
}
if(lst.empty()){
while(true){
}
}
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |