#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
21 ms |
34904 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
1368 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
21 ms |
34904 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |