Submission #496036

# Submission time Handle Problem Language Result Execution time Memory
496036 2021-12-20T13:00:02 Z asandikci Sob (COCI19_sob) C++17
39 / 110
88 ms 10064 KB
#include"iostream"
#include"vector"
// #include"queue"
// #include"deque"
// #include"set"
// #include"map"
#include"algorithm"
// #include"iomanip"
#include"cstring"
#include"cmath"
#include"bitset"
#define int long long
using namespace std;  

const int maxn=2*1e6+5;

void solve(){
  int n,k;
  cin >> n >> k;
  int til = ceil(log2(n)); //+1 maybe
  // cout << til << "\n";
  if(log2(n)==ceil(log2(n))){
    int num;
    bitset<32> bt;
    vector<pair<int,int>> vec;
    for(int i=k;i<k+n;i++){
      bt = i;
      num=0;
      for(int j=0;j<til;j++){
        if(bt[j]==1){
          num+=(1<<j);
        }
      }
      if(num==n){num=0;}
      vec.push_back({num,i});
      // cout << num << "\n";
    }
    sort(vec.begin(),vec.end());
    for(auto it : vec){
      cout << it.first << " " << it.second << "\n";
    }
  }
  else if(log2(n+k)==ceil(log2(n+k))){
    int num;
    bitset<32> bt;
    bool isactive[maxn];
    vector<pair<int,int>> vec;
    for(int i=k;i<k+n;i++){
      bt = i;
      num=0;
      for(int j=0;j<til;j++){
        if(bt[j]==1){
          num+=(1<<j);
          if(isactive[num]==0){
            isactive[num]=1;
            break;
          }
        }
      }
      if(num==n){num=0;til--;}
      vec.push_back({num,i});
      // cout << num << "\n";
    }
    sort(vec.begin(),vec.end());
    for(auto it : vec){
      cout << it.first << " " << it.second << "\n";
    } 
  }
  else{
    int num;
    bitset<32> bt;
    vector<pair<int,int>> vec;
    bool isactive[maxn];
    for(int i=k;i<k+n;i++){
      bt = i;
      num=0;
      for(int j=til-1;j>=0;j--){
        if(bt[j]==1){
          num+=(1<<j);
          if(isactive[num]==0){
            isactive[num]=1;
            break;
          }
        }
      }
      vec.push_back({num,i});
      // cout << num << "\n";
    }
    sort(vec.begin(),vec.end());
    for(auto it : vec){
      cout << it.first << " " << it.second << "\n";
    }
  }
  
}

signed main(){
  // ios::sync_with_stdio(false); cin.tie(0);
  // freopen("","r",stdin);freopen("","w",stdout);
  int t=1;
  // cin >> t;
  for(int i=1;i<=t;i++){
    // cout << "Case " << i << ":\n";
    solve();
  }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2252 KB Output is correct
2 Correct 2 ms 2124 KB Output is correct
3 Correct 1 ms 2124 KB Output is correct
4 Correct 73 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2380 KB Output is correct
2 Correct 2 ms 2252 KB Output is correct
3 Correct 1 ms 2252 KB Output is correct
4 Correct 2 ms 2124 KB Output is correct
5 Correct 2 ms 2252 KB Output is correct
6 Correct 88 ms 10048 KB Output is correct
7 Correct 37 ms 5956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2124 KB Integer parameter [name=x] equals to 12, violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2252 KB Output is correct
2 Correct 2 ms 2124 KB Output is correct
3 Correct 1 ms 2124 KB Output is correct
4 Correct 73 ms 10064 KB Output is correct
5 Correct 2 ms 2380 KB Output is correct
6 Correct 2 ms 2252 KB Output is correct
7 Correct 1 ms 2252 KB Output is correct
8 Correct 2 ms 2124 KB Output is correct
9 Correct 2 ms 2252 KB Output is correct
10 Correct 88 ms 10048 KB Output is correct
11 Correct 37 ms 5956 KB Output is correct
12 Incorrect 1 ms 2124 KB Integer parameter [name=x] equals to 12, violates the range [0, 11]
13 Halted 0 ms 0 KB -