Submission #145904

# Submission time Handle Problem Language Result Execution time Memory
145904 2019-08-21T10:49:24 Z davitmarg "The Lyuboyn" code (IZhO19_lyuboyn) C++17
0 / 100
1000 ms 133756 KB
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;

int cnt(int num)
{
    int res=0;
    while(num)
    {
        res+=num%2;
        num/=2;
    }
    return res;
}

vector<int> dirs,path;
int n,k,t,s,used[(1<<18)+10],is[(1<<18)+10]; 

void print(int num)
{
    string s;
    for(int i=0;i<n;i++)
    {
        s+=(char)(num%2+'0');
        num/=2;
    }
    reverse(all(s));
    for(int i=0;i<s.length();i++)
        printf("%c",s[i]);
    putchar(10);
}

void dfs(int v)
{
    vector<int> d=dirs;
    path.PB(v);
    used[v]=1;
    if(path.size()==(1<<n) && is[(path[0]^v)])
    {
        for(int i=0;i<path.size();i++)
            print(path[i]);
        exit(0);
    }
    random_shuffle(all(d));
    for(int i=0;i<d.size();i++)
    {
        int to=v^d[i];
        if(used[to])
            continue;
        dfs(to);
    }
    used[v]=0;
}


int main()
{
    cin>>n>>k>>t;
    for(int i=0;i<n;i++)
    {
        char x;
        cin>>x;
        s=s*2+(x-'0');
    }
    for(int i=1;i<(1<<n);i++)
        if(cnt(i)==k)
        {
            dirs.PB(i);
            is[i]=1;
        }
    dfs(s);
    
	return 0;
}
 
/*


*/

Compilation message

lyuboyn.cpp: In function 'void print(int)':
lyuboyn.cpp:49:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<s.length();i++)
                 ~^~~~~~~~~~~
lyuboyn.cpp: In function 'void dfs(int)':
lyuboyn.cpp:59:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if(path.size()==(1<<n) && is[(path[0]^v)])
        ~~~~~~~~~~~^~~~~~~~
lyuboyn.cpp:61:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0;i<path.size();i++)
                     ~^~~~~~~~~~~~
lyuboyn.cpp:66:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<d.size();i++)
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB The output is neither -1 nor the length of the answer
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Expected integer, but "0000" found
# Verdict Execution time Memory Grader output
1 Execution timed out 1069 ms 4268 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 44028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1052 ms 4584 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 133756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 44028 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1074 ms 81136 KB Time limit exceeded
2 Halted 0 ms 0 KB -