제출 #867745

#제출 시각UTC-0아이디문제언어결과실행 시간메모리
8677452023-10-29 12:07:53goodspeed0208Group Photo (JOI21_ho_t3)C++14
12 / 100
1866 ms123556 KiB
#include<iostream>
#include<vector>
#include<algorithm>
#define INF 1000000000
using namespace std;
int main() {
int n;
cin >> n;
vector<int>v(n);
for (auto &i : v) cin >> i;
vector<vector<int> >dp((1 << n), vector<int>(n, INF));
vector<int>back(n, 0);
for (int i = n-2 ; i >= 0 ; i--) {
back[i] = back[i+1] | (1 << (i+1));
//cout << back[i] << " ";
}
//cout << "\n";
int cost = 1;
for (int i = 0 ; i < n ; i++) dp[1 << i][i] = i;
for (int i = 1 ; i < (1 << n) ; i++) {
int t = __builtin_popcount(i);
for (int j = 0 ; j < n ; j++) {
for (int k = 0 ; k < n ; k++) {
if ( ((i >> k) & 1)==0 && (v[j] < v[k] + 2) ) {
int cost = k - t + __builtin_popcount(i & back[k]);
//cout << k << " " << t << " " << __builtin_popcount(i & back[k]) << "\n";
dp[i | (1 << k) ][k] = min(dp[i | (1 << k)][k], dp[i][j] + cost);
}
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

Main.cpp: In function 'int main()':
Main.cpp:19:6: warning: unused variable 'cost' [-Wunused-variable]
   19 |  int cost = 1;
      |      ^~~~
#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...