結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
omochana1
|
| 提出日時 | 2014-12-03 01:12:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,585 bytes |
| コンパイル時間 | 768 ms |
| コンパイル使用メモリ | 91,428 KB |
| 実行使用メモリ | 9,812 KB |
| 最終ジャッジ日時 | 2024-06-11 07:56:36 |
| 合計ジャッジ時間 | 7,267 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 TLE * 1 -- * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:65:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
65 | scanf("%d%d", &N, &M);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:68:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
68 | scanf("%d%d%d", &from, &cost, &to);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <string.h>
#include <map>
#include <fstream>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <set>
#include <climits>
#define MAX_N 510
#define PI 3.141592653589
#define ESP 1e-20
#define BS 10
#define MOD 1000000007
#define ZERO 10001
#define YJSNPI 810
#define INF (1LL << 50)
#define ADD(a, b) a = (a + (ll)b) % MOD
#define MUL(a, b) a = (a * (ll)b) % MOD
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
struct edge {
int to, cost;
edge(int to, int cost) :
to(to), cost(cost) {}
};
int N, M;
vector<edge> E[110];
vector<edge> rE[110];
int ans[110];
vector<int> vs;
void dfs(int v) {
bool ok = false;
for(int i = 0; i < rE[v].size(); i++) {
dfs(rE[v][i].to); ok = true;
}
if(!ok) vs.push_back(v);
}
int loop(int v) {
if(v == N - 1) return 1;
int res = 0;
for(int i = 0; i < E[v].size(); i++) {
res += loop(E[v][i].to) * E[v][i].cost;
}
return res;
}
int main() {
scanf("%d%d", &N, &M);
for(int i = 0; i < M; i++) {
int from, cost, to;
scanf("%d%d%d", &from, &cost, &to);
from--; to--;
E[from].push_back(edge(to, cost));
rE[to].push_back(edge(from, cost));
}
dfs(N - 1);
for(int i = 0; i < vs.size(); i++) {
ans[vs[i]] = loop(vs[i]);
}
for(int i = 0; i < N - 1; i++) {
printf("%d\n", ans[i]);
}
}
omochana1