제출 #1022464

#제출 시각아이디문제언어결과실행 시간메모리
1022464TroySerUnscrambling a Messy Bug (IOI16_messy)C++17
20 / 100
1 ms348 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector<int> swappedBetween(string s) { vector<int> perm(s.size()); for (int i = 0; i < s.size(); i++) { perm[i] = i; } vector<int> zeroes, ones; for (int i = 0; i < s.length(); i++) { if (s[i] == '0') zeroes.push_back(i); else ones.push_back(i); } for (int i = 0; i < zeroes.size(); i++) { for (int j = 0; j < ones.size(); j++) { swap(s[zeroes[i]], s[ones[j]]); if (check_element(s)) { swap(perm[zeroes[i]], perm[ones[j]]); return perm; } swap(s[zeroes[i]], s[ones[j]]); } } } vector<int> restore_permutation(int n, int w, int r) { string toAdd[n-1]; for (int i = 1; i <= n-1; i++) { string s = ""; for (int j = 0; j < i; j++) { s += "1"; } for (int j = i; j < 8; j++) { s += "0"; } toAdd[i - 1] = s; } for (int i = 0; i < n-1; i++) { add_element(toAdd[i]); } // add_element("10000000"); // add_element("11000000"); // add_element("11100000"); // add_element("11110000"); // add_element("11111000"); // add_element("11111100"); // add_element("11111110"); compile_set(); vector<int> perm(n); for (int i = 0; i < n; i++) { perm[i] = i; } for (int i = 0; i < n-1; i++) { if (!check_element(toAdd[i])) { return swappedBetween(toAdd[i]); } } return perm; }

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

messy.cpp: In function 'std::vector<int> swappedBetween(std::string)':
messy.cpp:9:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for (int i = 0; i < s.size(); i++) {
      |                     ~~^~~~~~~~~~
messy.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < s.length(); i++) {
      |                     ~~^~~~~~~~~~~~
messy.cpp:19:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i = 0; i < zeroes.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~
messy.cpp:20:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (int j = 0; j < ones.size(); j++) {
      |                         ~~^~~~~~~~~~~~~
messy.cpp:13:17: warning: control reaches end of non-void function [-Wreturn-type]
   13 |     vector<int> zeroes, ones;
      |                 ^~~~~~
#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...