제출 #172957

#제출 시각아이디문제언어결과실행 시간메모리
172957emil_physmath"The Lyuboyn" code (IZhO19_lyuboyn)C++17
11 / 100
823 ms51388 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

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)
                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...