제출 #514790

#제출 시각아이디문제언어결과실행 시간메모리
514790Theo830Cheerleaders (info1cup20_cheerleaders)C++17
13 / 100
2084 ms40876 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e9+7; const ll MOD = 998244353; typedef pair<ll,ll> ii; #define iii pair<ii,ll> #define f(i,a,b) for(ll i = a;i < b;i++) #define pb push_back #define vll vector<ll> #define F first #define S second #define all(x) (x).begin(), (x).end() ///I hope I will get uprating and don't make mistakes ///I will never stop programming ///sqrt(-1) Love C++ ///Please don't hack me ///@TheofanisOrfanou Theo830 ///Think different approaches (bs,dp,greedy,graphs,shortest paths,mst) ///Stay Calm ///Look for special cases ///Beware of overflow and array bounds ///Think the problem backwards ///Training ll n; vll arr; ll c(vll a){ ll ans = 0; f(i,0,a.size()){ f(j,i+1,a.size()){ ans += a[i] > a[j]; } } return ans; } vll ena(vll a){ vll ans; ll m = a.size() / 2; f(i,m,a.size()){ ans.pb(a[i]); } f(i,0,m){ ans.pb(a[i]); } return ans; } vll dio(vll a){ vll ans; f(i,0,a.size()){ ans.pb(a[i]); i++; } f(i,1,a.size()){ ans.pb(a[i]); i++; } return ans; } int main(void){ ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; n = (1LL<<n); f(i,0,n){ ll a; cin>>a; arr.pb(a); } map<vll,bool>v; queue<vll>q; q.push(arr); v[arr] = 1; ll ans = 1e18; while(!q.empty()){ vll f = q.front(); q.pop(); ans = min(ans,c(f)); vll A = ena(f); if(!v[A]){ v[A] = 1; q.push(A); } A = dio(f); if(!v[A]){ v[A] = 1; q.push(A); } } cout<<ans<<"\n"; }

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

cheerleaders.cpp: In function 'll c(std::vector<long long int>)':
cheerleaders.cpp:8:33: 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]
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
......
   29 |     f(i,0,a.size()){
      |       ~~~~~~~~~~~~               
cheerleaders.cpp:29:5: note: in expansion of macro 'f'
   29 |     f(i,0,a.size()){
      |     ^
cheerleaders.cpp:8:33: 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]
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
......
   30 |         f(j,i+1,a.size()){
      |           ~~~~~~~~~~~~~~         
cheerleaders.cpp:30:9: note: in expansion of macro 'f'
   30 |         f(j,i+1,a.size()){
      |         ^
cheerleaders.cpp: In function 'std::vector<long long int> ena(std::vector<long long int>)':
cheerleaders.cpp:8:33: 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]
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
......
   39 |     f(i,m,a.size()){
      |       ~~~~~~~~~~~~               
cheerleaders.cpp:39:5: note: in expansion of macro 'f'
   39 |     f(i,m,a.size()){
      |     ^
cheerleaders.cpp: In function 'std::vector<long long int> dio(std::vector<long long int>)':
cheerleaders.cpp:8:33: 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]
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
......
   49 |     f(i,0,a.size()){
      |       ~~~~~~~~~~~~               
cheerleaders.cpp:49:5: note: in expansion of macro 'f'
   49 |     f(i,0,a.size()){
      |     ^
cheerleaders.cpp:8:33: 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]
    8 | #define f(i,a,b) for(ll i = a;i < b;i++)
......
   53 |     f(i,1,a.size()){
      |       ~~~~~~~~~~~~               
cheerleaders.cpp:53:5: note: in expansion of macro 'f'
   53 |     f(i,1,a.size()){
      |     ^
#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...