Submission #97768

#TimeUsernameProblemLanguageResultExecution timeMemory
97768KLPPBinary Subsequences (info1cup17_binary)C++14
82 / 100
922 ms384 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lld; typedef pair<lld,lld> pii; int main(){ int T; scanf("%d",&T); while(T--){ int K; scanf("%d",&K); lld ans1=0; lld ans2=1000000000; vector<int> v; //cout<<-1<<endl; pii best; for(int t=0;t*2<K;t++){ lld can=0; vector<int> seq; pii p=pii(t,K-t); while(p.first!=0 || p.second!=0){ //cout<<p.first<<" "<<p.second<<endl; if(p.first>p.second){ can+=p.first/(p.second+1); p.first%=(p.second+1); } else{ if(p.first<p.second){ can+=p.second/(p.first+1); p.second%=(p.first+1); } else{ can=-1; break; } } }//cout<<t<<" "<<K-t<<" "<<can<<endl; if(can!=-1)ans1++; if(can<ans2 && can!=-1){ best=pii(t,K-t); ans2=can; } } printf("%d\n",ans1*2); pii p=best; //cout<<best.first<<" "<<best.second<<endl; while(p.first!=0 || p.second!=0){ //cout<<p.first<<" "<<p.second<<endl; if(p.first>p.second){ p.first-=p.second+1; v.push_back(0); } else{ if(p.first<p.second){v.push_back(1); p.second-=p.first+1; } else{ break; } } } for(int i=0;i<v.size();i++)printf("%d ",v[i]); printf("\n"); } return 0; }

Compilation message (stderr)

binary.cpp: In function 'int main()':
binary.cpp:48:23: warning: format '%d' expects argument of type 'int', but argument 2 has type 'lld {aka long long int}' [-Wformat=]
   printf("%d\n",ans1*2);
                 ~~~~~~^
binary.cpp:69:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<v.size();i++)printf("%d ",v[i]);
               ~^~~~~~~~~
binary.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&T);
  ~~~~~^~~~~~~~~
binary.cpp:13:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&K);
   ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...