Submission #257704

# Submission time Handle Problem Language Result Execution time Memory
257704 2020-08-04T15:09:35 Z BThero "The Lyuboyn" code (IZhO19_lyuboyn) C++17
19 / 100
448 ms 6740 KB
// chrono::system_clock::now().time_since_epoch().count()
#include<bits/stdc++.h>

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " = " << x << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

vi gen(int n, int k) {
  if (k % 2 == 0) {
    return {};
  }
  
  vi ret;
  
  if (k == 1) {
    if (n == 1) {
      return vi({0, 1});
    }
    
    vi A = gen(n - 1, k);
    vi B = A;
    reverse(all(B));
    
    for (int &x : B) {
      x += (1 << (n - 1));
    }
    
    for (int x : A) {
      ret.pb(x);
    }
    
    for (int x : B) {
      ret.pb(x);
    }
    
    return ret;
  }
  
  if (n % 2 == k % 2) {
    return {};
  }
  
  vi A = gen(n - 2, k - 2);
  int rot = (1 << (n - 1)) + (1 << (n - 2));
  int cur = 0;
  
  for (int i : {n - 2, n - 1, n - 2, n - 1}) {
    for (int x : A) {
      ret.pb(cur + x);
      cur ^= rot;
    }
    
    cur ^= (1 << i);
    rotate(A.begin(), A.begin() + 1, A.end());
  }
  
  return ret;
}

void solve() {
  int n, k, T;
  string S;
  scanf("%d %d %d", &n, &k, &T);
  cin >> S;
  int st = 0;
  
  for (int i = 0; i < n; ++i) {
    if (S[i] == '1') {
      st += (1 << i);
    }
  }
  
  vi vec = gen(n, k);
  
  if (vec.empty()) {
    printf("-1\n");
    return;
  }
  
  rotate(vec.begin(), find(all(vec), st), vec.end());
  printf("%d\n", (1 << n));
  
  for (int x : vec) {
    for (int i = 0; i < n; ++i) {
      printf("%d", (x >> i) & 1);
    }
    
    printf("\n");
  }
}

int main() {
  int tt = 1;
  
  while (tt--) {
    solve();
  }

  return 0;
}

Compilation message

lyuboyn.cpp: In function 'void solve()':
lyuboyn.cpp:73:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d %d", &n, &k, &T);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Ok
2 Correct 0 ms 256 KB Ok
3 Correct 1 ms 256 KB Ok
4 Correct 0 ms 256 KB Ok
5 Correct 0 ms 256 KB Ok
6 Correct 0 ms 256 KB Ok
7 Correct 1 ms 384 KB Ok
8 Correct 0 ms 256 KB Ok
# Verdict Execution time Memory Grader output
1 Correct 435 ms 6740 KB Ok
2 Correct 207 ms 3376 KB Ok
3 Correct 3 ms 384 KB Ok
4 Correct 1 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 448 ms 6500 KB Fail, not exactly k bits are different: line = 10039
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 435 ms 6740 KB Ok
2 Correct 207 ms 3376 KB Ok
3 Correct 3 ms 384 KB Ok
4 Correct 1 ms 384 KB Ok
5 Correct 0 ms 384 KB Ok
6 Incorrect 1 ms 256 KB Output -1 while solution exists
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output -1 while solution exists
2 Halted 0 ms 0 KB -