Submission #966949

#TimeUsernameProblemLanguageResultExecution timeMemory
966949MarwenElarbiUnscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
1 ms436 KiB
#include <bits/stdc++.h> //#include "messy.h" using namespace std; void add_element(std::string x); bool check_element(std::string x); void compile_set(); std::vector<int> restore_permutation(int n, int w, int r){ vector<int> res(n); string cur; set<int> st; int a=1; for (int i = 0; i < 8; ++i) { res[i]=i; st.insert(a); a*=2; } for (int i = 0; i < n; ++i) { cur.push_back('0'); } for (int i = 0; i < n; ++i) { cur[i]='1'; add_element(cur); } compile_set(); int ok[(1<<n)]; vector<int> compare[n+1]; //cout <<"nabba"<<endl; for (int i = 0; i < (1<<n); ++i) { string ne=""; for (int j = 0; j < n; ++j) { if(i&(1<<j)) ne.push_back('1'); else ne.push_back('0'); } //cout <<compiled<<" "<<ne<<endl; compare[__builtin_popcount(i)].push_back(i); ok[i]=check_element(ne); //cout <<ne<<" "<<i<<" "<<ok[i]<<endl; } //cout <<ok[2]<<endl; for (int i = 1; i <= n; ++i) { //cout <<i<<" "<<compare[i].size()<<endl; for (int j = 0; j < compare[i].size(); ++j) { //cout <<compare[i][j]<<endl; if(ok[compare[i][j]]==0||st.count(compare[i][j])) continue; else { //cout <<"hey"<<" "<<i<<" "<<compare[i][j]<<endl; for (int k = i; k < n; ++k) { if((1<<k)&compare[i][j]){ //cout <<i-1<<" "<<k<<endl; res[i-1]=k; res[k]=i-1; return res; } } } } } return res; }

Compilation message (stderr)

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