Submission #415145

#TimeUsernameProblemLanguageResultExecution timeMemory
415145ly20Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms484 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; vector <int> resp; int m; void cria(int ini, int fim) { string s; //s.clear(); //printf("oi %d %d\n", ini, fim); if(ini == fim) return; //printf("oi\n"); //printf("%d\n", m); s.resize(m); for(int i = 0; i < m; i++) { if(i < ini || i > fim) s[i] = '0'; else s[i] = '1'; } int md = (ini + fim) / 2; //printf("%d %d\n", ini, md); for(int i = ini; i <= md; i++) { s[i] = '0'; //printf("oi1\n"); add_element(s); //printf("oi2\n"); //cout << s << endl; s[i] = '1'; } //printf("%d %d %d %d\n", ini, md, md + 1, fim); cria(ini, md); cria(md + 1, fim); } string olha; void responde(int ini, int fim) { //printf("%d %d\n", ini, fim); vector <int> esq, dir; if(ini == fim) { for(int i = 0; i < m; i++){ if(olha[i] == '1') { resp[i] = ini; } } return; } for(int i = 0; i < m; i++) { if(olha[i] == '1') { olha[i] = '0'; if(check_element(olha)) { esq.push_back(i); } else { dir.push_back(i); } olha[i] = '1'; } } int md = (ini + fim) / 2; for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '0'; responde(ini, md); for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '1'; for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '0'; responde(md + 1, fim); for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '1'; } vector<int> restore_permutation(int n, int w, int r) { m = n; cria(0, n - 1); compile_set(); resp.resize(n); olha.resize(n); for(int i = 0; i < n; i++) olha[i] = '1'; responde(0, n - 1); //printf("oi\n"); //for(int i = 0; i < resp.size(); i++) printf("%d ", resp[i]); //printf("\n"); return resp; }

Compilation message (stderr)

messy.cpp: In function 'void responde(int, int)':
messy.cpp:58:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   58 |     for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '0';
      |                    ~~^~~~~~~~~~~~
messy.cpp:60:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for(int i = 0; i < dir.size(); i++) olha[dir[i]] = '1';
      |                    ~~^~~~~~~~~~~~
messy.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |     for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '0';
      |                    ~~^~~~~~~~~~~~
messy.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for(int i = 0; i < esq.size(); i++) olha[esq[i]] = '1';
      |                    ~~^~~~~~~~~~~~
#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...