제출 #428478

#제출 시각아이디문제언어결과실행 시간메모리
428478tqbfjotldCheerleaders (info1cup20_cheerleaders)C++14
25 / 100
2057 ms7376 KiB
#include <bits/stdc++.h> using namespace std; int arr[(1<<17)+5]; vector<int> f1(vector<int> v){ vector<int> nw; for (int x = 0; x<v.size(); x+=2){ nw.push_back(v[x]); } for (int x = 1; x<v.size(); x+=2){ nw.push_back(v[x]); } return nw; } vector<long long> allvals(vector<int> things){ if (things.size()==1){ return {0}; } long long inter1 = 0,inter2 = 0; vector<int> l,r; for (int x = 0; x<things.size(); x++){ if (x<things.size()/2) l.push_back(things[x]); else r.push_back(things[x]); } vector<long long> r1 = allvals(l); vector<long long> r2 = allvals(r); vector<long long> ans; sort(l.begin(),l.end()); sort(r.begin(),r.end()); long long c1 = 0; for (auto x : r){ while (c1<l.size() && l[c1]<x) c1++; inter2 += c1; } inter1 = ((long long)l.size()*(long long)(l.size()))-inter2; // printf("inter = %lld %lld\n",inter1,inter2); for (int x = 0; x<l.size(); x++){ ans.push_back(r1[x]+r2[x]+inter1); } for (int x = 0; x<l.size(); x++){ ans.push_back(r1[x]+r2[x]+inter2); } return ans; } int n,logn; int main(){ scanf("%d",&n); logn = n; n = 1<<n; vector<int> t; for(int x = 0; x<n; x++){ scanf("%d",&arr[x]); t.push_back(arr[x]); } long long ans = 999999999999999999LL; for (int x = 0; x<logn; x++){ auto res = allvals(t); for (auto x : res){ ans = min(ans,x); //printf("%lld \n",x); } t = f1(t); } printf("%lld\n",ans); }

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

cheerleaders.cpp: In function 'std::vector<int> f1(std::vector<int>)':
cheerleaders.cpp:8:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int x = 0; x<v.size(); x+=2){
      |                     ~^~~~~~~~~
cheerleaders.cpp:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (int x = 1; x<v.size(); x+=2){
      |                     ~^~~~~~~~~
cheerleaders.cpp: In function 'std::vector<long long int> allvals(std::vector<int>)':
cheerleaders.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int x = 0; x<things.size(); x++){
      |                     ~^~~~~~~~~~~~~~
cheerleaders.cpp:24:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         if (x<things.size()/2) l.push_back(things[x]);
      |             ~^~~~~~~~~~~~~~~~
cheerleaders.cpp:34:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         while (c1<l.size() && l[c1]<x) c1++;
      |                ~~^~~~~~~~~
cheerleaders.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int x = 0; x<l.size(); x++){
      |                     ~^~~~~~~~~
cheerleaders.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for (int x = 0; x<l.size(); x++){
      |                     ~^~~~~~~~~
cheerleaders.cpp: In function 'int main()':
cheerleaders.cpp:51:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   51 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
cheerleaders.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |         scanf("%d",&arr[x]);
      |         ~~~~~^~~~~~~~~~~~~~
#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...