제출 #20629

#제출 시각아이디문제언어결과실행 시간메모리
20629khsoo01Unscrambling a Messy Bug (IOI16_messy)C++11
100 / 100
5 ms640 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int n; void Add (int S, int E) { if(S>=E) return; int mid = (S+E)/2; for(int k = S; k <= mid; k++) { string ret = ""; for(int i = 0; i < n; i++) { if(i < S || i > E || i == k) ret += '1'; else ret += '0'; } add_element(ret); } Add(S, mid); Add(mid+1, E); } vector<int> Solve (vector<int> C) { vector<int> va, vb, a, b; if(C.size() == 1) { a.push_back(C[0]); return a; } string tmp = ""; for(int i=0;i<n;i++) tmp += '1'; for(int i=0;i<C.size();i++) tmp[C[i]] = '0'; for(int i=0;i<C.size();i++) { tmp[C[i]] = '1'; if(check_element(tmp)) va.push_back(C[i]); else vb.push_back(C[i]); tmp[C[i]] = '0'; } a = Solve(va); b = Solve(vb); for(int i=0;i<b.size();i++) a.push_back(b[i]); return a; } std::vector<int> restore_permutation(int N, int W, int R) { n = N; Add(0, n-1); compile_set(); vector<int> cand, ans; for(int i=0;i<n;i++) { cand.push_back(i); } vector<int> tmp = Solve(cand); for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { if(tmp[j] == i) {ans.push_back(j); break;} } } return ans; }

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

messy.cpp: In function 'std::vector<int> Solve(std::vector<int>)':
messy.cpp:28:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<C.size();i++) tmp[C[i]] = '0';
              ~^~~~~~~~~
messy.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<C.size();i++) {
              ~^~~~~~~~~
messy.cpp:36:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<b.size();i++) a.push_back(b[i]);
              ~^~~~~~~~~
#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...