제출 #1076267

#제출 시각아이디문제언어결과실행 시간메모리
1076267clementineUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms856 KiB
#include <vector> using namespace std; #include "messy.h" #include<bits/stdc++.h> int ans[130]; vector<string> subsets; void createSubsets(int l, int r, int n) { if(l != r) { int mid = (l + r) /2; string s(n, '1'); for(int i = l; i <=r; i ++) { s[i] = '0'; } for(int i = l; i <=mid; i ++) { string a = s; a[i] = '1'; subsets.push_back(a); add_element(a); } createSubsets(l, mid, n); createSubsets(mid + 1, r, n); } } void query(int l, int r, int n, vector<int> ones) { /* cout << l << " and " << r <<"\nones: "; for(auto val: ones) { cout << val << " "; }cout << '\n'; */ if(l == r) { for(int i= 0; i <n; i ++) { bool inones = false; for(int j = 0; j <ones.size(); j ++) { if(ones[j] == i) { inones = true; } } if(!inones) { //cout << l << "corresponds to " << i << '\n'; ans[i] = l; return; } } } int mid = (l + r) / 2; vector<int> futurelefts, futurerights; string s(n, '0'); for(auto idx: ones) { s[idx] = '1'; } for(int i = 0; i <n; i ++) { if(s[i] == '0') { string a = s; a[i] = '1'; if(check_element(a)) { //cout << a << " checnekd \n"; futurerights.push_back(i); } else { futurelefts.push_back(i); //cout << a << " notchecked \n"; } } } for(auto val:ones) { futurelefts.push_back(val); futurerights.push_back(val); } query(l, mid, n, futurelefts); query(mid + 1, r, n, futurerights); } vector<int> restore_permutation(int n, int w, int r) { createSubsets(0, n-1, n ); compile_set(); /* for(string s : subsets) { cout << s << '\n'; } cout << '\n';*/ vector<int> a; query(0, n-1, n, a); vector<int> ret; for(int i = 0; i <n; i ++) { ret.push_back(ans[i]); } return ret; }

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

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