# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
765015 | 2023-06-24T07:33:20 Z | 1075508020060209tc | Sob (COCI19_sob) | C++14 | 0 ms | 0 KB |
#include<bits/stdc++.h> using namespace std; #define int long long #define X first #define Y second int n;int m; int vis[1000006]; signed main(){ vector<pair<int,int>>ans; cin>>n>>m; int lst=0; for(int i=n-1;i>=0;i--){ if(lst!=0&&vis[lst-1]==0&&((i&(lst-1+m))==i) ){ lst--; ans.push_back({i,lst+m}); vis[lst]=1; continue; } for(int j=0;j<=n-1;j++){ if(vis[j]){continue;} if( ((i&(j+m))==i) ){ ans.push_back({i,j+m}); lst=j; vis[j]=1; break; } } } for(int i=0;i<ans.size();i++){ cout<<ans[i].first<<" "<<ans[i].second<<endl; }