답안 #173664

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
173664 2020-01-04T21:43:19 Z RafaelSus "The Lyuboyn" code (IZhO19_lyuboyn) C++14
3 / 100
1000 ms 2668 KB
#include <bits/stdc++.h>
 
using namespace std;
const int N = 1e5 + 5;
typedef long long ll;
const ll inf=1e15;
#define pb push_back
const int INF=(0x3f3f3f3f);

int tod(vector<int>a){
  int res=0;
  reverse(a.begin(),a.end());
  for(int i=0;i<a.size();i++){
    res+=a[i]*(1<<i);
  }
  return res;
}

int tod(string s){
  int res=0;
  reverse(s.begin(),s.end());
  for(int i=0;i<s.size();i++){
    res+=(s[i]-'0')*(1<<i);
  }
  return res;
}

string tobin(int x,int h){
  string res="";
  if(x==0){
    res="0";
    while(res.size()<h)res+="0";
    return res;
  }
  while(x){
    if(x%2)res+="1";
    else res+="0";
    x/=2;
  }
  while(res.size()<h)res+="0";
  reverse(res.begin(),res.end());
  return res;
}
int n,k,t;

int used[(1<<18)+5];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);cout.tie(0);
  
  
  cin>>n>>k>>t;
  string s;
  cin>>s;
  int x=tod(s);
  vector<int>a(n,0);
  for(int i=0;i<k;i++){
    a[n-1-i]=1;
  }
  if(k%2==0){
    cout<<"-1";
    return 0;  
  }
  used[x]=1;
  vector<int>answ;
  answ.pb(x);
  int tmp=x;
  int tim=0,hin=0;
  int X=0;
  while(answ.size()<(1<<n)){
    do{
      if(answ.size()==(1<<n))break;
      int y=tod(a);
      if(!used[y^tmp]){
        answ.pb(y^tmp);
        tmp^=y;
        used[tmp]=1;
        break;
      }
    }while(next_permutation(a.begin(),a.end()));
    if(tim==answ.size()&&tim==hin&&X==10)break;
    if(tim==answ.size()){X++;hin=tim;}
    tim=answ.size();
  }
  if(answ.size()!=(1<<n)){
    cout<<"-1\n";
    return 0;
  }
  cout<<(1<<n)<<'\n';
  for(int i=0;i<answ.size();i++){
    cout<<tobin(answ[i],n)<<'\n';
  }
}

Compilation message

lyuboyn.cpp: In function 'int tod(std::vector<int>)':
lyuboyn.cpp:13:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<a.size();i++){
               ~^~~~~~~~~
lyuboyn.cpp: In function 'int tod(std::__cxx11::string)':
lyuboyn.cpp:22:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<s.size();i++){
               ~^~~~~~~~~
lyuboyn.cpp: In function 'std::__cxx11::string tobin(int, int)':
lyuboyn.cpp:32:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(res.size()<h)res+="0";
           ~~~~~~~~~~^~
lyuboyn.cpp:40:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(res.size()<h)res+="0";
         ~~~~~~~~~~^~
lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:71:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(answ.size()<(1<<n)){
         ~~~~~~~~~~~^~~~~~~
lyuboyn.cpp:73:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       if(answ.size()==(1<<n))break;
          ~~~~~~~~~~~^~~~~~~~
lyuboyn.cpp:82:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(tim==answ.size()&&tim==hin&&X==10)break;
        ~~~^~~~~~~~~~~~~
lyuboyn.cpp:83:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(tim==answ.size()){X++;hin=tim;}
        ~~~^~~~~~~~~~~~~
lyuboyn.cpp:86:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(answ.size()!=(1<<n)){
      ~~~~~~~~~~~^~~~~~~~
lyuboyn.cpp:91:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<answ.size();i++){
               ~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 380 KB Not a cycle!
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Correct 2 ms 376 KB Ok
3 Correct 2 ms 376 KB Ok
4 Correct 2 ms 380 KB Ok
5 Correct 2 ms 376 KB Ok
6 Correct 2 ms 376 KB Ok
7 Correct 2 ms 376 KB Ok
8 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 2548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
2 Execution timed out 1067 ms 504 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1079 ms 2668 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1062 ms 2548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 1528 KB Time limit exceeded
2 Halted 0 ms 0 KB -