Submission #66457


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <algorithm>
#include <iomanip>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <sstream>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <numeric>
#include <vector>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i, n) _rep2(i, 0, n)
#define _rep2(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using i64 = long long;
template<class T, class U>
bool chmin(T& a, const U& b) { return (b < a) ? (a = b, true) : false; }
template<class T, class U>
bool chmax(T& a, const U& b) { return (b > a) ? (a = b, true) : false; }
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(vector<T>&v){stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v){if(v.size())o<<join(v);return o;}
template<typename T>string join(vector<vector<T>>&vv){string s="\n";rep(i,vv.size())s+=join(vv[i])+"\n";return s;}
template<typename T>ostream& operator<<(ostream&o,vector<vector<T>>&vv){if(vv.size())o<<join(vv);return o;}
template<class T> using pq = priority_queue<T, vector<T>, greater<T>>;
int n;
i64 t;
vector edge(100010, vector<int>{});
vector<i64> C(100010);
vector<i64> P(100010);
i64 ans = 0;
void dfs(int u, int p, i64 num, i64 sum)
{
num = num * 10 + C[u];
if(num%t == 0) sum += P[u];
ans += sum;
for(auto v : edge[u])
{
if(v == p) continue;
dfs(v, u, num, sum);
}
}
int main()
{
cin >> n >> t;
rep(i, n - 1)
{
int u, v;
cin >> u >> v;
u--;
v--;
edge[u].push_back(v);
edge[v].push_back(u);
}
rep(i, n) cin >> C[i] >> P[i];
dfs(0, -1, 0, 0);
cout << ans << endl;
return 0;
}

ステータス

項目 データ
問題 1497 - Walkin' on Numbered Tree
ユーザー名 gunmaneko
投稿日時 2021-05-04 23:19:25
言語 C++11
状態 Compile Error
得点 0
ソースコード長 2327 Byte
最大実行時間 -
最大メモリ使用量

コンパイルメッセージ

./Main.cpp:47:1: error: invalid use of template-name ‘std::vector’ without an argument list
 vector edge(100010, vector<int>{});
 ^~~~~~
./Main.cpp:47:1: note: class template argument deduction is only available with -std=c++17 or -std=gnu++17
In file included from /usr/local/gcc-8.2.0/include/c++/8.2.0/vector:64,
                 from /usr/local/gcc-8.2.0/include/c++/8.2.0/queue:61,
                 from ./Main.cpp:13:
/usr/local/gcc-8.2.0/include/c++/8.2.0/bits/stl_vector.h:339:11: note: ‘template<class _Tp, class _Alloc> class std::vector’ declared here
     class vector : protected _Vector_base<_Tp, _Alloc>
           ^~~~~~
./Main.cpp:47:34: error: expected unqualified-id before ‘)’ token
 vector edge(100010, vector<int>{});
                                  ^
./Main.cpp: In function ‘void dfs(int, int, i64, i64)’:
./Main.cpp:56:18: error: ‘edge’ was not declared in this scope
     for(auto v : edge[u])
                  ^~~~
./Main.cpp: In function ‘int main()’:
./Main.cpp:73:9: error: ‘edge’ was not declared in this scope
         edge[u].push_back(v);
         ^~~~

セット

セット 得点 Cases

テストケース

ファイル名 状態 実行時間 メモリ使用量 #