# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173943 | 2020-01-05T20:11:37 Z | emil_physmath | "The Lyuboyn" code (IZhO19_lyuboyn) | C++17 | 317 ms | 8296 KB |
#include <algorithm> #include <vector> #include <string> #include <iostream> using namespace std; typedef unsigned int uint; int n; uint a[1 << 20]; bool used[1 << 20]; bool is[1 << 20]; int changeInd[1 << 20]; ostream& PrintBin(uint a) { for (int i = n - 1; i >= 0; --i) cout << (bool)(a & (1 << i)); return cout; } int Bits(uint a) { int res = 0; while (a) { res += a & 1; a >>= 1; } return res; } void Print(string s_str) { cout << (1 << n) << endl; for (int i = 0; i < (1 << n); ++i) PrintBin(a[i]) << '\n'; } int main() { int k, t; cin >> n >> k >> t; if (k % 2 == 0) { cout << -1; exit(0); } vector<uint> changes; for (uint mask = 0; mask < (1U << n); ++mask) if (Bits(mask) == k) { changes.push_back(mask); is[mask] = true; // PrintBin(mask) << endl; } random_shuffle(changes.begin(), changes.end()); string s; cin >> s; int top = 1; used[0] = true; while (top) { /*cerr << "top = " << top << endl; for (int i = 0; i < top; ++i) PrintBin(a[i]) << '\n';*/ if (top == (1 << n)) { if (is[a[0] ^ a[top - 1]]) { Print(s); exit(0); } else { if (++changeInd[top - 1] == changes.size()) { cout << "-1\n"; exit(0); } used[a[top - 1]] = false; --top; } } if (changeInd[top] == changes.size()) { changeInd[top] = 0; used[a[top - 1]] = false; --top; } else { uint newTop = a[top - 1] ^ changes[changeInd[top]]; // cerr << "XORed with " << changes[changeInd[top]] << endl; // cerr << "newTop: " << newTop << endl; if (!used[newTop]) { a[top] = newTop; ++changeInd[top]; used[newTop] = true; ++top; } else ++changeInd[top]; } } cout << -1 << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | First number in answer is not x 1 0 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | 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 | 376 KB | Ok |
5 | Correct | 2 ms | 380 KB | Ok |
6 | Correct | 2 ms | 376 KB | Ok |
7 | Correct | 2 ms | 376 KB | Ok |
8 | Correct | 2 ms | 256 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 307 ms | 7772 KB | Ok |
2 | Correct | 146 ms | 3940 KB | Ok |
3 | Correct | 3 ms | 376 KB | Ok |
4 | Correct | 2 ms | 376 KB | Ok |
5 | Correct | 2 ms | 376 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Ok |
2 | Correct | 9 ms | 504 KB | Ok |
3 | Correct | 147 ms | 4020 KB | Ok |
4 | Correct | 71 ms | 2168 KB | Ok |
5 | Correct | 2 ms | 376 KB | Ok |
6 | Correct | 3 ms | 376 KB | Ok |
7 | Correct | 34 ms | 1272 KB | Ok |
8 | Correct | 2 ms | 376 KB | Ok |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 317 ms | 8296 KB | First number in answer is not x 44202 0 |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 307 ms | 7772 KB | Ok |
2 | Correct | 146 ms | 3940 KB | Ok |
3 | Correct | 3 ms | 376 KB | Ok |
4 | Correct | 2 ms | 376 KB | Ok |
5 | Correct | 2 ms | 376 KB | Ok |
6 | Correct | 2 ms | 376 KB | Ok |
7 | Correct | 9 ms | 504 KB | Ok |
8 | Correct | 147 ms | 4020 KB | Ok |
9 | Correct | 71 ms | 2168 KB | Ok |
10 | Correct | 2 ms | 376 KB | Ok |
11 | Correct | 3 ms | 376 KB | Ok |
12 | Correct | 34 ms | 1272 KB | Ok |
13 | Correct | 2 ms | 376 KB | Ok |
14 | Incorrect | 317 ms | 8296 KB | First number in answer is not x 44202 0 |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 149 ms | 3928 KB | First number in answer is not x 92826 0 |
2 | Halted | 0 ms | 0 KB | - |