제출 #252826

#제출 시각아이디문제언어결과실행 시간메모리
252826verngutz질문 (CEOI14_question_grader)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 10; int A(int x, int y) { int least_differing_bit; for(int i = 0; i < N; i++) { if((x & (1 << i)) ^ (y & (1 << i))) { least_differing_bit = i; break; } } int x0 = (x & (1 << least_differing_bit)) == 0; if(least_differing_bit < 8) { return least_differing_bit | (x0 << 3); } else { return (least_differing_bit << 1) | x0; } } bool B(int q, int h) { int x0, least_differing_bit; if(h < 16) { x0 = h >> 3; least_differing_bit = h & 0b111; } else { x0 = h & 1; least_differing_bit = h >> 1; } return ((q >> least_differing_bit) & 1) ^ x0; } void test() { ifstream in("input.txt"); int N, T; in >> N >> T; while(T--) { int x, y, q; in >> x >> y >> q; cout << "query " << x << " " << y << " " << q << endl; int h = A(x, y); assert(h < 21); if(B(q, h)) { assert(q == x); } else { assert(q == y); } cout << "ok h = " << h << endl; } } int main() { // test(); int mode, N, T; cin >> mode >> N >> T; while(T--) { if(mode == 1) { int x, y; cin >> x >> y; cout << A(x, y) << endl; } else { int q, h; cin >> q >> h; cout << (B(q, h) ? "yes" : "no") << endl; } } return 0; }

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

encoder.cpp: In function 'int A(int, int)':
encoder.cpp:16:37: warning: 'least_differing_bit' may be used uninitialized in this function [-Wmaybe-uninitialized]
         return (least_differing_bit << 1) | x0;
                ~~~~~~~~~~~~~~~~~~~~~^~~~~
encoder.cpp: In function 'void test()':
encoder.cpp:14:46: warning: 'least_differing_bit' may be used uninitialized in this function [-Wmaybe-uninitialized]
         return least_differing_bit | (x0 << 3);
                                              ^
encoder.cpp:5:9: note: 'least_differing_bit' was declared here
     int least_differing_bit;
         ^~~~~~~~~~~~~~~~~~~
encoder.cpp: In function 'int main()':
encoder.cpp:14:46: warning: 'least_differing_bit' may be used uninitialized in this function [-Wmaybe-uninitialized]
         return least_differing_bit | (x0 << 3);
                                              ^
encoder.cpp:5:9: note: 'least_differing_bit' was declared here
     int least_differing_bit;
         ^~~~~~~~~~~~~~~~~~~
/tmp/ccVw2Za6.o: In function `main':
grader_encode.c:(.text.startup+0x0): multiple definition of `main'
/tmp/ccaBW7O1.o:encoder.cpp:(.text.startup+0x0): first defined here
/tmp/ccVw2Za6.o: In function `main':
grader_encode.c:(.text.startup+0x10a): undefined reference to `encode(int, int, int)'
collect2: error: ld returned 1 exit status

/tmp/ccNIOuoW.o: In function `main':
grader_decode.c:(.text.startup+0x19f): undefined reference to `decode(int, int, int)'
collect2: error: ld returned 1 exit status