Submission #112504

#TimeUsernameProblemLanguageResultExecution timeMemory
112504KCSCQuestion (Grader is different from the original contest) (CEOI14_question_grader)C++14
100 / 100
1306 ms114552 KiB
#include <bits/stdc++.h> using namespace std; int codes[925]; void codeGenerator(int N) { if (codes[1]) { return; } int val = 0; for (int mask = 0; mask < (1 << 12); ++mask) { if (__builtin_popcount(mask) == 6) { codes[++val] = mask; } } } int encode(int N, int X, int Y) { codeGenerator(N); for (int i = 0; i < 12; ++i) { if (((codes[X] >> i) & 1) and !((codes[Y] >> i) & 1)) { return i + 1; } } } int decode(int N, int Q, int H) { codeGenerator(N); if (codes[Q] & (1 << (H - 1))) { return 1; } return 0; } #ifdef HOME int main(void) { freopen("question.in", "r", stdin); freopen("question.out", "w", stdout); int T; cin >> T; while (T--) { int N, X, Y, Q; cin >> N >> X >> Y >> Q; cout << decode(N, Q, encode(N, X, Y)) << endl; } return 0; } #endif
#include <bits/stdc++.h> using namespace std; int codes[925]; void codeGenerator(int N) { if (codes[1]) { return; } int val = 0; for (int mask = 0; mask < (1 << 12); ++mask) { if (__builtin_popcount(mask) == 6) { codes[++val] = mask; } } } int encode(int N, int X, int Y) { codeGenerator(N); for (int i = 0; i < 12; ++i) { if (((codes[X] >> i) & 1) and !((codes[Y] >> i) & 1)) { return i + 1; } } } int decode(int N, int Q, int H) { codeGenerator(N); if (codes[Q] & (1 << (H - 1))) { return 1; } return 0; } #ifdef HOME int main(void) { freopen("question.in", "r", stdin); freopen("question.out", "w", stdout); int T; cin >> T; while (T--) { int N, X, Y, Q; cin >> N >> X >> Y >> Q; cout << decode(N, Q, encode(N, X, Y)) << endl; } return 0; } #endif

Compilation message (stderr)

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:18:22: warning: control reaches end of non-void function [-Wreturn-type]
    return i + 1; } } }
                      ^

decoder.cpp: In function 'int encode(int, int, int)':
decoder.cpp:18:22: warning: control reaches end of non-void function [-Wreturn-type]
    return i + 1; } } }
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...