Submission #794287

#TimeUsernameProblemLanguageResultExecution timeMemory
794287KhizriUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms508 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define F first #define S second #define INF 1e18 #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define pii pair<int,int> #define pll pair<ll,ll> #define OK cout<<"Ok"<<endl; #define MOD (ll)(1e9+7) const int mxn=200+5; int n,arr[mxn]; void funk(int l,int r){ int m=(l+r)/2; string s=""; for(int i=0;i<n;i++){ s+='1'; } for(int i=l;i<=r;i++){ s[i]='0'; } for(int i=l;i<=m;i++){ s[i]='1'; add_element(s); s[i]='0'; } if(r-l==1) return; funk(l,m); funk(m+1,r); } void funk2(int l,int r,vector<int>vt){ if(vt.size()==1){ arr[l]=vt[0]; return; } string s=""; for(int i=0;i<n;i++){ s+='1'; } for(int v:vt){ s[v]='0'; } vector<int>x,y; for(int i=0;i<s.size();i++){ if(s[i]=='1') continue; s[i]='1'; if(check_element(s)){ x.pb(i); } else{ y.pb(i); } s[i]='0'; } int m=(l+r)/2; funk2(l,m,x); funk2(m+1,r,y); } vector<int> restore_permutation(int N, int w, int r) { n=N; funk(0,n-1); compile_set(); vector<int>vt; for(int i=0;i<n;i++){ vt.pb(i); } funk2(0,n-1,vt); vector<int>ans(n); for(int i=0;i<n;i++){ ans[arr[i]]=i; } return ans; }

Compilation message (stderr)

messy.cpp: In function 'void funk2(int, int, std::vector<int>)':
messy.cpp:48:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for(int i=0;i<s.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...