結果

問題 No.30 たこやき工場
ユーザー なおなお
提出日時 2014-09-25 23:32:35
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 910 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 67,968 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-28 18:32:05
合計ジャッジ時間 7,142 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
    }
}
0