Submission #516420

#TimeUsernameProblemLanguageResultExecution timeMemory
516420leakedSob (COCI19_sob)C++14
110 / 110
614 ms9304 KiB
#include <bits/stdc++.h> #define f first #define s second #define fast_izho ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define vec vector #define pb push_back #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() #define sz(x) (int)(x).size() #define pw(x) (1LL<<(x)) #define m_p make_pair //#pragma GCC optimize ("unroll-loops") using namespace std; typedef long long ll; typedef pair<long long,int> pli; typedef pair<int,int> pii; template <class T> bool umin(T &a,const T &b){return (a>b?a=b,1:0);} template <class T> bool umax(T &a,const T &b){return (a<b?a=b,1:0);} const int N=1e6+1; int ans[N]; void solve(int n,int m){ if(n<0) return; int v=-1; for(int j=m;j<=m+n;j++){ if((n&j)==n){ v=j; break; } } int l=v+1; while(v>=m){ ans[n--]=v; --v; } solve(n,l); } signed main(){ fast_izho; int n,m; cin>>n>>m; int x=31-__builtin_clz(n); if(pw(x)<n) ++x; solve(n-1,m); for(int i=0;i<n;i++) cout<<i<<' '<<ans[i]<<endl; 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...