Submission #139834

#TimeUsernameProblemLanguageResultExecution timeMemory
139834farhad13Unscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
5 ms632 KiB
#include <bits/stdc++.h> #include "messy.h" 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[100]; 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); x[i]='0'; if(!m[x] && p)vec[j]=i; } x[vec[j]]='1';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; vector<int> ans(n); for(int i=0;i<n;i++) ans[vec[i]]=i; return ans; }

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:39:1: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
 for(int i=0;i<n;i++)
 ^~~
messy.cpp:43:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
     return ans;
     ^~~~~~
messy.cpp:33: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...