結果
| 問題 |
No.30 たこやき工場
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2014-09-25 23:32:35 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 910 bytes |
| コンパイル時間 | 719 ms |
| コンパイル使用メモリ | 66,944 KB |
| 実行使用メモリ | 10,016 KB |
| 最終ジャッジ日時 | 2024-12-30 03:16:23 |
| 合計ジャッジ時間 | 7,690 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 TLE * 1 |
ソースコード
#include <cstdlib>
#include <iostream>
#include <vector>
#include <set>
using namespace std;
const int MAXN = 100;
typedef unsigned long long ull;
int N,M;
int matrix[MAXN][MAXN];
ull item[MAXN];
set<int> s;
void dfs(int i, ull n){
if(s.count(i)){ cout << "矛盾しています。" << endl; exit(1); }
s.insert(i);
//cout << "i = " << i << ", n = " << n << endl;
bool f = false;
for(int j = 0; j < N; j++){
if(matrix[i][j] > 0){
dfs(j, n * matrix[i][j]);
f = true;
}
}
if(!f){
item[i] += n;
}
s.erase(i);
}
int main(){
cin >> N >> M;
for(int i = 0; i < M; i++){
int P,Q,R;
cin >> P >> Q >> R;
if(matrix[R-1][P-1]){ cout << "不正データ" << endl; exit(1); }
matrix[R-1][P-1] = Q;
}
dfs(N-1, 1);
for(int i = 0; i < N-1; i++){
cout << item[i] << endl;
}
}