Submission #139861

#TimeUsernameProblemLanguageResultExecution timeMemory
139861farhad13Unscrambling a Messy Bug (IOI16_messy)C++14
38 / 100
9 ms760 KiB
#include <bits/stdc++.h> #include "messy.h" #define pb push_back using namespace std; vector<int> restore_permutation(int n, int w, int r) { vector<int> vec; vec.assign(n,-1); map<string,int> m; string x(n,'0'); string y(n,'0'); for(int i=0;i<n-1;i++) {y[i]='1'; add_element(y); m[y]=1; } compile_set(); int cnt[129]; vector<int> asd; for(int i=0;i<n;i++)cnt[i]=1; for(int j=0;j<n;j++){ for(int i=0;i<n;i++) { if(x[i]=='1')continue; x[i]='1'; bool p=check_element(x); if(!m[x] && p)asd.pb(j),asd.pb(i); x[i]='0'; if(!m[x] && p)vec[j]=i; } if(vec[j]!=-1)x[vec[j]]='1',cnt[vec[j]]=0; else if(n<=8)x[j]='1',vec[j]=j,cnt[vec[j]]=0; } int h,d=0; for(int i=0;i<n;i++)if(cnt[i])h=i; for(int i=0;i<n;i++)if(vec[i]==-1)vec[i]=h,d++; if(d>1) for(int i=0;i<n;i++) vec[i]=i; if(asd.size()==2) vec[asd[0]]=asd[1],vec[asd[1]]=asd[0]; vector<int> ans(n); for(int i=0;i<n;i++) {ans[vec[i]]=i;} //for(int i=0;i<n;i++)cout<<ans[i]<<" "; return ans; }

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:41:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 for(int i=0;i<n;i++)
 ^~~
messy.cpp:44:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     if(asd.size()==2)
     ^~
messy.cpp:39:41: warning: 'h' may be used uninitialized in this function [-Wmaybe-uninitialized]
 for(int i=0;i<n;i++)if(vec[i]==-1)vec[i]=h,d++;
#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...