Submission #1044524

#TimeUsernameProblemLanguageResultExecution timeMemory
1044524fv3Unscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
0 ms348 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 - 1; i++) { if (perm[i] == -1) index = i; else sum += perm[i]; } perm[index] = (N * N - N) / 2 - sum; return perm; }

Compilation message (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...