Submission #516420

# Submission time Handle Problem Language Result Execution time Memory
516420 2022-01-21T09:50:17 Z leaked Sob (COCI19_sob) C++14
110 / 110
614 ms 9304 KB
#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 time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 315 ms 4836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 315 ms 4804 KB Output is correct
7 Correct 153 ms 2364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 315 ms 4836 KB Output is correct
5 Correct 5 ms 332 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 324 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 315 ms 4804 KB Output is correct
11 Correct 153 ms 2364 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 204 KB Output is correct
19 Correct 66 ms 1188 KB Output is correct
20 Correct 243 ms 3668 KB Output is correct
21 Correct 9 ms 420 KB Output is correct
22 Correct 5 ms 360 KB Output is correct
23 Correct 356 ms 5156 KB Output is correct
24 Correct 614 ms 9304 KB Output is correct
25 Correct 605 ms 8956 KB Output is correct