제출 #405133

#제출 시각아이디문제언어결과실행 시간메모리
405133MDarioUnscrambling a Messy Bug (IOI16_messy)C++11
100 / 100
3 ms460 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #include "messy.h" vector<int> v; void fw(ll lf, ll rf, ll n){ if(rf-lf+1<=2)return; string s, s1; for(int i=0; i<n; i++){ s.push_back('0'); s1.push_back('0'); } for(int i=lf; i<=(lf+rf)/2; i++){ s[i]='1'; } for(int i=(lf+rf)/2+1; i<=rf; i++){ s1[i]='1'; } for(int i=lf; i<=(lf+(lf+rf)/2)/2; i++){ s1[i]='1'; add_element(s1); s1[i]='0'; } for(int i=(lf+rf)/2+1; i<=((lf+rf)/2+1+rf)/2; i++){ s[i]='1'; add_element(s); s[i]='0'; } fw(lf, (lf+rf)/2, n); fw((lf+rf)/2+1, rf, n); return ; } void fr(vector<int>v1, vector<int> v2, ll lf, ll rf, ll n){ if(rf-lf+1==2){ v[v1[0]]=lf; v[v2[0]]=rf; return; } string s, s1; for(int i=0; i<n; i++){ s.push_back('0'); s1.push_back('0'); } for(int i=0; i<v1.size(); i++){ s[v1[i]]='1'; } for(int i=0; i<v2.size(); i++){ s1[v2[i]]='1'; } vector<int> v3, v4; for(int i=0; i<v2.size(); i++){ s[v2[i]]='1'; if(check_element(s))v3.push_back(v2[i]); else v4.push_back(v2[i]); s[v2[i]]='0'; } fr(v3, v4, (lf+rf)/2+1, rf, n); v3.clear(); v4.clear(); for(int i=0; i<v1.size(); i++){ s1[v1[i]]='1'; if(check_element(s1))v3.push_back(v1[i]); else v4.push_back(v1[i]); s1[v1[i]]='0'; } fr(v3, v4, lf, (lf+rf)/2, n); return ; } vector<int> restore_permutation(int n, int w, int r) { string s; for(int i=0; i<n; i++){ s.push_back('0'); v.push_back(0); } for(int i=0; i<n/2; i++){ s[i]='1'; add_element(s); s[i]='0'; } fw(0, n-1, n); compile_set(); vector<int> v1, v2; for(int i=0; i<n; i++){ s[i]='1'; if(check_element(s))v1.push_back(i); else v2.push_back(i); s[i]='0'; } fr(v1, v2, 0, n-1, n); return v; }

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

messy.cpp: In function 'void fr(std::vector<int>, std::vector<int>, ll, ll, ll)':
messy.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for(int i=0; i<v1.size(); i++){
      |                  ~^~~~~~~~~~
messy.cpp:49:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0; i<v2.size(); i++){
      |                  ~^~~~~~~~~~
messy.cpp:53:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for(int i=0; i<v2.size(); i++){
      |                  ~^~~~~~~~~~
messy.cpp:62:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   62 |     for(int i=0; i<v1.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...