답안 #895075

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
895075 2023-12-29T11:38:01 Z mychecksedad "The Lyuboyn" code (IZhO19_lyuboyn) C++17
0 / 100
1000 ms 1752 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 = 40, K = 52, MX = 30;

int n, k, t;
void solve(){
  cin >> n >> k >> t;
  bitset<18> b;
  for(int i = 0; i< n; ++i){
    char c; cin >> c;
    b[i] = c == '1';
  }
  vector<int> v;
  for(int i = 0; i < (1<<n); ++i){
    v.pb(i);
  }
  do{   
    bool ok = 1;
    for(int i = 1; i < v.size(); ++i){
      bitset<18> b1(v[i-1]);
      bitset<18> b2(v[i]);
      if((b1^b2).count() != k){ok = 0; break;}
    }
    if(ok){
      if(t){
        bitset<18> b1(v[0]);
        bitset<18> b2(v.back());
        if((b1^b2).count() == k){
          for(int i = 0; i < v.size(); ++i){
            for(int j = n-1; j >= 0; --j) cout << ((((1<<j)&v[i])>0)^b[j]);
            en;
          }
          return;
        }
      } else{
        for(int i = 0; i < v.size(); ++i){
          for(int j = n-1; j >= 0; --j) cout << ((((1<<j)&v[i])>0)^b[j]);
          en;
        }
        return;
      }  
    }
  }while(next_permutation(all(v)));
  cout << -1;
}


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

Compilation message

lyuboyn.cpp: In function 'void solve()':
lyuboyn.cpp:26:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i = 1; i < v.size(); ++i){
      |                    ~~^~~~~~~~~~
lyuboyn.cpp:29:26: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   29 |       if((b1^b2).count() != k){ok = 0; break;}
      |          ~~~~~~~~~~~~~~~~^~~~
lyuboyn.cpp:35:28: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |         if((b1^b2).count() == k){
      |            ~~~~~~~~~~~~~~~~^~~~
lyuboyn.cpp:36:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |           for(int i = 0; i < v.size(); ++i){
      |                          ~~^~~~~~~~~~
lyuboyn.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |         for(int i = 0; i < v.size(); ++i){
      |                        ~~^~~~~~~~~~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:57:15: warning: unused variable 'aa' [-Wunused-variable]
   57 |   int tt = 1, aa;
      |               ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Expected integer, but "01" found
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1059 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1047 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1014 ms 1752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1037 ms 348 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 1500 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1014 ms 1752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1055 ms 992 KB Time limit exceeded
2 Halted 0 ms 0 KB -