제출 #50692

#제출 시각아이디문제언어결과실행 시간메모리
50692faishol27Unscrambling a Messy Bug (IOI16_messy)C++14
38 / 100
3 ms432 KiB
//////////////////////////////////////////////// // // // Author: Muhammad Faishol Amirul Mukminin // // // //////////////////////////////////////////////// #include "messy.h" #include <bits/stdc++.h> using namespace std; vector<int>ans; string solve(int cnt, string s){ string ret = s; int len = s.length(), terkiri; for(int i=len-1;i>=0;i--) if(ret[i] == '0'){ terkiri = i; break; } for(int i=0;i<terkiri;i++){ if(ret[i]=='1') continue; ret[i] = '1'; if(check_element(ret)){ ans[i] = cnt-1; return ret; }else{ ret[i] = '0'; } } ans[terkiri] = cnt-1; ret[terkiri] = '1'; return ret; } std::vector<int> restore_permutation(int N, int W, int R) { ans.resize(N, -1); string B = "", tmp = ""; for(int i=0;i<N;i++){ B += "0"; tmp += "0"; } for(int i=0;i<N-1;i++){ B[i] = '1'; add_element(B); } compile_set(); for(int i=1;i<N;i++){ tmp = solve(i, tmp); } for(int i=0;i<N;i++) if(ans[i]==-1) ans[i] = N-1; return std::vector<int>(ans); }

컴파일 시 표준 에러 (stderr) 메시지

messy.cpp: In function 'std::__cxx11::string solve(int, std::__cxx11::string)':
messy.cpp:16:9: warning: 'terkiri' may be used uninitialized in this function [-Wmaybe-uninitialized]
         terkiri;
         ^~~~~~~
#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...