제출 #784068

#제출 시각아이디문제언어결과실행 시간메모리
784068zsomborUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include <iostream> #include <vector> #include "messy.h" using namespace std; string s = ""; char opp(int i) { return (s[i] == '0' ? '1' : '0'); } vector <int> restore_permutation(int n, int w, int r) { int l; for (int j = 0; j <= 7; j++) if (n & (1 << j)) l = j; for (int i = 0; i < n; i++) s.push_back('0'); for (int i = 1; i < n; i += 2) { s[i] = '1'; add_element(s); s[i] = '0'; } for (int j = 1; j < l; j++) { for (int i = 0; i < n; i++) s[i] = (i & (1 << (j - 1))) ? '1' : '0'; for (int i = 0; i < n; i++) { if ((i & (1 << j)) == 0) continue; s[i] = opp(i); add_element(s); s[i] = opp(i); } } compile_set(); fill(s.begin(), s.end(), '0'); vector <vector <bool>> b(n, vector <bool>(l, false)); for (int i = 0; i < n; i++) { s[i] = '1'; b[i][0] = check_element(s); s[i] = '0'; } for (int j = 1; j < l; j++) { for (int i = 0; i < n; i++) s[i] = b[i][j - 1] ? '1' : '0'; for (int i = 0; i < n; i++) { s[i] = opp(i); b[i][j] = check_element(s); s[i] = opp(i); } } vector <int> ans(n, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < l; j++) { if (b[i][j]) ans[i] += (1 << j); } } return ans; }

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

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:13:9: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 |     int l; for (int j = 0; j <= 7; j++) if (n & (1 << j)) l = j;
      |         ^
#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...