제출 #1040938

#제출 시각아이디문제언어결과실행 시간메모리
1040938vjudge1Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms628 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define pb push_back vector<int>ans; int N; void insertion(int l,int r){ if(l==r)return; int mid=(l+r)>>1; string s=string(N,'0'); for(int i=l;i<=r;i++)s[i]='1'; for(int i=l;i<=mid;i++){ s[i]='0'; add_element(s); s[i]='1'; } insertion(l,mid),insertion(mid+1,r); } bool dontcare[128]; void finding(int l,int r){ if(l==r){ for(int i=0;i<N;i++){ if(!dontcare[i]){ ans[i]=l; break; } } return; } int mid=(l+r)>>1; vector<int>firsthalf,secondhalf; int mxsz=mid-l+1; string s=string(N,'0'); for(int i=0;i<N;i++){ if(!dontcare[i]){ s[i]='1'; } } for(int i=0;i<N;i++){ if(!dontcare[i]){ if(firsthalf.size()==mxsz){ secondhalf.pb(i); } else if(secondhalf.size()==mxsz){ firsthalf.pb(i); }else{ s[i]='0'; bool res=check_element(s); if(res){ firsthalf.pb(i); }else{ secondhalf.pb(i); } s[i]='1'; } } } for(int i:secondhalf){ dontcare[i]=1; } finding(l,mid); for(int i:firsthalf){ dontcare[i]=1; } for(int i:secondhalf){ dontcare[i]=0; } finding(mid+1,r); for(int i:firsthalf){ dontcare[i]=0; } } std::vector<int> restore_permutation(int n, int w, int r) { N=n; insertion(0,n-1); compile_set(); ans=vector<int>(n); memset(dontcare,0,sizeof(dontcare)); finding(0,n-1); return ans; }

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

messy.cpp: In function 'void finding(int, int)':
messy.cpp:48:32: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   48 |             if(firsthalf.size()==mxsz){
      |                ~~~~~~~~~~~~~~~~^~~~~~
messy.cpp:51:38: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   51 |             else if(secondhalf.size()==mxsz){
      |                     ~~~~~~~~~~~~~~~~~^~~~~~
#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...