제출 #846093

#제출 시각아이디문제언어결과실행 시간메모리
846093jamkel19Cheerleaders (info1cup20_cheerleaders)C++14
84 / 100
2052 ms76036 KiB
#include <bits/stdc++.h> using namespace std; #define st first #define nd second typedef long long ll; ll n; ll k; void liczenie(vector<ll>a,ll q,vector<ll>&x,vector<ll>&y) { if(q==-1) { return; } ll jeden=0, zero=0,ifnie=0,iftak=0; vector<ll>b; vector<ll>c; for(ll i=0;i<a.size();i++) { if(a[i]&(1<<q)) { jeden++; iftak+=zero; b.push_back(a[i]); } else { zero++; ifnie+=jeden; c.push_back(a[i]); } } x[q]+=ifnie; y[q]+=iftak; liczenie(b,q-1,x,y);liczenie(c,q-1,x,y); } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin>>k; n=pow(2,k); if(k==0) { cout<<0<<endl; cout<<"2222"<<endl;; } vector<ll>a(n); for(ll i=0;i<n;i++) { ll w; cin>>w; a[w]=i; } ll wynik=9999999999999; ll wy; ll wynik2; for(ll i=0;i<k;i++) { vector<ll>x(k); vector<ll>y(k); liczenie(a,k-1,x,y); ll r=0,u=0; for(ll j=0;j<k;j++) { if(x[j]>y[j]) { r+=(1<<j); } u+=min(x[j],y[j]); } if(u<wynik) { wynik2=i; wy=r; wynik=u; } for(ll j=0;j<n;j++) { ll e=a[j]%2; a[j]/=2; a[j]+=(e<<(k-1)); } } cout<<wynik<<endl; //cout<<wy<<endl; for(ll i=0;i<wynik2;i++) { cout<<2; } if((1<<(k-1))&wy) { cout<<1; } cout<<2; for(ll i=0;i<k-1;i++) { if(wy&(1<<i)) { cout<<1; } cout<<2; } cout<<endl; }

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

cheerleaders.cpp: In function 'void liczenie(std::vector<long long int>, ll, std::vector<long long int>&, std::vector<long long int>&)':
cheerleaders.cpp:18:17: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for(ll i=0;i<a.size();i++)
      |                ~^~~~~~~~~
cheerleaders.cpp: In function 'int main()':
cheerleaders.cpp:86:17: warning: 'wynik2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   86 |     for(ll i=0;i<wynik2;i++)
      |                ~^~~~~~~
cheerleaders.cpp:90:18: warning: 'wy' may be used uninitialized in this function [-Wmaybe-uninitialized]
   90 |     if((1<<(k-1))&wy)
      |        ~~~~~~~~~~^~~
#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...