답안 #172957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
172957 2020-01-02T20:50:15 Z emil_physmath "The Lyuboyn" code (IZhO19_lyuboyn) C++17
11 / 100
823 ms 51388 KB
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

vector<string> a;

int Diff(const string& a, const string& b)
{
    int res = 0;
    for (int i = 0; i < a.length(); ++i)
        res += (a[i] != b[i]);
    return res;
}
void Get1(int n)
{
    if (n == 1)
    {
        a.resize(2);
        a[0] = "0";
        a[1] = "1";
        return;
    }
    Get1(n - 1);
    a.resize(2 * a.size());
    for (int i = 0; i < a.size(); ++i)
        a[i].resize(n - 1);
    for (int j = 0; j < n - 1; ++j)
        for (int r = a.size() / 2, l = a.size() / 2 - 1; r < a.size(); ++r, --l)
            a[r][j] = a[l][j];
    for (int i = 0; i < a.size(); ++i)
        a[i].insert(a[i].begin(), (i < a.size() / 2 ? '0' : '1'));
}
void Get(int n, int k)
{
    // cerr << n << ", " << k << endl;
    if (k == 1)
    {
        Get1(n);
        return;
    }
    Get(n - 1, k - 1);
    bool f = true;
    for (int i = 0; f && i < a.size(); i += 2)
        for (int j = 1; f && j < a.size(); j += 2)
            if (Diff(a[i], a[j]) == k - 1)
            {
                vector<string> temp;
                for (int k = i + 1; k < a.size(); ++k)
                    temp.push_back(a[k]);
                for (int k = 0; k <= i; ++k)
                    temp.push_back(a[k]);
                for (int k = j; k < a.size(); ++k)
                    temp.push_back(a[k]);
                for (int k = 0; k < j; ++k)
                    temp.push_back(a[k]);
                a.swap(temp);
                f = false;
            }
    for (int i = 0; i < a.size(); ++i)
        a[i].insert(a[i].begin(), i % 2 ? '1' : '0');
}
int main()
{
    int n, k, t;
    cin >> n >> k >> t;
    string s;
    cin >> s;
    Get(n, k);
    cout << a.size() << endl;
    for (auto it = find(a.begin(), a.end(), s); it != a.end(); ++it)
        cout << *it << endl;
    for (int i = 0; a[i] != s; ++i)
        cout << a[i] << endl;
}

Compilation message

lyuboyn.cpp: In function 'int Diff(const string&, const string&)':
lyuboyn.cpp:12:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.length(); ++i)
                     ~~^~~~~~~~~~~~
lyuboyn.cpp: In function 'void Get1(int)':
lyuboyn.cpp:27:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
lyuboyn.cpp:30:60: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int r = a.size() / 2, l = a.size() / 2 - 1; r < a.size(); ++r, --l)
                                                          ~~^~~~~~~~~~
lyuboyn.cpp:32:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
lyuboyn.cpp:33:38: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         a[i].insert(a[i].begin(), (i < a.size() / 2 ? '0' : '1'));
                                    ~~^~~~~~~~~~~~~~
lyuboyn.cpp: In function 'void Get(int, int)':
lyuboyn.cpp:45:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; f && i < a.size(); i += 2)
                          ~~^~~~~~~~~~
lyuboyn.cpp:46:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for (int j = 1; f && j < a.size(); j += 2)
                              ~~^~~~~~~~~~
lyuboyn.cpp:50:39: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int k = i + 1; k < a.size(); ++k)
                                     ~~^~~~~~~~~~
lyuboyn.cpp:54:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for (int k = j; k < a.size(); ++k)
                                 ~~^~~~~~~~~~
lyuboyn.cpp:61:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < a.size(); ++i)
                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 1264 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 777 ms 25988 KB Ok
2 Correct 383 ms 13028 KB Ok
3 Correct 5 ms 356 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 376 KB Ok
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 823 ms 51388 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 777 ms 25988 KB Ok
2 Correct 383 ms 13028 KB Ok
3 Correct 5 ms 356 KB Ok
4 Correct 2 ms 256 KB Ok
5 Correct 2 ms 376 KB Ok
6 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 410 ms 25916 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -