Submission #1258435

#TimeUsernameProblemLanguageResultExecution timeMemory
1258435SalihSahinSob (COCI19_sob)C++20
0 / 110
5 ms580 KiB
#include "bits/stdc++.h"
#define pb push_back
#define int long long
using namespace std;

const int inf = 1e15;
const int N = 1e6 + 5;

int32_t main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0), cout.tie(0);
   int n, m;
   cin>>n>>m;

   // ilk k bit işime yarıyor olsun, bütün sayılara + m eklendiğindeki bit gösterimi içersin istiyoruz
   // k'nın ilk x biti 0 olsun öyleyse ben şunu biliyorum ki eklediğim sum bu bitlere etki etmiyor
   // k'nın ilk 1 olduğu bit için şunu biliyorum bu bit 0 -> 1 ve 1 -> 0 olacak ve sonraki bitlere bazı etkileri olacak(yine sonraki reverse 1 oldugu sürece sola devam)
   // öyleyse şunu diyebilirim ki : 0 olduğu sürece salladık sonra ilk 1 den itibaren bu biti 0 ve 1 olanlar yer değiştirdi

   // 0 1 2 3 4 5 6 7 olsun ve 4 eklensin 
   // 8 9 10 11 4 5 6 7, 

   vector<int> ans(n);
   for(int i = 0; i < n; i++){
      ans[i] = i;
   }

   for(int i = 0; i < 21; i++){
      int bt = (1 << i);
      if(!(m&bt)) continue;

      vector<int> updans = ans;
      vector<int> type[2][2];
      for(int j = 0; j < n; j++){
         type[(j&bt) > 0][(updans[j]&bt) > 0].pb(j);
      }
      
      if(type[0][0].size() < type[1][1].size()){
         cout<<"proof hatalı"<<endl;
         return 0;
      }
      int ind = 0;
      for(auto itr: type[1][1]){
         swap(updans[itr], updans[type[0][0][ind]]);
         ind++;
      }

      for(int j = 0; j < n; j++){
         updans[j] += bt;
      }
      swap(updans, ans);
   }

   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...