Submission #895631

# Submission time Handle Problem Language Result Execution time Memory
895631 2023-12-30T12:13:25 Z mychecksedad "The Lyuboyn" code (IZhO19_lyuboyn) C++17
34 / 100
319 ms 6640 KB
/* Author : Mychecksdead  */
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define pb push_back
#define all(x) x.begin(), x.end()
#define en cout << '\n'
const int N = 1e6+100, M = 1e5+10, K = 52, MX = 30;

int n, k, t, b = 0;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
  cin >> n >> k >> t;
  for(int i = n-1; i >= 0; --i){
    char c; cin >> c;
    b += (1<<i)*(c=='1');
  }
  vector<int> s, base;

  for(int i = 0; i < (1<<n); ++i) if(__builtin_popcount(i) == k) base.pb(i);

  bool ok = 0;

  for(int rep = 0; rep < 100; ++rep){
    vector<bool> used((1<<n));
    s.clear();
    used[0] = 1;
    for(int j = 0; j < n; ++j){
      int mask = 0;
      while(used[mask]){
        mask = base[uniform_int_distribution<int>(0,(int)(base.size()-1))(rng)];
      }
      s.pb(mask);
      used[mask] = 1;
    }
    ok = 1;
    for(int mask = 1; mask < (1<<n); ++mask){
      int x = 0;
      for(int j = 0; j < n; ++j){
        if((1<<j)&mask){
          x ^= s[j];
        }
      }
      if(x == 0){
        ok = 0;
        break;
      }
    }
    if(ok) break;
  }
  if(!ok){
    cout << -1;
    return;
  }
  vector<int> cur;
  cur.pb(0);
  for(int i = 0; i < n; ++i){
    vector<int> t;
    for(int j = cur.size() - 1; j >= 0; --j){
      t.pb(cur[j]^s[i]);
    }
    for(int x: t) cur.pb(x);
  }
  cout << (1<<n) << '\n';
  for(int x: cur){
    int num = x^b;
    for(int j = (n-1); j >= 0; --j){
      cout << (((1<<j)&x)>0);
    }
    en;
  }
}



int main(){
  cin.tie(0); ios::sync_with_stdio(0);
  int tt = 1, aa;
  // freopen("in.txt", "r", stdin);
  // freopen("out.txt", "w", stdout);
  // cin >> tt;
  while(tt--){
    solve();
    // en;
    en;
  }
  cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" seconds\n";
  return 0;
} 

Compilation message

lyuboyn.cpp: In function 'void solve()':
lyuboyn.cpp:68:9: warning: unused variable 'num' [-Wunused-variable]
   68 |     int num = x^b;
      |         ^~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:80:15: warning: unused variable 'aa' [-Wunused-variable]
   80 |   int tt = 1, aa;
      |               ^~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB First number in answer is not x 1 0
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 7 ms 348 KB Ok
2 Correct 164 ms 348 KB Ok
3 Correct 319 ms 660 KB Ok
4 Correct 1 ms 348 KB Ok
5 Correct 2 ms 344 KB Ok
6 Correct 10 ms 348 KB Ok
7 Correct 16 ms 348 KB Ok
8 Correct 283 ms 600 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 178 ms 6624 KB Ok
2 Correct 86 ms 3296 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Ok
2 Correct 5 ms 604 KB Ok
3 Correct 103 ms 3404 KB Ok
4 Correct 49 ms 1756 KB Ok
5 Correct 1 ms 348 KB Ok
6 Correct 1 ms 348 KB Ok
7 Correct 20 ms 1116 KB Ok
8 Correct 1 ms 460 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 189 ms 6640 KB First number in answer is not x 44202 0
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 178 ms 6624 KB Ok
2 Correct 86 ms 3296 KB Ok
3 Correct 1 ms 348 KB Ok
4 Correct 0 ms 348 KB Ok
5 Correct 0 ms 348 KB Ok
6 Correct 1 ms 344 KB Ok
7 Correct 5 ms 604 KB Ok
8 Correct 103 ms 3404 KB Ok
9 Correct 49 ms 1756 KB Ok
10 Correct 1 ms 348 KB Ok
11 Correct 1 ms 348 KB Ok
12 Correct 20 ms 1116 KB Ok
13 Correct 1 ms 460 KB Ok
14 Incorrect 189 ms 6640 KB First number in answer is not x 44202 0
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 140 ms 3396 KB First number in answer is not x 92826 0
2 Halted 0 ms 0 KB -