結果

問題 No.30 たこやき工場
ユーザー hogeover30hogeover30
提出日時 2015-02-26 03:05:09
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 876 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 51,100 KB
最終ジャッジ日時 2024-04-27 02:06:50
合計ジャッジ時間 765 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:7:1: error: ‘vector’ does not name a type
    7 | vector<int> from[110], to[110];
      | ^~~~~~
main.cpp:8:1: error: ‘vector’ does not name a type
    8 | vector<ll> memo[110];
      | ^~~~~~
main.cpp:10:1: error: ‘vector’ does not name a type
   10 | vector<ll> func(int k, int n)
      | ^~~~~~
main.cpp: In function ‘int main()’:
main.cpp:32:32: error: ‘from’ was not declared in this scope
   32 |         for(int i=0;i<n;++i) { from[i].clear(); to[i].clear(); memo[i].clear(); }
      |                                ^~~~
main.cpp:32:49: error: ‘to’ was not declared in this scope; did you mean ‘tm’?
   32 |         for(int i=0;i<n;++i) { from[i].clear(); to[i].clear(); memo[i].clear(); }
      |                                                 ^~
      |                                                 tm
main.cpp:32:64: error: ‘memo’ was not declared in this scope
   32 |         for(int i=0;i<n;++i) { from[i].clear(); to[i].clear(); memo[i].clear(); }
      |                                                                ^~~~
main.cpp:36:13: error: ‘from’ was not declared in this scope
   36 |             from[b].push_back(a);
      |             ^~~~
main.cpp:37:13: error: ‘to’ was not declared in this scope; did you mean ‘tm’?
   37 |             to[a].push_back(b);
      |             ^~
      |             tm
main.cpp:39:18: error: ‘func’ was not declared in this scope
   39 |         auto res=func(n-1, n);
      |                  ^~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

ll cost[110][110];
vector<int> from[110], to[110];
vector<ll> memo[110];

vector<ll> func(int k, int n)
{
    if (memo[k].size())
        return memo[k];

    vector<ll> res(n);
    if (from[k].empty()) {
        res[k]=1;
        return res;
    }
    for(int v: from[k]) {
        auto t=func(v, n);
        for(int i=0;i<n;++i)
            res[i]+=cost[v][k]*t[i];
    }
    return memo[k]=res;
}

int main()
{
    int n, m;
    while (cin>>n>>m) {
        for(int i=0;i<n;++i) { from[i].clear(); to[i].clear(); memo[i].clear(); }
        while (m--) {
            int a, c, b; cin>>a>>c>>b;
            cost[--a][--b]=c;
            from[b].push_back(a);
            to[a].push_back(b);
        }
        auto res=func(n-1, n);
        for(int i=0;i<n-1;++i) cout<<res[i]<<endl;
    }
}
0