제출 #218820

#제출 시각아이디문제언어결과실행 시간메모리
218820Lawliet"The Lyuboyn" code (IZhO19_lyuboyn)C++14
20 / 100
96 ms3312 KiB
#include <bits/stdc++.h> using namespace std; int n, k, t; void printBinary(int k) { for(int i = n - 1 ; i >= 0 ; i--) { if( k & (1 << i) ) printf("1"); else printf("0"); } printf("\n"); } bool isGood(int a, int b, int v) { int aux = a^b; return ( __builtin_popcount(aux) == v ); } int main() { string s; cin >> n >> k >> t >> s; vector< int > ans; ans.push_back( 0 ); ans.push_back( 1 ); for(int i = 2 ; i <= 4 ; i++) { int curSz = ans.size(); for(int j = 0 ; j < ans.size() ; j++) ans[j] = 2*ans[j]; for(int j = curSz - 1 ; j >= 0 ; j--) ans.push_back( ans[j] + 1 ); } for(int i = 1 ; i < ans.size() ; i += 2) ans[i] = 15 - ans[i]; for(int i = 5 ; i <= n ; i++) { int curSz = ans.size(); int indFirst = -1; //printf("................ i = %d\n",i); for(int j = 1 ; j < ans.size() && indFirst == -1 ; j++) { if( !isGood( ans[j] , ans.back() , k - 1 ) ) continue; if( !isGood( ans[j - 1] , ans[0] , k - 1 ) ) continue; indFirst = j; } assert( indFirst != -1 ); for(int j = 0 ; j < ans.size() ; j++) ans[j] = 2*ans[j]; int lim = indFirst - 1; if( lim == -1 ) lim = curSz - 1; for(int j = indFirst ; j != lim ; j++, j %= curSz) ans.push_back( ans[j] + 1 ); ans.push_back( ans[lim] + 1 );//printf("\n\n\n"); } /*for(int i = 1 ; i < ans.size() ; i++) assert( __builtin_popcount( ans[i - 1]^ans[i] ) == k ), printf("i = %d\n",i);*/ printf("%d\n",(int) ans.size()); for(int i = 0 ; i < ans.size() ; i++) printBinary( ans[i] ); }

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

lyuboyn.cpp: In function 'int main()':
lyuboyn.cpp:38:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < ans.size() ; j++)
                   ~~^~~~~~~~~~~~
lyuboyn.cpp:45:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 1 ; i < ans.size() ; i += 2)
                  ~~^~~~~~~~~~~~
lyuboyn.cpp:56:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 1 ; j < ans.size() && indFirst == -1 ; j++)
                   ~~^~~~~~~~~~~~
lyuboyn.cpp:66:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0 ; j < ans.size() ; j++)
                   ~~^~~~~~~~~~~~
lyuboyn.cpp:83:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < ans.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...