結果

問題 No.30 たこやき工場
ユーザー motxxmotxx
提出日時 2014-09-26 01:49:49
言語 C++11
(gcc 11.4.0)
結果
MLE  
実行時間 -
コード長 902 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 150,828 KB
実行使用メモリ 812,952 KB
最終ジャッジ日時 2023-08-28 19:49:57
合計ジャッジ時間 3,913 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 6 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 MLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

#define INF (1<<29)

struct Edge
{
  int dst;
  int cost;
  Edge(int d, int c) : dst(d), cost(c) {}
};

vector<Edge> G[110];

typedef pair<int, int> Pii;

int N, M;
int ans[110];
void get(int st)
{
  queue<int> q1, q2;
  q1.push(st);
  q2.push(1);
  while(!q1.empty()) {
    int pos = q1.front(); q1.pop();
    int cost = q2.front(); q2.pop();
    ans[pos] += cost;
    rep(i, G[pos].size()) {
      q1.push(G[pos][i].dst);
      q2.push(G[pos][i].cost*cost);
    }
  }
}

int main() {
  
  cin >> N >> M;
  
  bool isntLast[110] = {};
  rep(i, M) {
    int p, q, r;
    cin >> p >> q >> r; p --, r --;
    G[r].push_back(Edge(p, q));
    isntLast[r] = 1;
  }

  get(N-1);
  
  rep(i, N-1) {
    if(isntLast[i]) cout << 0 << endl;
    else printf("%d\n", ans[i]);
  }
  
  return 0;
}
0