제출 #288919

#제출 시각아이디문제언어결과실행 시간메모리
288919phillipArranging Shoes (IOI19_shoes)C++14
30 / 100
98 ms61556 KiB
#include "shoes.h" #include <bits/stdc++.h> #define ll long long #define fast cin.tie(0);cout.tie(0); #define order ios::sync_with_stdio(0);ios_base::sync_with_stdio(0); #define pb push_back using namespace std; vector<int>v; int n,dp[100009]; int bt(int x,vector<int>cur,int st=0) { if(dp[x]!=-1)return dp[x]; if(x==(1<<n)-1){return 0;} dp[x]=1e9; for(int i=0;i<n;i++) { if((1<<i)&x)continue; vector<int>con=cur; int c=0; for(int j=st*2;j<2*n;j++) { if(con[j]*(-1)==v[i]) { while(j>st*2) { c++; swap(con[j],con[j-1]); j--; } break; } } for(int j=st*2;j<2*n;j++) { if(con[j]==v[i]) { while(j>st*2+1) { c++; swap(con[j],con[j-1]); j--; } break; } } dp[x]=min(dp[x],bt(x+(1<<i),con,st+1)+c); } return dp[x]; } long long count_swaps(vector<int> s) { n=s.size()/2; memset(dp,-1,sizeof(dp)); if(n<=8) { for(int i=0;i<n*2;i++) { if(s[i]<0)continue; v.push_back(s[i]); } return bt(0,s); } }

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

shoes.cpp: In function 'long long int count_swaps(std::vector<int>)':
shoes.cpp:62:1: warning: control reaches end of non-void function [-Wreturn-type]
   62 | }
      | ^
#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...