結果

問題 No.1 道のショートカット
ユーザー hogeover30hogeover30
提出日時 2015-02-01 03:27:14
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 930 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 51,460 KB
最終ジャッジ日時 2023-09-27 21:37:35
合計ジャッジ時間 1,023 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:5:1: error: ‘vector’ does not name a type; did you mean ‘perror’?
 vector<unsigned> Cost[51][51], Time[51][51];
 ^~~~~~
 perror
main.cpp: In function ‘void dfs(int, unsigned int, unsigned int)’:
main.cpp:12:43: error: ‘Cost’ was not declared in this scope
     for(int i=p+1;i<=N;++i) for(int j=0;j<Cost[p][i].size();++j)
                                           ^~~~
main.cpp:13:35: error: ‘Time’ was not declared in this scope
         dfs(i, m+Cost[p][i][j], t+Time[p][i][j]);
                                   ^~~~
main.cpp:13:35: note: suggested alternative: ‘time’
         dfs(i, m+Cost[p][i][j], t+Time[p][i][j]);
                                   ^~~~
                                   time
main.cpp: In function ‘int main()’:
main.cpp:20:13: error: ‘Cost’ was not declared in this scope
             Cost[i][j].clear();
             ^~~~
main.cpp:21:13: error: ‘Time’ was not declared in this scope
             Time[i][j].clear();
             ^~~~
main.cpp:21:13: note: suggested alternative: ‘time’
             Time[i][j].clear();
             ^~~~
             time
main.cpp:23:9: error: ‘vector’ was not declared in this scope
         vector<int> s(V), t(V), y(V), m(V);
         ^~~~~~
main.cpp:23:9: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:4:1:
+#include <vector>
 using namespace std;
main.cpp:23:9:
         vector<int> s(V), t(V), y(V), m(V);
         ^~~~~~
main.cpp:23:16: error: expected primary-expression before ‘int’
         vector<int> s(V), t(V), y(V), m(V);
                ^~~
main.cpp:24:21: error: ‘s’ was not declared in this scope
         for(int& x: s) cin>>x;
                     ^
main.cpp:25:21: error: ‘t’ was not declared in this scope
         for(int& x: t) cin>>x;
                     ^
main.cpp:26:21: error: ‘y’ was not declared in this scope
         for(int& x: y) cin>>x;
                     ^
main

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
vector<unsigned> Cost[51][51], Time[51][51];
int N, C, V;
unsigned res;
void dfs(int p, unsigned m, unsigned t)
{
    if (m>C or t>res) return;
    if (p==N) res=t;
    for(int i=p+1;i<=N;++i) for(int j=0;j<Cost[p][i].size();++j)
        dfs(i, m+Cost[p][i][j], t+Time[p][i][j]);
}

int main()
{
    while (cin>>N>>C>>V) {
        for(int i=1;i<=N;++i) for(int j=1;j<=N;++j) {
            Cost[i][j].clear();
            Time[i][j].clear();
        }
        vector<int> s(V), t(V), y(V), m(V);
        for(int& x: s) cin>>x;
        for(int& x: t) cin>>x;
        for(int& x: y) cin>>x;
        for(int& x: m) cin>>x;
        for(int i=0;i<V;++i) {
            int a=s[i], b=t[i];
            Cost[a][b].push_back(y[i]);
            Time[a][b].push_back(m[i]);
        }
        res=-1u;
        dfs(1, 0, 0);
        cout<<(int)res<<endl;
    }
}
0