Submission #469746

#TimeUsernameProblemLanguageResultExecution timeMemory
469746luciocfUnscrambling a Messy Bug (IOI16_messy)C++14
70 / 100
2 ms492 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; const int maxn = 210; int p[maxn]; void write(string s) { vector<int> pos; for (int i = 0; i < s.size(); i++) if (s[i] == '1') pos.push_back(i); if (pos.size() == 1) return; if (pos.size() == 2) { s[pos[0]] = '0'; add_element(s); return; } int mid = pos.size()/2; for (int i = 0; i < mid; i++) { s[pos[i]] = '0'; add_element(s); s[pos[i]] = '1'; } for (int i = mid; i < pos.size(); i++) s[pos[i]] = '0'; write(s); for (int i = 0; i < mid; i++) s[pos[i]] = '0'; for (int i = mid; i < pos.size(); i++) s[pos[i]] = '1'; write(s); } void read(string s, string match) { vector<int> pos[2]; for (int i = 0; i < s.size(); i++) { if (s[i] == '1') pos[0].push_back(i); if (match[i] == '1') pos[1].push_back(i); } if (pos[0].size() == 1) { p[pos[1][0]] = pos[0][0]; return; } string match2; for (int i = 0; i < match.size(); i++) match2 += '0'; for (int i = 0; i < pos[1].size(); i++) { match[pos[1][i]] = '0'; if (check_element(match)) match2[pos[1][i]] = '1'; match[pos[1][i]] = '1'; } int mid = pos[0].size()/2; for (int i = mid; i < pos[0].size(); i++) s[pos[0][i]] = '0'; if (pos[0].size() == 2) s[pos[0][1]] = '0'; read(s, match2); for (int i = 0; i < match.size(); i++) match2[i] = '0'; for (int i = 0; i < pos[1].size(); i++) { match[pos[1][i]] = '0'; if (!check_element(match)) match2[pos[1][i]] = '1'; match[pos[1][i]] = '1'; } for (int i = mid; i < pos[0].size(); i++) s[pos[0][i]] = '1'; for (int i = 0; i < mid; i++) s[pos[0][i]] = '0'; if (pos[0].size() == 2) s[pos[0][1]] = '1', s[pos[0][0]] = '0'; read(s, match2); } vector<int> restore_permutation(int n, int w, int r) { string s, match; for (int i = 0; i < n; i++) { s += '1'; match += '1'; } write(s); compile_set(); read(s, match); vector<int> ans; for (int i = 0; i < n; i++) ans.push_back(p[i]); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void write(std::string)':
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.size(); i++)
      |                     ~~^~~~~~~~~~
messy.cpp:36:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = mid; i < pos.size(); i++)
      |                       ~~^~~~~~~~~~~~
messy.cpp:43:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |     for (int i = mid; i < pos.size(); i++)
      |                       ~~^~~~~~~~~~~~
messy.cpp: In function 'void read(std::string, std::string)':
messy.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 0; i < s.size(); i++)
      |                     ~~^~~~~~~~~~
messy.cpp:70:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for (int i = 0; i < match.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
messy.cpp:73:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |     for (int i = 0; i < pos[1].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
messy.cpp:85:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   85 |     for (int i = mid; i < pos[0].size(); i++)
      |                       ~~^~~~~~~~~~~~~~~
messy.cpp:93:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   93 |     for (int i = 0; i < match.size(); i++)
      |                     ~~^~~~~~~~~~~~~~
messy.cpp:96:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   96 |     for (int i = 0; i < pos[1].size(); i++)
      |                     ~~^~~~~~~~~~~~~~~
messy.cpp:106:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  106 |     for (int i = mid; i < pos[0].size(); i++)
      |                       ~~^~~~~~~~~~~~~~~
#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...