제출 #742937

#제출 시각아이디문제언어결과실행 시간메모리
742937boris_mihovUnscrambling a Messy Bug (IOI16_messy)C++17
38 / 100
1 ms340 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <vector> #include <random> #include "messy.h" typedef long long llong; const int MAXN = 128; const int INF = 1e9; std::vector <int> perm; std::vector <int> restore_permutation(int n, int w, int r) { perm.resize(n); std::string element(n, '0'); for (int i = 0 ; i < n ; ++i) { element[i] = '1'; add_element(element); } compile_set(); std::mt19937 mt(69420); std::fill(element.begin(), element.end(), '0'); for (int i = 0 ; i < n ; ++i) { std::vector <int> zeroPos; for (int j = 0 ; j < n ; ++j) { if (element[j] == '0') { zeroPos.push_back(j); } } bool found = false; std::shuffle(zeroPos.begin(), zeroPos.end(), mt); for (int j = 0 ; j < zeroPos.size() - 1 ; ++j) { element[zeroPos[j]] = '1'; if (check_element(element)) { perm[zeroPos[j]] = i; found = true; break; } element[zeroPos[j]] = '0'; } if (!found) { element[zeroPos.back()] = '1'; perm[zeroPos.back()] = i; } } return perm; }

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

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:39:28: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         for (int j = 0 ; j < zeroPos.size() - 1 ; ++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...