Submission #516410

# Submission time Handle Problem Language Result Execution time Memory
516410 2022-01-21T09:40:36 Z leaked Sob (COCI19_sob) C++14
10 / 110
59 ms 48084 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;
vec<int> g[N];
int mt[N],used[N],tt=1;
bool try_kuhn(int v){
    if(used[v]==tt) return 0;
    used[v]=tt;
    for(auto &z : g[v]){
        if(mt[z]==-1){
            mt[z]=v;return 1;
        }
    }
    for(auto &z : g[v]){
        if(try_kuhn(mt[z])){
            mt[z]=v;return 1;
        }
    }
    return 0;
}
signed main(){
    fast_izho;
    int n,m;
    cin>>n>>m;
    int x=31-__builtin_clz(n);
    if(pw(x)<n) ++x;
    x=pw(x);
    vec<int>b(x,-1);
    int j=0;int kk=0;
    for(int i=m;i<m+n;i++){
        if(i%x==0) kk=1;
//        j+=(!kk);
        b[i%x]=i;
    }
//    for(int i=0;i<n;i++)
//        cout<<i<<' '<<b[i]<<endl;
//    cout<<endl;
    int v=-1;
    for(int i=n-1;i>=n-1;i--){
        int kt=0;
        for(int k=m;k<m+n;k++){
            if((i&k)==i && b[k%x]!=-1){
                b[k%x]=-1;
//                cout<<i<<' '<<k<<endl;
                v=k;
                kt=1;
                break;
            }
        }
        assert(kt);
    }
    int k=0;
    while(v>=m){
        cout<<n-k-1<<' '<<v<<'\n';
        k++;v--;
    }
    int jt=1;
    for(int i=n-k-1;i>=0;i--)
        cout<<i<<' '<<m+n-jt<<'\n',assert((i&(m+n-jt))==i),jt++;
//    for(int i=0;i<x;i++)
//        cout<<i<<' '<<b[i]<<'\n';
    return 0;
}
/*

*/

Compilation message

sob.cpp: In function 'int main()':
sob.cpp:46:9: warning: unused variable 'j' [-Wunused-variable]
   46 |     int j=0;int kk=0;
      |         ^
sob.cpp:46:17: warning: variable 'kk' set but not used [-Wunused-but-set-variable]
   46 |     int j=0;int kk=0;
      |                 ^~
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Correct 11 ms 23756 KB Output is correct
4 Correct 59 ms 28404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 28 ms 48076 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23716 KB Output is correct
2 Runtime error 30 ms 48084 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 23756 KB Output is correct
2 Correct 11 ms 23756 KB Output is correct
3 Correct 11 ms 23756 KB Output is correct
4 Correct 59 ms 28404 KB Output is correct
5 Runtime error 28 ms 48076 KB Execution killed with signal 6
6 Halted 0 ms 0 KB -