제출 #967603

#제출 시각아이디문제언어결과실행 시간메모리
967603MarwenElarbiUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms604 KiB
#include<bits/stdc++.h> using namespace std; void add_element(std::string x); bool check_element(std::string x); void compile_set(); string text; set<int> st; void dav_add(int l,int r){ int mid=(r+l)/2; if(l==r) return; for (int i = l; i <= mid; ++i) { text[i]='1'; //cout <<text<<endl; add_element(text); text[i]='0'; } for (int i = mid+1; i <= r ; ++i) { text[i]='1'; } dav_add(l,mid); for (int i = mid+1; i <= r ; ++i) { text[i]='0'; } for (int i = l; i <= mid; ++i) { text[i]='1'; } dav_add(mid+1,r); for (int i = l; i <= mid; ++i) { text[i]='0'; } return; } vector<int> res; void dav_check(int l,int r){ vector<int> left; vector<int> right; if(l==r){ res[*st.begin()]=l; return; } for(auto u:st){ text[u]='1'; //cout <<u<<" "; if(!check_element(text)){ right.push_back(u); }else { left.push_back(u); //cout <<text<<endl; } text[u]='0'; }//cout <<endl; for (int i = 0; i < right.size(); ++i) { //cout <<right[i]<<" "; text[right[i]]='1'; st.erase(right[i]); }//cout <<endl; int mid=(r+l)/2; dav_check(l,mid); for (int i = 0; i < right.size(); ++i) { text[right[i]]='0'; st.insert(right[i]); } for (int i = 0; i < left.size(); ++i) { text[left[i]]='1'; st.erase(left[i]); } dav_check(mid+1,r); for (int i = 0; i < left.size(); ++i) { text[left[i]]='0'; st.insert(left[i]); } return; } std::vector<int> restore_permutation(int n, int w, int r) { text=""; res.resize(n); for (int i = 0; i < n; ++i) { st.insert(i); text.push_back('0'); } dav_add(0,n-1); compile_set(); dav_check(0,n-1); return res; }

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

messy.cpp: In function 'void dav_check(int, int)':
messy.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     for (int i = 0; i < right.size(); ++i)
      |                     ~~^~~~~~~~~~~~~~
messy.cpp:67:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     for (int i = 0; i < right.size(); ++i)
      |                     ~~^~~~~~~~~~~~~~
messy.cpp:72:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |     for (int i = 0; i < left.size(); ++i)
      |                     ~~^~~~~~~~~~~~~
messy.cpp:78:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |     for (int i = 0; i < left.size(); ++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...