結果

問題 No.3312 Fire Engine
コンテスト
ユーザー GOTKAKO
提出日時 2025-10-24 22:14:47
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 733 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,031 ms
コンパイル使用メモリ 201,432 KB
最終ジャッジ日時 2026-07-15 23:20:53
合計ジャッジ時間 1,938 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:76,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/algorithm:62,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/x86_64-pc-linux-gnu/bits/stdc++.h:53,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit: In instantiation of 'constexpr int std::__popcount(_Tp) [with _Tp = int]':
main.cpp:19:48:   required from here
   19 |             cost += D.at(l).at(k)*(N-__popcount(i-(1<<k)));
      |                                      ~~~~~~~~~~^~~~~~~~~~
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bit:308:34: error: argument 1 in call to function '__builtin_popcountg' has signed type
  308 |       return __builtin_popcountg(__x);
      |                                  ^~~

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
 
    int N; cin >> N;
    vector<vector<int>> D(N,vector<int>(N));
    for(auto &h : D) for(auto &w : h) cin >> w;

    int n2 = 1<<N;
    vector<vector<int>> dp(n2,vector<int>(N,1001001001));
    dp.at(1).at(0) = 0;
    for(int i=2; i<n2; i++) for(int k=0; k<N; k++) if(i&(1<<k)){
        for(int l=0; l<N; l++) if(i&(1<<k)){
            if(k == l) continue;
            int cost = dp.at(i-(1<<k)).at(l);
            cost += D.at(l).at(k)*(N-__popcount(i-(1<<k)));
            dp.at(i).at(k) = min(dp.at(i).at(k),cost);
        }
    }

    cout << *min_element(dp.at(n2-1).begin(),dp.at(n2-1).end()) << endl;
}
0