제출 #1044528

#제출 시각아이디문제언어결과실행 시간메모리
1044528fv3Unscrambling a Messy Bug (IOI16_messy)C++14
38 / 100
1 ms388 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; vector<int> restore_permutation(int N, int W, int R) { // Try with different bitcounts: // 1000 // 1100 // 1110 // w = n - 1 // r = n*(n+1)/2 - 1 string element(N, '0'); for (int i = 0; i < N - 1; i++) { element[i] = '1'; add_element(element); } compile_set(); vector<int> perm(N, -1); string securedBits(N, '0'); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { if (securedBits[j] == '1') continue; securedBits[j] = '1'; if (check_element(securedBits)) { perm[j] = i; break; } securedBits[j] = '0'; } } int sum = 0; int index; for (int i = 0; i < N; i++) { if (perm[i] == -1) index = i; else sum += perm[i]; } perm[index] = (N * N - N) / 2 - sum; return perm; }

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

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:50:15: warning: 'index' may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |     perm[index] = (N * N - N) / 2 - sum;
      |               ^
#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...