submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s887393464 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < (n); i++)
int main() {
ll n;cin>>n;
vector<ll> a(n-1),b(n-1),c(n-1);
rep(i,n-1) cin>>a[i]>>b[i]>>c[i],a[i]--,b[i]--;
ll q,k;cin>>q>>k;k--;
vector<ll> x(q),y(q);
vector<ll> g[n];
rep(i,n-1){
g[a[i]].push_back(b[i]);
g[b[i]].push_back(a[i]);
}
vector<ll> to_k(n,-1);
ll value[10000000000][100000000000];
rep(i,n-1) value[a[i]][b[i]]=value[b[i]][a[i]]=c[i];
rep(i,n) value[i][i]=0;
queue<ll> que;
que.push(k);
to_k[k]=0;
while(!que.empty()){
auto tmp=que.front();
que.pop();
for(auto c:g[tmp]){
if(to_k[c]==-1){
to_k[c]=to_k[tmp]+value[tmp][c];
que.push(c);
}
}
}
rep(i,q){
ll x,y;cin>>x>>y;x--;y--;
cout<<to_k[x]+to_k[y]<<endl;
}
} | a.cc: In function 'int main()':
a.cc:17:6: error: size of array 'value' exceeds maximum object size '9223372036854775807'
17 | ll value[10000000000][100000000000];
| ^~~~~
a.cc:18:14: error: 'value' was not declared in this scope
18 | rep(i,n-1) value[a[i]][b[i]]=value[b[i]][a[i]]=c[i];
| ^~~~~
a.cc:19:12: error: 'value' was not declared in this scope
19 | rep(i,n) value[i][i]=0;
| ^~~~~
a.cc:28:27: error: 'value' was not declared in this scope
28 | to_k[c]=to_k[tmp]+value[tmp][c];
| ^~~~~
|
s755751690 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define limit 100002
struct edge2{
int to;
int cost;
}edge;
void dfs(int v,int p,ll dist)
{
depth[v]=dist;
for(auto x:arr[v])
{
if(x.to==p)
{
continue;
}
else
{
dfs(x.to,v,dist+x.cost);
}
}
}
int main()
{
vector<edge> arr[limit];
ll depth[limit];
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
int a,b,c;
cin>>a>>b>>c;
a--;b--;
arr[a].push_back({b,c});
arr[b].push_back({a,c});
}
int q,k;
cin>>q>>k;
dfs(k,-1,0);
for(int i=0;i<q;i++)
{
int x,y;
x--,y--;
cout<<depth[x]+depth[y]<<endl;
}
}
| a.cc: In function 'void dfs(int, int, long long int)':
a.cc:12:3: error: 'depth' was not declared in this scope
12 | depth[v]=dist;
| ^~~~~
a.cc:14:14: error: 'arr' was not declared in this scope
14 | for(auto x:arr[v])
| ^~~
a.cc: In function 'int main()':
a.cc:30:14: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
30 | vector<edge> arr[limit];
| ^
a.cc:30:14: note: expected a type, got 'edge'
a.cc:30:14: error: template argument 2 is invalid
a.cc:42:12: error: request for member 'push_back' in 'arr[a]', which is of non-class type 'int'
42 | arr[a].push_back({b,c});
| ^~~~~~~~~
a.cc:43:12: error: request for member 'push_back' in 'arr[b]', which is of non-class type 'int'
43 | arr[b].push_back({a,c});
| ^~~~~~~~~
|
s240188262 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define limit 100002
struct edge2{
int to;
int cost;
}edge;
void dfs(int v,int p,ll dist)
{
depth[v]=dist;
for(auto x:arr[v])
{
if(x.to==p)
{
continue;
}
else
{
dfs(x.to,v,dist+x.cost);
}
}
}
int main()
{
vector<edge> arr[limit];
ll depth[limit];
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
int a,bc;
cin>>a>>b>>c;
a--;b--;
arr[a].push_back({b,c});
arr[b].push_back({a,c});
}
int q,k;
cin>>q>>k;
dfs(k,-1,0);
for(int i=0;i<q;i++)
{
int x,y;
x--,y--;
cout<<depth[x]+depth[y]<<endl;
}
}
| a.cc:9:22: error: 'll' has not been declared
9 | void dfs(int v,int p,ll dist)
| ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:11:3: error: 'depth' was not declared in this scope
11 | depth[v]=dist;
| ^~~~~
a.cc:13:14: error: 'arr' was not declared in this scope
13 | for(auto x:arr[v])
| ^~~
a.cc: In function 'int main()':
a.cc:29:14: error: type/value mismatch at argument 1 in template parameter list for 'template<class _Tp, class _Alloc> class std::vector'
29 | vector<edge> arr[limit];
| ^
a.cc:29:14: note: expected a type, got 'edge'
a.cc:29:14: error: template argument 2 is invalid
a.cc:30:3: error: 'll' was not declared in this scope
30 | ll depth[limit];
| ^~
a.cc:38:13: error: 'b' was not declared in this scope; did you mean 'bc'?
38 | cin>>a>>b>>c;
| ^
| bc
a.cc:38:16: error: 'c' was not declared in this scope; did you mean 'bc'?
38 | cin>>a>>b>>c;
| ^
| bc
a.cc:41:12: error: request for member 'push_back' in 'arr[a]', which is of non-class type 'int'
41 | arr[a].push_back({b,c});
| ^~~~~~~~~
a.cc:54:11: error: 'depth' was not declared in this scope
54 | cout<<depth[x]+depth[y]<<endl;
| ^~~~~
|
s602615029 | p03634 | C++ | #include<bits/stdc++.h>
using maespace std;
#define limit 100002
struct edge{
int to;
int cost;4
}
void dfs(int v,int p,ll dist)
{
depth[v]=dist;
for(auto x:arr[v])
{
if(x.to==p)
{
continue;
}
else
{
dfs(x.to,v,dist+x.cost);
}
}
}
int main()
{
vector<edge> arr[limit];
ll depth[limit];
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
int a,bc;
cin>>a>>b>>c;
a--;b--;
arr[a].push_back({b,c});
arr[b].push_back({a,c});
}
int q,k;
cin>>q>>k;
dfs(k,-1,0);
for(int i=0;i<q;i++)
{
int x,y;
x--,y--;
cout<<depth[x]+depth[y]<<endl;
}
} | a.cc:2:7: error: expected nested-name-specifier before 'maespace'
2 | using maespace std;
| ^~~~~~~~
a.cc:6:18: error: expected unqualified-id before numeric constant
6 | int cost;4
| ^
a.cc:7:2: error: expected ';' after struct definition
7 | }
| ^
| ;
a.cc:8:22: error: 'll' has not been declared
8 | void dfs(int v,int p,ll dist)
| ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:10:3: error: 'depth' was not declared in this scope
10 | depth[v]=dist;
| ^~~~~
a.cc:12:14: error: 'arr' was not declared in this scope
12 | for(auto x:arr[v])
| ^~~
a.cc: In function 'int main()':
a.cc:28:3: error: 'vector' was not declared in this scope
28 | vector<edge> arr[limit];
| ^~~~~~
a.cc:28:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:28:14: error: expected primary-expression before '>' token
28 | vector<edge> arr[limit];
| ^
a.cc:28:16: error: 'arr' was not declared in this scope
28 | vector<edge> arr[limit];
| ^~~
a.cc:29:3: error: 'll' was not declared in this scope
29 | ll depth[limit];
| ^~
a.cc:31:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
31 | cin>>n;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:37:13: error: 'b' was not declared in this scope; did you mean 'bc'?
37 | cin>>a>>b>>c;
| ^
| bc
a.cc:37:16: error: 'c' was not declared in this scope; did you mean 'bc'?
37 | cin>>a>>b>>c;
| ^
| bc
a.cc:53:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
53 | cout<<depth[x]+depth[y]<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:53:11: error: 'depth' was not declared in this scope
53 | cout<<depth[x]+depth[y]<<endl;
| ^~~~~
a.cc:53:30: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
53 | cout<<depth[x]+depth[y]<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s924338139 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
vector<pair<int,int>> gra;
ll dist[10050];
void dfs(ll x,ll y){
for(const auto& it:gra[x]){
ll s=it.first,len=it.second;
if(dist[s])continue;
dist[s]=y+len;
dfs(s,dist[s]);
}
}
int main(){
int n,q,k;cin >> n;
gra.resize(n-1);
rep(i,n-1){
int a,b,c;cin >> a>>b>>c;
a--;b--;
gra[a].pb(b,c);
gra[b].pb(a,c);
}
cin >> q>>k;
k--;
dfs(k,0);
rep(i,q){
int x,y;cin >> x>>y;x--;y--;
ll ans=dist[x]+dist[y];
cout << ans << endl;
}
}
| a.cc: In function 'void dfs(ll, ll)':
a.cc:11:27: error: no matching function for call to 'begin(std::pair<int, int>&)'
11 | for(const auto& it:gra[x]){
| ^
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
from /usr/include/c++/14/bits/stl_algo.h:59,
from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/initializer_list:88:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(initializer_list<_Tp>)'
88 | begin(initializer_list<_Tp> __ils) noexcept
| ^~~~~
/usr/include/c++/14/initializer_list:88:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: 'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
11 | for(const auto& it:gra[x]){
| ^
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:52:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
52 | begin(_Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/14/bits/range_access.h:52:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&) [with _Container = std::pair<int, int>]':
a.cc:11:27: required from here
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/bits/range_access.h:52:50: error: 'struct std::pair<int, int>' has no member named 'begin'
52 | begin(_Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/14/bits/range_access.h:63:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
63 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ^~~~~
/usr/include/c++/14/bits/range_access.h:63:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&) [with _Container = std::pair<int, int>]':
a.cc:11:27: required from here
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/bits/range_access.h:63:56: error: 'const struct std::pair<int, int>' has no member named 'begin'
63 | begin(const _Container& __cont) -> decltype(__cont.begin())
| ~~~~~~~^~~~~
/usr/include/c++/14/bits/range_access.h:95:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
95 | begin(_Tp (&__arr)[_Nm]) noexcept
| ^~~~~
/usr/include/c++/14/bits/range_access.h:95:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
11 | for(const auto& it:gra[x]){
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/valarray:1227:5: note: candidate: 'template<class _Tp> _Tp* std::begin(valarray<_Tp>&)'
1227 | begin(valarray<_Tp>& __va) noexcept
| ^~~~~
/usr/include/c++/14/valarray:1227:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: 'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/valarray:1238:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const valarray<_Tp>&)'
1238 | begin(const valarray<_Tp>& __va) noexcept
| ^~~~~
/usr/include/c++/14/valarray:1238:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: 'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
11 | for(const auto& it:gra[x]){
| ^
a.cc:11:27: error: no matching function for call to 'end(std::pair<int, int>&)'
/usr/include/c++/14/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: 'std::pair<int, int>' is not derived from 'std::initializer_list<_Tp>'
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&) [with _Container = std::pair<int, int>]':
a.cc:11:27: required from here
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/bits/range_access.h:74:48: error: 'struct std::pair<int, int>' has no member named 'end'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/range_access.h: In substitution of 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&) [with _Container = std::pair<int, int>]':
a.cc:11:27: required from here
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/bits/range_access.h:85:54: error: 'const struct std::pair<int, int>' has no member named 'end'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ~~~~~~~^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: mismatched types '_Tp [_Nm]' and 'std::pair<int, int>'
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: 'std::pair<int, int>' is not derived from 'std::valarray<_Tp>'
11 | for(const auto& it:gra[x]){
| ^
/usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1265:5: note: template argument deduction/substitution failed:
a.cc:11:27: note: 'std::pair<int, int>' is not derived from 'const std::valarray<_Tp>'
11 | for(const auto& it:gra[x]){
| ^
a.cc:14:15: error: 'len' was not declared in this scope
14 | dist[s]=y+len;
| ^~~
a.cc: In function 'int main()':
a.cc:25:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'pb'
25 | gra[a].pb(b,c);
| ^~
a.cc:26:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'pb'
26 | gra[b].pb(a,c);
| ^~
|
s678220293 | p03634 | C++ | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct edge {
long long int to;
long long int cost;
};
long long int d[100010];
long long int n;
typedef pair<long long int, long long int> P;
long long int V, d[100010];
vector<edge> G[100010];
void dijkstra(int s) {
fill(d, d + V, 10000000009);
d[s] = 0;
priority_queue<P, vector<P>, greater<P>> que;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
int v = p.second;
if (d[v] < p.first) {
continue;
}
for (auto e : G[v]) {
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
int main(){
long long int a[100010],b[100010],c[100010],q,k,x[100010],y[100010];
cin >>n;
for(int i=0;i<n;i++){
cin >> a[i] >> b[i] >> c[i];
a[i]--,b[i]--;
}
G[a[i]].push_back(edge{b[i],c[i]});
G[b[i]].push_back(edge{a[i],c[i]});
cin >> q >> k;
k--;
dijkstra(k);
for(int i=0;i<q;i++){
cin >> x[i] >> y[i];
x[i]--,y[i]--;
}
for(int i=0;i<q;i++){
cout << d[x[i]]+d[y[i]] << endl;
}
}
| a.cc:18:18: error: redefinition of 'long long int d [100010]'
18 | long long int V, d[100010];
| ^
a.cc:13:15: note: 'long long int d [100010]' previously declared here
13 | long long int d[100010];
| ^
a.cc: In function 'int main()':
a.cc:53:8: error: 'i' was not declared in this scope
53 | G[a[i]].push_back(edge{b[i],c[i]});
| ^
|
s228616851 | p03634 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
ll gcd(ll a, ll b){
if(b==0)return a;
return gcd(b, a%b);
}
ll lcm(ll a, ll b){
return a /gcd(a, b) * b;
}
struct edge {
int to; ll cost;
};
vector<edge> tree[114514];
ll depth[114514];
int q, k, x,y;
void dfs(int v, int p, ll d){
depth[v] = d;
for(auto &e : tree[v]){
if(e.to == p) continue;
dfs(e.to, v, d + e.cost);
}
}
int main(){
cin >> n;
rep(i, n-1) {
int a,b,c;
scanf("%d %d %d", &a, &b, &c);
a--; b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
cin >> q >> k;
k--;
dfs(k, -1,0);
rep(i, q) {
scanf("%d %d", &x, &y);
x--;y--;
cout << depth[x] + depth[y] << endl;
}
} | a.cc: In function 'int main()':
a.cc:46:16: error: 'n' was not declared in this scope; did you mean 'yn'?
46 | cin >> n;
| ^
| yn
|
s944367644 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(),(a).end()
#define Pi P<int,int>
#define elif else if
int low(V<int> a,int b){
decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b);
int d=c-a.bgn;
return d;
}
int upp(V<int> a,int b){
decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b);
int d=c-a.bgn;
return d;
}
template<class T>
void cou(vector<vector<T>> a){
int b=a.size();
int c=a[0].size();
fo(i,b){
fo(j,c){
cout<<a[i][j];
if(j==c-1)
cout<<endl;
else
cout<<' ';
}
}
}
int wari(int a,int b) {
if(a%b==0)
return a/b;
else
return a/b+1;
}
int keta(int a){
double b=a;
b=log10(b);
int c=b;
return c+1;
}
int souwa(int a){
return a*(a+1)/2;
}
int gcm(int a,int b){
if(a%b==0)
return b;
return gcm(b,a%b);
}
bool prime(int a){
if(a<2)
return false;
else if(a==2)
return true;
else if(a%2==0)
return false;
double b=sqrt(a);
for(int i=3;i<=b;i+=2){
if(a%i==0){
return false;
}
}
return true;
}
struct Union{
vector<int> par;
Union(int a){
par=vector<int>(a,-1);
}
int find(int a){
if(par[a]<0)
return a;
else
return par[a]=find(par[a]);
}
bool same(int a,int b){
return find(a)==find(b);
}
int Size(int a){
return -par[find(a)];
}
void unite(int a,int b){
a=find(a);
b=find(b);
if(a==b)
return;
if(Size(b)>Size(a))
swap<int>(a,b);
par[a]+=par[b];
par[b]=a;
}
};
int ketas(int a){
string b=to_string(a);
int c=0;
fo(i,keta(a)){
c+=b[i]-'0';
}
return c;
}
int lcm(int a,int b){
return a/gcm(a,b)*b;
}
bool fe(int a,int b){
a%=10;
b%=10;
if(a==0)
a=10;
if(b==0)
b=10;
if(a>b)
return true;
else
return false;
}
int INF=1000000007;
struct edge{int s,t,d; };
V<int> mojisyu(string a){
V<int> b(26,0);
fo(i,a.sz){
b[a[i]-'a']++;
}
return b;
}
int wa2(int a){
if(a%2==1)
return a/2;
return a/2-1;
}
/*signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}
?*/
int nCr(int n,int r){
int a=1;
r=min(r,n-r);
for(int i=n;i>n-r;i--){
a*=i;
a/=n-i+1;
}
return a;
}
/*void sea(int x,int y){
if(x<0||a<=x||y<0||b<=y||c[x][y]=='#')
return;
if(d[x][y])
return;
d[x][y]++;
sea(x+1,y);
sea(x-1,y);
sea(x,y+1);
sea(x,y-1);
}*/
int kaijou(int a){
int b=1;
fo(i,a)
b*=i+1;
return b;
}
int nPr(int a,int b){
int c=1;
for(int i=a;i>=b;i--)
c*=i;
return c;
}
int MOD=INF;
int fac[1000010], finv[1000010], inv[1000010];
// テーブルを作る前処理
//先にCOMinit()で前処理をする
//ABC145D
void COMinit() {
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for(int i=2;i<1000010;i++){
fac[i]=fac[i-1]*i%MOD;
inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
finv[i]=finv[i-1]*inv[i]%MOD;
}
}
// 二項係数計算
int COM(int n,int k){
if(n<k)
return 0;
if(n<0||k<0)
return 0;
return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
bool naka(int a,int b,V<V<char>> c){
return (a>=0&&b>=0&&a<c.sz&&b<c[0].sz);
}
V<P<int,int>> mawari4={{0,-1},{0,1},{1,0},{-1,0}};
V<P<int,int>> mawari8={{0,-1},{0,1},{1,0},{-1,0},{-1,-1},{1,1},{1,-1},{-1,-1}};
// 最短距離の表:c
// スタート:sx,sy
// ゴール:gx,gy
/*int bfs(V<V<char>> a){
Q<P<int,int>> b;
fo(i,a.sz){
fo(j,a[0].sz){
c[i][j]==INF;
}
}
b.push({sx,sy});
c[sx][sy]=0;
while(b.sz){
P d=b.front();
b.pop();
if(d=={gx,gy})
break;
fo(i,4){
int e=d.fi+mawari4[i],f=d.se+mawari4[i];
if(naka(e,f,a)&&a[e][f]=='.'&&c[e][f]==INF){
b.push({e,f});
c[e][f]==c[d.fi][d.se]+1;
}
}
}
return c[gx][gy];
}*/
signed main(){
int a;
cin>>a;
V<V<edge>> b(a);
fo(i,a){
edge c;
cin>>c.s>>c.t>>c.d;
b[c.s].pb(c);
}
int c,d;
cin>>c>>d;
V<P<int,int>> e(c);
fo(i,a){
cin>>e[c].fi>>e[c].se;
}
V<int> z(a,INF);
PriP f;
f.push({0,d});
while(!f.empty()){
P<int,int> g=f.top();
f.pop();
int h=g.se,m=g.fi;
fo(i,d[h].sz){
edge n=d[h][i];
if(z[n.t]>m+n.d){
z[n.t]=m+n.d;
f.push({m+n.d,n.t});
}
}
}
fo(i,c){
cout<<z[e[i].fi-1]+z[e[i].se-1]<<endl;
}
} | a.cc: In function 'int main()':
a.cc:301:11: error: invalid types 'long long int[long long int]' for array subscript
301 | fo(i,d[h].sz){
| ^
a.cc:5:31: note: in definition of macro 'fo'
5 | #define fo(a,b) for(int a=0;a<b;a++)
| ^
a.cc:302:15: error: invalid types 'long long int[long long int]' for array subscript
302 | edge n=d[h][i];
| ^
|
s892373111 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb push_back
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
#define Q queue
#define pri priority_queue
#define Pri priority_queue<int,vector<int>,greater<int>>
#define PriP priority_queue<P<int,int>,vector<P<int,int>>,greater<P<int,int>>>
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define all(a) (a).begin(),(a).end()
#define Pi P<int,int>
#define elif else if
int low(V<int> a,int b){
decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b);
int d=c-a.bgn;
return d;
}
int upp(V<int> a,int b){
decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b);
int d=c-a.bgn;
return d;
}
template<class T>
void cou(vector<vector<T>> a){
int b=a.size();
int c=a[0].size();
fo(i,b){
fo(j,c){
cout<<a[i][j];
if(j==c-1)
cout<<endl;
else
cout<<' ';
}
}
}
int wari(int a,int b) {
if(a%b==0)
return a/b;
else
return a/b+1;
}
int keta(int a){
double b=a;
b=log10(b);
int c=b;
return c+1;
}
int souwa(int a){
return a*(a+1)/2;
}
int gcm(int a,int b){
if(a%b==0)
return b;
return gcm(b,a%b);
}
bool prime(int a){
if(a<2)
return false;
else if(a==2)
return true;
else if(a%2==0)
return false;
double b=sqrt(a);
for(int i=3;i<=b;i+=2){
if(a%i==0){
return false;
}
}
return true;
}
struct Union{
vector<int> par;
Union(int a){
par=vector<int>(a,-1);
}
int find(int a){
if(par[a]<0)
return a;
else
return par[a]=find(par[a]);
}
bool same(int a,int b){
return find(a)==find(b);
}
int Size(int a){
return -par[find(a)];
}
void unite(int a,int b){
a=find(a);
b=find(b);
if(a==b)
return;
if(Size(b)>Size(a))
swap<int>(a,b);
par[a]+=par[b];
par[b]=a;
}
};
int ketas(int a){
string b=to_string(a);
int c=0;
fo(i,keta(a)){
c+=b[i]-'0';
}
return c;
}
int lcm(int a,int b){
return a/gcm(a,b)*b;
}
bool fe(int a,int b){
a%=10;
b%=10;
if(a==0)
a=10;
if(b==0)
b=10;
if(a>b)
return true;
else
return false;
}
int INF=1000000007;
struct edge{int s,t,d; };
V<int> mojisyu(string a){
V<int> b(26,0);
fo(i,a.sz){
b[a[i]-'a']++;
}
return b;
}
int wa2(int a){
if(a%2==1)
return a/2;
return a/2-1;
}
/*signed main(){
int a,b,c;
cin>>a>>b>>c;
V<V<edge>> d(a);
fo(i,b){
edge e;
cin>>e.s>>e.t>>e.d;
d[e.s].pb(e);
}
V<int> e(a,INF);
e[c]=0;
priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f;
f.push({0,c});
int h=INF;
while(!f.empty()){
P<int,int> g;
g=f.top();
f.pop();
int v = g.second, i = g.first;
for(edge l : d[v]){
if(e[l.t] > i + l.d){
e[l.t] = i + l.d;
f.push({i+l.d , l.t});
}
}
}
fo(i,a){
if(e[i]==INF)
cout<<"INF"<<endl;
else
cout<<e[i]<<endl;
}
}
?*/
int nCr(int n,int r){
int a=1;
r=min(r,n-r);
for(int i=n;i>n-r;i--){
a*=i;
a/=n-i+1;
}
return a;
}
/*void sea(int x,int y){
if(x<0||a<=x||y<0||b<=y||c[x][y]=='#')
return;
if(d[x][y])
return;
d[x][y]++;
sea(x+1,y);
sea(x-1,y);
sea(x,y+1);
sea(x,y-1);
}*/
int kaijou(int a){
int b=1;
fo(i,a)
b*=i+1;
return b;
}
int nPr(int a,int b){
int c=1;
for(int i=a;i>=b;i--)
c*=i;
return c;
}
int MOD=INF;
int fac[1000010], finv[1000010], inv[1000010];
// テーブルを作る前処理
//先にCOMinit()で前処理をする
//ABC145D
void COMinit() {
fac[0]=fac[1]=1;
finv[0]=finv[1]=1;
inv[1]=1;
for(int i=2;i<1000010;i++){
fac[i]=fac[i-1]*i%MOD;
inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
finv[i]=finv[i-1]*inv[i]%MOD;
}
}
// 二項係数計算
int COM(int n,int k){
if(n<k)
return 0;
if(n<0||k<0)
return 0;
return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
bool naka(int a,int b,V<V<char>> c){
return (a>=0&&b>=0&&a<c.sz&&b<c[0].sz);
}
V<P<int,int>> mawari4={{0,-1},{0,1},{1,0},{-1,0}};
V<P<int,int>> mawari8={{0,-1},{0,1},{1,0},{-1,0},{-1,-1},{1,1},{1,-1},{-1,-1}};
// 最短距離の表:c
// スタート:sx,sy
// ゴール:gx,gy
int bfs(V<V<char>> a){
Q<P<int,int>> b;
fo(i,a.sz){
fo(j,a[0].sz){
c[i][j]==INF;
}
}
b.push({sx,sy});
c[sx][sy]=0;
while(b.sz){
P d=b.front();
b.pop();
if(d=={gx,gy})
break;
fo(i,4){
int e=d.fi+mawari4[i],f=d.se+mawari4[i];
if(naka(e,f,a)&&a[e][f]=='.'&&c[e][f]==INF){
b.push({e,f});
c[e][f]==c[d.fi][d.se]+1;
}
}
}
return c[gx][gy];
}
signed main(){
int a;
cin>>a;
V<V<edge>> b(a);
fo(i,a){
edge c;
cin>>c.s>>c.t>>c.d;
b[c.s].pb(c);
}
int c,d;
cin>>c>>d;
V<P<int,int>> e(c);
fo(i,a){
cin>>e[c].fi>>e[c].se;
}
V<int> z(a,INF);
PriP f;
f.push({0,d});
while(!f.empty()){
P<int,int> g=f.top();
f.pop();
int h=g.se,m=g.fi;
fo(i,d[h].sz){
edge n=d[h][i];
if(z[n.t]>m+n.d){
z[n.t]=m+n.d;
f.push({m+n.d,n.t});
}
}
}
fo(i,c){
cout<<z[e[i].fi-1]+z[e[i].se-1]<<endl;
}
} | a.cc: In function 'long long int bfs(std::vector<std::vector<char> >)':
a.cc:259:7: error: 'c' was not declared in this scope
259 | c[i][j]==INF;
| ^
a.cc:262:11: error: 'sx' was not declared in this scope; did you mean 'sf'?
262 | b.push({sx,sy});
| ^~
| sf
a.cc:262:14: error: 'sy' was not declared in this scope; did you mean 'sf'?
262 | b.push({sx,sy});
| ^~
| sf
a.cc:262:9: error: no matching function for call to 'std::queue<std::pair<long long int, long long int> >::push(<brace-enclosed initializer list>)'
262 | b.push({sx,sy});
| ~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157,
from a.cc:1:
/usr/include/c++/14/bits/stl_queue.h:283:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
283 | push(const value_type& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:283:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::queue<std::pair<long long int, long long int> >::value_type&' {aka 'const std::pair<long long int, long long int>&'}
283 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:288:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; value_type = std::pair<long long int, long long int>]'
288 | push(value_type&& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:288:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
288 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc:263:3: error: 'c' was not declared in this scope
263 | c[sx][sy]=0;
| ^
a.cc:267:11: error: expected primary-expression before '{' token
267 | if(d=={gx,gy})
| ^
a.cc:267:11: error: expected ')' before '{' token
267 | if(d=={gx,gy})
| ~ ^
| )
a.cc:270:17: error: no match for 'operator+' (operand types are 'long long int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
1798 | operator+(typename move_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::move_iterator<_IteratorL>'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
In file included from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3616 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: mismatched types 'const _CharT*' and 'long long int'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed:
a.cc:270:27: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'long long int'
270 | int e=d.fi+mawari4[i],f=d.se+mawari4[i];
| ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3696 | operator+(basic_string<_CharT, _T |
s858096195 | p03634 | C++ | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }
const int limit =100010;
using edge =struct {int to, ll cost;};
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v,int p,ll d){
depth[v]=d;
for(auto &e:tree[v]){
if(e.to==p) continue;
dfs(e.to,v,d+e.cost);
}
}
int main()
{
int n;
cin>>n;
REP(i,n-1)
{
int a,b,c;
cin>>a>>b>>c;
a--,b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
int q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
REP(i,q)
{
int x,y;
cin>>x>>y;
x--,y--;
cout<<depth[x]+depth[y]<<endl;
}
return 0;
}
| a.cc:38:29: error: expected ';' at end of member declaration
38 | using edge =struct {int to, ll cost;};
| ^~
| ;
a.cc:38:32: error: 'cost' does not name a type; did you mean 'const'?
38 | using edge =struct {int to, ll cost;};
| ^~~~
| const
a.cc: In function 'void dfs(int, int, ll)':
a.cc:46:20: error: 'struct<unnamed>' has no member named 'cost'
46 | dfs(e.to,v,d+e.cost);
| ^~~~
|
s870566933 | p03634 | C | #include <stdio.h>
#define N 100000
int oo[1 + (N - 1) * 2], oj[1 + (N - 1) * 2], oc[1 + (N - 1) * 2];
int link(int o, int j, int c) {
static int _ = 1;
oo[_] = o, oj[_] = j, oc[_] = c;
return _++;
}
int ae[N];
void dfs(int p, int i, int d) {
int o;
for (o = ae[i]; o; o = oo[o]) {
int j;
j = oj[o];
if (j != p)
dfs(i, j);
}
}
int main() {
int n, h, i, j, c;
scanf("%d", &n);
for (h = 0; h < n - 1; h++) {
scanf("%d%d%d", &i, &j, &c), i--, j--;
ae[i] = link(ae[i], j, c);
ae[j] = link(ae[j], i, c);
}
dfs(-1, 0, 0);
for (i = 0; i < n; i++) {
int o;
printf("%d:", i + 1);
for (o = ae[i]; o; o = oo[o])
printf(" %d", oj[o] + 1);
printf("\n");
}
/*
dfs(-1, 0);
*/
return 0;
} | main.c: In function 'dfs':
main.c:24:25: error: too few arguments to function 'dfs'
24 | dfs(i, j);
| ^~~
main.c:16:6: note: declared here
16 | void dfs(int p, int i, int d) {
| ^~~
|
s676401560 | p03634 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
final Scanner scanner = new Scanner(System.in);
solve(scanner);
}
static void solve(Scanner scanner) {
int N = Integer.parseInt(scanner.nextLine());
List<List<Edge>> edges = new ArrayList<>();
for (int i = 0; i < N; i++) {
edges.add(new ArrayList<>());
}
for (int i = 0; i < N - 1; i++) {
int[] e = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
edges.get(e[0] - 1).add(new Edge(e[1] - 1, e[2]));
edges.get(e[1] - 1).add(new Edge(e[0] - 1, e[2]));
}
String[] qv = scanner.nextLine().split(" ");
int Q = Integer.parseInt(qv[0]);
int via = Integer.parseInt(qv[1]) - 1;
dist = new long[N];
es = edges;
getDist(via, 0, new HashSet<>());
for (int i = 0; i < Q; i++) {
int[] q = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
int from = q[0] - 1;
int to = q[1] - 1;
System.out.println(dist[from] + dist[to]);
}
}
static long[] dist;
static List<List<Edge>> es;
static Set<Integer> used = new HashSet<>();
static void getDist(int s, long cost) {
used.add(s);
dist[s] = cost;
for (Edge next : es.get(s)) {
if (!used.contains(next.to)) {
getDist(next.to, cost + (long) next.cost);
}
}
}
static class Edge {
int to;
int cost;
public Edge(int to, int cost) {
this.to = to;
this.cost = cost;
}
}
} | Main.java:26: error: method getDist in class Main cannot be applied to given types;
getDist(via, 0, new HashSet<>());
^
required: int,long
found: int,int,HashSet<Object>
reason: actual and formal argument lists differ in length
1 error
|
s821523586 | p03634 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> P;
const ll INF = 1001001001001001;
ll d[100000];
ll dist[100000][100000];
vector<vector<int>> to(100000);
void dfs(int v,int p,ll di){
d[v]=di;
for(auto u:to[v]){
if(u==p) continue;
dfs(u,v,di+dist[u][v]);
}
}
int main(){
int n;
cin >> n;
rep(i,n) d[i]=INF;
rep(i,n)rep(j,n) dist[i][j]=0;
rep(i,n-1){
int a,b;
ll c;
cin >> a >> b >> c;
a--; b--;
dist[a][b]=c;
dist[b][a]=c;
to[a].push_back(b);
to[b].push_back(a);
}
int q,k;
cin >> q >> k;
k--;
dfs(k,-1,0);
rep(i,q){
int x,y;
cin >> x >> y;
x--; y--;
cout << d[x]+d[y] << endl;
}
return 0;
}
| /tmp/ccoQtAiY.o: in function `dfs(int, int, long long)':
a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
/tmp/ccoQtAiY.o: in function `main':
a.cc:(.text+0x254): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
/tmp/ccoQtAiY.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3c9): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
a.cc:(.text+0x3ef): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccoQtAiY.o
collect2: error: ld returned 1 exit status
|
s866139909 | p03634 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<ll,ll> P;
const ll INF = 1001001001001001;
ll d[100100];
ll dist[100100][100100];
vector<vector<int>> to(100100);
void dfs(int v,int a,ll di){
d[v]=di;
for(auto u:to[v]){
if(a==u) continue;
dfs(u,v,di+dist[u][v]);
}
}
int main(){
int n;
cin >> n;
rep(i,n) d[i]=INF;
rep(i,n)rep(j,n) dist[i][j]=0;
rep(i,n-1){
int a,b;
ll c;
cin >> a >> b >> c;
a--; b--;
dist[a][b]=c;
dist[b][a]=c;
to[a].push_back(b);
to[b].push_back(a);
}
int q,k;
cin >> q >> k;
k--;
dfs(k,-1,0);
rep(i,q){
int x,y;
cin >> x >> y;
x--; y--;
ll ans = d[x]+d[y];
cout << ans << endl;
}
return 0;
}
| /tmp/ccG4dcvX.o: in function `dfs(int, int, long long)':
a.cc:(.text+0x39): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
/tmp/ccG4dcvX.o: in function `main':
a.cc:(.text+0x254): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
/tmp/ccG4dcvX.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x3d1): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
a.cc:(.text+0x3f7): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/ccG4dcvX.o
collect2: error: ld returned 1 exit status
|
s890976015 | p03634 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=1;i<=n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<ll,int> P;
const ll INF = 1001001001001;
int n;
ll d[100100];
ll dist[100100][100100];
vector<vector<int>> to(100100);
//単一始点最短路問題
void dijkstra(int s){
priority_queue<P,vector<P>,greater<P>> pq;
//pair(distance,vertex) to[vertex]を全探索
rep(i,n) d[i]=INF;
d[s]=0;
pq.push(P(0,s));
while(!pq.empty()){
P p = pq.top();
pq.pop();
ll c = p.se;
if(d[c]<p.fi) continue; //無駄
for(auto u:to[c]){
if(d[u]>d[c]+dist[c][u]){
d[u]=d[c]+dist[c][u];
pq.push(P(d[u],u));
}
}
}
}
int main(){
cin >> n;
rep(i,n-1){
int a,b;
ll c;
cin >> a >> b >> c;
a--; b--;
dist[a][b]=c;
dist[b][a]=c;
to[a].push_back(b);
to[b].push_back(a);
}
int q,k;
cin >> q >> k;
k--;
//k始点での各頂点への最短距離
dijkstra(k);
rep(i,q){
int x,y;
cin >> x >> y;
x--; y--;
ll ans = d[x]+d[y];
cout << ans << endl;
}
}
| /tmp/cc7valJn.o: in function `dijkstra(int)':
a.cc:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
/tmp/cc7valJn.o: in function `main':
a.cc:(.text+0x3cb): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
a.cc:(.text+0x3f4): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
/tmp/cc7valJn.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x541): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
a.cc:(.text+0x567): relocation truncated to fit: R_X86_64_PC32 against symbol `to' defined in .bss section in /tmp/cc7valJn.o
collect2: error: ld returned 1 exit status
|
s302930205 | p03634 | C++ | package contest;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
Integer N = Integer.parseInt(sc.next());
Node v[] = new Node[N];
int c[] = new int[N-1];
for(int i=0;i<N;i++){
v[i] = new Node(i);
}
Edge e[] = new Edge[N-1];
for(int i=0;i<N-1;i++) {
e[i] = new Edge(v[Integer.parseInt(sc.next())-1],v[Integer.parseInt(sc.next())-1],Integer.parseInt(sc.next()));
}
int Q = Integer.parseInt(sc.next());
int K = Integer.parseInt(sc.next());
int x[] = new int[Q];
int y[] = new int[Q];
for(int i=0;i<Q;i++) {
x[i] = Integer.parseInt(sc.next());
y[i] = Integer.parseInt(sc.next());
}
PriorityQueue<Node> searching = new PriorityQueue<>((u,w)->u.d>w.d?1:u.d<w.d?-1:0);
PriorityQueue<Node> searched = new PriorityQueue<>((u,w)->u.d>w.d?1:u.d<w.d?-1:0);
boolean used[] = new boolean[N];
Arrays.fill(used, false);
v[K-1].Reload_dist(0);
used[K-1] = true;
for(Edge connect:v[K-1].edges) {
Node another = connect.Other_one(v[K-1]);
another.Reload_dist(connect.cost);
searching.add(another);
used[another.id] = true;
}
searched.add(v[K-1]);
Node vertex=null;
while(searching.size()>0) {
vertex = searching.poll();
for(Edge connect:vertex.edges) {
Node another = connect.Other_one(vertex);
if(!used[another.id]) {
another.Reload_dist(vertex.d + connect.cost);
if(!searched.contains(another)){
searching.add(another);
}
searched.add(vertex);
used[another.id] = true;
}
}
}
long result = 0;
for(int i=0;i<Q;i++) {
result = v[x[i]-1].d + v[y[i]-1].d;
out.println(result);
}
out.flush();
}
}
class Node{
int id;
long d;
Node prev = null;
ArrayList<Edge> edges = new ArrayList<>();
public Node(int id) {
this.id = id;
this.d = Integer.MAX_VALUE;
}
public void Reset() {
this.d = Integer.MAX_VALUE;
this.prev = null;
}
public void Reload_dist(long dist) {
this.d = dist;
}
//
// public void Reload_prev(Node v) {
// this.prev = v;
// }
// @Override public Node clone() {
// return new Node(this.id);
// }
public void Connect(Edge e) {
edges.add(e);
}
}
class Edge{
Node v1, v2;
int cost;
public Edge(Node id1,Node id2, int c) {
this.v1 = id1;
this.v2 = id2;
this.cost = c;
v1.Connect(this);
v2.Connect(this);
}
// public Node First_one() {
// return this.v1;
// }
// public Node Second_one() {
// return this.v2;
// }
public Node Other_one(Node v) {
if(v.equals(this.v1)) {
return this.v2;
}
else {
return this.v1;
}
}
}
| a.cc:1:1: error: 'package' does not name a type
1 | package contest;
| ^~~~~~~
a.cc:3:1: error: 'import' does not name a type
3 | import java.io.PrintWriter;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.ArrayList;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Arrays;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.util.Comparator;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.util.PriorityQueue;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
8 | import java.util.Scanner;
| ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:10:1: error: expected unqualified-id before 'public'
10 | public class Main {
| ^~~~~~
a.cc:78:14: error: field 'prev' has incomplete type 'Node'
78 | Node prev = null;
| ^~~~
a.cc:75:7: note: definition of 'class Node' is not complete until the closing brace
75 | class Node{
| ^~~~
a.cc:79:9: error: 'ArrayList' does not name a type
79 | ArrayList<Edge> edges = new ArrayList<>();
| ^~~~~~~~~
a.cc:81:15: error: expected ':' before 'Node'
81 | public Node(int id) {
| ^~~~~
| :
a.cc:86:15: error: expected ':' before 'void'
86 | public void Reset() {
| ^~~~~
| :
a.cc:91:15: error: expected ':' before 'void'
91 | public void Reload_dist(long dist) {
| ^~~~~
| :
a.cc:103:15: error: expected ':' before 'void'
103 | public void Connect(Edge e) {
| ^~~~~
| :
a.cc:103:29: error: 'Edge' has not been declared
103 | public void Connect(Edge e) {
| ^~~~
a.cc:106:2: error: expected ';' after class definition
106 | }
| ^
| ;
a.cc: In constructor 'Node::Node(int)':
a.cc:82:22: error: request for member 'id' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
82 | this.id = id;
| ^~
a.cc:83:22: error: request for member 'd' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
83 | this.d = Integer.MAX_VALUE;
| ^
a.cc:83:26: error: 'Integer' was not declared in this scope
83 | this.d = Integer.MAX_VALUE;
| ^~~~~~~
a.cc: In member function 'void Node::Reset()':
a.cc:87:22: error: request for member 'd' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
87 | this.d = Integer.MAX_VALUE;
| ^
a.cc:87:26: error: 'Integer' was not declared in this scope
87 | this.d = Integer.MAX_VALUE;
| ^~~~~~~
a.cc:88:22: error: request for member 'prev' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
88 | this.prev = null;
| ^~~~
a.cc:88:29: error: 'null' was not declared in this scope
88 | this.prev = null;
| ^~~~
a.cc: In member function 'void Node::Reload_dist(long int)':
a.cc:92:22: error: request for member 'd' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?)
92 | this.d = dist;
| ^
a.cc: In member function 'void Node::Connect(int)':
a.cc:104:17: error: 'edges' was not declared in this scope
104 | edges.add(e);
| ^~~~~
a.cc: At global scope:
a.cc:111:15: error: expected ':' before 'Edge'
111 | public Edge(Node id1,Node id2, int c) {
| ^~~~~
| :
a.cc:127:15: error: expected ':' before 'Node'
127 | public Node Other_one(Node v) {
| ^~~~~
| :
a.cc:135:2: error: expected ';' after class definition
135 | }
| ^
| ;
a.cc: In constructor 'Edge::Edge(Node, Node, int)':
a.cc:111:47: error: no matching function for call to 'Node::Node()'
111 | public Edge(Node id1,Node id2, int c) {
| ^
a.cc:81:16: note: candidate: 'Node::Node(int)'
81 | public Node(int id) {
| ^~~~
a.cc:81:16: note: candidate expects 1 argument, 0 provided
a.cc:75:7: note: candidate: 'constexpr Node::Node(const Node&)'
75 | class Node{
| ^~~~
a.cc:75:7: note: candidate expects 1 argument, 0 provided
a.cc:75:7: note: candidate: 'constexpr Node::Node(Node&&)'
a.cc:75:7: note: candidate expects 1 argument, 0 provided
a.cc:111:47: error: no matching function for call to 'Node::Node()'
111 | public Edge(Node id1,Node id2, int c) {
| ^
a.cc:81:16: note: candidate: 'Node::Node(int)'
81 | public Node(int id) {
| ^~~~
a.cc:81:16: note: candidate expects 1 argument, 0 provided
a.cc:75:7: note: candidate: 'constexpr Node::Node(const Node&)'
75 | class Node{
| ^~~~
a.cc:75:7: note: candidate expects 1 argument, 0 provided
a.cc:75:7: note: candidate: 'constexpr Node::Node(Node&&)'
a.cc:75:7: note: candidate expects 1 argument, 0 provided
a.cc:112:22: error: request for member 'v1' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
112 | this.v1 = id1;
| ^~
a.cc:113:22: error: request for member 'v2' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
113 | this.v2 = id2;
| ^~
a.cc:114:22: error: request for member 'cost' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
114 | this.cost = c;
| ^~~~
a.cc:115:28: error: invalid conversion from 'Edge*' to 'int' [-fpermissive]
115 | v1.Connect(this);
| ^~~~
| |
| Edge*
a.cc:103:34: note: initializing argument 1 of 'void Node::Connect(int)'
103 | public void Connect(Edge e) {
| ~~~~~^
a.cc:116:28: error: invalid conversion from 'Edge*' to 'int' [-fpermissive]
116 | v2.Connect(this);
| ^~~~
| |
| Edge*
a.cc:103:34: note: initializing argument 1 of 'void Node::Connect(int)'
103 | public void Connect(Edge e) {
| ~~~~~^
a.cc: In member function 'Node Edge::Other_one(Node)':
a.cc:128:22: error: 'class Node' has no member named 'equals'
128 | if(v.equals(this.v1)) {
| ^~~~~~
a.cc:128:34: error: request for member 'v1' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
128 | if(v.equals(this.v1)) {
| ^~
a.cc:129:37: error: request for member 'v2' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
129 | return this.v2;
| ^~
a.cc:132:37: error: request for member 'v1' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
132 | return this.v1;
| ^~
|
s334642423 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N >> endl;
Node v[] = new Node[N];
int c[] = new int[N-1];
for(int i=0;i<N;i++){
v[i] = new Node(i);
}
Edge e[] = new Edge[N-1];
for(int i=0;i<N-1;i++) {
cin >> a >> b >> c >> endl;
e[i] = new Edge[a-1],v[b-1],c);
}
int Q;
cin >> Q >> endl;
int K;
cin >> K >> endl;
int x[] = new int[Q];
int y[] = new int[Q];
for(int i=0;i<Q;i++) {
cin >> x[i] >> endl;
cin >> y[i] >> endl;
}
PriorityQueue<Node> searching = new PriorityQueue<>((u,w)->u.d>w.d?1:u.d<w.d?-1:0);
PriorityQueue<Node> searched = new PriorityQueue<>((u,w)->u.d>w.d?1:u.d<w.d?-1:0);
boolean used[] = new boolean[N];
Arrays.fill(used, false);
v[K-1].Reload_dist(0);
used[K-1] = true;
for(Edge connect:v[K-1].edges) {
Node another = connect.Other_one(v[K-1]);
another.Reload_dist(connect.cost);
searching.add(another);
used[another.id] = true;
}
searched.add(v[K-1]);
Node vertex=null;
while(searching.size()>0) {
vertex = searching.poll();
for(Edge connect:vertex.edges) {
Node another = connect.Other_one(vertex);
if(!used[another.id]) {
another.Reload_dist(vertex.d + connect.cost);
if(!searched.contains(another)){
searching.add(another);
}
searched.add(vertex);
used[another.id] = true;
}
}
}
long result = 0;
for(int i=0;i<Q;i++) {
result = v[x[i]-1].d + v[y[i]-1].d;
cout << result << endl;
}
return 0;
}
void Node{
int id;
long d;
Node prev = null;
ArrayList<Edge> edges = new ArrayList<>();
public Node(int id) {
this.id = id;
this.d = Integer.MAX_VALUE;
}
public void Reset() {
this.d = Integer.MAX_VALUE;
this.prev = null;
}
public void Reload_dist(long dist) {
this.d = dist;
}
public void Reload_prev(Node v) {
this.prev = v;
}
@Override public Node clone() {
return new Node(this.id);
}
public void Connect(Edge e) {
edges.add(e);
}
}
void Edge{
Node v1, v2;
int cost;
public Edge(Node id1,Node id2, int c) {
this.v1 = id1;
this.v2 = id2;
this.cost = c;
v1.Connect(this);
v2.Connect(this);
}
public Node First_one() {
return this.v1;
}
public Node Second_one() {
return this.v2;
}
public Node Other_one(Node v) {
if(v.equals(this.v1)) {
return this.v2;
}
else {
return this.v1;
}
}
}
void Graph{
static Node[] nodes;
static Edge[] edges;
public Graph(Node[] v,Edge[] e) {
Graph.nodes = v;
Graph.edges = e;
}
public static int size() {
return nodes.length;
}
public boolean Bellman_Ford(Node s) {
boolean negative_loop[] = new boolean[size()];
Arrays.fill(negative_loop, false);
s.Reload_dist(0);
for(int i=0;i<size();i++) {
for(Node v : nodes) {
for(Edge e : v.edges) {
if((v.d != Long.MAX_VALUE && e.Other_one(v).d > v.d + e.cost)) {
e.Other_one(v).Reload_dist(v.d + e.cost);
negative_loop[e.Other_one(v).id] = true;
}
if(i==size()-1) {
return true;
}
}
}
}
return false;
}
}
| a.cc:93:9: error: stray '@' in program
93 | @Override public Node clone() {
| ^
a.cc: In function 'int main()':
a.cc:7:16: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and '<unresolved overloaded function type>')
7 | cin >> N >> endl;
| ~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool&'
170 | operator>>(bool& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int&'
174 | operator>>(short& __n);
| ~~~~~~~^~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int&'
177 | operator>>(unsigned short& __n)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int&'
181 | operator>>(int& __n);
| ~~~~~^~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int&'
184 | operator>>(unsigned int& __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int&'
188 | operator>>(long& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int&'
192 | operator>>(unsigned long& __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int&'
199 | operator>>(long long& __n)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int&'
203 | operator>>(unsigned long long& __n)
| ~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double&'
223 | operator>>(double& __f)
| ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double&'
227 | operator>>(long double& __f)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ^~~~~~~~
/usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]'
352 | operator>>(__streambuf_type* __sb);
| |
s582752415 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std
int Main {
public static void main(String[] args) {
int N;
cin >> N >> endl;
Node v[] = new Node[N];
int c[] = new int[N-1];
for(int i=0;i<N;i++){
v[i] = new Node(i);
}
Edge e[] = new Edge[N-1];
for(int i=0;i<N-1;i++) {
cin >> a >> b >> c >> endl;
e[i] = new Edge[a-1],v[b-1],c);
}
int Q;
cin >> Q >> endl;
int K;
cin >> K >> endl;
int x[] = new int[Q];
int y[] = new int[Q];
for(int i=0;i<Q;i++) {
cin >> x[i] >> endl;
cin >> y[i] >> endl;
}
PriorityQueue<Node> searching = new PriorityQueue<>((u,w)->u.d>w.d?1:u.d<w.d?-1:0);
PriorityQueue<Node> searched = new PriorityQueue<>((u,w)->u.d>w.d?1:u.d<w.d?-1:0);
boolean used[] = new boolean[N];
Arrays.fill(used, false);
v[K-1].Reload_dist(0);
used[K-1] = true;
for(Edge connect:v[K-1].edges) {
Node another = connect.Other_one(v[K-1]);
another.Reload_dist(connect.cost);
searching.add(another);
used[another.id] = true;
}
searched.add(v[K-1]);
Node vertex=null;
while(searching.size()>0) {
vertex = searching.poll();
for(Edge connect:vertex.edges) {
Node another = connect.Other_one(vertex);
if(!used[another.id]) {
another.Reload_dist(vertex.d + connect.cost);
if(!searched.contains(another)){
searching.add(another);
}
searched.add(vertex);
used[another.id] = true;
}
}
}
long result = 0;
for(int i=0;i<Q;i++) {
result = v[x[i]-1].d + v[y[i]-1].d;
out.println(result);
}
out.flush();
}
}
void Node{
int id;
long d;
Node prev = null;
ArrayList<Edge> edges = new ArrayList<>();
public Node(int id) {
this.id = id;
this.d = Integer.MAX_VALUE;
}
public void Reset() {
this.d = Integer.MAX_VALUE;
this.prev = null;
}
public void Reload_dist(long dist) {
this.d = dist;
}
public void Reload_prev(Node v) {
this.prev = v;
}
@Override public Node clone() {
return new Node(this.id);
}
public void Connect(Edge e) {
edges.add(e);
}
}
void Edge{
Node v1, v2;
int cost;
public Edge(Node id1,Node id2, int c) {
this.v1 = id1;
this.v2 = id2;
this.cost = c;
v1.Connect(this);
v2.Connect(this);
}
public Node First_one() {
return this.v1;
}
public Node Second_one() {
return this.v2;
}
public Node Other_one(Node v) {
if(v.equals(this.v1)) {
return this.v2;
}
else {
return this.v1;
}
}
}
void Graph{
static Node[] nodes;
static Edge[] edges;
public Graph(Node[] v,Edge[] e) {
Graph.nodes = v;
Graph.edges = e;
}
public static int size() {
return nodes.length;
}
public boolean Bellman_Ford(Node s) {
boolean negative_loop[] = new boolean[size()];
Arrays.fill(negative_loop, false);
s.Reload_dist(0);
for(int i=0;i<size();i++) {
for(Node v : nodes) {
for(Edge e : v.edges) {
if((v.d != Long.MAX_VALUE && e.Other_one(v).d > v.d + e.cost)) {
e.Other_one(v).Reload_dist(v.d + e.cost);
negative_loop[e.Other_one(v).id] = true;
}
if(i==size()-1) {
return true;
}
}
}
}
return false;
}
}
| a.cc:96:9: error: stray '@' in program
96 | @Override public Node clone() {
| ^
a.cc:2:20: error: expected ';' before 'int'
2 | using namespace std
| ^
| ;
3 |
4 | int Main {
| ~~~
a.cc:6:9: error: expected primary-expression before 'public'
6 | public static void main(String[] args) {
| ^~~~~~
a.cc:6:9: error: expected '}' before 'public'
a.cc:4:10: note: to match this '{'
4 | int Main {
| ^
a.cc:70:1: error: expected declaration before '}' token
70 | }
| ^
a.cc:72:6: error: variable or field 'Node' declared void
72 | void Node{
| ^~~~
a.cc:73:9: error: expected primary-expression before 'int'
73 | int id;
| ^~~
a.cc:73:9: error: expected '}' before 'int'
a.cc:72:10: note: to match this '{'
72 | void Node{
| ^
a.cc:75:9: error: 'Node' does not name a type
75 | Node prev = null;
| ^~~~
a.cc:76:9: error: 'ArrayList' does not name a type
76 | ArrayList<Edge> edges = new ArrayList<>();
| ^~~~~~~~~
a.cc:78:9: error: expected unqualified-id before 'public'
78 | public Node(int id) {
| ^~~~~~
a.cc:83:9: error: expected unqualified-id before 'public'
83 | public void Reset() {
| ^~~~~~
a.cc:88:9: error: expected unqualified-id before 'public'
88 | public void Reload_dist(long dist) {
| ^~~~~~
a.cc:92:9: error: expected unqualified-id before 'public'
92 | public void Reload_prev(Node v) {
| ^~~~~~
a.cc:96:10: error: 'Override' does not name a type
96 | @Override public Node clone() {
| ^~~~~~~~
a.cc:100:9: error: expected unqualified-id before 'public'
100 | public void Connect(Edge e) {
| ^~~~~~
a.cc:103:1: error: expected declaration before '}' token
103 | }
| ^
a.cc:105:6: error: variable or field 'Edge' declared void
105 | void Edge{
| ^~~~
a.cc:106:9: error: 'Node' was not declared in this scope
106 | Node v1, v2;
| ^~~~
a.cc:106:14: error: expected '}' before 'v1'
106 | Node v1, v2;
| ^~
a.cc:105:10: note: to match this '{'
105 | void Edge{
| ^
a.cc:108:9: error: expected unqualified-id before 'public'
108 | public Edge(Node id1,Node id2, int c) {
| ^~~~~~
a.cc:116:9: error: expected unqualified-id before 'public'
116 | public Node First_one() {
| ^~~~~~
a.cc:120:9: error: expected unqualified-id before 'public'
120 | public Node Second_one() {
| ^~~~~~
a.cc:124:9: error: expected unqualified-id before 'public'
124 | public Node Other_one(Node v) {
| ^~~~~~
a.cc:132:1: error: expected declaration before '}' token
132 | }
| ^
a.cc:134:6: error: variable or field 'Graph' declared void
134 | void Graph{
| ^~~~~
a.cc:135:9: error: expected primary-expression before 'static'
135 | static Node[] nodes;
| ^~~~~~
a.cc:135:9: error: expected '}' before 'static'
a.cc:134:11: note: to match this '{'
134 | void Graph{
| ^
a.cc:136:16: error: 'Edge' does not name a type
136 | static Edge[] edges;
| ^~~~
a.cc:138:9: error: expected unqualified-id before 'public'
138 | public Graph(Node[] v,Edge[] e) {
| ^~~~~~
a.cc:143:9: error: expected unqualified-id before 'public'
143 | public static int size() {
| ^~~~~~
a.cc:147:9: error: expected unqualified-id before 'public'
147 | public boolean Bellman_Ford(Node s) {
| ^~~~~~
a.cc:167:1: error: expected declaration before '}' token
167 | }
| ^
|
s279776089 | p03634 | Java | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
int N = in.nextInt();
ArrayList<ArrayList<int[]>> edge = new ArrayList<ArrayList<int[]>>();
for (int i=0;i<N-1;i++) {
int a = in.nextInt()-1;
int b = in.nextInt()-1;
int c = in.nextInt();
int[] add_1 = {b, c};
int[] add_2 = {a, c};
edge.get(a).add(add_1);
edge.get(b).add(add_2);
}
int Q = in.nextInt();
int K = in.nextInt();
ArrayDeque<int[]> queue = new ArrayDeque<int[]>();
int[] flag = new int[N];
long[] cost = new long[N];
long[] init = {(long)K-1, 0};
queue.add(init);
while(!queue.isEmpty()) {
long[] rem = queue.poll();
if (flag[rem[0]]==1) {
continue;
}
flag[rem[0]]=1;
cost[rem[0]]=rem[1];
for (long[] tmp : edge.get(rem[0])) {
long[] add = {tmp[0], rem[1]+tmp[1]};
queue.add(add);
}
}
for (int i=0;i<Q;i++) {
int x = in.nextInt();
int y = in.nextInt();
out.println((cost[x-1]+cost[y-1]));
}
out.println(N);
out.close();
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
}
| Main.java:37: error: incompatible types: long[] cannot be converted to int[]
queue.add(init);
^
Main.java:39: error: incompatible types: int[] cannot be converted to long[]
long[] rem = queue.poll();
^
Main.java:40: error: incompatible types: possible lossy conversion from long to int
if (flag[rem[0]]==1) {
^
Main.java:43: error: incompatible types: possible lossy conversion from long to int
flag[rem[0]]=1;
^
Main.java:44: error: incompatible types: possible lossy conversion from long to int
cost[rem[0]]=rem[1];
^
Main.java:46: error: incompatible types: possible lossy conversion from long to int
for (long[] tmp : edge.get(rem[0])) {
^
Main.java:48: error: incompatible types: long[] cannot be converted to int[]
queue.add(add);
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
7 errors
|
s617661694 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
static const int MAX = 1e5;
static const int INF = 1e9;
// 隣接リストを用いた幅優先探索 O(|V|+|E|)
int n;
vector<pair<ll, ll>> G[MAX]; // 頂点数がnのグラフを表す隣接リスト
vector<ll> d(MAX, INF); // 始点sから頂点iまでの最短距離をd[i]に記録
// main関数からこれらを削除すること
void bfs(int s) {
queue<int> q;
q.push(s);
d[s] = 0;
while(!q.empty()){
int u = q.front();
q.pop();
for(int v = 0; v < G[u].size(); v++){
if(d[G[u][v].first] == INF){
d[G[u][v]] = d[u] + G[u][v].second;
q.push(G[u][v].first);
}
}
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
// 重み付き無向(有向)グラフの隣接リスト
ll u, v, w;
cin >> n;
for(int i = 0; i < n - 1; i++){
cin >> u >> v >> w;
u--;
v--;
G[u].push_back(make_pair(v, w));
G[v].push_back(make_pair(u, w)); // 有向グラフではこの行をコメントアウト
}
int q, k;
cin >> q >> k;
bfs(k - 1);
int x, y;
for(int i = 0; i < q; i++){
cin >> x >> y;
cout << d[x - 1] + d[y - 1] << endl;
}
} | a.cc: In function 'void bfs(int)':
a.cc:23:10: error: no match for 'operator[]' (operand types are 'std::vector<long long int>' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'})
23 | d[G[u][v]] = d[u] + G[u][v].second;
| ^
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = long long int; _Alloc = std::allocator<long long int>; reference = long long int&; size_type = long unsigned int]'
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = long long int; _Alloc = std::allocator<long long int>; const_reference = const long long int&; size_type = long unsigned int]'
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note: no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'std::pair<long long int, long long int>'} to 'std::vector<long long int>::size_type' {aka 'long unsigned int'}
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
|
s860515529 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<ll>>;
typedef long long ll;
const ll mod = 1000000007;
int main() {
int n;
cin >> n;
Graph to(n), cost(n);
rep(i, n-1) {
ll a, b, w;
cin >> a >> b >> w;
a--; b--;
to[a].push_back(b);
to[b].push_back(a);
cost[a].push_back(w);
cost[b].push_back(w);
}
int q, K;
cin >> q >> K;
K--;
vector<ll> dist(n, -1); // dist[i] : 頂点iの根からの距離
queue<ll> Q;
const int root = K; // 根は頂点K
dist[root] = 0;
Q.push(root);
while(!Q.empty()) {
ll v = Q.front();
Q.pop();
rep(i, to[v].size()) {
ll u = to[v][i];
if(dist[u] != -1) {
continue;
}
dist[u] = dist[v] + cost[v][i];
Q.push(u);
}
}
vector<ll> ans(q);
rep(i, q) {
int x, y;
cin >> x >> y;
x--; y--;
ans[i] = dist[x] + dist[y];
}
rep(i, q) {
cout << ans[i] << "\n";
}
return 0;
} | a.cc:13:29: error: 'll' was not declared in this scope
13 | using Graph = vector<vector<ll>>;
| ^~
a.cc:13:29: error: template argument 1 is invalid
a.cc:13:29: error: template argument 2 is invalid
a.cc:13:31: error: template argument 1 is invalid
13 | using Graph = vector<vector<ll>>;
| ^~
a.cc:13:31: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:21:5: error: 'Graph' was not declared in this scope; did you mean 'isgraph'?
21 | Graph to(n), cost(n);
| ^~~~~
| isgraph
a.cc:26:9: error: 'to' was not declared in this scope; did you mean 'tm'?
26 | to[a].push_back(b);
| ^~
| tm
a.cc:28:9: error: 'cost' was not declared in this scope; did you mean 'cosl'?
28 | cost[a].push_back(w);
| ^~~~
| cosl
a.cc:47:16: error: 'to' was not declared in this scope; did you mean 'tm'?
47 | rep(i, to[v].size()) {
| ^~
a.cc:11:38: note: in definition of macro 'rep'
11 | #define rep(i, n) for(int i = 0; i < n; i++)
| ^
a.cc:55:33: error: 'cost' was not declared in this scope; did you mean 'cosl'?
55 | dist[u] = dist[v] + cost[v][i];
| ^~~~
| cosl
|
s184133529 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long INF=1e15;
int N;
vector<int> g[size];long len[size][size];
long d[size],pre[size];
priority_queue<pair<long,int>> pq;
void dijkstra(int a){//O(E+NlogN)
rep(i,0,N){
d[i]=INF;
pq.push(make_pair(-d[i],i));
}
d[a]=0;pq.push({0,a});
int v;long temp;
rep(i,0,N){
v=pq.top().second;
pq.pop();
for(int u:g[v]){
temp=d[v]+len[v][u];
if(d[u]>temp){
d[u]=temp;
pre[u]=v;
pq.push({-d[u],u});
}
}
}return;
}
int main(){
cin>>N;
int a,b;long c;
rep(i,0,N-1){
cin>>a>>b>>c;a--;b--;
g[a].push_back(b);
g[b].push_back(a);
len[a][b]=c;
len[b][a]=c;
}
int Q,K;cin>>Q>>K;
dijkstra(K-1);
int x,y;
rep(i,0,Q){
cin>>x>>y;
cout<<d[x-1]+d[y-1]<<endl;
}
} | a.cc:11:15: error: reference to 'size' is ambiguous
11 | vector<int> g[size];long len[size][size];
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:11: note: 'const int size'
8 | const int size=1e5;
| ^~~~
a.cc:11:30: error: reference to 'size' is ambiguous
11 | vector<int> g[size];long len[size][size];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:11: note: 'const int size'
8 | const int size=1e5;
| ^~~~
a.cc:11:36: error: reference to 'size' is ambiguous
11 | vector<int> g[size];long len[size][size];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:11: note: 'const int size'
8 | const int size=1e5;
| ^~~~
a.cc:12:8: error: reference to 'size' is ambiguous
12 | long d[size],pre[size];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:11: note: 'const int size'
8 | const int size=1e5;
| ^~~~
a.cc:12:18: error: reference to 'size' is ambiguous
12 | long d[size],pre[size];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:8:11: note: 'const int size'
8 | const int size=1e5;
| ^~~~
a.cc: In function 'void dijkstra(int)':
a.cc:16:17: error: 'd' was not declared in this scope
16 | d[i]=INF;
| ^
a.cc:19:9: error: 'd' was not declared in this scope
19 | d[a]=0;pq.push({0,a});
| ^
a.cc:24:27: error: 'g' was not declared in this scope
24 | for(int u:g[v]){
| ^
a.cc:25:35: error: 'len' was not declared in this scope
25 | temp=d[v]+len[v][u];
| ^~~
a.cc:28:33: error: 'pre' was not declared in this scope; did you mean 'pread'?
28 | pre[u]=v;
| ^~~
| pread
a.cc:29:40: error: no matching function for call to 'std::priority_queue<std::pair<long int, int> >::push(<brace-enclosed initializer list>)'
29 | pq.push({-d[u],u});
| ~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/queue:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:157:
/usr/include/c++/14/bits/stl_queue.h:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<long int, int>; _Sequence = std::vector<std::pair<long int, int>, std::allocator<std::pair<long int, int> > >; _Compare = std::less<std::pair<long int, int> >; value_type = std::pair<long int, int>]'
736 | push(const value_type& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:736:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<long int, int> >::value_type&' {aka 'const std::pair<long int, int>&'}
736 | push(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_queue.h:744:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<long int, int>; _Sequence = std::vector<std::pair<long int, int>, std::allocator<std::pair<long int, int> > >; _Compare = std::less<std::pair<long int, int> >; value_type = std::pair<long int, int>]'
744 | push(value_type&& __x)
| ^~~~
/usr/include/c++/14/bits/stl_queue.h:744:25: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<long int, int> >::value_type&&' {aka 'std::pair<long int, int>&&'}
744 | push(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc: In function 'int main()':
a.cc:39:17: error: 'g' was not declared in this scope
39 | g[a].push_back(b);
| ^
a.cc:41:17: error: 'len' was not declared in this scope
41 | len[a][b]=c;
| ^~~
a.cc:49:23: error: 'd' was not declared in this scope
49 | cout<<d[x-1]+d[y-1]<<endl;
| ^
|
s361227080 | p03634 | C++ | #include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;
// hamko utils
#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double; using vld = vector<ld>;
using vi = vector<int>; using vvi = vector<vi>; vll conv(vi& v) { vll r(v.size()); rep(i, v.size()) r[i] = v[i]; return r; }
inline void input(int &v){ v=0;char c=0;int p=1; while(c<'0' || c>'9'){if(c=='-')p=-1;c=getchar();} while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();} v*=p; } // これを使うならば、tieとかを消して!!
template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) { o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args>
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; o << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const deque<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T> ostream &operator<<(ostream &o, const unordered_set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T, typename U> ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]"; return o; }
template <typename T, typename U, typename V> ostream &operator<<(ostream &o, const unordered_map<T, U, V> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]"; return o; }
vector<int> range(const int x, const int y) { vector<int> v(y - x + 1); iota(v.begin(), v.end(), x); return v; }
template <typename T> istream& operator>>(istream& i, vector<T>& o) { rep(j, o.size()) i >> o[j]; return i;}
template <typename T, typename S, typename U> ostream &operator<<(ostream &o, const priority_queue<T, S, U> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " ";} return o; }
template <typename T> ostream &operator<<(ostream &o, const queue<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.front(); tmp.pop(); o << x << " ";} return o; }
template <typename T> ostream &operator<<(ostream &o, const stack<T> &v) { auto tmp = v; while (tmp.size()) { auto x = tmp.top(); tmp.pop(); o << x << " ";} return o; }
template <typename T> unordered_map<T, ll> counter(vector<T> vec){unordered_map<T, ll> ret; for (auto&& x : vec) ret[x]++; return ret;};
string substr(string s, P x) {return s.substr(x.fi, x.se - x.fi); }
void vizGraph(vvll& g, int mode = 0, string filename = "out.png") { ofstream ofs("./out.dot"); ofs << "digraph graph_name {" << endl; set<P> memo; rep(i, g.size()) rep(j, g[i].size()) { if (mode && (memo.count(P(i, g[i][j])) || memo.count(P(g[i][j], i)))) continue; memo.insert(P(i, g[i][j])); ofs << " " << i << " -> " << g[i][j] << (mode ? " [arrowhead = none]" : "")<< endl; } ofs << "}" << endl; ofs.close(); system(((string)"dot -T png out.dot >" + filename).c_str()); }
size_t random_seed; namespace std { using argument_type = P; template<> struct hash<argument_type> { size_t operator()(argument_type const& x) const { size_t seed = random_seed; seed ^= hash<ll>{}(x.fi); seed ^= (hash<ll>{}(x.se) << 1); return seed; } }; }; // hash for various class
#define ldout fixed << setprecision(40)
#define EPS (double)1e-14
#define INF (ll)1e18
#define mo (ll)(1e9+7)
// end of hamko utils
//Kからの最短経路を全部作っといてクエリが出るたびに出発点-K間+到着点-K間の距離を足して出力するだけ
int N,Q,K;
struct edge{int to; ll cost;}
vector<edge> graph[110000];
ll depth[110000];
void dfs(int v, int p, ll d){
depth[v] = d;
for(auto &e : graph[v]){
if(e.to == p) continue;
dfs(e.to, v, d+e.cost);
}
}
int main(){
int N;
cin >> N;
for(int i=0; i<N-1; i++){
int a, b, c;
cin >> a >> b >> c;
a--, b--;
graph[a].push_back({b,c});
graph[b].push_back({a,c});
}
int q, k;
cin >> q >> k;
k--;
dfs(k, -1, 0);
for(int i=0; i<q; i++){
int x,y;
cin >> x >> y;
x--, y--;
cout << depth[x] + depth[y] << endl;
}
return 0;
} | a.cc:56:14: error: invalid declarator before 'graph'
56 | vector<edge> graph[110000];
| ^~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:61:19: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
61 | for(auto &e : graph[v]){
| ^~~~~
| isgraph
a.cc: In function 'int main()':
a.cc:75:9: error: 'graph' was not declared in this scope; did you mean 'isgraph'?
75 | graph[a].push_back({b,c});
| ^~~~~
| isgraph
|
s004056526 | p03634 | C++ | #include <iostream>
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s)
{
int v;
istringstream sin(s);
sin >> v;
return v;
}
template <class T>
inline string toString(T x)
{
ostringstream sout;
sout << x;
return sout.str();
}
//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0, sizeof(a))
//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
// << " " << __FILE__ << endl;
using node = pair<LL, LL>; // vert index, cost
enum Color
{
Black,
White,
Gray
};
int main()
{
LL N;
cin >> N;
vector<vector<node>> nodes(N, vector<node>());
REP(i, N)
{
LL a, b, c;
cin >> a >> b >> c;
nodes[a].push_back(make_pair(b, c));
}
vector<LL> lowest_costs(N, __LONG_LONG_MAX__ - 1);
vector<Color> colors(N, Color::White);
LL Q, K;
cin >> Q >> K;
K = K - 1;
lowest_costs[K] = 0;
auto cmp = [](node a, node b) { return a.second < b.second; };
priority_queue<node, vector<node>, decltype(cmp)> q;
LL idx = 0;
EACH(i, lowest_costs)
{
q.push(make_pair(idx, *i));
idx++;
}
while (!q.empty())
{
auto u = q.top();
q.pop();
colors[u.first] = Color::Black;
if (lowest_costs[u.first] < u.second)
continue;
EACH(nde, nodes[u.first])
{
auto to = nde->first;
auto cost_to = nde->second;
if (colors[to] != Color::Black)
{
auto new_cost = lowest_costs[u.first] + cost_to;
if (new_cost < lowest_costs[to])
{
lowest_costs[to] = new_cost;
colors[to] = Color::Gray;
q.push(make_pair(to, lowest_costs[to]));
}
}
}
}
REP(i, Q)
{
LL x, y;
cin >> x >> y;
x = x - 1;
y = y - 1;
cout << lowest_costs[x] + lowest_costs[y] << endl;
}
} | a.cc: In function 'int main()':
a.cc:125:55: error: no matching function for call to 'std::priority_queue<std::pair<long long int, long long int>, std::vector<std::pair<long long int, long long int> >, main()::<lambda(node, node)> >::priority_queue()'
125 | priority_queue<node, vector<node>, decltype(cmp)> q;
| ^
In file included from /usr/include/c++/14/queue:66,
from a.cc:11:
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate: 'template<class _InputIterator, class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&, const _Alloc&) [with _Alloc = _InputIterator; _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
691 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:691:9: note: candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
679 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:679:9: note: candidate expects 5 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
671 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:671:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate: 'template<class _InputIterator, class _Alloc, class, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Alloc&) [with _Alloc = _InputIterator; <template-parameter-2-3> = _Alloc; _Requires = <template-parameter-1-3>; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
663 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:663:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, _Sequence&&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
649 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:649:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&, const _Sequence&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
638 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:638:9: note: candidate expects 4 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate: 'template<class _InputIterator, class> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(_InputIterator, _InputIterator, const _Compare&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
629 | priority_queue(_InputIterator __first, _InputIterator __last,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:629:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(std::priority_queue<_Tp, _Sequence, _Compare>&&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
594 | priority_queue(priority_queue&& __q, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:594:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const std::priority_queue<_Tp, _Sequence, _Compare>&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
590 | priority_queue(const priority_queue& __q, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:590:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
585 | priority_queue(const _Compare& __x, _Sequence&& __c, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:585:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
579 | priority_queue(const _Compare& __x, const _Sequence& __c,
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:579:9: note: candidate expects 3 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
573 | priority_queue(const _Compare& __x, const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:573:9: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate: 'template<class _Alloc, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Alloc&) [with _Requires = _Alloc; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
569 | priority_queue(const _Alloc& __a)
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:569:9: note: candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_queue.h:554:9: note: candidate: 'template<class _Seq, class _Requires> std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue() [with _Requires = _Seq; _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
554 | priority_queue()
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:554:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_queue.h:551:43: error: no type named 'type' in 'struct std::enable_if<false, void>'
551 | template<typename _Seq = _Sequence, typename _Requires = typename
| ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, _Sequence&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::pair<long long int, long long int> >; _Compare = main()::<lambda(node, node)>]'
563 | priority_queue(const _Compare& __x, _Sequence&& __s = _Sequence())
| ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:563:7: note: candidate expects 2 arguments, 0 provided
/usr/include/c++/14/bits/stl_queue.h:558:7: note: candidate: 'std::priority_queue<_Tp, _Sequence, _Compare>::priority_queue(const _Compare&, const _Sequence&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::vector<std::p |
s839453870 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;
void add(long long &a, long long b) {
a += b;
if (a >= MOD) a -= MOD;
}
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
void rec(const Graph &G, int v, int p, ll sum, vector<ll> &dist){
dist[v] = sum;
for(auto e : G[v]){
if(e.first == p) continue;
rec(G, e.first, v, sum+e.second, dist);
}
}
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
int N;
cin >> N;
Graph(N);
rep(i,N-1){
int a,b; ll c; cin >> a >> b >> c;
--a,--b;
G[a].push_back({b,c});
G[b].push_back({a,c});
}
int Q, K; cin >> Q >> K; --K;
vector<ll> dist(N, 0);
rec(G,K,-1,0,dist);
rep(q,Q){
int x,y;
cin >> x >> y;
--x,--y;
cout << dist[x] + dist[y] << endl;
}
}
| a.cc: In function 'int main()':
a.cc:39:11: error: conflicting declaration 'Graph N'
39 | Graph(N);
| ^
a.cc:37:13: note: previous declaration as 'int N'
37 | int N;
| ^
a.cc:43:7: error: 'G' was not declared in this scope
43 | G[a].push_back({b,c});
| ^
a.cc:48:9: error: 'G' was not declared in this scope
48 | rec(G,K,-1,0,dist);
| ^
|
s279560568 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;
void add(long long &a, long long b) {
a += b;
if (a >= MOD) a -= MOD;
}
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
void rec(const Graph &G, int v, int p, ll sum, vector<ll> &dist){
dist[v] = sum;
for(auto e : G[v]){
if(e.first == p) continue;
rec(G, e.first, v, sum+e.second, dist);
}
}
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
Graph(N);
rep(i,N-1){
int a,b; ll c; cin >> a >> b >> c;
--a,--b;
G[a].push_back({b,c});
G[b].push_back({a,c});
}
int Q, K; cin >> Q >> K; --K;
vector<ll> dist(N, 0);
rec(G,K,-1,0,dist);
rep(q,Q){
int x,y;
cin >> x >> y;
--x,--y;
cout << dist[x] + dist[y] << endl;
}
} | a.cc: In function 'int main()':
a.cc:38:12: error: no match for 'operator-' (operand types are 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} and 'int')
38 | rep(i,N-1){
| ~^~
| | |
| | int
| Graph {aka std::vector<std::vector<std::pair<int, long long int> > >}
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
618 | operator-(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::reverse_iterator<_Iterator>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1790 | operator-(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::move_iterator<_IteratorL>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
In file included from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)'
370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::complex<_Tp>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)'
379 | operator-(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::complex<_Tp>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)'
388 | operator-(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: mismatched types 'const std::complex<_Tp>' and 'int'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)'
465 | operator-(const complex<_Tp>& __x)
| ^~~~~~~~
/usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed:
a.cc:38:13: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
| ^
/usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)'
1197 | _DEFINE_BINARY_OPERATOR(-, __minus)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed:
a.cc:38:13: note: 'Graph' {aka 'std::vector<std::vector<std::pair<int, long long int> > >'} is not derived from 'const std::valarray<_Tp>'
38 | rep(i,N-1){
| ^
a.cc:5:39: note: in definition of macro 'rep'
5 | #define rep(i,n) for(ll i=0, i##_len=(n); i |
s730881444 | p03634 | C++ | #include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <utility>
#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
#define NMAX 100000
using namespace std;
ll ranges[NMAX] = {};
vector<pair<int,int>> graph[NMAX]; //first is ngh. second is ranges.
bool used[NMAX] = {};
void dfs(int v,ll range){
ranges[v] = range;
used[v] = true;
rep(i,0,graph[v].size()){
if(!used[graph[v][i].first]){
dfs(graph[v][i].first,range+graph[v][i].second);
}
}
}
int main(){
int N;
cin >> N;
int tmp1,tmp2,tmp3;
rep(i,0,N-1){
cin >> tmp1 >> tmp2 >> tmp3;
graph[tmp1-1].push_back(make_pair(tmp2-1,tmp3));
graph[tmp2-1].push_back(make_pair(tmp1-1,tmp3));
}
int Q,K;
int x[Q],y[Q];
cin >> Q >> K;
rep(i,0,Q){
cin >> x[i] >> y[i];
}
dfs(K-1,0);
rep(i,0,Q){
cout << ranges[x[i]-1] + ranges[y[i]-1] << endl;
}
}
| a.cc: In function 'int main()':
a.cc:31:9: error: 'cin' was not declared in this scope
31 | cin >> N;
| ^~~
a.cc:7:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
6 | #include <utility>
+++ |+#include <iostream>
7 | #define ll long long int
a.cc:46:17: error: 'cout' was not declared in this scope
46 | cout << ranges[x[i]-1] + ranges[y[i]-1] << endl;
| ^~~~
a.cc:46:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s583386439 | p03634 | C++ | #include <iostream>
#include <vector>
#include <queue>
struct edge{
int to, cost;
};
using namespace std;
//ダイクストラで多用する型
typedef pair<int, int> P;//(その頂点までの距離,頂点)として使う。
vector<edge> G[100000];//頂点iから出る辺の配列G[i]の配列。
int dist[100000];//特定の頂点から各頂点への距離が格納される。
bool used[100000];//dijkstra実行中に、頂点iまでの距離を確定したかどうかを持つ。
void dijkstra(int v){//vは始点。
//以下のリンクでpriority_queueの使い方を参照
//http://shirokurostone.hatenablog.com/entry/20110522/1306052844
priority_queue<P, vector<P>, greater<P>> que;
que.push(P(0, v));
while(!que.empty()){
P top = que.top();
que.pop();
int u = top.second;
int d = top.first;
//cout << u << ' ' << d << endl;
if(used[u]) continue;
dist[u] = d;
used[u] = true;
for(int i = 0; i < G[u].size(); i++){
if(!used[G[u][i].to]){
que.push(P(d+G[u][i].cost, G[u][i].to));
//cout << G[u][i].to << ' ' << d+G[u][i].cost << endl;
}
}
}
}
int main(){
int n;
cin >> n;
int a,b,c;
for(int i = 0; i < n-1; i++){
cin>>a>>b>>c;
a--;b--;
G[a].push_back(edge{b, c});
G[b].push_back(edge{a, c});
}
int q,k;
cin>>q>>k;
k--;
dijkstra(k);
int x,y;
long long res;
REP(i,q){
cin>>x>>y;
x--;y--;
res = (long long)(dist[x]+dist[y]);
cout<<res<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:57:7: error: 'i' was not declared in this scope
57 | REP(i,q){
| ^
a.cc:57:3: error: 'REP' was not declared in this scope
57 | REP(i,q){
| ^~~
|
s765713882 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
typedef pair<ll,ll> P;
const ll INF=10000000000000000;
const ll mod=1000000007;
#define F first
#define S second
#define all(a) (a.begin(),a.end())
struct node{int to,ll cost};
int main(void){
ll n;cin>>n;
vector<node>v(n);
int x;
rep(i,n-1){
node d;
cin>>x>>d.to>>d.cost;
x--;d.to--;d.cost--;
v[x].push_back(d);
swap(x,d.to);
v[x].push_back(d);
}
ll q,k;cin>>q>>k;
k--;queue q<int>;
q.push(k);
vector<ll>dist(n);
while(!q.empty()){
}
} | a.cc:11:20: error: expected ';' at end of member declaration
11 | struct node{int to,ll cost};
| ^~
| ;
a.cc:11:23: error: 'cost' does not name a type; did you mean 'const'?
11 | struct node{int to,ll cost};
| ^~~~
| const
a.cc: In function 'int main()':
a.cc:18:25: error: 'struct node' has no member named 'cost'
18 | cin>>x>>d.to>>d.cost;
| ^~~~
a.cc:19:22: error: 'struct node' has no member named 'cost'
19 | x--;d.to--;d.cost--;
| ^~~~
a.cc:20:14: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'push_back'
20 | v[x].push_back(d);
| ^~~~~~~~~
a.cc:22:14: error: '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type' {aka 'struct node'} has no member named 'push_back'
22 | v[x].push_back(d);
| ^~~~~~~~~
a.cc:25:16: error: expected initializer before '<' token
25 | k--;queue q<int>;
| ^
a.cc:26:7: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'}
26 | q.push(k);
| ^~~~
a.cc:28:14: error: request for member 'empty' in 'q', which is of non-class type 'll' {aka 'long long int'}
28 | while(!q.empty()){
| ^~~~~
|
s452264061 | p03634 | C++ | #include <iostream>
const long long INF = 10000000000000000;
const int MAX_N = 100000;
int N;
int d[MAX_N+1][MAX_N+1];
bool visit[MAX_N+1];
long long dfs(int x, int y, long long distance){
if(x==y) return distance;
if(visit[x]) return INF;
visit[x] = true;
long long min;
bool first = true;
for(int i=1; i<=N; ++i){
if(d[x][i]>0){
if(first){
min = dfs(i,y,distance+d[x][i]);
first = false;
}else min = std::min(min,dfs(i,y,distance+d[x][i]));
}
}
return min;
}
int main(){
std::cin >> N;
int a, b, c;
for(int i=1; i<N; ++i){
std::cin >> a >> b >> c;
d[a][b] = c;
d[b][a] = c;
}
int Q, K;
std::cin >> Q >> K;
int x[Q], y[Q];
for(int i=0; i<Q; ++i){
std::cin >> x[i] >> y[i];
}
long long ans;
for(int i=0; i<Q; ++i){
for(int j=0; j<N; ++j) visit[j] = false;
ans = dfs(x[i],K, 0);
for(int j=0; j<N; ++j) visit[j] = false;
ans += dfs(K,y[i], 0);
std::cout << ans << std::endl;
}
return 0;
}
| /tmp/ccjEM1PP.o: in function `dfs(int, int, long long)':
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
a.cc:(.text+0x4e): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
/tmp/ccjEM1PP.o: in function `main':
a.cc:(.text+0x36b): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
a.cc:(.text+0x3b5): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccjEM1PP.o
collect2: error: ld returned 1 exit status
|
s323496486 | p03634 | C++ | #include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919
#define double long double
using namespace std;
typedef pair<ll, ll>P;
struct edge { int to, cost; };
ll n;
vector<edge> g[114514];
ll d[114514];
ll x[114514], y[114514];
void dijkstra(ll s) {
prique<P, vector<P>, greater<P>>que;
fill(d, d + n, inf);
d[s] = 0;
que.push(P(0, s));
while (que.size()) {
P p = que.top(); que.pop();
ll nv = p.second;
if (d[nv] < p.first)continue;
for (int i = 0; i < g[nv].size(); i++) {
edge e = g[nv][i];
if (d[e.to] > d[nv] + e.cost) {
d[e.to] = d[nv] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
signed main() {
cin >> n;
rep(i, n - 1) {
ll a, b, c;
cin >> a >> b >> c;
g[a].push_back({b, c});
q.to = a;
g[b].push_back({a, c});
}
ll q, k;
cin >> q >> k;
rep(i, q) cin >> x[i] >> y[i];
ll ans = 0;
rep(i, q) {
dijkstra(x[i]);
ans += d[k];
dijkstra(k);
ans += d[y[i]];
cout << ans << endl;
ans = 0;
}
ggr
}
| a.cc: In function 'int main()':
a.cc:47:33: warning: narrowing conversion of 'b' from 'long long int' to 'int' [-Wnarrowing]
47 | g[a].push_back({b, c});
| ^
a.cc:47:36: warning: narrowing conversion of 'c' from 'long long int' to 'int' [-Wnarrowing]
47 | g[a].push_back({b, c});
| ^
a.cc:48:17: error: 'q' was not declared in this scope
48 | q.to = a;
| ^
a.cc:49:33: warning: narrowing conversion of 'a' from 'long long int' to 'int' [-Wnarrowing]
49 | g[b].push_back({a, c});
| ^
a.cc:49:36: warning: narrowing conversion of 'c' from 'long long int' to 'int' [-Wnarrowing]
49 | g[b].push_back({a, c});
| ^
|
s980320898 | p03634 | C++ | #include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;
typedef long long ll;
ll cost[100000][100000];
ll dist[100000], used[100000];
int main() {
int N;
cin >> N;
vector<int> vt[N];
for(int i=0; i<N-1; i++){
int a,b,c;
cin >> a >> b >> c;
a--;
b--;
vt[a].push_back(b);
vt[b].push_back(a);
cost[a][b]=c;
cost[b][a]=c;
}
queue<int> que;
int Q,K;
cin >> Q >> K;
K--;
que.push(K);
used[K]=1;
while(true){
int s=que.size();
for(int i=0; i<s; i++){
int tmp = que.front(); que.pop();
for(int next=0; next<vt[tmp].size(); next++){
if(used[vt[tmp][next]]==1) continue;
dist[vt[tmp][next]]=dist[tmp]+cost[tmp][vt[tmp][next]];
que.push(vt[tmp][next]);
used[vt[tmp][next]]=1;
}
}
if(que.size()==0) break;
}
ll ans[Q];
for(int i=0; i<Q; i++){
int x,y;
cin >> x >> y;
x--;
y--;
ans[i] = dist[x]+dist[y];
}
for(int i=0; i<Q; i++){
cout << ans[i] << endl;
}
return 0;
}
| /tmp/ccXEHHjr.o: in function `main':
a.cc:(.text+0x2c7): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x359): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x380): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x415): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x495): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x5c6): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
a.cc:(.text+0x5e1): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccXEHHjr.o
collect2: error: ld returned 1 exit status
|
s485581790 | p03634 | C | #include<bits/stdc++.h>
using namespace std;
long long n;
vector<long long> v(100005);
map<long long,vector<pair<long long,long long>>> mp;
bool used[100005];
void dfs(long long s,long long dist){
used[s]=true;
v[s]=dist;
for(auto i:mp[s]){
if(!used[i.first])
dfs(i.first,dist+i.second);
}
}
int main(){
cin>>n;
long long a,b,c;
for(long long i=0;i<n-1;i++){
cin>>a>>b>>c;
a--,b--;
mp[a].push_back(make_pair(b,c));
mp[b].push_back(make_pair(a,c));
}
long long k,q;
cin>>q>>k;
k--;
dfs(k,0);
for(long long i=0;i<q;i++){
long long x,y;
cin>>x>>y;
x--,y--;
cout<<v[x]+v[y]<<endl;
}
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s756587891 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{int to;ll cost;};
vector<edge> tree[100010];
ll dist[100010];
void dfs(int v, int p, ll d){
dist[v]=d;
for (auto& e:tree[v]){
if(e.to==p) continue;
dfs(e.to, e, d+e.cost);
}
}
int main(){
int N;cin>>N;
for (int i=0;i<N-1;++i){
int a, b;ll c;cin>> a>>b >> c; a--,b--;
tree[a].push_back({b,c});tree[b].push_back({a,c});
}
int Q, K;cin>>Q>>K;
dfs(K, -1, 0);
for (int i=0;i<Q;++i){
int x, y;cin>>x>>y;x--,y--;
cout << dist[x]+dist[y] << endl;
}
return 0;
} | a.cc: In function 'void dfs(int, int, ll)':
a.cc:14:15: error: cannot convert 'edge' to 'int'
14 | dfs(e.to, e, d+e.cost);
| ^
| |
| edge
a.cc:10:21: note: initializing argument 2 of 'void dfs(int, int, ll)'
10 | void dfs(int v, int p, ll d){
| ~~~~^
|
s893945962 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct edge{int to;ll cost;};
vector<edge> tree[100010];
ll dist[100010];
void dfs(int v, int p, ll d){
dist[v]=d;
for (auto& e:tree[v]){
if(e.to==p) continue;
dfs(e.to, e, d+e.cost;)
}
}
int main(){
int N;cin>>N;
for (int i=0;i<N-1;++i){
int a, b;ll c;cin>> a>>b >> c; a--,b--;
tree[a].push_back({b,c});tree[b].push_back({a,c});
}
int Q, K;cin>>Q>>K;
dfs(K, -1, 0);
for (int i=0;i<Q;++i){
int x, y;cin>.x>>y;x--,y--;
cout << dist[x]+dist[y] << endl;
}
return 0;
} | a.cc: In function 'void dfs(int, int, ll)':
a.cc:14:26: error: expected ')' before ';' token
14 | dfs(e.to, e, d+e.cost;)
| ~ ^
| )
a.cc:14:27: error: expected primary-expression before ')' token
14 | dfs(e.to, e, d+e.cost;)
| ^
a.cc: In function 'int main()':
a.cc:29:18: error: expected primary-expression before '.' token
29 | int x, y;cin>.x>>y;x--,y--;
| ^
|
s547750414 | p03634 | C++ | #include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map>
#define ALL(a) (a).begin(),(a).end()
const long long INF = 1LL<<58;
const long long MOD=4*1e18;
using namespace std;
typedef long long ll;
struct point{
int x;
int y;
};
int gcd(int a, int b)
{
if(a>b){
return gcd(b,a);
}
return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
// 引数に0がある場合は0を返す
if ( ( 0 == m ) || ( 0 == n ) )
return 0;
return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
int x;
cin>>x;
return x;
}
int moji(char in)
{
int ans = (int)in-(int)'a';
if((ans < 0) || (ans > 25)){
ans = 26;
}
return ans;
}
const int VV=100000;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
fill(d,d+VV,100000);
fill(used,used+VV,false);
d[s]=0;
while(true){
cout<<"Hello"<<endl;
int v=-1;
for(int u=0;u<VV;u++){
if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
}
if(v==-1)break;
used[v]=true;
for(int u=0;u<VV;u++){
d[u]=min(d[u],d[v]+cost[v][u]);
}
}
}
int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
return *(int*)a - *(int*)b;
}
int binary_searchh(long long x,long long k[],int n){
int l=0;
int r=n;
while(r-l>=1){
int i=(l+r)/2;
if(k[i]==x)return i;
else if(k[i]<x)l=i+1;
else r=i;
}
return -1;
}
struct File {
int aa;
int bb;
File(const int& aa, const int& bb)
: aa(aa), bb(bb) {}
};
bool operator<(const File& a, const File& b)
{
// ファイル種別、ファイル名の順番で優先順位を付けて比較
return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long kaijo(long long x){
long long l=10*10*10*10*10*10*10*10*10+7;
long long sum=1;
for(int i=x;i>0;i--){
sum*=i;
if(sum>l){
sum%=l;
}
}
return sum;
}
template<class T>void chmin(T &a,T b){
if(a>b){
a=b;
}
}
//formerは前方のindex(自分自身を含んで良い)
template<class T>int former(const vector<T>&v,T x){
return upper_bound(v.begin(),v.end(),x)-v.begin()-1;
}
//latterは後方のindex(自分自身を含んで良い)
template<class T>int latter(const vector<T>&v,T x){
return lower_bound(v.begin(),v.end(),x)-v.begin();
}
struct UnionFind{
//par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである
vector<int>par;
//sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる
vector<int>sizes;
UnionFind(int n):par(n),sizes(n,1){
//最初は全てのデータiがグループiに存在するものとして初期化
for(int i=0;i<n;i++){
par[i]=i;
}
}
//データxが属する木の根を得る
int find(int x){
if(x==par[x]){
return x;
}
return par[x]=find(par[x]);
}
//2つのデータx,yが属する木をマージする
void unite(int x,int y){
//データの根ノードを得る
x=find(x);
y=find(y);
//もしすでに同じ木に属しているならマージの必要はない
if(x==y){
return;
}
//xの木がyの木よりも大きくなるようにする
if(sizes[x]<sizes[y]){
swap(x,y);
}
//xがyの親になるように連結する
par[y]=x;
sizes[x]+=sizes[y];
}
//2つのデータx,yが属する木が同じならtrueを返す
bool same(int x,int y){
return find(x)==find(y);
}
//データxが含まれる木の大きさを返す
int size(int x){
return sizes[find(x)];
}
};
//クラスカル法
//頂点a,bをつなぐコストcostの(無向)辺
struct Edge{
int a,b,cost;
//コストの大小で順序定義
bool operator<(const Edge& o)const{
return cost<o.cost;
}
};
//頂点数と辺集合の組として定義したグラフ
struct Graph{
int n;//頂点数
vector<Edge>es;//辺集合
//クラスカル法で無向最小全域木のコストの和を計算する
//グラフが非連結の時は最小全域森のコストの和になる
//使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
int kruskal(){
//コストが小さい順にソーと
sort(es.begin(),es.end());
UnionFind uf(n);
int min_cost=0;
for(int ei=0;ei<es.size();ei++){
Edge& e=es[ei];
if(!uf.same(e.a,e.b)){
//その辺によって2つの木が連結される
min_cost+=e.cost;
uf.unite(e.a,e.b);
}
}
return min_cost;
}
};
//標準入力からグラフを読み込む
Graph input_graph(){
Graph g;
int m;
cin>>g.n>>m;
for(int i=0;i<m;i++){
Edge e;
cin>>e.a>>e.b>>e.cost;
g.es.push_back(e);
}
return g;
}
long long labs(long long x){
if(x<0){
return -x;
}
return x;
}
struct edge{long long to,cost;};
const int limit=100010;
vector<edge>tree[limit];
long long depth[limit];
void dfs(long long v,long long p,long long d){
depth[v]=d;
for(auto &e:tree[v]){
if(e.to==p){
continue;
}
dfs(e.to,v,d+e.cost);
}
}
int main() {
long long n;
cin>>n;
for(int i=0;i<n-1;i++)
{
long long a,b,c;
cin>>a>>b>>c;
a--;
b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
long long q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
for(int i=0;i<q;i++){
long long x,y;
cin>>x>>y;
x--;
y--;
cout<<depth[x]+depth[y]<<endl;
}
}
| /tmp/ccBhWCkR.o: in function `dijkstra(int)':
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x188): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x1c4): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x1f4): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x218): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccBhWCkR.o
a.cc:(.text+0x25b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s703222753 | p03634 | C++ | #include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map>
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
const long long INF = 1LL<<58;
const long long MOD=4*1e18;
using namespace std;
typedef long long ll;
struct point{
int x;
int y;
};
int gcd(int a, int b)
{
if(a>b){
return gcd(b,a);
}
return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
// 引数に0がある場合は0を返す
if ( ( 0 == m ) || ( 0 == n ) )
return 0;
return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
int x;
cin>>x;
return x;
}
int moji(char in)
{
int ans = (int)in-(int)'a';
if((ans < 0) || (ans > 25)){
ans = 26;
}
return ans;
}
const int VV=100000;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
fill(d,d+VV,100000);
fill(used,used+VV,false);
d[s]=0;
while(true){
cout<<"Hello"<<endl;
int v=-1;
for(int u=0;u<VV;u++){
if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
}
if(v==-1)break;
used[v]=true;
for(int u=0;u<VV;u++){
d[u]=min(d[u],d[v]+cost[v][u]);
}
}
}
int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
return *(int*)a - *(int*)b;
}
int binary_searchh(long long x,long long k[],int n){
int l=0;
int r=n;
while(r-l>=1){
int i=(l+r)/2;
if(k[i]==x)return i;
else if(k[i]<x)l=i+1;
else r=i;
}
return -1;
}
struct File {
int aa;
int bb;
File(const int& aa, const int& bb)
: aa(aa), bb(bb) {}
};
bool operator<(const File& a, const File& b)
{
// ファイル種別、ファイル名の順番で優先順位を付けて比較
return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long kaijo(long long x){
long long l=10*10*10*10*10*10*10*10*10+7;
long long sum=1;
for(int i=x;i>0;i--){
sum*=i;
if(sum>l){
sum%=l;
}
}
return sum;
}
template<class T>void chmin(T &a,T b){
if(a>b){
a=b;
}
}
//formerは前方のindex(自分自身を含んで良い)
template<class T>int former(const vector<T>&v,T x){
return upper_bound(v.begin(),v.end(),x)-v.begin()-1;
}
//latterは後方のindex(自分自身を含んで良い)
template<class T>int latter(const vector<T>&v,T x){
return lower_bound(v.begin(),v.end(),x)-v.begin();
}
struct UnionFind{
//par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである
vector<int>par;
//sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる
vector<int>sizes;
UnionFind(int n):par(n),sizes(n,1){
//最初は全てのデータiがグループiに存在するものとして初期化
for(int i=0;i<n;i++){
par[i]=i;
}
}
//データxが属する木の根を得る
int find(int x){
if(x==par[x]){
return x;
}
return par[x]=find(par[x]);
}
//2つのデータx,yが属する木をマージする
void unite(int x,int y){
//データの根ノードを得る
x=find(x);
y=find(y);
//もしすでに同じ木に属しているならマージの必要はない
if(x==y){
return;
}
//xの木がyの木よりも大きくなるようにする
if(sizes[x]<sizes[y]){
swap(x,y);
}
//xがyの親になるように連結する
par[y]=x;
sizes[x]+=sizes[y];
}
//2つのデータx,yが属する木が同じならtrueを返す
bool same(int x,int y){
return find(x)==find(y);
}
//データxが含まれる木の大きさを返す
int size(int x){
return sizes[find(x)];
}
};
//クラスカル法
//頂点a,bをつなぐコストcostの(無向)辺
struct Edge{
int a,b,cost;
//コストの大小で順序定義
bool operator<(const Edge& o)const{
return cost<o.cost;
}
};
//頂点数と辺集合の組として定義したグラフ
struct Graph{
int n;//頂点数
vector<Edge>es;//辺集合
//クラスカル法で無向最小全域木のコストの和を計算する
//グラフが非連結の時は最小全域森のコストの和になる
//使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
int kruskal(){
//コストが小さい順にソーと
sort(es.begin(),es.end());
UnionFind uf(n);
int min_cost=0;
for(int ei=0;ei<es.size();ei++){
Edge& e=es[ei];
if(!uf.same(e.a,e.b)){
//その辺によって2つの木が連結される
min_cost+=e.cost;
uf.unite(e.a,e.b);
}
}
return min_cost;
}
};
//標準入力からグラフを読み込む
Graph input_graph(){
Graph g;
int m;
cin>>g.n>>m;
for(int i=0;i<m;i++){
Edge e;
cin>>e.a>>e.b>>e.cost;
g.es.push_back(e);
}
return g;
}
long long labs(long long x){
if(x<0){
return -x;
}
return x;
}
struct edge{long long to,cost;};
const int limit=100010;
vector<edge>tree[limit];
long long depth[limit];
void dfs(int v,int p,long long d){
depth[v]=d;
for(auto &e:tree[v]){
if(e.to==p){
continue;
}
dfs(e.to,v,d+e.cost);
}
}
int main() {
long long n;
cin>>n;
for(int i=0;i<n-1;i++)
{
long long a,b,c;
cin>>a>>b>>c;
a--;
b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
long long q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
for(int i=0;i<q;i++){
long long x,y;
cin>>x>>y;
x--;
y--;
cout<<depth[x]+depth[y]<<endl;
}
}
| /tmp/ccDouQfs.o: in function `dijkstra(int)':
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x188): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x1c4): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x1f4): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x218): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccDouQfs.o
a.cc:(.text+0x25b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s659357629 | p03634 | C++ | #include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map>
#define ALL(a) (a).begin(),(a).end()
const long long INF = 1LL<<58;
const long long MOD=4*1e18;
using namespace std;
typedef long long ll;
struct point{
int x;
int y;
};
int gcd(int a, int b)
{
if(a>b){
return gcd(b,a);
}
return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
// 引数に0がある場合は0を返す
if ( ( 0 == m ) || ( 0 == n ) )
return 0;
return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
int x;
cin>>x;
return x;
}
int moji(char in)
{
int ans = (int)in-(int)'a';
if((ans < 0) || (ans > 25)){
ans = 26;
}
return ans;
}
const int VV=100000;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
fill(d,d+VV,100000);
fill(used,used+VV,false);
d[s]=0;
while(true){
cout<<"Hello"<<endl;
int v=-1;
for(int u=0;u<VV;u++){
if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
}
if(v==-1)break;
used[v]=true;
for(int u=0;u<VV;u++){
d[u]=min(d[u],d[v]+cost[v][u]);
}
}
}
int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
return *(int*)a - *(int*)b;
}
int binary_searchh(long long x,long long k[],int n){
int l=0;
int r=n;
while(r-l>=1){
int i=(l+r)/2;
if(k[i]==x)return i;
else if(k[i]<x)l=i+1;
else r=i;
}
return -1;
}
struct File {
int aa;
int bb;
File(const int& aa, const int& bb)
: aa(aa), bb(bb) {}
};
bool operator<(const File& a, const File& b)
{
// ファイル種別、ファイル名の順番で優先順位を付けて比較
return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long kaijo(long long x){
long long l=10*10*10*10*10*10*10*10*10+7;
long long sum=1;
for(int i=x;i>0;i--){
sum*=i;
if(sum>l){
sum%=l;
}
}
return sum;
}
template<class T>void chmin(T &a,T b){
if(a>b){
a=b;
}
}
//formerは前方のindex(自分自身を含んで良い)
template<class T>int former(const vector<T>&v,T x){
return upper_bound(v.begin(),v.end(),x)-v.begin()-1;
}
//latterは後方のindex(自分自身を含んで良い)
template<class T>int latter(const vector<T>&v,T x){
return lower_bound(v.begin(),v.end(),x)-v.begin();
}
struct UnionFind{
//par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである
vector<int>par;
//sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる
vector<int>sizes;
UnionFind(int n):par(n),sizes(n,1){
//最初は全てのデータiがグループiに存在するものとして初期化
for(int i=0;i<n;i++){
par[i]=i;
}
}
//データxが属する木の根を得る
int find(int x){
if(x==par[x]){
return x;
}
return par[x]=find(par[x]);
}
//2つのデータx,yが属する木をマージする
void unite(int x,int y){
//データの根ノードを得る
x=find(x);
y=find(y);
//もしすでに同じ木に属しているならマージの必要はない
if(x==y){
return;
}
//xの木がyの木よりも大きくなるようにする
if(sizes[x]<sizes[y]){
swap(x,y);
}
//xがyの親になるように連結する
par[y]=x;
sizes[x]+=sizes[y];
}
//2つのデータx,yが属する木が同じならtrueを返す
bool same(int x,int y){
return find(x)==find(y);
}
//データxが含まれる木の大きさを返す
int size(int x){
return sizes[find(x)];
}
};
//クラスカル法
//頂点a,bをつなぐコストcostの(無向)辺
struct Edge{
int a,b,cost;
//コストの大小で順序定義
bool operator<(const Edge& o)const{
return cost<o.cost;
}
};
//頂点数と辺集合の組として定義したグラフ
struct Graph{
int n;//頂点数
vector<Edge>es;//辺集合
//クラスカル法で無向最小全域木のコストの和を計算する
//グラフが非連結の時は最小全域森のコストの和になる
//使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
int kruskal(){
//コストが小さい順にソーと
sort(es.begin(),es.end());
UnionFind uf(n);
int min_cost=0;
for(int ei=0;ei<es.size();ei++){
Edge& e=es[ei];
if(!uf.same(e.a,e.b)){
//その辺によって2つの木が連結される
min_cost+=e.cost;
uf.unite(e.a,e.b);
}
}
return min_cost;
}
};
//標準入力からグラフを読み込む
Graph input_graph(){
Graph g;
int m;
cin>>g.n>>m;
for(int i=0;i<m;i++){
Edge e;
cin>>e.a>>e.b>>e.cost;
g.es.push_back(e);
}
return g;
}
long long labs(long long x){
if(x<0){
return -x;
}
return x;
}
struct edge{long long to,cost;};
const int limit=100010;
vector<edge>tree[limit];
long long depth[limit];
void dfs(int v,int p,long long d){
depth[v]=d;
for(auto &e:tree[v]){
if(e.to==p){
continue;
}
dfs(e.to,v,d+e.cost);
}
}
int main() {
long long n;
cin>>n;
for(int i=0;i<n-1;i++)
{
long long a,b,c;
cin>>a>>b>>c;
a--;
b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
long long q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
for(int i=0;i<q;i++){
long long x,y;
cin>>x>>y;
x--;
y--;
cout<<depth[x]+depth[y]<<endl;
}
}
| /tmp/ccMg2Mp5.o: in function `dijkstra(int)':
a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x10d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x11e): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x13a): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x188): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x1c4): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x1f4): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x218): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccMg2Mp5.o
a.cc:(.text+0x25b): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s048667477 | p03634 | C++ | #include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map>
#define ALL(a) (a).begin(),(a).end()
const long long INF = 1LL<<58;
const long long MOD=4*1e18;
using namespace std;
typedef long long ll;
struct point{
int x;
int y;
};
int gcd(int a, int b)
{
if(a>b){
return gcd(b,a);
}
return a == 0 ? b : gcd(b % a, a);
}
int lcm( int m, int n )
{
// 引数に0がある場合は0を返す
if ( ( 0 == m ) || ( 0 == n ) )
return 0;
return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
int x;
cin>>x;
return x;
}
int moji(char in)
{
int ans = (int)in-(int)'a';
if((ans < 0) || (ans > 25)){
ans = 26;
}
return ans;
}
const int VV=100000;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
fill(d,d+VV,100000);
fill(used,used+VV,false);
d[s]=0;
while(true){
cout<<"Hello"<<endl;
int v=-1;
for(int u=0;u<VV;u++){
if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
}
if(v==-1)break;
used[v]=true;
for(int u=0;u<VV;u++){
d[u]=min(d[u],d[v]+cost[v][u]);
}
}
}
int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
return *(int*)a - *(int*)b;
}
int binary_searchh(long long x,long long k[],int n){
int l=0;
int r=n;
while(r-l>=1){
int i=(l+r)/2;
if(k[i]==x)return i;
else if(k[i]<x)l=i+1;
else r=i;
}
return -1;
}
struct File {
int aa;
int bb;
File(const int& aa, const int& bb)
: aa(aa), bb(bb) {}
};
bool operator<(const File& a, const File& b)
{
// ファイル種別、ファイル名の順番で優先順位を付けて比較
return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}
long long kaijo(long long x){
long long l=10*10*10*10*10*10*10*10*10+7;
long long sum=1;
for(int i=x;i>0;i--){
sum*=i;
if(sum>l){
sum%=l;
}
}
return sum;
}
template<class T>void chmin(T &a,T b){
if(a>b){
a=b;
}
}
//formerは前方のindex(自分自身を含んで良い)
template<class T>int former(const vector<T>&v,T x){
return upper_bound(v.begin(),v.end(),x)-v.begin()-1;
}
//latterは後方のindex(自分自身を含んで良い)
template<class T>int latter(const vector<T>&v,T x){
return lower_bound(v.begin(),v.end(),x)-v.begin();
}
struct UnionFind{
//par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである
vector<int>par;
//sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる
vector<int>sizes;
UnionFind(int n):par(n),sizes(n,1){
//最初は全てのデータiがグループiに存在するものとして初期化
for(int i=0;i<n;i++){
par[i]=i;
}
}
//データxが属する木の根を得る
int find(int x){
if(x==par[x]){
return x;
}
return par[x]=find(par[x]);
}
//2つのデータx,yが属する木をマージする
void unite(int x,int y){
//データの根ノードを得る
x=find(x);
y=find(y);
//もしすでに同じ木に属しているならマージの必要はない
if(x==y){
return;
}
//xの木がyの木よりも大きくなるようにする
if(sizes[x]<sizes[y]){
swap(x,y);
}
//xがyの親になるように連結する
par[y]=x;
sizes[x]+=sizes[y];
}
//2つのデータx,yが属する木が同じならtrueを返す
bool same(int x,int y){
return find(x)==find(y);
}
//データxが含まれる木の大きさを返す
int size(int x){
return sizes[find(x)];
}
};
//クラスカル法
//頂点a,bをつなぐコストcostの(無向)辺
struct Edge{
int a,b,cost;
//コストの大小で順序定義
bool operator<(const Edge& o)const{
return cost<o.cost;
}
};
//頂点数と辺集合の組として定義したグラフ
struct Graph{
int n;//頂点数
vector<Edge>es;//辺集合
//クラスカル法で無向最小全域木のコストの和を計算する
//グラフが非連結の時は最小全域森のコストの和になる
//使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/
int kruskal(){
//コストが小さい順にソーと
sort(es.begin(),es.end());
UnionFind uf(n);
int min_cost=0;
for(int ei=0;ei<es.size();ei++){
Edge& e=es[ei];
if(!uf.same(e.a,e.b)){
//その辺によって2つの木が連結される
min_cost+=e.cost;
uf.unite(e.a,e.b);
}
}
return min_cost;
}
};
//標準入力からグラフを読み込む
Graph input_graph(){
Graph g;
int m;
cin>>g.n>>m;
for(int i=0;i<m;i++){
Edge e;
cin>>e.a>>e.b>>e.cost;
g.es.push_back(e);
}
return g;
}
long long labs(long long x){
if(x<0){
return -x;
}
return x;
}
using edge struct{int to; long long cost;};
const int limit=100010;
vector<edge>tree[limit];
long long depth[limit];
void dfs(int v,int p,long long d){
depth[v]=d;
for(auto &e:tree[v]){
if(e.to==p){
continue;
}
dfs(e.to,v,d+e.cost);
}
}
int main() {
int n;
cin>>n;
for(int i=0;i<n;i++)
{
int a,b,c;
cin>>a>>b>>c;
a--;
b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
int q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
for(int i=0;i<q;i++){
int x,y;
cin>>x>>y;
x--;
y--;
cout<<depth[x]+depth[y]<<endl;
}
}
| a.cc:239:7: error: expected nested-name-specifier before 'edge'
239 | using edge struct{int to; long long cost;};
| ^~~~
a.cc:241:8: error: 'edge' was not declared in this scope; did you mean 'Edge'?
241 | vector<edge>tree[limit];
| ^~~~
| Edge
a.cc:241:12: error: template argument 1 is invalid
241 | vector<edge>tree[limit];
| ^
a.cc:241:12: error: template argument 2 is invalid
a.cc: In function 'void dfs(int, int, long long int)':
a.cc:246:21: error: 'begin' was not declared in this scope; did you mean 'std::begin'?
246 | for(auto &e:tree[v]){
| ^
| std::begin
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here
114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
| ^~~~~
a.cc:246:21: error: 'end' was not declared in this scope; did you mean 'std::end'?
246 | for(auto &e:tree[v]){
| ^
| std::end
/usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here
116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
| ^~~
a.cc: In function 'int main()':
a.cc:264:13: error: request for member 'push_back' in 'tree[a]', which is of non-class type 'int'
264 | tree[a].push_back({b,c});
| ^~~~~~~~~
a.cc:265:13: error: request for member 'push_back' in 'tree[b]', which is of non-class type 'int'
265 | tree[b].push_back({a,c});
| ^~~~~~~~~
|
s195849976 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
#define incant() cin.tie(0), ios::sync_with_stdio(false)
#define int long long
#define uint unsigned long long
#define double long double
using str = string;
template <class T> using vec = vector<T>;
template <class T> using vvec = vec<vec<T>>;
template <class T> using que = queue<T>;
template <class T> using pque = priority_queue<T>;
template <class... T> using tup = tuple<T...>;
using vint = vec<int>;
using vvint = vvec<int>;
using vstr = vec<str>;
using pint = pair<int, int>;
using vp = vec<pint>;
using tll = tup<int, int, int>;
using vt = vec<tll>;
using mint = map<int, int>;
using dict = map<str, int>;
using qint = que<int>;
using qp = que<pint>;
using pqint = pque<int>;
using pqp = pque<pint>;
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define mt make_tuple
#define fir first
#define sec second
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define sz(x) x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define ms(v, x) memset(v, x, sizeof v)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload3(__VA_ARGS__, revi, _rev,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) out(x), indent()
#define debug(x) cerr << __LINE__ << ": " << #x << ": " << (x) << '\n'
#define YN(x) print((x) ? "YES" : "NO")
#define Yn(x) print((x) ? "Yes" : "No")
#define yn(x) print((x) ? "yes" : "no")
#define POS(x) print((x) ? "POSSIBLE" : "IMPOSSIBLE")
#define Pos(x) print((x) ? "Possible" : "Impossible")
#define pos(x) print((x) ? "possible" : "impossible")
const int INF = 1e16, MOD = 1e9 + 7, LIMIT = 100001;
const int dx4[] = {-1, 0, 1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
const double EPS = 1e-9;
int gcd(int a, int b){return b == 0 ? a : gcd(b, a % b);}
int lcm(int a, int b){return a / gcd(a, b) * b;}
int factorial(int a){return a < 2 ? 1 : factorial(a - 1) * a;}
int summation(int a){return a < 1 ? 0 : (a * a + a) / 2;}
int combination(int n, int r) {int res = 1; rep(i, 1, r + 1) res *= n--, res /= i; return res;}
const str alphabet = "abcdefghijklmnopqrstuvwxyz";
int a, b, c, n, m, x, y, z, w, h, res = 0, cnt = 0, mx = -INF, mn = INF;
str s, t;
bool flag = true;
signed main(){
incant();
print();
}
| a.cc: In function 'int main()':
a.cc:48:26: error: expected primary-expression before ')' token
48 | #define out(x) cout << (x)
| ^
a.cc:50:18: note: in expansion of macro 'out'
50 | #define print(x) out(x), indent()
| ^~~
a.cc:75:5: note: in expansion of macro 'print'
75 | print();
| ^~~~~
|
s768091402 | p03634 | C++ | #include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#define MAX_V 100010
#define INF 10000000100
int N, Q, K;
long d[MAX_V];
long cost[MAX_V][MAX_V];
bool used[MAX_V];
void dijkstra(int s) {
std::fill(d, d+N, INF);
std::fill(used, used+N, false);
d[s] = 0;
while (true) {
int v = -1;
for (int u=0; u<N; ++u) {
if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
}
if (v == -1) break;
used[v] = true;
for (int u=0; u<N; ++u) {
d[u] = std::min(d[u], d[v] + cost[v][u]);
}
}
/*
std::cout << "\nDebug : ";
for (int i=0; i<N; ++i) std::cout << d[i] << ' ';
std::cout << std::endl;
*/
}
long solve(int x, int y) {
return d[x] + d[y];
}
int main() {
std::cin >> N;
for (int i=0; i<N; ++i) {
for (int j=0; j<N; ++j) {
cost[i][j] = INF;
if (i == j) cost[i][j] = 0;
}
}
for (int i=0; i<N-1; ++i) {
int from, to;
long w;
std::cin >> from >> to >> w;
--from; --to;
cost[from][ to ] = w;
cost[ to ][from] = w;
}
std::cin >> Q >> K;
dijkstra(K-1);
for (int i=0; i<Q; ++i) {
int x, y;
std::cin >> x >> y;
--x; --y;
std::cout << solve(x, y) << std::endl;
}
return 0;
} | /tmp/cc0SDrcX.o: in function `dijkstra(int)':
a.cc:(.text+0x5c): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc0SDrcX.o
collect2: error: ld returned 1 exit status
|
s935456466 | p03634 | C++ | #include "pch.h"
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <limits>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
template< typename T >
struct edge {
int src, to;
T cost;
edge(int to, T cost) : src(-1), to(to), cost(cost) {}
edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
edge &operator=(const int &x) {
to = x;
return *this;
}
operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
template< typename T >
vector< T > dijkstra(WeightedGraph< T > &g, int s) {
const auto INF = numeric_limits< T >::max();
vector< T > dist(g.size(), INF);
using Pi = pair< T, int >;
priority_queue< Pi, vector< Pi >, greater< Pi > > que;
dist[s] = 0;
que.emplace(dist[s], s);
while (!que.empty()) {
T cost;
int idx;
tie(cost, idx) = que.top();
que.pop();
if (dist[idx] < cost) continue;
for (auto &e : g[idx]) {
auto next_cost = cost + e.cost;
if (dist[e.to] <= next_cost) continue;
dist[e.to] = next_cost;
que.emplace(dist[e.to], e.to);
}
}
return dist;
}
int main() {
int V, E;
cin >> V;
E = V - 1;
WeightedGraph< int > g(V);
vector<int> x(E);
vector<int> y(E);
vector<int> z(E);
for (int i = 0; i < E; i++) {
cin >> x[i] >> y[i] >> z[i];
//1indexedなら--して
x[i]--; y[i]--;
g[x[i]].emplace_back(y[i], z[i]);
g[y[i]].emplace_back(x[i], z[i]);
}
int q, k; cin >> q >> k;
k--;
auto dist=dijkstra(g,k);
for (int i = 0; i < q; i++) {
int x, y; cin >> x >> y;
x--; y--;
cout << dist[x] + dist[y] << endl;
}
//dist == numeric_limits< int >::max()
//for (auto &dist : dijkstra(g, R)) {
//}
} | a.cc:1:10: fatal error: pch.h: No such file or directory
1 | #include "pch.h"
| ^~~~~~~
compilation terminated.
|
s008362589 | p03634 | C++ |
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18
const int limit = 100010;
using edge = struct { int to; LL cost; };
vector<edge> tree[limit];
LL depth[limit];
void dfs(int pos, int par, int d) {
depth[pos] = d;
for (auto e : tree[pos]) {
if (e.to == par)continue;
dfs(e.to, pos, d + e.cost);
}
}
int main() {
int n; cin >> n;
for (int i = 0; i < n-1; i++) {
int a, b, c; cin >> a >> b >> c;
a--; b--;
tree[a].emplace_back(b, c);
tree[b].emplace_back(a, c);
}
int q, k; cin >> q >> k;
k--;
dfs(k, -1, 0);
for (int i = 0; i < q; i++) {
int x, y; cin >> x >> y;
x--; y--;
cout << depth[x] + depth[y] << endl;
}
return 0;
} | In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33,
from /usr/include/c++/14/bits/allocator.h:46,
from /usr/include/c++/14/vector:63,
from a.cc:4:
/usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = <unnamed struct>; _Args = {int&, int&}; _Tp = <unnamed struct>]':
/usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_Tp1> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = <unnamed struct>; _Args = {int&, int&}; _Tp = <unnamed struct>; allocator_type = std::allocator<<unnamed struct> >]'
575 | __a.construct(__p, std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:117:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int&, int&}; _Tp = <unnamed struct>; _Alloc = std::allocator<<unnamed struct> >; reference = <unnamed struct>&]'
117 | _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish,
| ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
118 | std::forward<_Args>(__args)...);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:95:23: required from here
95 | tree[a].emplace_back(b, c);
| ~~~~~~~~~~~~~~~~~~~~^~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: new initializer expression list treated as compound expression [-fpermissive]
191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to '<unnamed struct>::._anon_105(int&)'
a.cc:72:21: note: candidate: '<unnamed struct>::<constructor>()'
72 | using edge = struct { int to; LL cost; };
| ^
a.cc:72:21: note: candidate expects 0 arguments, 1 provided
a.cc:72:21: note: candidate: 'constexpr<unnamed struct>::<constructor>(const<unnamed struct>&)'
a.cc:72:21: note: no known conversion for argument 1 from 'int' to 'const<unnamed struct>&'
a.cc:72:21: note: candidate: 'constexpr<unnamed struct>::<constructor>(<unnamed struct>&&)'
a.cc:72:21: note: no known conversion for argument 1 from 'int' to '<unnamed struct>&&'
|
s176804087 | p03634 | C++ | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;
//input sample
//5
//0 3 2 3 3 1 1 2
//1 2 0 2 3 4
//2 3 0 3 3 1 4 1
//3 4 2 1 0 1 1 4 4 3
//4 2 2 1 3 3
//output sample
//shortest cost of each node
//0 0
//1 2
//2 2
//3 1
//4 3
//parent id of each node
//0 - 1
//1 0
//2 3
//3 0
//4 2
static const int MAX = 100000;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
vector<pair<int, int>> adj[MAX];
ll pre[MAX];
ll p[MAX];
ll d[MAX];
ll color[MAX];
priority_queue<pair<int, int>>PQ;
ll n;
void dijkstra(int s) {
repe(i, 1, n) {
d[i] = INF;
pre[i] = INF;
color[i] = WHITE;
}
d[s] = 0;
p[s] = -1;
PQ.push(make_pair(s, s)); // ?reverse?
color[s] = GRAY;
while (!PQ.empty()) {
pair<ll, ll> f = PQ.top(); PQ.pop();
ll u = f.second;
color[u] = BLACK;
if (d[u] < f.first * (-1)) continue;
rep(j, 0, adj[u].size()) {
ll v = adj[u][j].first;
if (color[v] == BLACK) continue;
if (d[v] > d[u] + adj[u][j].second) {
d[v] = d[u] + adj[u][j].second;
PQ.push(make_pair(d[v] * (-1), v));
p[v] = u;
color[v] = GRAY;
}
}
}
//rep(i, 0, n) cout << i << " " << (d[i] == INF ? -1 : d[i]) << endl;
//rep(i, 0, n) cout << i << " " << (p[i] == INF ? -1 : p[i]) << endl;
}
vector<int> get_path(int t) {
vector<int> path;
for (; t != -1; t = p[t])path.push_back(t);
reverse(path.begin(), path.end());
return path;
}
int main()
{
cin >> n;
rep(i, 0, n - 1) {
ll a, b, c; cin >> a >> b >> c;
adj[a].push_back(make_pair(b, c));
adj[b].push_back(make_pair(a, c));
}
ll q, k; cin >> q >> k;
dijkstra(k);
rep(i, 0, q) {
ll x, y; cin >> x >> y;
cout << d[x] + d[y] << endl;
}
//int k, u, v, c;
//cin >> n;
//rep(i, 0, n) {
// cin >> u >> k;
// rep(j, 0, k) {
// cin >> v >> c;
// adj[u].push_back(make_pair(v, c));
// }
//}
//dijkstra(0);
//pass start index;
return 0;
} | a.cc: In function 'std::vector<int> get_path(int)':
a.cc:82:9: error: 'reverse' was not declared in this scope
82 | reverse(path.begin(), path.end());
| ^~~~~~~
|
s066570741 | p03634 | C++ | (eval-when (:compile-toplevel :load-toplevel :execute)
(defparameter OPT
#+swank '(optimize (speed 3) (safety 2))
#-swank '(optimize (speed 3) (safety 0) (debug 0)))
#+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
(shadow :run)
(use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
;; BEGIN_INSERTED_CONTENTS
(defmacro nlet (name args &body body)
(labels ((ensure-list (x) (if (listp x) x (list x))))
(let ((args (mapcar #'ensure-list args)))
`(labels ((,name ,(mapcar #'car args) ,@body))
(,name ,@(mapcar #'cadr args))))))
;; (with-memoizing (:hash-table :test #'equal :key #'cons)
;; (defun ...))
;; (with-memoizing (:array (10 10 * 10) :initial-element -1 :element-type 'fixnum)
;; (defun ...))
(defmacro with-memoizing (cache-attribs def-form)
(let* ((cache-attribs (if (atom cache-attribs) (list cache-attribs) cache-attribs))
(cache-type (first cache-attribs))
(dimensions-with-* (when (eql cache-type :array) (second cache-attribs)))
(dimensions (remove '* dimensions-with-*))
(rank (length dimensions))
(rest-attribs (ecase cache-type
(:hash-table (cdr cache-attribs))
(:array (cddr cache-attribs))))
(key (prog1 (getf rest-attribs :key) (remf rest-attribs :key)))
(cache-form (case cache-type
(:hash-table `(make-hash-table ,@rest-attribs))
(:array `(make-array ',dimensions ,@rest-attribs))))
(initial-element (when (eql cache-type :array)
(assert (member :initial-element rest-attribs))
(getf rest-attribs :initial-element))))
(let ((cache (gensym))
(value (gensym))
(present-p (gensym))
(name-alias (gensym))
(args-lst (gensym))
(indices (loop repeat rank collect (gensym))))
(labels ((make-cache-check-form (cache-type args)
(case cache-type
(:hash-table
`(let ((,args-lst (funcall ,(or key #'list) ,@args)))
(multiple-value-bind (,value ,present-p)
(gethash ,args-lst ,cache)
(if ,present-p
,value
(setf (gethash ,args-lst ,cache)
(,name-alias ,@args))))))
(:array
(let ((memoized-args (loop for dimension in dimensions-with-*
for arg in args
unless (eql dimension '*)
collect arg)))
(if key
`(multiple-value-bind ,indices
(funcall ,key ,@memoized-args)
(let ((,value (aref ,cache ,@indices)))
(if (eql ,initial-element ,value)
(setf (aref ,cache ,@indices)
(,name-alias ,@args))
,value)))
`(let ((,value (aref ,cache ,@memoized-args)))
(if (eql ,initial-element ,value)
(setf (aref ,cache ,@memoized-args)
(,name-alias ,@args))
,value)))))))
(make-reset-form (cache-type)
(case cache-type
(:hash-table `(setf ,cache (make-hash-table ,@rest-attribs)))
(:array `(prog1 nil
(fill (array-storage-vector ,cache) ,initial-element)))))
(make-reset-name (name)
(intern (format nil "RESET-~A" (symbol-name name))))
(extract-declarations (body)
(remove-if-not (lambda (form) (eql 'declare (car form))) body)))
(ecase (car def-form)
((defun)
(destructuring-bind (_ name args &body body) def-form
(declare (ignore _))
`(let ((,cache ,cache-form))
(defun ,(make-reset-name name) () ,(make-reset-form cache-type))
(defun ,name ,args
(labels ((,name-alias ,args ,@body))
(declare (inline ,name-alias))
,@(extract-declarations body)
,(make-cache-check-form cache-type args))))))
((nlet)
(destructuring-bind (_ name bindings &body body) def-form
(declare (ignore _))
`(let ((,cache ,cache-form))
(nlet ,name ,bindings
,(let ((args (mapcar (lambda (x) (if (atom x) x (car x))) bindings)))
`(labels ((,name-alias ,args ,@body))
(declare (inline ,name-alias))
,@(extract-declarations body)
,(make-cache-check-form cache-type args)))))))
((labels flet)
(destructuring-bind (_ definitions &body labels-body) def-form
(declare (ignore _))
(destructuring-bind (name args &body body) (car definitions)
`(let ((,cache ,cache-form))
(,(car def-form)
((,(make-reset-name name) () ,(make-reset-form cache-type))
(,name ,args
(labels ((,name-alias ,args ,@body))
(declare (inline ,name-alias))
,@(extract-declarations body)
,(make-cache-check-form cache-type args)))
,@(cdr definitions))
(declare (ignorable #',(make-reset-name name)))
,@labels-body))))))))))
;; (test with-memoizing
;; (finishes (macroexpand `(with-memoizing (:hash-table :test #'equal)
;; (defun add (x y) (+ x y)))))
;; (finishes (macroexpand `(with-memoizing (:array '(10 10)
;; :element-type 'fixnum
;; :initial-element -1)
;; (defun add (x y) (+ x y)))))
;; (finishes (macroexpand `(with-memoizing (:array '(10 10)
;; :element-type 'fixnum
;; :initial-element -1)
;; (labels ((add (x y) (+ x y))
;; (my-print (x) (print x)))
;; (add 1 2))))))
(defmacro buffered-read-line (&optional (buffer-size 30) (in '*standard-input*) (terminate-char #\Space))
"Note that the returned string will be reused."
(let ((buffer (gensym))
(character (gensym))
(idx (gensym)))
`(let ((,buffer (load-time-value (make-string ,buffer-size
:element-type 'base-char))))
(declare (simple-base-string ,buffer))
(loop for ,character of-type base-char =
#-swank (code-char (read-byte ,in nil #.(char-code #\Newline)))
#+swank (read-char ,in nil #\Newline)
for ,idx from 0
until (char= ,character #\Newline)
do (setf (schar ,buffer ,idx) ,character)
finally (setf (schar ,buffer ,idx) ,terminate-char)
(return (values ,buffer ,idx))))))
(defmacro split-ints-and-bind (vars string &body body)
(let ((pos1 (gensym "POS"))
(pos2 (gensym "POS"))
(str (gensym "STR")))
(labels ((expand (vars &optional (init-pos1 t))
(if (null vars)
body
`((let* ((,pos1 ,(if init-pos1 0 `(1+ ,pos2)))
(,pos2 (position #\space ,str :start ,pos1 :test #'char=))
(,(car vars) (parse-integer ,str :start ,pos1 :end ,pos2)))
,@(expand (cdr vars) nil))))))
`(let ((,str ,string))
(declare (string ,str))
,@(expand vars)))))
(defmacro define-int-types (&rest bits)
`(progn
,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)
(defmacro println (obj &optional (stream '*standard-output*))
`(let ((*read-default-float-format* 'double-float))
(prog1 (princ ,obj ,stream) (terpri ,stream))))
(defconstant +mod+ 1000000007)
;; Hauptteil
(defun main ()
(declare #.OPT)
(let* ((n (read))
(graph (make-array n :element-type 'list :initial-element nil))
(tree (make-array n :element-type 'list :initial-element nil)))
(dotimes (i (- n 1))
(split-ints-and-bind (a b c) (buffered-read-line)
(declare (uint32 a b c))
(push (cons (- b 1) c) (aref graph (- a 1)))
(push (cons (- a 1) c) (aref graph (- b 1)))))
(let ((q (read))
(k (- (read) 1)))
(declare (uint32 k q))
(nlet recurse ((i k) (prev -1))
(declare (fixnum i prev))
(loop for (next . cost) of-type (uint32 . uint32) in (aref graph i)
do (unless (= next prev)
(push (cons i cost) (aref tree next))
(recurse next i))))
(with-memoizing (:array (100001) :element-type 'fixnum :initial-element -1)
(labels ((cost-k (i)
(cond ((= i k) 0)
((null (aref tree i)) #.(expt 10 15))
(t (loop for (next . cost) of-type (uint32 . uint32) in (aref tree i)
minimize (+ cost (cost-k next))
of-type fixnum)))))
(dotimes (i q)
(split-ints-and-bind (x y) (buffered-read-line 20)
(declare (uint32 x y))
(println (the fixnum (+ (cost-k (- x 1))
(cost-k (- y 1))))))))))))
#-swank(main)
| a.cc:3:6: error: invalid preprocessing directive #+
3 | #+swank '(optimize (speed 3) (safety 2))
| ^
a.cc:3:13: warning: missing terminating ' character
3 | #+swank '(optimize (speed 3) (safety 2))
| ^
a.cc:4:6: error: invalid preprocessing directive #-
4 | #-swank '(optimize (speed 3) (safety 0) (debug 0)))
| ^
a.cc:4:13: warning: missing terminating ' character
4 | #-swank '(optimize (speed 3) (safety 0) (debug 0)))
| ^
a.cc:5:4: error: invalid preprocessing directive #+
5 | #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
| ^
a.cc:5:32: warning: missing terminating ' character
5 | #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
| ^
a.cc:8:2: error: invalid preprocessing directive #+
8 | #+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
| ^
a.cc:13:25: error: stray '#' in program
13 | (let ((args (mapcar #'ensure-list args)))
| ^
a.cc:13:26: warning: missing terminating ' character
13 | (let ((args (mapcar #'ensure-list args)))
| ^
a.cc:13:26: error: missing terminating ' character
13 | (let ((args (mapcar #'ensure-list args)))
| ^~~~~~~~~~~~~~~~~~~~
a.cc:14:7: error: stray '`' in program
14 | `(labels ((,name ,(mapcar #'car args) ,@body))
| ^
a.cc:14:33: error: stray '#' in program
14 | `(labels ((,name ,(mapcar #'car args) ,@body))
| ^
a.cc:14:34: warning: missing terminating ' character
14 | `(labels ((,name ,(mapcar #'car args) ,@body))
| ^
a.cc:14:34: error: missing terminating ' character
14 | `(labels ((,name ,(mapcar #'car args) ,@body))
| ^~~~~~~~~~~~~~~~~~~
a.cc:15:18: error: stray '@' in program
15 | (,name ,@(mapcar #'cadr args))))))
| ^
a.cc:15:27: error: stray '#' in program
15 | (,name ,@(mapcar #'cadr args))))))
| ^
a.cc:15:28: warning: missing terminating ' character
15 | (,name ,@(mapcar #'cadr args))))))
| ^
a.cc:15:28: error: missing terminating ' character
15 | (,name ,@(mapcar #'cadr args))))))
| ^~~~~~~~~~~~~~~~
a.cc:17:39: error: stray '#' in program
17 | ;; (with-memoizing (:hash-table :test #'equal :key #'cons)
| ^
a.cc:17:40: warning: multi-character literal with 12 characters exceeds 'int' size of 4 bytes
17 | ;; (with-memoizing (:hash-table :test #'equal :key #'cons)
| ^~~~~~~~~~~~~~~~~~
a.cc:19:75: warning: missing terminating ' character
19 | ;; (with-memoizing (:array (10 10 * 10) :initial-element -1 :element-type 'fixnum)
| ^
a.cc:19:75: error: missing terminating ' character
19 | ;; (with-memoizing (:array (10 10 * 10) :initial-element -1 :element-type 'fixnum)
| ^~~~~~~~
a.cc:25:30: warning: missing terminating ' character
25 | (dimensions (remove '* dimensions-with-*))
| ^
a.cc:25:30: error: missing terminating ' character
25 | (dimensions (remove '* dimensions-with-*))
| ^~~~~~~~~~~~~~~~~~~~~~
a.cc:32:37: error: stray '`' in program
32 | (:hash-table `(make-hash-table ,@rest-attribs))
| ^
a.cc:32:56: error: stray '@' in program
32 | (:hash-table `(make-hash-table ,@rest-attribs))
| ^
a.cc:33:32: error: stray '`' in program
33 | (:array `(make-array ',dimensions ,@rest-attribs))))
| ^
a.cc:33:45: warning: missing terminating ' character
33 | (:array `(make-array ',dimensions ,@rest-attribs))))
| ^
a.cc:33:45: error: missing terminating ' character
33 | (:array `(make-array ',dimensions ,@rest-attribs))))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:46:21: error: stray '`' in program
46 | `(let ((,args-lst (funcall ,(or key #'list) ,@args)))
| ^
a.cc:46:57: error: stray '#' in program
46 | `(let ((,args-lst (funcall ,(or key #'list) ,@args)))
| ^
a.cc:46:58: warning: missing terminating ' character
46 | `(let ((,args-lst (funcall ,(or key #'list) ,@args)))
| ^
a.cc:46:58: error: missing terminating ' character
46 | `(let ((,args-lst (funcall ,(or key #'list) ,@args)))
| ^~~~~~~~~~~~~~~~
a.cc:52:50: error: stray '@' in program
52 | (,name-alias ,@args))))))
| ^
a.cc:56:70: warning: missing terminating ' character
56 | unless (eql dimension '*)
| ^
a.cc:56:70: error: missing terminating ' character
56 | unless (eql dimension '*)
| ^~~
a.cc:59:27: error: stray '`' in program
59 | `(multiple-value-bind ,indices
| ^
a.cc:60:47: error: stray '@' in program
60 | (funcall ,key ,@memoized-args)
| ^
a.cc:61:58: error: stray '@' in program
61 | (let ((,value (aref ,cache ,@indices)))
| ^
a.cc:63:56: error: stray '@' in program
63 | (setf (aref ,cache ,@indices)
| ^
a.cc:64:56: error: stray '@' in program
64 | (,name-alias ,@args))
| ^
a.cc:66:27: error: stray '`' in program
66 | `(let ((,value (aref ,cache ,@memoized-args)))
| ^
a.cc:66:56: error: stray '@' in program
66 | `(let ((,value (aref ,cache ,@memoized-args)))
| ^
a.cc:68:54: error: stray '@' in program
68 | (setf (aref ,cache ,@memoized-args)
| ^
a.cc:69:54: error: stray '@' in program
69 | (,name-alias ,@args))
| ^
a.cc:73:33: error: stray '`' in program
73 | (:hash-table `(setf ,cache (make-hash-table ,@rest-attribs)))
| ^
a.cc:73:65: error: stray '@' in program
73 | (:hash-table `(setf ,cache (make-hash-table ,@rest-attribs)))
| ^
a.cc:74:28: error: stray '`' in program
74 | (:array `(prog1 nil
| ^
a.cc:79:53: warning: missing terminating ' character
79 | (remove-if-not (lambda (form) (eql 'declare (car form))) body)))
| ^
a.cc:79:53: error: missing terminating ' character
79 | (remove-if-not (lambda (form) (eql 'declare (car form))) body)))
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:84:14: error: stray '`' in program
84 | `(let ((,cache ,cache-form))
| ^
a.cc:87:48: error: stray '@' in program
87 | (labels ((,name-alias ,args ,@body))
| ^
a.cc:89:22: error: stray '@' in program
89 | ,@(extract-declarations body)
| ^
a.cc:94:14: error: stray '`' in program
94 | `(let ((,cache ,cache-form))
| ^
a.cc:97:26: error: stray '`' in program
97 | `(labels ((,name-alias ,args ,@body))
| ^
a.cc:97:56: error: stray '@' in program
97 | `(labels ((,name-alias ,args ,@body))
| ^
a.cc:99:30: error: stray '@' in program
99 | ,@(extract-declarations body)
| ^
a.cc:105:16: error: stray '`' in program
105 | `(let ((,cache ,cache-form))
| ^
a.cc:109:57: error: stray '@' in program
109 | (labels ((,name-alias ,args ,@body))
| ^
a.cc:111:31: error: stray '@' in program
111 | ,@(extract-declarations body)
| ^
a.cc:113:22: error: stray '@' in program
113 | ,@(cdr definitions))
| ^
a.cc:114:40: error: stray '#' in program
114 | (declare (ignorable #',(make-reset-name name)))
| ^
a.cc:114:41: warning: missing terminating ' character
114 | (declare (ignorable #',(ma |
s144567655 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int limit = 100010;
using edge = struct {
int to;
ll cost;
depth[v] = d;
for (auto &e : tree[v]) {
if (e.to == p) continue;
dfs(e.to, v, d + e.cost);
}
}
int main(void) {
int n;
cin >> n;
for (int i = 0; i < n - 1; ++i) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
tree[a].push_back({b, c});
tree[b].push_back({a, c});
}
int q, k;
cin >> q >> k;
k--;
dfs(k, -1, 0);
for (int i = 0; i < q; ++i) {
int x, y;
cin >> x >> y;
x--, y--;
cout << depth[x] + depth[y] << endl;
}
return 0;
}
| a.cc:8:3: error: 'depth' does not name a type
8 | depth[v] = d;
| ^~~~~
a.cc:9:3: error: expected unqualified-id before 'for'
9 | for (auto &e : tree[v]) {
| ^~~
a.cc:13:2: error: expected ';' after struct definition
13 | }
| ^
| ;
a.cc: In function 'int main()':
a.cc:21:5: error: 'tree' was not declared in this scope; did you mean 'free'?
21 | tree[a].push_back({b, c});
| ^~~~
| free
a.cc:27:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
27 | dfs(k, -1, 0);
| ^~~
| ffs
a.cc:32:13: error: 'depth' was not declared in this scope
32 | cout << depth[x] + depth[y] << endl;
| ^~~~~
|
s568895002 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,q,k;
long long total=0;
int kyori[100001][100001];
long long cost[100001];
vector<int> node[100001];
bool edge[100001];
void dfs(int e){
edge[e]=true;
for(auto i:node[e]){
if(!edge[i]){
total+=kyori[e][i];
cost[i]=total;
dfs(i);
total-=kyori[e][i];
}
}
}
int main(){
cin>>n;
for(int i=0;i<n-1;i++){
int a,b,c;
cin>>a>>b>>c;
a--,b--;
node[a].push_back(b);
node[b].push_back(a);
kyori[a][b]=c;
kyori[b][a]=c;
}
cin>>q>>k;
k--;
cost[k]=0;
dfs(k);
for(int i=0;i<q;i++){
int x,y;
cin>>x>>y;
x--,y--;
cout<<cost[x]+cost[y]<<endl;
}
} | /tmp/cccofs0e.o: in function `dfs(int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
/tmp/cccofs0e.o: in function `main':
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x212): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x2e4): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x353): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x36b): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/cccofs0e.o
/tmp/cccofs0e.o: in function `__tcf_0':
a.cc:(.text+0x3c4): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/cccofs0e.o
a.cc:(.text+0x3cb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s750545607 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,q,k;
ll total;
int kyori[100001][100001];
ll cost[100001];
vector<int> node[100001];
bool edge[100001];
void dfs(int e){
edge[e]=true;
for(auto i:node[e]){
if(!edge[i]){
total+=kyori[e][i];
cost[i]=total;
dfs(i);
total-=kyori[e][i];
}
}
}
int main(){
cin>>n;
for(int i=0;i<n-1;i++){
int a,b,c;
cin>>a>>b>>c;
a--,b--;
node[a].push_back(b);
node[b].push_back(a);
kyori[a][b]=c;
kyori[b][a]=c;
}
cin>>q>>k;
k--;
cost[k]=0;
dfs(k);
for(int i=0;i<k;i++){
int x,y;
cin>>x>>y;
x--,y--;
cout<<cost[x]+cost[y]<<endl;
}
} | /tmp/ccSPwqcw.o: in function `dfs(int)':
a.cc:(.text+0x13): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x31): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x7a): relocation truncated to fit: R_X86_64_PC32 against symbol `edge' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
/tmp/ccSPwqcw.o: in function `main':
a.cc:(.text+0x1e6): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x212): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x2e4): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x353): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x36b): relocation truncated to fit: R_X86_64_PC32 against symbol `cost' defined in .bss section in /tmp/ccSPwqcw.o
/tmp/ccSPwqcw.o: in function `__tcf_0':
a.cc:(.text+0x3c4): relocation truncated to fit: R_X86_64_PC32 against symbol `node' defined in .bss section in /tmp/ccSPwqcw.o
a.cc:(.text+0x3cb): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s858066790 | p03634 | C++ | #include<bits/stdc++.h>
using ll = long long;
const int limit = 100010;
using edge = struct {
int to; //行先
ll cost; //距離
};
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v, int p, ll d) { //v:行先,p:ひとつ前,d:累積距離
depth[v] = d;
for (auto &e : tree[v]) {
if (e.to == p) continue; //逆戻り不可
dfs(e.to, v, d + e.cost); //次の行き先,現在地,累積距離
}
}
int main(void) {
int n;
cin >> n;
for (int i = 0; i < n - 1; ++i) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
tree[a].push_back({b, c}); //aからbへの距離
tree[b].push_back({a, c}); //bからaへの距離
}
int q, k;
cin >> q >> k;
k--;
dfs(k, -1, 0); //kから各方面への距離
for (int i = 0; i < q; ++i) {
int x, y;
cin >> x >> y;
x--, y--;
cout << depth[x] + depth[y] << endl;
}
return 0;
}
/*
5
1 2 1
1 3 1
2 4 1
3 5 1
3 1
2 4
2 3
4 5
tree[0]=(1,1),(2,1)
tree[1]=(0,1),(3,1)
tree[2]=(0,1),(4,1)
tree[3]=(1,1)
tree[4]=(2,1)
dfs(0,-1,0){
depth[0]=0
dfs(1,0,0+1){
depth[1]=1
dfs(3,1,1+1){
depth[3]=2
}
}
dfs(2,0,0+1){
depth[2]=1
dfs(4,2,1+1){
depth[4]=2
}
}
}
*/ | a.cc:8:1: error: 'vector' does not name a type
8 | vector<edge> tree[limit];
| ^~~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:12:18: error: 'tree' was not declared in this scope; did you mean 'free'?
12 | for (auto &e : tree[v]) {
| ^~~~
| free
a.cc: In function 'int main()':
a.cc:19:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
19 | cin >> n;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:24:5: error: 'tree' was not declared in this scope; did you mean 'free'?
24 | tree[a].push_back({b, c}); //aからbへの距離
| ^~~~
| free
a.cc:35:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
35 | cout << depth[x] + depth[y] << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:35:36: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
35 | cout << depth[x] + depth[y] << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s709379322 | p03634 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
bool visited[100005];
ll c, graph[100005][100005], value[100005];
void dfs(int v) {
visited[v] = true;
for (int i = 0; i < 100005; i++) {
if (graph[v][i] > 0 && visited[i] == false) {
value[i] = graph[v][i] + value[v];
dfs(i);
}
}
}
int main() {
int n, a, b, q, k, x, y;
cin >> n;
fill(graph[0], graph[n], 0);
fill(visited, visited+n, false);
for (int i = 0; i < n-1; i++) {
cin >> a >> b >> c;
graph[a][b] = c;
graph[b][a] = c;
}
cin >> q >> k;
value[k] = 0;
dfs(k);
for (int i = 0; i < q; i++) {
cin >> x >> y;
cout << value[x] + value[y] << endl;
}
return 0;
} | /tmp/ccVgRM1N.o: in function `dfs(int)':
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
/tmp/ccVgRM1N.o: in function `main':
a.cc:(.text+0x25c): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
a.cc:(.text+0x2b6): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
a.cc:(.text+0x2ce): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccVgRM1N.o
collect2: error: ld returned 1 exit status
|
s176623885 | p03634 | C | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
bool visited[100005];
ll c, graph[100005][100005], value[100005];
void dfs(int v) {
visited[v] = true;
for (int i = 0; i < 100005; i++) {
if (graph[v][i] > 0 && visited[i] == false) {
value[i] = graph[v][i] + value[v];
dfs(i);
}
}
}
int main() {
int n, a, b, q, k, x, y;
cin >> n;
fill(graph[0], graph[n], 0);
fill(visited, visited+n, false);
for (int i = 0; i < n-1; i++) {
cin >> a >> b >> c;
graph[a][b] = c;
graph[b][a] = c;
}
cin >> q >> k;
value[k] = 0;
dfs(k);
for (int i = 0; i < q; i++) {
cin >> x >> y;
cout << value[x] + value[y] << endl;
}
return 0;
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s245896167 | p03634 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
bool visited[100005];
ll c, graph[100005][100005], value[100005];
void dfs(int v) {
visited[v] = true;
for (int i = 0; i < 100005; i++) {
if (graph[v][i] > 0 && visited[i] == false) {
value[i] = graph[v][i] + value[v];
dfs(i);
}
}
}
int main() {
int n, a, b, q, k, x, y;
cin >> n;
fill(graph[0], graph[n], 0);
fill(visited, visited+n, false);
for (int i = 0; i < n-1; i++) {
cin >> a >> b >> c;
graph[a][b] = c;
graph[b][a] = c;
}
cin >> q >> k;
value[k] = 0;
dfs(k);
for (int i = 0; i < q; i++) {
cin >> x >> y;
cout << value[x] + value[y] << endl;
}
return 0;
} | /tmp/ccaGHiFU.o: in function `dfs(int)':
a.cc:(.text+0xa3): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
/tmp/ccaGHiFU.o: in function `main':
a.cc:(.text+0x25c): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
a.cc:(.text+0x2b6): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
a.cc:(.text+0x2ce): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccaGHiFU.o
collect2: error: ld returned 1 exit status
|
s514116853 | p03634 | C++ | using ll = long long;
const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v, int p, ll d) {
depth[v] = d;
for (auto &e : tree[v]) {
if (e.to == p) continue;
dfs(e.to, v, d + e.cost);
}
}
int main(void) {
int n;
cin >> n;
for (int i = 0; i < n - 1; ++i) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
tree[a].push_back({b, c});
tree[b].push_back({a, c});
}
int q, k;
cin >> q >> k;
k--;
dfs(k, -1, 0);
for (int i = 0; i < q; ++i) {
int x, y;
cin >> x >> y;
x--, y--;
cout << depth[x] + depth[y] << endl;
}
return 0;
} | a.cc:4:2: error: 'vector' does not name a type
4 | vector<edge> tree[limit];
| ^~~~~~
a.cc: In function 'void dfs(int, int, ll)':
a.cc:9:21: error: 'tree' was not declared in this scope
9 | for (auto &e : tree[v]) {
| ^~~~
a.cc: In function 'int main()':
a.cc:18:6: error: 'cin' was not declared in this scope
18 | cin >> n;
| ^~~
a.cc:24:10: error: 'tree' was not declared in this scope
24 | tree[a].push_back({b, c});
| ^~~~
a.cc:37:10: error: 'cout' was not declared in this scope
37 | cout << depth[x] + depth[y] << endl;
| ^~~~
a.cc:37:41: error: 'endl' was not declared in this scope
37 | cout << depth[x] + depth[y] << endl;
| ^~~~
|
s555879856 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool bo[100001]={false};
ll dfs(int x,int y,vector<ll>a,vector<ll>b,vector<ll>c){
queue<int> s;
queue<int> q;
bo[x]=true;
ll sum=0;;
for(int i=0;i<a.size();i++){
if(a[i]==x){
s.push(b[i]);
q.push(c[i]);
}
if(b[i]==x){
s.push(a[i]);
q.push(c[i]);
}
}
if(s.size()==0){
bo[x]=false;
return -1000000000000000;
}
while(s.size()>0){
int fi=s.front();
s.pop();
int dis=q.front();
q.pop();
if(s==y) sum+=dis;
else if(bo[s]==true) sum=-1000000000000000;
else{
sum+=dis;
sum+=dfs(s,y,a,b,c);
}
if(sum>0){
bo[x]=false;
return sum;
}
}
return 0;
}
int main(){
int n;cin>>n;
vector<ll> a(n-1),b(n-1),c(n-1);
for(int i=0;i<n-1;i++) cin>>a[i]>>b[i]>>c[i];
int q,k;cin>>q>>k;
int x[q],y[q];
for(int i=0;i<q;i++) cin>>x[i]>>y[i];
for(int i=0;i<q;i++){
cout<<dfs(x[i],k,a,b,c)+dfs(k,y[i],a,b,c)<<endl;
}
} | a.cc: In function 'll dfs(int, int, std::vector<long long int>, std::vector<long long int>, std::vector<long long int>)':
a.cc:29:9: error: no match for 'operator==' (operand types are 'std::queue<int>' and 'int')
29 | if(s==y) sum+=dis;
| ~^~~
| | |
| | int
| std::queue<int>
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1274 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1441 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1613 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
29 | if(s==y) sum+=dis;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::pair<_T1, _T2>'
29 | if(s==y) sum+=dis;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::reverse_iterator<_Iterator>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::move_iterator<_IteratorL>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::move_iterator<_IteratorL>'
29 | if(s==y) sum+=dis;
| ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::fpos<_StateT>'
29 | if(s==y) sum+=dis;
| ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'const std::allocator<_CharT>'
29 | if(s==y) sum+=dis;
| ^
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
629 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
29 | if(s==y) sum+=dis;
| ^
/usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
637 | operator==(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed:
a.cc:29:11: note: 'std::queue<int>' is not derived from 'std::basic_string_view<_CharT, _Tra |
s367806612 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i=0;i<n;i++)
int n;
int a,b;
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,int p,long d){
ans[s]=d;
for(int i=0;i<(int)v[s].size();i++){
if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc:8:1: error: expected initializer before 'long'
8 | long c;
| ^~~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'b' was not declared in this scope
27 | cin>>a>>b>>c;
| ^
a.cc:27:28: error: 'c' was not declared in this scope
27 | cin>>a>>b>>c;
| ^
a.cc:28:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
28 | v[a].push_back({b,c});
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
|
s466239416 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a;
int b;
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,int p,long d){
ans[s]=d;
for(int i=0;i<v[s].size();i++){
if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:34:19: error: expected ';' before 'for'
34 | dfs(k,0,0)
| ^
| ;
a.cc:35:13: error: 'i' was not declared in this scope
35 | rep(i,q){
| ^
a.cc:3:30: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s056031442 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a;
int b;
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,int p,long d){
ans[s]=d;
for(int i=0;i<v[s].size();i++){
if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc:9:1: error: expected initializer before 'long'
9 | long c;
| ^~~~
a.cc: In function 'int main()':
a.cc:28:25: error: 'b' was not declared in this scope
28 | cin>>a>>b>>c;
| ^
a.cc:28:28: error: 'c' was not declared in this scope
28 | cin>>a>>b>>c;
| ^
a.cc:29:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
29 | v[a].push_back({b,c});
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc:34:19: error: expected ';' before 'for'
34 | dfs(k,0,0)
| ^
| ;
a.cc:35:13: error: 'i' was not declared in this scope
35 | rep(i,q){
| ^
a.cc:3:30: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s115860459 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a,b;
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,int p,long d){
ans[s]=d;
for(int i=0;i<v[s].size();i++){
if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc:8:1: error: expected initializer before 'long'
8 | long c;
| ^~~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'b' was not declared in this scope
27 | cin>>a>>b>>c;
| ^
a.cc:27:28: error: 'c' was not declared in this scope
27 | cin>>a>>b>>c;
| ^
a.cc:28:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
28 | v[a].push_back({b,c});
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc:33:19: error: expected ';' before 'for'
33 | dfs(k,0,0)
| ^
| ;
a.cc:34:13: error: 'i' was not declared in this scope
34 | rep(i,q){
| ^
a.cc:3:30: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s643160512 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i=0;i<n;i++)
int n;
int a,b;
long c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,int p,long d){
ans[s]=d;
for(int i=0;i<v[s].size();i++){
if(v[s][i].first!=p)dfs(v[p][i].first,p,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc:8:1: error: expected initializer before 'long'
8 | long c;
| ^~~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'b' was not declared in this scope
27 | cin>>a>>b>>c;
| ^
a.cc:27:28: error: 'c' was not declared in this scope
27 | cin>>a>>b>>c;
| ^
a.cc:28:31: error: no matching function for call to 'std::vector<std::pair<int, long int> >::push_back(<brace-enclosed initializer list>)'
28 | v[a].push_back({b,c});
| ~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/vector:66,
from /usr/include/c++/14/functional:64,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long int> >::value_type&' {aka 'const std::pair<int, long int>&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long int>; _Alloc = std::allocator<std::pair<int, long int> >; value_type = std::pair<int, long int>]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long int> >::value_type&&' {aka 'std::pair<int, long int>&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
|
s301446316 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a,b,c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,long d){
ans[s]=d;
for(int i=0;i<v[s].size();i++){
if(ans[v[s][i].second]==10000000000000000)continue;
dfs(v[s][i].first,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:17: error: expected ';' before 'for'
33 | dfs(k,0)
| ^
| ;
a.cc:34:13: error: 'i' was not declared in this scope
34 | rep(i,q){
| ^
a.cc:3:30: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s609133182 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n;
int a,b,c;
int q;
int k;
int x,y;
long ans[100001];
bool used[100001];
vector<pair<int,long>>v[100001];
void dfs(int s,long d){
ans[s]=d;
for(int i=0;i<v[s].size();i++){
if(ans[v[s][i].second]==10000000000000000)continue;
dfs(v[s][i].first,d+v[s][i].second);
}
}
int main(){
cin>>n;
rep(i,n-1){
cin>>a>>b>>c;
v[a].push_back({b,c});
v[b].push_back({a,c});
}
cin>>q>>k;
for(int i=1;i<=n;i++)ans[i]=10000000000000000;
dfs(k,0)
rep(i,q){
cin>>x>>y;
cout<<ans[x]+ans[y]<<endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:17: error: expected ';' before 'for'
33 | dfs(k,0)
| ^
| ;
a.cc:34:13: error: 'i' was not declared in this scope
34 | rep(i,q){
| ^
a.cc:3:30: note: in definition of macro 'rep'
3 | #define rep(i,n) for(int i=0;i<n;i++)
| ^
|
s249613805 | p03634 | C++ | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;
#define INF LONG_MAX
typedef long long ll;
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
ll V;
vector<vector<edge> > G;
vector<ll> d;
graph(ll n){
init(n);
}
void init(ll n){
V = n;
G.resize(V);
d.resize(V);
for(int i = 0; i < V; i++){
d[i] = INF;
}
}
void add_edge(ll s, ll t, ll cost){
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s){
for(int i = 0; i < V; i++){
d[i] = INF;
}
d[s] = 0;
priority_queue<P,vector<P>, greater<P> > que;
que.push(P(0,s));
while(!que.empty()){
P p = que.top(); que.pop();
ll v = p.second;
if(d[v]<p.first) continue;
for(auto e : G[v]){
if(d[e.to]>d[v]+e.cost){
d[e.to] = d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
};
int main(){
int from,to,cost,N;
cin >> N ;
graph g(N);
for(int i = 0; i < N-1; i++){
cin >> from >> to >> cost;
from --; to --;
g.add_edge(from,to,cost);
g.add_edge(to,from,cost);
}
int Q,K,x,y;
cin >> Q >> K;
K--;
g.dijkstra(K);
for(int i = 0; i < Q; i++){
cin >> x >> y;
x--; y--;
long long ans = g.d[x] + g.d[y];
cout << ans << endl;;
}
return 0;
}
| a.cc: In member function 'void graph::init(ll)':
a.cc:27:13: error: 'LONG_MAX' was not declared in this scope
27 | #define INF LONG_MAX
| ^~~~~~~~
a.cc:46:14: note: in expansion of macro 'INF'
46 | d[i] = INF;
| ^~~
a.cc:23:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
22 | #include <queue>
+++ |+#include <climits>
23 |
a.cc: In member function 'void graph::dijkstra(ll)':
a.cc:27:13: error: 'LONG_MAX' was not declared in this scope
27 | #define INF LONG_MAX
| ^~~~~~~~
a.cc:58:14: note: in expansion of macro 'INF'
58 | d[i] = INF;
| ^~~
a.cc:27:13: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
27 | #define INF LONG_MAX
| ^~~~~~~~
a.cc:58:14: note: in expansion of macro 'INF'
58 | d[i] = INF;
| ^~~
|
s073427336 | p03634 | C++ | using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int mainVertex;
static int[] howlong = new int[n];//頂点kからの距離
static int n;
static void Main()
{
for(int i = 0; i < n; i++) howlong[i] = -1;
n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
for(int i = 0; i < n; i++) List<int[]> nextList[i] = new List<int[]>();//隣接リスト
for(int i = 0; i < n; i++)
{
int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
int[] numsSub = new int[2]{nums[1]-1, nums[2]};
int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
nextList[nums[1]-1].Add(numsSubB);
}
string[] inputSub = Console.ReadLine().Split(' ');
int q = int.Parse(inputSub[0]);
k = int.Parse(inputSub[1]);
k--;
mainVertex = k;
howlong[k] = 0;
Length(k,0);//頂点kの、頂点kからの距離は0
for(int i = 0; i < q; i++)
{
string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
int xx = int.Parse(input[0]);
int yy = int.Parse(input[1]);
Console.WriteLine(xx+yy);
}
Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
}
static void Length(int vertexNum, int length)//頂点番号と、頂点kからの距離
{
for(int i = 0; i < nextList[vertexNum].Count(); i++)
{
int x = howlong[nextList[vertexNum][i][0]];
int y = nextList[vertexNum][i][1];
if(x != -1)
{
x = y + length;
Length(nextList[vertexNum][i],x);
}
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Linq;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Collections.Generic;
| ^~~~~~
a.cc:7:11: error: expected unqualified-id before '[' token
7 | static int[] howlong = new int[n];//頂点kからの距離
| ^
a.cc:57:2: error: expected ';' after class definition
57 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main()':
a.cc:12:32: error: 'howlong' was not declared in this scope; did you mean 'long'?
12 | for(int i = 0; i < n; i++) howlong[i] = -1;
| ^~~~~~~
| long
a.cc:13:9: error: expected primary-expression before 'int'
13 | n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
| ^~~
a.cc:14:32: error: 'List' was not declared in this scope
14 | for(int i = 0; i < n; i++) List<int[]> nextList[i] = new List<int[]>();//隣接リスト
| ^~~~
a.cc:14:37: error: expected primary-expression before 'int'
14 | for(int i = 0; i < n; i++) List<int[]> nextList[i] = new List<int[]>();//隣接リスト
| ^~~
a.cc:18:8: error: structured binding declaration cannot have type 'int'
18 | int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
| ^~
a.cc:18:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:18:8: error: empty structured binding declaration
a.cc:18:11: error: expected initializer before 'nums'
18 | int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
| ^~~~
a.cc:19:8: error: structured binding declaration cannot have type 'int'
19 | int[] numsSub = new int[2]{nums[1]-1, nums[2]};
| ^~
a.cc:19:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:19:8: error: empty structured binding declaration
a.cc:19:11: error: expected initializer before 'numsSub'
19 | int[] numsSub = new int[2]{nums[1]-1, nums[2]};
| ^~~~~~~
a.cc:20:8: error: structured binding declaration cannot have type 'int'
20 | int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
| ^~
a.cc:20:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:20:8: error: empty structured binding declaration
a.cc:20:11: error: expected initializer before 'numsSubB'
20 | int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
| ^~~~~~~~
a.cc:21:5: error: 'nextList' was not declared in this scope
21 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~~~~~
a.cc:21:14: error: 'nums' was not declared in this scope
21 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~
a.cc:21:29: error: 'numsSub' was not declared in this scope
21 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~~~~
a.cc:22:29: error: 'numsSubB' was not declared in this scope
22 | nextList[nums[1]-1].Add(numsSubB);
| ^~~~~~~~
a.cc:25:5: error: 'string' was not declared in this scope
25 | string[] inputSub = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:25:12: error: expected primary-expression before ']' token
25 | string[] inputSub = Console.ReadLine().Split(' ');
| ^
a.cc:26:19: error: expected primary-expression before 'int'
26 | int q = int.Parse(inputSub[0]);
| ^~~
a.cc:27:11: error: 'k' was not declared in this scope
27 | k = int.Parse(inputSub[1]);
| ^
a.cc:27:15: error: expected primary-expression before 'int'
27 | k = int.Parse(inputSub[1]);
| ^~~
a.cc:30:5: error: 'howlong' was not declared in this scope; did you mean 'long'?
30 | howlong[k] = 0;
| ^~~~~~~
| long
a.cc:34:12: error: expected primary-expression before ']' token
34 | string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
| ^
a.cc:35:14: error: expected primary-expression before 'int'
35 | int xx = int.Parse(input[0]);
| ^~~
a.cc:36:14: error: expected primary-expression before 'int'
36 | int yy = int.Parse(input[1]);
| ^~~
a.cc:37:7: error: 'Console' was not declared in this scope
37 | Console.WriteLine(xx+yy);
| ^~~~~~~
a.cc:40:9: error: 'Console' was not declared in this scope
40 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^~~~~~~
a.cc:40:28: error: 'a' was not declared in this scope
40 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:40:30: error: 'b' was not declared in this scope
40 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:40:32: error: 'c' was not declared in this scope
40 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:40:43: error: 's' was not declared in this scope
40 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc: In static member function 'static void Program::Length(int, int)':
a.cc:45:24: error: 'nextList' was not declared in this scope
45 | for(int i = 0; i < nextList[vertexNum].Count(); i++)
| ^~~~~~~~
a.cc:47:15: error: 'howlong' was not declared in this scope; did you mean 'long'?
47 | int x = howlong[nextList[vertexNum][i][0]];
| ^~~~~~~
| long
|
s116482896 | p03634 | C++ | using System;
class Program
{
static int mainVertex;
static int[] howlong = new int[n];//頂点kからの距離
static int n;
static void Main()
{
for(int i = 0; i < n; i++) howlong[i] = -1;
n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
for(int i = 0; i < n; i++) nextList[i] = new List<int[]>();//隣接リスト
for(int i = 0; i < n; i++)
{
int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
int[] numsSub = new int[2]{nums[1]-1, nums[2]};
int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
nextList[nums[1]-1].Add(numsSubB);
}
string[] inputSub = Console.ReadLine().Split(' ');
int q = int.Parse(inputSub[0]);
k = int.Parse(inputSub[1]);
k--;
mainVertex = k;
howlong[k] = 0;
Length(k,0);//頂点kの、頂点kからの距離は0
for(int i = 0; i < q; i++)
{
string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
int xx = int.Parse(input[0]);
int yy = int.Parse(input[1]);
Console.WriteLine(xx+yy);
}
Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
}
static void Length(int vertexNum, int length)//頂点番号と、頂点kからの距離
{
for(int i = 0; i < nextList[vertexNum].Count(); i++)
{
int x = howlong[nextList[vertexNum][i][0]];
int y = nextList[vertexNum][i][1];
if(x != -1)
{
x = y + length;
Length(nextList[vertexNum][i],x);
}
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:5:11: error: expected unqualified-id before '[' token
5 | static int[] howlong = new int[n];//頂点kからの距離
| ^
a.cc:55:2: error: expected ';' after class definition
55 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main()':
a.cc:10:32: error: 'howlong' was not declared in this scope; did you mean 'long'?
10 | for(int i = 0; i < n; i++) howlong[i] = -1;
| ^~~~~~~
| long
a.cc:11:9: error: expected primary-expression before 'int'
11 | n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
| ^~~
a.cc:12:32: error: 'nextList' was not declared in this scope
12 | for(int i = 0; i < n; i++) nextList[i] = new List<int[]>();//隣接リスト
| ^~~~~~~~
a.cc:12:50: error: 'List' does not name a type
12 | for(int i = 0; i < n; i++) nextList[i] = new List<int[]>();//隣接リスト
| ^~~~
a.cc:12:55: error: expected primary-expression before 'int'
12 | for(int i = 0; i < n; i++) nextList[i] = new List<int[]>();//隣接リスト
| ^~~
a.cc:16:8: error: structured binding declaration cannot have type 'int'
16 | int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
| ^~
a.cc:16:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:16:8: error: empty structured binding declaration
a.cc:16:11: error: expected initializer before 'nums'
16 | int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
| ^~~~
a.cc:17:8: error: structured binding declaration cannot have type 'int'
17 | int[] numsSub = new int[2]{nums[1]-1, nums[2]};
| ^~
a.cc:17:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:17:8: error: empty structured binding declaration
a.cc:17:11: error: expected initializer before 'numsSub'
17 | int[] numsSub = new int[2]{nums[1]-1, nums[2]};
| ^~~~~~~
a.cc:18:8: error: structured binding declaration cannot have type 'int'
18 | int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
| ^~
a.cc:18:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:18:8: error: empty structured binding declaration
a.cc:18:11: error: expected initializer before 'numsSubB'
18 | int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
| ^~~~~~~~
a.cc:19:5: error: 'nextList' was not declared in this scope
19 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~~~~~
a.cc:19:14: error: 'nums' was not declared in this scope
19 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~
a.cc:19:29: error: 'numsSub' was not declared in this scope
19 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~~~~
a.cc:20:29: error: 'numsSubB' was not declared in this scope
20 | nextList[nums[1]-1].Add(numsSubB);
| ^~~~~~~~
a.cc:23:5: error: 'string' was not declared in this scope
23 | string[] inputSub = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:23:12: error: expected primary-expression before ']' token
23 | string[] inputSub = Console.ReadLine().Split(' ');
| ^
a.cc:24:19: error: expected primary-expression before 'int'
24 | int q = int.Parse(inputSub[0]);
| ^~~
a.cc:25:11: error: 'k' was not declared in this scope
25 | k = int.Parse(inputSub[1]);
| ^
a.cc:25:15: error: expected primary-expression before 'int'
25 | k = int.Parse(inputSub[1]);
| ^~~
a.cc:28:5: error: 'howlong' was not declared in this scope; did you mean 'long'?
28 | howlong[k] = 0;
| ^~~~~~~
| long
a.cc:32:12: error: expected primary-expression before ']' token
32 | string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
| ^
a.cc:33:14: error: expected primary-expression before 'int'
33 | int xx = int.Parse(input[0]);
| ^~~
a.cc:34:14: error: expected primary-expression before 'int'
34 | int yy = int.Parse(input[1]);
| ^~~
a.cc:35:7: error: 'Console' was not declared in this scope
35 | Console.WriteLine(xx+yy);
| ^~~~~~~
a.cc:38:9: error: 'Console' was not declared in this scope
38 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^~~~~~~
a.cc:38:28: error: 'a' was not declared in this scope
38 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:38:30: error: 'b' was not declared in this scope
38 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:38:32: error: 'c' was not declared in this scope
38 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:38:43: error: 's' was not declared in this scope
38 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc: In static member function 'static void Program::Length(int, int)':
a.cc:43:24: error: 'nextList' was not declared in this scope
43 | for(int i = 0; i < nextList[vertexNum].Count(); i++)
| ^~~~~~~~
a.cc:45:15: error: 'howlong' was not declared in this scope; did you mean 'long'?
45 | int x = howlong[nextList[vertexNum][i][0]];
| ^~~~~~~
| long
|
s236868890 | p03634 | C++ | using System;
class Program
{
static int mainVertex;
static int[] howlong = new int[n];//頂点kからの距離
for(int i = 0; i < n; i++) howlong[i] = -1;
int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
for(int i = 0; i < n; i++) static List<int[]> nextList[i] = new List<int[]>();//隣接リスト
static void Main()
{
for(int i = 0; i < n; i++)
{
int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
int[] numsSub = new int[2]{nums[1]-1, nums[2]};
int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
nextList[nums[1]-1].Add(numsSubB);
}
string[] inputSub = Console.ReadLine().Split(' ');
int q = int.Parse(inputSub[0]);
k = int.Parse(inputSub[1]);
k--;
mainVertex = k;
howlong[k] = 0;
Length(k,0);//頂点kの、頂点kからの距離は0
for(int i = 0; i < q; i++)
{
string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
int xx = int.Parse(input[0]);
int yy = int.Parse(input[1]);
Console.WriteLine(xx+yy);
}
Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
}
static void Length(int vertexNum, int length)//頂点番号と、頂点kからの距離
{
for(int i = 0; i < nextList[vertexNum].Count(); i++)
{
int x = howlong[nextList[vertexNum][i][0]];
int y = nextList[vertexNum][i][1];
if(x != -1)
{
x = y + length;
Length(nextList[vertexNum][i],x);
}
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:5:11: error: expected unqualified-id before '[' token
5 | static int[] howlong = new int[n];//頂点kからの距離
| ^
a.cc:6:1: error: expected unqualified-id before 'for'
6 | for(int i = 0; i < n; i++) howlong[i] = -1;
| ^~~
a.cc:6:16: error: 'i' does not name a type
6 | for(int i = 0; i < n; i++) howlong[i] = -1;
| ^
a.cc:6:23: error: 'i' does not name a type
6 | for(int i = 0; i < n; i++) howlong[i] = -1;
| ^
a.cc:8:1: error: expected unqualified-id before 'for'
8 | for(int i = 0; i < n; i++) static List<int[]> nextList[i] = new List<int[]>();//隣接リスト
| ^~~
a.cc:8:16: error: 'i' does not name a type
8 | for(int i = 0; i < n; i++) static List<int[]> nextList[i] = new List<int[]>();//隣接リスト
| ^
a.cc:8:23: error: 'i' does not name a type
8 | for(int i = 0; i < n; i++) static List<int[]> nextList[i] = new List<int[]>();//隣接リスト
| ^
a.cc:53:2: error: expected ';' after class definition
53 | }
| ^
| ;
a.cc:7:9: error: expected primary-expression before 'int'
7 | int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
| ^~~
a.cc: In static member function 'static void Program::Main()':
a.cc:12:24: error: invalid use of member 'Program::n' in static member function
12 | for(int i = 0; i < n; i++)
| ^
a.cc:7:5: note: declared here
7 | int n = int.Parse(Console.ReadLine());//int.Parseは文字列を整数に変換。
| ^
a.cc:14:8: error: structured binding declaration cannot have type 'int'
14 | int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
| ^~
a.cc:14:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:14:8: error: empty structured binding declaration
a.cc:14:11: error: expected initializer before 'nums'
14 | int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);//1行ごとに受け取る
| ^~~~
a.cc:15:8: error: structured binding declaration cannot have type 'int'
15 | int[] numsSub = new int[2]{nums[1]-1, nums[2]};
| ^~
a.cc:15:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:15:8: error: empty structured binding declaration
a.cc:15:11: error: expected initializer before 'numsSub'
15 | int[] numsSub = new int[2]{nums[1]-1, nums[2]};
| ^~~~~~~
a.cc:16:8: error: structured binding declaration cannot have type 'int'
16 | int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
| ^~
a.cc:16:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:16:8: error: empty structured binding declaration
a.cc:16:11: error: expected initializer before 'numsSubB'
16 | int[] numsSubB = new int[2]{nums[0]-1, nums[2]};
| ^~~~~~~~
a.cc:17:5: error: 'nextList' was not declared in this scope
17 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~~~~~
a.cc:17:14: error: 'nums' was not declared in this scope
17 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~
a.cc:17:29: error: 'numsSub' was not declared in this scope
17 | nextList[nums[0]-1].Add(numsSub);//隣接リストへ追加。第2成分は距離。
| ^~~~~~~
a.cc:18:29: error: 'numsSubB' was not declared in this scope
18 | nextList[nums[1]-1].Add(numsSubB);
| ^~~~~~~~
a.cc:21:5: error: 'string' was not declared in this scope
21 | string[] inputSub = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:21:12: error: expected primary-expression before ']' token
21 | string[] inputSub = Console.ReadLine().Split(' ');
| ^
a.cc:22:19: error: expected primary-expression before 'int'
22 | int q = int.Parse(inputSub[0]);
| ^~~
a.cc:23:11: error: 'k' was not declared in this scope
23 | k = int.Parse(inputSub[1]);
| ^
a.cc:23:15: error: expected primary-expression before 'int'
23 | k = int.Parse(inputSub[1]);
| ^~~
a.cc:26:5: error: 'howlong' was not declared in this scope; did you mean 'long'?
26 | howlong[k] = 0;
| ^~~~~~~
| long
a.cc:30:12: error: expected primary-expression before ']' token
30 | string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
| ^
a.cc:31:14: error: expected primary-expression before 'int'
31 | int xx = int.Parse(input[0]);
| ^~~
a.cc:32:14: error: expected primary-expression before 'int'
32 | int yy = int.Parse(input[1]);
| ^~~
a.cc:33:7: error: 'Console' was not declared in this scope
33 | Console.WriteLine(xx+yy);
| ^~~~~~~
a.cc:36:9: error: 'Console' was not declared in this scope
36 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^~~~~~~
a.cc:36:28: error: 'a' was not declared in this scope
36 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:36:30: error: 'b' was not declared in this scope
36 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:36:32: error: 'c' was not declared in this scope
36 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc:36:43: error: 's' was not declared in this scope
36 | Console.WriteLine((a+b+c) + " " + s);//WriteLineをWriteとすると、改行なしで出力。
| ^
a.cc: In static member function 'static void Program::Length(int, int)':
a.cc:41:24: error: 'nextList' was not declared in this scope
41 | for(int i = 0; i < nextList[vertexNum].Count(); i++)
| ^~~~~~~~
a.cc:43:15: error: 'howlong' was not declared in this scope; did you mean 'long'?
43 | int x = howlong[nextList[vertexNum][i][0]];
| ^~~~~~~
| long
|
s285326808 | p03634 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#include <unordered_map>
#include <map>
#define INF 2147483647
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
struct e { ll to, cost; };
typedef pair<ll, ll> P;
int main() {
int N;
cin >> N;
vector<vector<e> > G(N,vector<e>());
vector<ll> d(N, LLONG_MAX);
for (int i = 0; i < N - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
G[a-1].push_back(e{ b-1, c });
G[b-1].push_back(e{ a-1, c });
}
int Q, K;
cin >> Q >> K; K--;
priority_queue<P, vector<P>, greater<P>> que;
d[K] = 0;
que.push(P(0, K));
while (!que.empty()) {
P p = que.top(); que.pop();
int v = p.second;
if (d[v] < p.first)continue;
for (int i = 0; i < G[v].size(); i++) {
e next = G[v][i];
if (d[next.to] > d[v] + next.cost) {
d[next.to] = d[v] + next.cost;
que.push(P(d[next.to], next.to));
}
}
}
for (int i = 0; i < Q; i++) {
ll x, y;
cin >> x >> y;
cout << d[x-1] + d[y-1] << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:23:25: error: 'LLONG_MAX' was not declared in this scope
23 | vector<ll> d(N, LLONG_MAX);
| ^~~~~~~~~
a.cc:11:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
10 | #include <map>
+++ |+#include <climits>
11 |
|
s508447066 | p03634 | C | #include <stdio.h>
#include <string.h>
#include <stdbool.h>
int n,q,k;
int m,head[300020],next[300020],to[300020];
long long len[300020],dis[300020];
bool visited[300020];
void dfs(int x,int y, long long d){
dis[x]=d;
visited[x]=true;
for (int e=head[x]; e!=-1; e=next[e]){
if (visited[to[e]]==false){
if (to[e]==y) {
continue;
}
dfs(to[e],x,len[e]+d);
visited[to[e]]=false;
}
}
}
int main(void){
scanf("%d",&n);
for (int i=0, i<n; i++){
head[i]=-1;
}
for (int i=0; i<n-1; i++){
int a,b;
long long c;
scanf("%d%d%lld",&a,&b,&c);
a--;
b--;
next[m]=head[a];
head[a]=m;
to[m]=b;
len[m]=c;
m++;
next[m]=head[b];
head[b]=m;
to[m]=a;
len[m]=c;
m++;
}
scanf("%d%d",&q,&k);
dfs(k-1,-1,0);
for (int i=0; i<q; i++){
int x,y;
scanf("%d%d",&x,&y);
printf("%lld\n",dis[x-1]+dis[y-1]);
}
return 0 ;
} | main.c: In function 'main':
main.c:26:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token
26 | for (int i=0, i<n; i++){
| ^
main.c:26:27: error: expected ';' before ')' token
26 | for (int i=0, i<n; i++){
| ^
| ;
|
s353027375 | p03634 | C | #include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 1 << 58;
const int MOD = 1000000007;
int N, Q, K;
vector<pair<int, int> > ab[100010];
long saitankyori[100010];
bool tootta[100010];
int kyori(int genzaichi){
tootta[genzaichi] = true;
while(!ab[genzaichi].empty()){
int tuginogenzaichi = ab[genzaichi][0].first;
long tuginogenzaichimadenokyori = ab[genzaichi][0].second;
ab[genzaichi].erase(ab[genzaichi].begin());
if(!tootta[tuginogenzaichi]){
saitankyori[tuginogenzaichi] = saitankyori[genzaichi] + tuginogenzaichimadenokyori;
kyori(tuginogenzaichi);
}
}
if(genzaichi == K)return 0;
return 0;
}
int transittreepath(){
cin >> N;
REP(i, N - 1){
int a, b, c;
cin >> a >> b >> c;
ab[a].push_back(pair<int, int>(b,c));
ab[b].push_back(pair<int, int>(a,c));
}
cin >> Q >> K;
int x, y;
long answers[100010];
REP(i, N + 1){
saitankyori[i] = INF;
saitankyori[i] *= 256;
}
saitankyori[K] = 0;
kyori(K);
REP(i, Q){
cin >> x >> y;
answers[i] = saitankyori[x] + saitankyori[y];
}
REP(i, Q){
printf("%ld\n", answers[i]);
}
return 0;
}
/*
vector<int> ab[100010];
int konokazu[100100] = {0};
ll dpf[100100] = {0};
ll dpg[100100] = {0};
bool tootta[100010] = {false};
int N;
int kyori(int genzaichi){
bool hasi = true;
tootta[genzaichi] = true;
while(!ab[genzaichi].empty()){
int tuginogenzaichi = ab[genzaichi][0];
ab[genzaichi].erase(ab[genzaichi].begin());
if(!tootta[tuginogenzaichi]){
kyori(tuginogenzaichi);
dpf[genzaichi] = (dpg[tuginogenzaichi] * dpf[genzaichi]) % MOD;
dpg[genzaichi] = (dpf[tuginogenzaichi] * dpg[genzaichi]) % MOD;
}
}
dpf[genzaichi] += dpg[genzaichi];
dpf[genzaichi] %= MOD;
dpg[genzaichi] %= MOD;
return 0;
}
int nurie(){
//treeDP
cin >> N;
REP(i, N - 1){
int a,b;
cin >> a >> b;
ab[a].push_back(b);
ab[b].push_back(a);
}
REP(i, N + 1){
dpf[i] = 1;
dpg[i] = 1;
}
tootta[1] = true;
kyori(1);
return dpf[1];
}
*/
int main(){
transittreepath();
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s206780219 | p03634 | C++ | #include<cstdio>
#include <vector>
#include <map>
#define int long long int
using namespace std;
typedef pair<int,int> P;
vector<P> G[200000];
int d[200000];
void dfs(int prev, int now, int cost) {
d[now] = cost;
for(P p : G[now]) {
int next = p.first;
int ncost = p.second;
if(next == prev) continue;
dfs(now, next, cost + ncost);
}
}
int main(void) {
int n;
scanf("%lld",&n);
for(int i=0; i<n-1; i++) {
int a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
a--, b--;
G[a].push_back(P(b,c));
G[b].push_back(P(a,c));
}
int q,k;
scanf("%lld%lld",&q,&k);
k--;
dfs(-1, k, 0);
for(int i=0; i<q; i++) {
int x,y;
scanf("%lld%lld",&x,&y);
x--, y--;
printf("%lld\n", d[x] + d[y]);
}
} | a.cc:4:23: error: '::main' must return 'int'
4 | #define int long long int
| ^~~
a.cc:21:1: note: in expansion of macro 'int'
21 | int main(void) {
| ^~~
|
s539677001 | p03634 | C++ | #include<cstdio>
#include <vector>
#include <map>
#define int long long int;
using namespace std;
typedef pair<int,int> P;
vector<P> G[200000];
int d[200000];
void dfs(int prev, int now, int cost) {
d[now] = cost;
for(P p : G[now]) {
int next = p.first;
int ncost = p.second;
if(next == prev) continue;
dfs(now, next, cost + ncost);
}
}
int main(void) {
int n;
scanf("%lld",&n);
for(int i=0; i<n-1; i++) {
int a,b,c;
scanf("%lld%lld%lld",&a,&b,&c);
a--, b--;
G[a].push_back(P(b,c));
G[b].push_back(P(a,c));
}
int q,k;
scanf("%lld%lld",&q,&k);
k--;
dfs(-1, k, 0);
for(int i=0; i<q; i++) {
int x,y;
scanf("%lld%lld",&x,&y);
x--, y--;
printf("%lld\n", d[x] + d[y]);
}
} | a.cc:4:23: error: wrong number of template arguments (1, should be 2)
4 | #define int long long int;
| ^~~
a.cc:7:14: note: in expansion of macro 'int'
7 | typedef pair<int,int> P;
| ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/bits/stl_pair.h:89:12: note: provided for 'template<class _T1, class _T2> struct std::pair'
89 | struct pair;
| ^~~~
a.cc:7:1: warning: 'typedef' was ignored in this declaration
7 | typedef pair<int,int> P;
| ^~~~~~~
a.cc:7:17: error: expected unqualified-id before ',' token
7 | typedef pair<int,int> P;
| ^
a.cc:4:13: error: expected unqualified-id before 'long'
4 | #define int long long int;
| ^~~~
a.cc:7:18: note: in expansion of macro 'int'
7 | typedef pair<int,int> P;
| ^~~
a.cc:7:21: error: expected unqualified-id before '>' token
7 | typedef pair<int,int> P;
| ^
a.cc:8:8: error: 'P' was not declared in this scope
8 | vector<P> G[200000];
| ^
a.cc:8:9: error: template argument 1 is invalid
8 | vector<P> G[200000];
| ^
a.cc:8:9: error: template argument 2 is invalid
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
4 | #define int long long int;
| ^~~
a.cc:9:1: note: in expansion of macro 'int'
9 | int d[200000];
| ^~~
a.cc:9:5: error: 'd' does not name a type
9 | int d[200000];
| ^
a.cc:4:26: error: expected ')' before ';' token
4 | #define int long long int;
| ^
a.cc:11:10: note: in expansion of macro 'int'
11 | void dfs(int prev, int now, int cost) {
| ^~~
a.cc:11:9: note: to match this '('
11 | void dfs(int prev, int now, int cost) {
| ^
a.cc:11:14: error: 'prev' does not name a type
11 | void dfs(int prev, int now, int cost) {
| ^~~~
a.cc:11:24: error: 'now' does not name a type
11 | void dfs(int prev, int now, int cost) {
| ^~~
a.cc:11:33: error: 'cost' does not name a type; did you mean 'const'?
11 | void dfs(int prev, int now, int cost) {
| ^~~~
| const
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
4 | #define int long long int;
| ^~~
a.cc:21:1: note: in expansion of macro 'int'
21 | int main(void) {
| ^~~
a.cc:21:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
21 | int main(void) {
| ^~~~
a.cc: In function 'int main()':
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
4 | #define int long long int;
| ^~~
a.cc:22:5: note: in expansion of macro 'int'
22 | int n;
| ^~~
a.cc:22:9: error: 'n' was not declared in this scope
22 | int n;
| ^
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
4 | #define int long long int;
| ^~~
a.cc:25:9: note: in expansion of macro 'int'
25 | for(int i=0; i<n-1; i++) {
| ^~~
a.cc:25:13: error: 'i' was not declared in this scope
25 | for(int i=0; i<n-1; i++) {
| ^
a.cc:25:23: error: expected ')' before ';' token
25 | for(int i=0; i<n-1; i++) {
| ~ ^
| )
a.cc:25:25: error: 'i' was not declared in this scope
25 | for(int i=0; i<n-1; i++) {
| ^
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
4 | #define int long long int;
| ^~~
a.cc:33:5: note: in expansion of macro 'int'
33 | int q,k;
| ^~~
a.cc:33:9: error: 'q' was not declared in this scope
33 | int q,k;
| ^
a.cc:33:11: error: 'k' was not declared in this scope
33 | int q,k;
| ^
a.cc:4:23: error: declaration does not declare anything [-fpermissive]
4 | #define int long long int;
| ^~~
a.cc:38:9: note: in expansion of macro 'int'
38 | for(int i=0; i<q; i++) {
| ^~~
a.cc:38:21: error: expected ')' before ';' token
38 | for(int i=0; i<q; i++) {
| ~ ^
| )
|
s049388155 | p03634 | C++ | #include<bits/stdc++.h>
using namespace std;
#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long
typedef pair<int, int> P;
ll cost[100100][100100];
ll d[100100];
bool used[100100];
ll V;
void dk(int s) {
fill(d, d + V, 10000000000);
fill(used, used + V, false);
d[s] = 0;
while (true) {
int v = -1;
rep(u, V){
if (!used[u] && (v == -1 || d[u] < d[v])) {
v = u;
}
}
if (v == -1) break;
used[v] = true;
rep(u, V){
d[u] = min(d[u], d[v] + cost[v][u]);
}
}
}
int main(){
cin >> V;
int a, b, c;
rep(i, V){
rep(j, V){
cost[i][j] = 10000000000;
}
}
rep(i, V-1){
cin >> a >> b >> c;
cost[a-1][b-1] = c;
cost[b-1][a-1] = c;
}
int Q, K, x, y;
cin >> Q >> K;
dk(K-1); // 頂点1が配列番号の0と対応しているため
rep(i, Q){
cin >> x >> y;
cout << d[x-1] + d[y-1] << endl;
}
}
| /tmp/ccIRfkAn.o: in function `dk(int)':
a.cc:(.text+0x1c): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x5d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x72): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0xef): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccIRfkAn.o
a.cc:(.text+0x10f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s310676995 | p03634 | C++ | #include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#define MAX 100010
#define int long long
using namespace std;
struct edge {
int to, cost;
};
typedef pair<int, int> P;
vector<edge> G[MAX];
int d[MAX];
int n;
void dijkstra(int s) {
priority_queue<P, vector<P>, greater<P> > que;
fill(d, d + n + 1, LLONG_MAX / 4);
d[s] = 0;
que.push(P(0, s));
while (!que.empty()) {
P p = que.top();
que.pop();
int v = p.second;
if (d[v] < p.first) continue;
for (int i = 0; i < G[v].size(); i++) {
edge e = G[v][i];
if (d[e.to] > d[v] + e.cost) {
d[e.to] = d[v] + e.cost;
que.push(P(d[e.to], e.to));
}
}
}
}
signed main() {
cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
edge tmp;
tmp.to = b;
tmp.cost = c;
G[a].push_back(tmp);
tmp.to = a;
G[b].push_back(tmp);
}
int q, k;
cin >> q >> k;
dijkstra(k);
for (int i = 0; i < q; i++) {
int x, y;
cin >> x >> y;
cout << d[x] + d[y] << endl;
}
return 0;
}
| a.cc: In function 'void dijkstra(long long int)':
a.cc:21:22: error: 'LLONG_MAX' was not declared in this scope
21 | fill(d, d + n + 1, LLONG_MAX / 4);
| ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <queue>
+++ |+#include <climits>
4 | #include <vector>
|
s788493247 | p03634 | C | #include<iostream>
#include<vector>
using namespace std;
int n,a,b,q,k,x,y,j,visit[100010]={},cnt[100010]={};
long c,dis[100010];
vector<vector<int>> v(100010);
vector<vector<int>> d(100010);
int dfs(int p){
visit[p]=1;
int i;
for(i=0;i<cnt[p];i++){
//cout<<p<<" "<<cnt[p]<<endl;
if(visit[v[p][i]]==0){
dis[v[p][i]]=dis[p]+d[p][i];
dfs(v[p][i]);
}
}
}
int main(){
int i;
cin >> n;
for(i=0;i<n-1;i++){
cin >> a >> b >> c;
v[a].push_back(b);
v[b].push_back(a);
cnt[a]++;
cnt[b]++;
d[a].push_back(c);
d[b].push_back(c);
}
cin >> q >> k;
dis[k]=0;
dfs(k);
for(i=0;i<q;i++){
cin >> x >> y;
cout <<dis[x]+dis[y]<<endl;
}
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s496229384 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long lint;
typedef pair<lint,lint> P;
#define rep(i, n) for (lint i = 0; i < (n); i++)
#define INF LLONG_MAX
#define MAX_V 100005
struct edge{lint to,cost;};
lint n;
vector<edge> vec[MAX_V];
lint d[MAX_V];
void dijkstra(lint k);
signed main(){
cin>>n;
rep(i,n-1){
lint a,b,c;
cin>>a>>b>>c;
a--;
b--;
vec[a].push_back({b,c});
vec[b].push_back({a,c});
}
lint q,k;
cin>>q>>k;
k--;
dijkstra(k);
rep(i,q){
lint x,y;
cin>>x>>y;
x--;
y--;
cout<<d[x]+d[y]<<endl;
}
return 0;
}
void dijkstra(lint k){
priority_queue<P, vector<P>,greater<P> >que;
fill(d,d+n,INF);
d[k]=0;
que.push(P(0,k));
while(!que.empty()){
P p=que.top();
que.pop();
lint v= p.second;
if(d[v]<p.first)continue;
for(lint i=0;i<vec[v].size();i++){
edge temp=vec[v][i];
if(d[temp.to]>d[v]+temp.cost){
d[temp.to]=d[v]+temp.cost;
que.push(P(d[temp.to],temp.to));
}
}
}
}
| a.cc: In function 'void dijkstra(lint)':
a.cc:14:13: error: 'LLONG_MAX' was not declared in this scope
14 | #define INF LLONG_MAX
| ^~~~~~~~~
a.cc:46:16: note: in expansion of macro 'INF'
46 | fill(d,d+n,INF);
| ^~~
a.cc:10:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
9 | #include <utility>
+++ |+#include <climits>
10 | using namespace std;
|
s883591469 | p03634 | C++ | #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF INT_MAX
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};
using namespace std;
const int limit=10010;
vector<pair<int,ll>> G[limit];
vector<ll> dis[limit];
void dfs(int v,int p,ll d){
dis[v]=d;
doe(auto x:g[v]){
if(x.fi==p)continue;
dfs(x.fi,v,d+x.se);
}
}
int main(){
int n;
cin>>n;
rep(i,0,n-1){
int a,b,c;
a--; b--;
cin>>a>>b>>c;
G[a].pb(MP(b,c));
G[b].pb(MP(a,c));
}
int q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
rep(i,0,q){
int x,y;
cin>>x>>y;
x--; y--;
cout<<(dis[x]+dis[y])<<endl;
}
return 0;
}
| a.cc: In function 'void dfs(int, int, ll)':
a.cc:35:12: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'll' {aka 'long long int'})
35 | dis[v]=d;
| ^
In file included from /usr/include/c++/14/vector:72,
from a.cc:4:
/usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
a.cc:36:9: error: expected primary-expression before 'auto'
36 | doe(auto x:g[v]){
| ^~~~
a.cc:36:5: error: 'doe' was not declared in this scope
36 | doe(auto x:g[v]){
| ^~~
a.cc: In function 'int main()':
a.cc:62:22: error: no match for 'operator+' (operand types are 'std::vector<long long int>' and 'std::vector<long long int>')
62 | cout<<(dis[x]+dis[y])<<endl;
| ~~~~~~^~~~~~~
| | |
| | vector<[...]>
| vector<[...]>
In file included from /usr/include/c++/14/string:48,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
1798 | operator+(typename move_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3616 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: mismatched types 'const _CharT*' and 'std::vector<long long int>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed:
a.cc:62:28: note: 'std::vector<long long int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
62 | cout<<(dis[x]+dis[y])<<endl;
| ^
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3719 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note: template |
s397176859 | p03634 | Java | import java.util.*;
public class Main {
@lombok.ToString
private class Edge {
int to;
long cost;
public Edge(int to, long cost) {
this.to = to;
this.cost = cost;
}
}
@lombok.ToString
private class Node {
long minCost = Long.MAX_VALUE;
List<Edge> childs = new ArrayList<>();
boolean isFix = false;
public void addEdge(Edge e) {
childs.add(e);
}
public void fixed() {
isFix = true;
}
}
public void main(Scanner sc) {
int n = sc.nextInt();
Node nodes[] = new Node[n + 1];
for (int i = 1; i <= n; i++) {
nodes[i] = new Node();
}
for (int i = 0; i < n - 1; i++) {
int a = sc.nextInt();
int b = sc.nextInt();
long c = sc.nextLong();
nodes[a].addEdge(new Edge(b, c));
nodes[b].addEdge(new Edge(a, c));
}
int q = sc.nextInt();
int k = sc.nextInt();
dijkstra(k, n, nodes);
for (int i = 0; i < q; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
System.out.println(nodes[x].minCost + nodes[y].minCost);
}
}
public void dijkstra(int start, int n, Node nodes[]) {
nodes[start].minCost = 0;
Queue<Node> queue = new PriorityQueue<>((n1, n2) -> Long.compare(n1.minCost, n2.minCost));
queue.add(nodes[start]);
while (!queue.isEmpty()) {
Node src = queue.poll();
src.fixed();
for (Edge e : src.childs) {
Node dst = nodes[e.to];
if (!dst.isFix) {
dst.minCost = Math.min(dst.minCost, src.minCost + e.cost);
queue.add(dst);
}
}
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
new Main().main(sc);
sc.close();
}
}
| Main.java:15: error: package lombok does not exist
@lombok.ToString
^
Main.java:4: error: package lombok does not exist
@lombok.ToString
^
2 errors
|
s026402316 | p03634 | C | #include <bits/stdc++.h>
using namespace std;
#define INF 100100100100100
#define NMAX 100000
typedef long long llong;
llong d[NMAX];
vector<pair<llong, int>> g[NMAX];
void dijkstra(int s) {
priority_queue<pair<llong, int>, vector<pair<llong, int>>, greater<pair<llong, int>>> que;
fill(d, d + NMAX, INF);
d[s] = 0;
que.push({0, s});
while (!que.empty()) {
auto p = que.top(); que.pop();
int v = p.second;
if (d[v] < p.first)
continue;
for (int i = 0; i < g[v].size(); i++) {
auto e = g[v][i];
if (d[e.second] > d[v] + e.first) {
d[e.second] = d[v] + e.first;
que.push({d[e.second], e.second});
}
}
}
}
int main(void) {
int n;
cin >> n;
for (int i = 0; i < n - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
g[a].push_back({c, b});
g[b].push_back({c, a});
}
int q, k;
cin >> q >> k;
k--;
dijkstra(k);
for (int i = 0; i < q; i++) {
int x, y;
cin >> x >> y;
x--, y--;
cout << d[x] + d[y] << endl;
}
}
| main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s807742439 | p03634 | C | #include <bits/stdc++.h>
#define inf (1<<29)
#define sq(n) ((n)*(n))
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define MEMSET(a) memset(a,0,sizeof(a))
using namespace std;
using ll=long long;
const int limit=100010;
using edge=struct{int to;ll cost;};
vector<edge> tree[limit];
ll depth[limit];
void dfs(int v,int p,ll d){
depth[v]=d;
for(auto &e:tree[v]){
if(e.to==p)continue;
dfs(e.to,v,d+e.cost);
}
}
int main(){
int n;
cin>>n;
rep(i,n-1){
int a,b,c;
cin>>a>>b>>c;
a--;b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
int q,k;
cin>>q>>k;
k--;
dfs(k,-1,0);
rep(i,q){
int x,y;
cin>>x>>y;
x--;y--;
cout<<depth[x]+depth[y]<<endl;
}
return 0;
} | main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s870842768 | p03634 | C++ |
int n,a,b,q,k;
ll c;
ll depth[100000] ={0};
typedef struct{int to;ll cost;} edge;
vector<edge> tree[100000];
void dfs(int v,int p, ll d){
depth[v] = d;
for(int i = 0;i<tree[v].size();i++){
if(tree[v][i].to == p) continue;
dfs(tree[v][i].to, v, d + tree[v][i].cost);
}
}
int main(){
scanf("%d", &n);
REP(i,n){
scanf("%d %d %lld",&a,&b,&c);
a--;b--;
tree[a].push_back({b,c});
tree[b].push_back({a,c});
}
scanf("%d %d",&q,&k);
k--;
dfs(k,-1,0);
REP(i,q){
int x,y;
scanf("%d %d",&x,&y);
x--;y--;
printf("%lld\n",depth[x]+depth[y]);
}
}
| a.cc:3:1: error: 'll' does not name a type
3 | ll c;
| ^~
a.cc:4:1: error: 'll' does not name a type
4 | ll depth[100000] ={0};
| ^~
a.cc:6:23: error: 'll' does not name a type
6 | typedef struct{int to;ll cost;} edge;
| ^~
a.cc:7:1: error: 'vector' does not name a type
7 | vector<edge> tree[100000];
| ^~~~~~
a.cc:9:23: error: 'll' has not been declared
9 | void dfs(int v,int p, ll d){
| ^~
a.cc: In function 'void dfs(int, int, int)':
a.cc:10:3: error: 'depth' was not declared in this scope
10 | depth[v] = d;
| ^~~~~
a.cc:11:19: error: 'tree' was not declared in this scope
11 | for(int i = 0;i<tree[v].size();i++){
| ^~~~
a.cc: In function 'int main()':
a.cc:18:3: error: 'scanf' was not declared in this scope
18 | scanf("%d", &n);
| ^~~~~
a.cc:19:7: error: 'i' was not declared in this scope
19 | REP(i,n){
| ^
a.cc:19:3: error: 'REP' was not declared in this scope
19 | REP(i,n){
| ^~~
|
s395965642 | p03634 | C | #include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define mem memset(a,0,sizeof(a))
const int mo=1000000007;
const int inf=0x3f3f3f3f;
typedef long long ll;
using namespace std;
ll d[100005];
typedef pair<int,int>P;
vector<P>vec[100005];
void dfs(int x,int y)
{
int n=vec[x].size();
for(int i=0;i<n;i++)
{
if(vec[x][i].first!=y)
{
P s=vec[x][i];
d[s.first]=d[x]+s.second;
dfs(s.first,x);
}
}
}
int main()
{
int n,m,k,q;
int i;
cin>>n;
int a,b,c;
for(i=0;i<n-1;i++)
{
cin>>a>>b>>c;
vec[a].push_back(P(b,c));
vec[b].push_back(P(a,c));
}
cin>>q>>k;
d[k]=0;
dfs(k,k);
while(q--)
{
cin>>a>>b;
cout<<d[a]+d[b]<<endl;
}
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s741673548 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
using namespace std;
#define ll long long
static const ll INF=1e9;
static const ll MAX=1e5+7;
const ll len=1e5+5;
ll n;
ll d[len];
struct ss{
ll y;
ll w;
};
vector<ss>ve[len];
void dkstl(ll s)
{
ll u,minm;
ll flag[len];
for(ll i=0;i<n;++i)
{
d[i]=INF;
flag[i]=0;
}
d[s]=0;
flag[s]=1;
while(1)
{
minm=INF;u=-1;
for(ll i=0;i<n;++i)
{
if(flag[i]==0&&d[i]<minm)
{
u=i;
minm=d[i];
}
}
if(u==-1)break;
flag[u]=1;
for(ll v=0;v<ve[u].size();++v)
{
if(flag[ve[u][v].y]==0)
{
if(d[ve[u][v].y]>ve[u][v].w+d[u])
d[ve[u][v].y]=ve[u][v].w+d[u];
}
}
}
}
int main()
{
while(cin>>n)
{
ll i,j,t;
ss kkk;
for(int i=0;i<n;i++)
vec[i].clear();
for(ll u=0;u<n-1;++u)
{
scanf("%lld%lld",&i,&j);
i--;j--;
cin>>t;
kkk.y=j;
kkk.w=t;
ve[i].push_back(kkk);
}
ll q,k;
cin>>q>>k;
k--;
dkstl(k);
for(ll v=1;v<=q;++v)
{
scanf("%lld%lld",&i,&j);
i--;j--;
printf("%lld\n",d[i]+d[j]);
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:69:16: error: 'vec' was not declared in this scope; did you mean 've'?
69 | vec[i].clear();
| ^~~
| ve
|
s651737413 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
using namespace std;
#define ll long long
static const ll INF=1e9;
static const ll MAX=1e5+7;
const ll len=1e5+5;
ll n;
ll m[len][len],d[len];
struct ss{
ll y;
ll w;
};
vector<ss>ve[len];
void dkstl(ll s)
{
ll u,minm;
ll flag[len];
for(ll i=0;i<n;++i)
{
d[i]=INF;
flag[i]=0;
}
d[s]=0;
while(1)
{
minm=INF;u=-1;
for(ll i=0;i<n;++i)
{
if(flag[i]==0&&d[i]<minm)
{
u=i;
minm=d[i];
}
}
if(u==-1)break;
flag[u]=1;
for(ll v=0;v<ve[u].size();++v)
{
if(flag[ve[u][v].y]==0)
{
if(d[ve[u][v].y]>ve[u][v].w+d[u])
d[ve[u][v].y]=ve[u][v].w+d[u];
}
}
}
//for(ll i=0;i<n;++i)
// printf("%lld ",d[i]);
//return d[z];
}
int main()
{
while(cin>>n)
{
ll i,j,t;
//for(i=0;i<n;++i)
{
//for(j=0;j<n;++j)
//m[i][j]=INF;
}
ss kkk;
for(ll u=0;u<n-1;++u)
{
scanf("%lld%lld",&i,&j);
i--;j--;
cin>>t;
kkk.y=j;
kkk.w=t;
ve[i].push_back(kkk);
}
//for(i=0;i<n;++i)
{
//for(j=0;j<n;++j)
//cout<<m[i][j]<<' ';
//cout<<endl;
}
ll q,k;
cin>>q>>k;
k--;
dkstl(k);
for(ll v=1;v<=q;++v)
{
scanf("%lld%lld",&i,&j);
i--;j--;
printf("%lld\n",d[i]+d[j]);
}
}
return 0;
} | /tmp/cclyGdz3.o: in function `dkstl(long long)':
a.cc:(.text+0x2c): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x6c): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0xb2): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0xd7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x131): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x174): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x198): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x1b4): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x1dd): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x20a): relocation truncated to fit: R_X86_64_PC32 against symbol `ve' defined in .bss section in /tmp/cclyGdz3.o
a.cc:(.text+0x233): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s278766013 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <string>
#include <cctype>
#include <cstdlib>
#include <set>
#include <map>
#include <sstream>
using namespace std;
#define ll long long
static const ll INF=1e9;
static const ll MAX=1e5+7;
const ll len=1e5+5;
ll n;
ll m[len][len],d[len];
void dkstl(ll s)
{
ll u,minm;
ll flag[len];
for(ll i=0;i<n;++i)
{
d[i]=INF;
flag[i]=0;
}
d[s]=0;
while(1)
{
minm=INF;u=-1;
for(ll i=0;i<n;++i)
{
if(flag[i]==0&&d[i]<minm)
{
u=i;
minm=d[i];
}
}
if(u==-1)break;
flag[u]=1;
for(ll v=0;v<n;++v)
{
if(flag[v]==0&&m[u][v]!=INF)
{
if(d[v]>m[u][v]+d[u])
d[v]=m[u][v]+d[u];
}
}
}
//for(ll i=0;i<n;++i)
// printf("%lld ",d[i]);
//return d[z];
}
int main()
{
while(cin>>n)
{
ll i,j,t;
for(i=0;i<n;++i)
{
for(j=0;j<n;++j)
m[i][j]=INF;
}
for(ll u=0;u<n-1;++u)
{
scanf("%lld%lld",&i,&j);
i--;j--;
cin>>t;
m[i][j]=t;
m[j][i]=t;
}
//for(i=0;i<n;++i)
{
//for(j=0;j<n;++j)
//cout<<m[i][j]<<' ';
//cout<<endl;
}
ll q,k;
cin>>q>>k;
k--;
dkstl(k);
for(ll v=1;v<=q;++v)
{
scanf("%lld%lld",&i,&j);
i--;j--;
printf("%lld\n",d[i]+d[j]);
}
}
return 0;
} | /tmp/ccA4akB4.o: in function `dkstl(long long)':
a.cc:(.text+0x2b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x6b): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0xd6): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x171): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x1f1): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x20c): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
/tmp/ccA4akB4.o: in function `main':
a.cc:(.text+0x40e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
a.cc:(.text+0x425): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/ccA4akB4.o
collect2: error: ld returned 1 exit status
|
s111321276 | p03634 | C | /*
cat <<EOF >mistaken-paste
*/
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define BIG 2000000007
#define VERYBIG 200000000000007LL
#define MOD 1000000007
typedef uint64_t ull;
typedef int64_t sll;
#define N_MAX 100000
#define M_MAX 400
#ifdef __cplusplus
#include <queue>
#include <stack>
// #include <tuple>
using namespace std; // I'm NOT gonna use C++ without compro. shit
typedef priority_queue<ull, vector<ull>, greater<ull> > upque123;
typedef priority_queue<ull, vector<ull> > upque321;
typedef priority_queue<sll, vector<sll>, greater<sll> > spque123;
typedef priority_queue<sll, vector<sll> > spque321;
#endif
typedef struct {
int32_t a;
int32_t b;
} hw;
typedef struct {
sll a;
sll b;
} hwll;
typedef struct {
hwll a;
hwll b;
} linell;
typedef struct {
ull s;
ull t;
int32_t c;
} struct_a;
typedef struct {
int32_t from;
int32_t to;
sll cost;
} struct_b;
const hw vector8[8] = {
{-1, -1},
{-1, 0},
{-1, +1},
{ 0, -1},
{ 0, +1},
{+1, -1},
{+1, 0},
{+1, +1}
};
ull n, m;
ull h, w;
ull k;
ull q;
ull vua, vub, vuc, vud, vue, vuf;
sll vsa, vsb, vsc, vsd, vse, vsf;
long double vra, vrb, vrc;
double vda, vdb, vdc;
size_t slen;
size_t tlen;
char ch, dh;
void swap_adj (ull *a, ull *b) {
if (*a != *b) {
ull tmp = *b;
*b = *a;
*a = tmp;
}
return;
}
ull divide (ull a, ull b) {
ull x = MOD - 2;
ull ans = 1;
while (x) {
if (x & 1) ans = (ans * b) % MOD;
b = (b * b) % MOD;
x /= 2;
}
return (a * ans) % MOD;
}
int32_t digits (ull x) {
int32_t i = 1;
while (x >= 10) {
x /= 10;
i++;
}
return i;
}
ull umin (ull x, ull y) {
return (x < y) ? x : y;
}
ull umax (ull x, ull y) {
return (x > y) ? x : y;
}
sll smin (sll x, sll y) {
return (x < y) ? x : y;
}
sll smax (sll x, sll y) {
return (x > y) ? x : y;
}
ull gcd (ull x, ull y) {
if (x < y) {
return gcd(y, x);
} else if (y == 0) {
return x;
} else {
return gcd(y, x % y);
}
}
ull bitpow (ull a, ull x, ull modulo) {
ull result = 1;
while (x) {
if (x & 1) {
result *= a;
result %= modulo;
}
x /= 2;
a = (a * a) % modulo;
}
return result;
}
int32_t targetdig (ull x, int32_t index /* 1-indexed */) {
// static...?
int32_t posmax = digits(x);
if (posmax < index) return -1;
while (posmax > index) {
posmax--;
x /= 10;
}
return x % 10;
}
int32_t charcomp (const char left, const char right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t pcharcomp (const void *left, const void *right) {
char lval = *(char*)left;
char rval = *(char*)right;
return charcomp(lval, rval);
}
int32_t intcomp (const int32_t left, const int32_t right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t pintcomp (const void *left, const void *right) {
int lval = *(int*)left;
int rval = *(int*)right;
return intcomp(lval, rval);
}
int32_t ullcomp (const ull left, const ull right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t pullcomp (const void *left, const void *right) {
ull lval = *(ull*)left;
ull rval = *(ull*)right;
return ullcomp(lval, rval);
}
int32_t pullrevcomp (const void *left, const void *right) {
ull lval = *(ull*)left;
ull rval = *(ull*)right;
return -ullcomp(lval, rval);
}
int32_t sllcomp (const sll left, const sll right) {
if (left < right) {
return -1;
} else if (left > right) {
return +1;
} else {
return 0;
}
}
int32_t psllcomp (const void *left, const void *right) {
sll lval = *(sll*)left, rval = *(sll*)right;
return ullcomp(lval, rval);
}
int32_t hwllfraccomp (const hwll left, const hwll right) {
return ullcomp(left.a * right.b, left.b * right.a);
}
int32_t phwAcomp (const hw *left, const hw *right) {
return intcomp(left->a, right->a);
}
int32_t phwBcomp (const hw *left, const hw *right) {
return intcomp(left->b, right->b);
}
int32_t phwABcomp (const hw *left, const hw *right) {
int32_t x = phwAcomp(left, right);
if (x) return x;
return phwBcomp(left, right);
}
int32_t phwllAcomp (const hwll *left, const hwll *right) {
return sllcomp(left->a, right->a);
}
int32_t phwllBcomp (const hwll *left, const hwll *right) {
return sllcomp(left->b, right->b);
}
int32_t phwllABcomp (const void *left, const void *right) {
hwll lval = *(hwll*)left, rval = *(hwll*)right;
int32_t x = sllcomp(lval.a, rval.a);
if (x) return x;
return sllcomp(lval.b, rval.b);
}
int32_t phwllrAcBcomp (const hwll *left, const hwll *right) {
int32_t x = -phwllAcomp(left, right);
if (x) return x;
return phwllBcomp(left, right);
}
int32_t phwllBAcomp (const hwll *left, const hwll *right) {
int32_t x = phwllBcomp(left, right);
if (x) return x;
return phwllAcomp(left, right);
}
int32_t pstrAcomp (const struct_a *left, const struct_a *right) {
int32_t x;
if (x = ullcomp(left->t, right->t)) return x;
if (x = ullcomp(left->s, right->s)) return x;
if (x = intcomp(left->c, right->c)) return x;
return 0;
}
int32_t bitlet (char c) {
return (1 << (c - 'a'));
}
ull ullabs (ull a, ull b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll sllabs (sll a, sll b) {
if (a >= b) {
return a - b;
} else {
return b - a;
}
}
sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) {
while (sllabs(ok, ng) > 1) {
sll med = (ok + ng) / 2;
if (func(med)) {
ok = med;
} else {
ng = med;
}
// printf("debug: [%lld %lld)\n", ok, ng);
}
if (!func(ok)) return ok * 2 - ng;
return ok;
}
bool nextrouteint (int32_t arr[], int32_t n) {
int32_t i = n - 1;
int32_t j, x;
while (i > 0 && arr[i - 1] > arr[i]) i--;
if (i == 0) return false;
x = n;
for (j = i; j < n; j++) {
if (arr[j] < arr[i - 1]) continue;
if (x == n || arr[x] > arr[j]) x = j;
}
arr[i - 1] ^= arr[x];
arr[x] ^= arr[i - 1];
arr[i - 1] ^= arr[x];
qsort(&arr[i], n - i, sizeof(int32_t), pintcomp);
return true;
}
bool nextrouteull (ull arr[], int32_t n) {
int32_t i = n - 1;
int32_t j, x;
while (i > 0 && arr[i - 1] > arr[i]) i--;
if (i == 0) return false;
x = n;
for (j = i; j < n; j++) {
if (arr[j] < arr[i - 1]) continue;
if (x == n || arr[x] > arr[j]) x = j;
}
arr[i - 1] ^= arr[x];
arr[x] ^= arr[i - 1];
arr[i - 1] ^= arr[x];
qsort(&arr[i], n - i, sizeof(ull), pintcomp);
return true;
}
void printUquotient (ull left, ull right) {
const int32_t digits = 20;
printf("%llu.", left / right);
left %= right;
for (int32_t i = 0; i < digits; i++) {
left *= 10;
printf("%1d", left / right);
left %= right;
}
puts("");
return;
}
void printSquotient (sll left, sll right) {
if (left * right < 0) putchar('-');
printUquotient(sllabs(left, 0), sllabs(right, 0));
return;
}
int bitcount (ull n) {
int result = 0;
while (n) {
if (n & 1) result++;
n /= 2;
}
return result;
}
#ifdef __cplusplus
typedef struct {
int32_t to;
sll cost;
} edge;
typedef pair<sll, int32_t> P;
std::vector<edge> g[N_MAX];
void dijk_init (ull n, struct_b arr[]) {
edge x;
for (int32_t i = 0; i < n; i++) {
x.to = arr[i].to;
x.cost = arr[i].cost;
g[arr[i].from].push_back(x);
}
}
void dijk_distinit (int s, sll distance[], ull n) {
for (int32_t i = 0; i < n; i++) {
distance[i] = VERYBIG;
}
distance[s] = 0;
return;
}
bool dijkstra (int s, sll distance[]) {
priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号)
que.push(P(distance[s], s));
bool ischanged = false;
while (!que.empty()) {
P p = que.top();
que.pop();
sll v = p.second;
if (distance[v] < p.first) continue;
int32_t maxsize = g[v].size();
for (int32_t i = 0; i < maxsize; i++) {
edge e = g[v][i];
if (distance[e.to] > distance[v] + e.cost) {
distance[e.to] = distance[v] + e.cost;
ischanged = true;
que.push(P(distance[e.to], e.to));
}
}
}
return ischanged;
}
#endif
sll dist[N_MAX];
struct_b path[M_MAX * 2];
ull a[N_MAX];
// sll a[N_MAX];
// ull a[N_MAX][N_MAX];
// sll a[N_MAX][N_MAX];
ull b[N_MAX];
// sll b[N_MAX];
ull c[N_MAX];
// char c[N_MAX];
// char s[N_MAX + 1];
// char s[N_MAX + 1][N_MAX + 1];
// char s[N_MAX + 1][M_MAX + 1];
// char t[N_MAX + 1];
// ull alphabets[26];
// char alphabets[26];
// ull dp[N_MAX + 1];
// ull dp[N_MAX + 1][N_MAX + 1];
// bool dp[N_MAX + 1];
// bool dp[N_MAX + 1][N_MAX + 1];
hwll arr[N_MAX];
// typedef tuple<sll, int32_t, int32_t> P2d;
// ull dp[N_MAX + 1][N_MAX + 1];
double distance (sll x1, sll y1, sll x2, sll y2) {
double xdist2, ydist2, origindist, dist;
xdist2 = (x1 - x2) * (x1 - x2);
ydist2 = (y1 - y2) * (y1 - y2);
return sqrt(xdist2 + ydist2);
}
ull solve () {
sll i, j, ki, l;
ull result = 0;
// sll result = 0;
// double result = 0;
ull maybe = 0;
// sll maybe = 0;
ull sum = 0;
// sll sum = 0;
ull item;
ull *dpcell;
// qsortの際には"p"ullcompを使う
for (i = 0; i < n - 1; i++) {
path[i].to = path[i + (n - 1)].from = arr[i].a;
path[i].from = path[i + (n - 1)].to = arr[i].b;
path[i].cost = path[i + (n - 1)].cost = c[i];
}
dijk_init((n - 1) * 2, path);
dijk_distinit(k, dist, n);
dijkstra(k, dist);
for (i = 0; i < q; i++) {
printf("%llu\n", dist[a[i]] + dist[b[i]]);
}
// printf("%llu\n", result);
// printf("%.12lf\n", (double)result);
// puts(s);
return 0;
success:
puts("YES");
// puts("Yes");
// printf("%llu\n", result);
// puts("0");
// puts("Alice");
return 0;
fail:
puts("NO");
// puts("No");
// puts("0");
// puts("-1");
// puts("-1 -1 -1");
// puts("Eel");
return 1;
}
int32_t main (void) {
int32_t i, j;
int32_t x, y;
// scanf("%lf%lf", &vda, &vdb);
// scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud);
// scanf("%llu%llu", &h, &w);
scanf("%llu", &n, &m);
// scanf("%*llu");
// scanf("%llu", &k, &m, &n);
// scanf("%llu%llu", &vua, &vub, &vuc, &vud, &vue, &vuf);
// scanf("%lld", &vsa, &vsb, &vsc);
// scanf("%s", s);
// scanf("%s", t);
// scanf("%llu", &k);
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// // a[i]--;
// }
// for (i = 0; i < m; i++) {
// scanf("%llu", &b[i]);
// }
// for (i = 0; i < h; i++) {
// scanf("%s", s[i]);
// }
// scanf("%s", t);
for (i = 0; i < n - 1; i++) {
scanf("%llu", &arr[i].a);
scanf("%llu", &arr[i].b);
scanf("%llu", &c[i]);
arr[i].a--;
arr[i].b--;
}
// for (i = 0; i < n; i++) {
// for (j = 0; j < n; j++) {
// scanf("%llu", &a[i][j]);
// }
// }
// for (i = 0; i < n; i++) {
// scanf("%llu%llu%llu", &a[i], &b[i], &c[i]);
// }
scanf("%llu", &q);
scanf("%llu", &k);
k--;
for (i = 0; i < q; i++) {
scanf("%llu%llu", &a[i], &b[i]);
a[i]--;
b[i]--;
// solve();
}
// for (i = 0; i < m; i++) {
// scanf("%llu%llu", &arr[i].a, &arr[i].b);
// arr[i].a--;
// arr[i].b--;
// }
// for (i = 0; i < n; i++) {
// for (j = 0; j < m; j++) {
// scanf("%llu", &a[i][j]);
// a[i][j]--;
// }
// }
solve();
// for (i = 0; i < m; i++) {
// scanf("%llu%llu%llu", &vua, &vub, &vuc);
// // scanf("%s%s", s, t);
// // scanf("%f%f%f", &vda, &vdb, &vdc);
// // scanf("%s", s);
// solve();
// }
// while (scanf("%llu%llu", &n, &k), n + k) {
// for (i = 0; i < n; i++) {
// scanf("%llu", &a[i]);
// }
// solve();
// }
return 0;
}
| main.c: In function 'solve':
main.c:508:9: error: implicit declaration of function 'dijk_init' [-Wimplicit-function-declaration]
508 | dijk_init((n - 1) * 2, path);
| ^~~~~~~~~
main.c:509:9: error: implicit declaration of function 'dijk_distinit' [-Wimplicit-function-declaration]
509 | dijk_distinit(k, dist, n);
| ^~~~~~~~~~~~~
main.c:510:9: error: implicit declaration of function 'dijkstra' [-Wimplicit-function-declaration]
510 | dijkstra(k, dist);
| ^~~~~~~~
|
s114441357 | p03634 | C++ | #include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
using PP = pair<int, long long>;
int N, Q, K;
vector<int> G[100000];
long long dist[100000];
long long calc(int l, int r) {
return dist[l] + dist[r];
}
void dfs(int i, int prev) {
for(PP p : G[i]) {
int to = p.first;
if(to == prev) continue;
dist[to] = dist[i] + p.second;
dfs(to, i);
}
}
void solve() {
fill(dist, dist + N, 1ll << 62);
dist[K] = 0;
dfs(K, -1);
}
int main() {
cin >> N;
for(int i = 0; i < N - 1; ++i) {
int a,b,c;
cin >> a >> b >> c;
--a; --b;
G[a].push_back(PP(b, c));
G[b].push_back(PP(a, c));
}
cin >> Q >> K;
--K;
solve();
for(int i = 0; i < Q; ++i) {
int l, r;
cin >> l >> r;
--l; --r;
cout << calc(l, r) << endl;
}
return 0;
}
| a.cc: In function 'void dfs(int, int)':
a.cc:18:17: error: conversion from 'int' to non-scalar type 'PP' {aka 'std::pair<int, long long int>'} requested
18 | for(PP p : G[i]) {
| ^
a.cc: In function 'int main()':
a.cc:38:19: error: no matching function for call to 'std::vector<int>::push_back(PP)'
38 | G[a].push_back(PP(b, c));
| ~~~~~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from 'PP' {aka 'std::pair<int, long long int>'} to 'const std::vector<int>::value_type&' {aka 'const int&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from 'PP' {aka 'std::pair<int, long long int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
a.cc:39:19: error: no matching function for call to 'std::vector<int>::push_back(PP)'
39 | G[b].push_back(PP(a, c));
| ~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1283 | push_back(const value_type& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note: no known conversion for argument 1 from 'PP' {aka 'std::pair<int, long long int>'} to 'const std::vector<int>::value_type&' {aka 'const int&'}
1283 | push_back(const value_type& __x)
| ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
1300 | push_back(value_type&& __x)
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note: no known conversion for argument 1 from 'PP' {aka 'std::pair<int, long long int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
1300 | push_back(value_type&& __x)
| ~~~~~~~~~~~~~^~~
|
s827076652 | p03634 | C++ | #include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using PP = pair<int, long long>;
int N, Q, K;
vector<int> G[100000];
long long dist[100000];
long long calc(int l, int r) {
return dist[l] + dist[r];
}
void dfs(int i, int prev) {
for(PP p : G[i]) {
int to = p.first;
if(to == prev) continue;
dist[to] = dist[i] + p.second;
dfs(to, i);
}
}
void solve() {
fill(dist, dist + N, 1ll << 62);
dist[K] = 0;
dfs(K, -1);
}
int main() {
cin >> N;
for(int i = 0; i < N - 1; ++i) {
int a,b,c;
cin >> a >> b >> c;
--a; --b;
G[a].push_back(PP(b, c));
G[b].push_back(PP(a, c));
}
cin >> Q >> K;
--K;
solve();
for(int i = 0; i < Q; ++i) {
int l, r;
cin >> l >> r;
--l; --r;
cout << calc(l, r) << endl;
}
return 0;
} | a.cc:5:12: error: 'pair' does not name a type
5 | using PP = pair<int, long long>;
| ^~~~
a.cc:8:1: error: 'vector' does not name a type
8 | vector<int> G[100000];
| ^~~~~~
a.cc: In function 'void dfs(int, int)':
a.cc:17:7: error: 'PP' was not declared in this scope
17 | for(PP p : G[i]) {
| ^~
a.cc:23:1: error: expected primary-expression before '}' token
23 | }
| ^
a.cc:22:4: error: expected ';' before '}' token
22 | }
| ^
| ;
23 | }
| ~
a.cc:23:1: error: expected primary-expression before '}' token
23 | }
| ^
a.cc:22:4: error: expected ')' before '}' token
22 | }
| ^
| )
23 | }
| ~
a.cc:17:6: note: to match this '('
17 | for(PP p : G[i]) {
| ^
a.cc:23:1: error: expected primary-expression before '}' token
23 | }
| ^
a.cc: In function 'void solve()':
a.cc:26:3: error: 'fill' was not declared in this scope; did you mean 'std::fill'?
26 | fill(dist, dist + N, 1ll << 62);
| ^~~~
| std::fill
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: 'std::fill' declared here
191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~
a.cc: In function 'int main()':
a.cc:32:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
32 | cin >> N;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:37:5: error: 'G' was not declared in this scope
37 | G[a].push_back(PP(b, c));
| ^
a.cc:37:20: error: 'PP' was not declared in this scope
37 | G[a].push_back(PP(b, c));
| ^~
a.cc:48:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
48 | cout << calc(l, r) << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:48:27: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
48 | cout << calc(l, r) << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s471725766 | p03634 | C++ | #include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<fcntl.h>
#include<unistd.h>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
struct Graph{
struct Edge{
int cost, from, dest;
Edge(int cost, int dest): cost(cost), from(-1), dest(dest){ }
Edge(int cost, int from, int dest): cost(cost), from(from), dest(dest){ }
ostream& operator >> (ostream& out){
return out << '(' << cost << ':' << from << ' ' << dest << ')';
}
};
struct Node{
vector<Edge> edges;
};
vector<Node> nodes;
Graph(int num): nodes(num){ }
void addEdge(int from, int dest, int cost = 1){
nodes[from].edges.emplace_back(cost, dest);
}
void addEdge2(int from, int dest, int cost = 1){
addEdge(from, dest, cost);
addEdge(dest, from, cost);
}
ll dijkstra2(int start, vector<ll> &lens){
struct DElem{
ll cost, dest;
bool operator < (const DElem& e) const { return cost > e.cost; }
};
priority_queue<DElem> pq;
pq.push({0, start});
while(pq.size()){
auto e = pq.top(); pq.pop();
if(lens[e.dest] <= e.cost){ continue; }
lens[e.dest] = e.cost;
for(auto& edge : nodes[e.dest].edges){
if(lens[edge.dest] > e.cost + edge.cost){
pq.push({e.cost + edge.cost, edge.dest});
}
}
}
return -1;
}
};
char buf[1 << 22];
char isnum[255] = { ['0'] = 1, ['1'] = 1, ['2'] = 1, ['3'] = 1, ['4'] = 1, ['5'] = 1, ['6'] = 1, ['7'] = 1, ['8'] = 1, ['9'] = 1, };
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cin.read(buf, sizeof(buf) - 1);
// read(STDIN_FILENO, buf, sizeof(buf) - 1);
int idx = 0;
auto next = [&](){
int ret = 0;
while(!isnum[(int)buf[idx]]){ idx++; }
while(isnum[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
return ret;
};
int n = 0;
while(isdigit(buf[idx])){
n = n * 10 + buf[idx++] - '0';
}
Graph g(n);
for(int i = 0; i < n - 1; i++){
int a = next(), b = next(), c = next();
a--; b--;
g.addEdge2(a, b, c);
}
int q = next(), k = next();
k--;
vector<ll> lens(n, MLL);
g.dijkstra2(k, lens);
prints(lens);
for(int i = 0; i < q; i++){
int x = next(), y = next();
x--; y--;
cout << lens[x] + lens[y] << '\n';
}
// int n; cin >> n;
// Graph g(n);
// for(int i = 0; i < n - 1; i++){
// int a, b, c;
// cin >> a >> b >> c;
// a--; b--;
// g.addEdge2(a, b, c);
// }
// int q, k;
// cin >> q >> k;
// k--;
// vector<ll> lens(n, MLL);
// g.dijkstra2(k, lens);
// prints(lens);
// for(int i = 0; i < q; i++){
// int x, y;
// cin >> x >> y;
// x--; y--;
// cout << lens[x] + lens[y] << '\n';
// }
}
| a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
72 | char isnum[255] = { ['0'] = 1, ['1'] = 1, ['2'] = 1, ['3'] = 1, ['4'] = 1, ['5'] = 1, ['6'] = 1, ['7'] = 1, ['8'] = 1, ['9'] = 1, };
| ^
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
a.cc:72:131: sorry, unimplemented: non-trivial designated initializers not supported
|
s450267939 | p03634 | C++ | #include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<cstdio>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
struct Graph{
struct Edge{
int cost, from, dest;
Edge(int cost, int dest): cost(cost), from(-1), dest(dest){ }
Edge(int cost, int from, int dest): cost(cost), from(from), dest(dest){ }
ostream& operator >> (ostream& out){
return out << '(' << cost << ':' << from << ' ' << dest << ')';
}
};
struct Node{
vector<Edge> edges;
};
vector<Node> nodes;
Graph(int num): nodes(num){ }
void addEdge(int from, int dest, int cost = 1){
nodes[from].edges.emplace_back(cost, dest);
}
void addEdge2(int from, int dest, int cost = 1){
addEdge(from, dest, cost);
addEdge(dest, from, cost);
}
ll dijkstra2(int start, vector<ll> &lens){
struct DElem{
ll cost, dest;
bool operator < (const DElem& e) const { return cost > e.cost; }
};
priority_queue<DElem> pq;
pq.push({0, start});
while(pq.size()){
auto e = pq.top(); pq.pop();
if(lens[e.dest] <= e.cost){ continue; }
lens[e.dest] = e.cost;
for(auto& edge : nodes[e.dest].edges){
if(lens[edge.dest] > e.cost + edge.cost){
pq.push({e.cost + edge.cost, edge.dest});
}
}
}
return -1;
}
};
char buf[1 << 22];
int main(){
// cin.tie(0);
// ios::sync_with_stdio(false);
// cin.read(buf, sizeof(buf) - 1);
read(STDIN_FILENO, buf, sizeof(buf) - 1);
int idx = 0;
auto next = [&](){
int ret = 0;
while(!isdigit(buf[idx])){ idx++; }
while(isdigit(buf[idx])){ ret = ret * 10 + buf[idx++] - '0'; }
return ret;
};
int n = 0;
while(isdigit(buf[idx])){
n = n * 10 + buf[idx++] - '0';
}
Graph g(n);
for(int i = 0; i < n - 1; i++){
int a = next(), b = next(), c = next();
a--; b--;
g.addEdge2(a, b, c);
}
int q = next(), k = next();
k--;
vector<ll> lens(n, MLL);
g.dijkstra2(k, lens);
prints(lens);
for(int i = 0; i < q; i++){
int x = next(), y = next();
x--; y--;
cout << lens[x] + lens[y] << '\n';
}
// int n; cin >> n;
// Graph g(n);
// for(int i = 0; i < n - 1; i++){
// int a, b, c;
// cin >> a >> b >> c;
// a--; b--;
// g.addEdge2(a, b, c);
// }
// int q, k;
// cin >> q >> k;
// k--;
// vector<ll> lens(n, MLL);
// g.dijkstra2(k, lens);
// prints(lens);
// for(int i = 0; i < q; i++){
// int x, y;
// cin >> x >> y;
// x--; y--;
// cout << lens[x] + lens[y] << '\n';
// }
}
| a.cc: In function 'int main()':
a.cc:76:10: error: 'STDIN_FILENO' was not declared in this scope
76 | read(STDIN_FILENO, buf, sizeof(buf) - 1);
| ^~~~~~~~~~~~
a.cc:76:5: error: 'read' was not declared in this scope; did you mean 'fread'?
76 | read(STDIN_FILENO, buf, sizeof(buf) - 1);
| ^~~~
| fread
|
s763687742 | p03634 | C++ | #include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
struct Graph{
struct Edge{
int cost, from, dest;
Edge(int cost, int dest): cost(cost), from(-1), dest(dest){ }
Edge(int cost, int from, int dest): cost(cost), from(from), dest(dest){ }
ostream& operator >> (ostream& out){
return out << '(' << cost << ':' << from << ' ' << dest << ')';
}
};
struct Node{
vector<Edge> edges;
};
vector<Node> nodes;
Graph(int num): nodes(num){ }
void addEdge(int from, int dest, int cost = 1){
nodes[from].edges.emplace_back(cost, dest);
}
void addEdge2(int from, int dest, int cost = 1){
addEdge(from, dest, cost);
addEdge(dest, from, cost);
}
ll dijkstra2(int start, vector<ll> &lens){
struct DElem{
ll cost, dest;
bool operator < (const DElem& e) const { return cost > e.cost; }
};
priority_queue<DElem> pq;
pq.push({0, start});
while(pq.size()){
auto e = pq.top(); pq.pop();
if(lens[e.dest] <= e.cost){ continue; }
lens[e.dest] = e.cost;
for(auto& edge : nodes[e.dest].edges){
if(lens[edge.dest] > e.cost + edge.cost){
pq.push({e.cost + edge.cost, edge.dest});
}
}
}
return -1;
}
};
char buf[1 << 22];
int main(){
// cin.tie(0);
// ios::sync_with_stdio(false);
// cin.read(buf, sizeof(buf) - 1);
read(STDIN_FILENO, buf, sizeof(buf) - 1);
int idx = 0;
auto next = [&](){
int ret = 0;
while(!isdigit(buf[idx])){ idx++; }
while(isdigit(buf[idx])){ ret = ret * 10 + buf[idx++] - '0'; }
return ret;
};
int n = 0;
while(isdigit(buf[idx])){
n = n * 10 + buf[idx++] - '0';
}
Graph g(n);
for(int i = 0; i < n - 1; i++){
int a = next(), b = next(), c = next();
a--; b--;
g.addEdge2(a, b, c);
}
int q = next(), k = next();
k--;
vector<ll> lens(n, MLL);
g.dijkstra2(k, lens);
prints(lens);
for(int i = 0; i < q; i++){
int x = next(), y = next();
x--; y--;
cout << lens[x] + lens[y] << '\n';
}
// int n; cin >> n;
// Graph g(n);
// for(int i = 0; i < n - 1; i++){
// int a, b, c;
// cin >> a >> b >> c;
// a--; b--;
// g.addEdge2(a, b, c);
// }
// int q, k;
// cin >> q >> k;
// k--;
// vector<ll> lens(n, MLL);
// g.dijkstra2(k, lens);
// prints(lens);
// for(int i = 0; i < q; i++){
// int x, y;
// cin >> x >> y;
// x--; y--;
// cout << lens[x] + lens[y] << '\n';
// }
}
| a.cc: In function 'int main()':
a.cc:75:10: error: 'STDIN_FILENO' was not declared in this scope
75 | read(STDIN_FILENO, buf, sizeof(buf) - 1);
| ^~~~~~~~~~~~
a.cc:75:5: error: 'read' was not declared in this scope; did you mean 'fread'?
75 | read(STDIN_FILENO, buf, sizeof(buf) - 1);
| ^~~~
| fread
|
s360045463 | p03634 | Java | import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
List<List<Edge>> edges = new ArrayList<>(n);
for(int i = 0;i < n;i++){
edges.add(new ArrayList<>());
}
for(int i = 0;i < n-1;i++){
int a = sc.nextInt() - 1;
int b = sc.nextInt() - 1;
int c= sc.nextInt();
edges.get(a).add(new Edge(a,b,c));
edges.get(b).add(new Edge(b,a,c));
}
int q = sc.nextInt();
int k = sc.nextInt() - 1;
int x[] = new int[q];
int y[] = new int[q];
for(int i = 0;i < q;i++){
x[i] = sc.nextInt()-1;
y[i] = sc.nextInt()-1;
}
long d[] = new long[n];
boolean used[] = new boolean[n];
Deque<Integer> st = new ArrayDeque<>();
st.push(k);
while(!st.isEmpty()){
int e = st.pop();
used[e] = true;
for(Edge next:edges.get(e)){
if(used[next.v]){
continue;
}
d[next.v] = d[e] + next.w;
st.push(next.v);
}
}
for(int i = 0;i < q;i++){
System.out.println(d[x[i]] + d[y[i]]);
}
}
static class Edge{
int u;//from
int v;//to
int w;//cost
Edge(int u ,int v,int w){
this.u = u;
this.v = v;
this.w = w;
}
}
} | Main.java:2: error: illegal character: '\u00a0'
?
^
Main.java:3: error: class, interface, enum, or record expected
class Main{
^
Main.java:5: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args){
^
(use --enable-preview to enable unnamed classes)
Main.java:78: error: class, interface, enum, or record expected
}
^
4 errors
|
s250620434 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define FOR(i,s,n) for(int i=s;i<n;++i)
#define FORR(i,s,n) for(int i=n-1;i>=s;--i)
#define ALL(c) (c).begin(),(c).end()
#define CLEAR(v) memset(v,0,sizeof(v))
#define MP(a,b) make_pair((a),(b))
#define ABS(a) ((a)>0?(a):-(a))
#define F first
#define S second
ll n, q, k, a, b, c;
vector<P> es[100000];
ll d[100000];
void dfs(int v, int pa, ll x) {
d[v] = x;
REP(i, es[v].size()) if (es[v][i].F != pa) dfs(es[v][i].F, v, x + es[v][i].S);
}
int main(int argc, char **argv) {
cin >> n;
REP(i, n) {
cin >> a >> b >> c;
--a; --b;
es[a].push_back(MP(b, c));
es[b].push_back(MP(a, c));
}
cin >> q >> k;
dfs(k, -1, 0);
REP(i, q) {
cin >> x >> y;
--x; --y;
cout << (d[x] + d[y]) << endl;
}
return 0;
}
| a.cc: In function 'int main(int, char**)':
a.cc:45:24: error: 'x' was not declared in this scope
45 | cin >> x >> y;
| ^
a.cc:45:29: error: 'y' was not declared in this scope
45 | cin >> x >> y;
| ^
|
s489404045 | p03634 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, ll> pil;
typedef vector<pil> vpil;
vector<vpil> adj;
vector<ll> d;
void dfs(int x) {
for(auto e:adj[x]) if(d[e.first]==-1) {
d[e.first]=d[x]+e.second;
dfs(e.first);
}
}
int main() {
int i, k, q, n, u, v;
ll w;
scanf("%d", &n);
adj.assign(n+1, vpil(0));
for(i=0; i<n-1; i++) {
scanf("%d%d%lld", &u, &v, &w);
adj[u].push_back(pil(v, w));
adj[v].push_back(pil(u, w));
}
d.assign(n+1, -1);
scanf("%d%d", &q, &k);
d[k]=0;
dfs(k);
for(; q; q--) {
scanf("%d%d", &u, &v);
printf("%lld\n", d[u]+d[v]);
}
return 0;
} | a.cc:7:9: error: 'vector' does not name a type
7 | typedef vector<pil> vpil;
| ^~~~~~
a.cc:9:1: error: 'vector' does not name a type
9 | vector<vpil> adj;
| ^~~~~~
a.cc:10:1: error: 'vector' does not name a type
10 | vector<ll> d;
| ^~~~~~
a.cc: In function 'void dfs(int)':
a.cc:13:20: error: 'adj' was not declared in this scope
13 | for(auto e:adj[x]) if(d[e.first]==-1) {
| ^~~
a.cc:13:31: error: 'd' was not declared in this scope
13 | for(auto e:adj[x]) if(d[e.first]==-1) {
| ^
a.cc: In function 'int main()':
a.cc:23:9: error: 'adj' was not declared in this scope
23 | adj.assign(n+1, vpil(0));
| ^~~
a.cc:23:25: error: 'vpil' was not declared in this scope; did you mean 'pil'?
23 | adj.assign(n+1, vpil(0));
| ^~~~
| pil
a.cc:29:9: error: 'd' was not declared in this scope
29 | d.assign(n+1, -1);
| ^
|
s819096743 | p03634 | C++ | 10
1 2 1000000000
2 3 1000000000
3 4 1000000000
4 5 1000000000
5 6 1000000000
6 7 1000000000
7 8 1000000000
8 9 1000000000
9 10 1000000000
1 1
9 10 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 10
| ^~
|
s130006338 | p03634 | C | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <algorithm>
#define inf 1000000000000000000
#define MAX 100010
#define M 1010
#define ll long long
using namespace std;
ll mp[M][M];
ll dist[M];
int p[M];
int c[MAX];
int main()
{
int n,m,o,x,y,z;
scanf("%d",&n);
memset(p,0,sizeof(p));
memset(c,0,sizeof(c));
for (int i = 0; i < M; i++)
{
dist[i]=inf;
for (int j = 0; j < M; j++)
{
mp[i][j]=inf;
}
}
int ic=1;
for (int i = 1; i < n; i++)
{
scanf("%d%d%d",&x,&y,&z);
if(c[x]==0)c[x]=ic++;
if(c[y]==0)c[y]=ic++;
if(mp[c[x]][c[y]]>z)mp[c[x]][c[y]]=mp[c[y]][c[x]]=z;
}
scanf("%d%d",&m,&o);
int point=c[o],iMIN;
ll MIN;
dist[c[o]]=0;
for (int i = 1; i < ic; i++)
{
if(i==c[o])continue;
MIN=inf+1;iMIN=0;
for (int j = 1; j < ic; j++)
{
if(j==c[o])continue;
if(p[j]==0)
{
dist[j]=min(dist[point]+mp[point][j],dist[j]);
if(MIN>dist[j]){MIN=dist[j];iMIN=j;}
}
}
point=iMIN;
p[point]=1;
}
for (int i = 0; i < m; i++)
{
scanf("%d%d",&x,&y);
if(x==o&&y==o)printf("0\n");
else if(x==o)printf("%lld\n",dist[c[y]]);
else if(y==o)printf("%lld\n",dist[c[x]]);
else printf("%lld\n",dist[c[x]]+dist[c[y]]);
}
return 0;
} | main.c:2:10: fatal error: iostream: No such file or directory
2 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s231626810 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Edge {
int to, cost;
};
int N, Q, K;
vector<Edge> d[100000];
ll v[100000];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
for (int i = 1; i < N; i++) {
int a, b, c;
--a, --b;
d[a].emplace_back((edge) {b, c});
d[b].emplace_back((edge) {a, c});
}
cin >> Q >> K;
dfs(--N);
while (Q--) {
int x, y;
cin >> x >> y;
--x, --y;
cout << v[x] + v[y] << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:24: error: 'edge' was not declared in this scope; did you mean 'Edge'?
23 | d[a].emplace_back((edge) {b, c});
| ^~~~
| Edge
a.cc:24:29: error: expected ')' before '{' token
24 | d[b].emplace_back((edge) {a, c});
| ~ ^~
| )
a.cc:27:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
27 | dfs(--N);
| ^~~
| ffs
|
s315711714 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Edge {
int to, cost;
}
int N, Q, K;
vector<Edge> d[100000];
ll v[100000];
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N;
for (int i = 1; i < N; i++) {
int a, b, c;
--a, --b;
d[a].emplace_back((edge) {b, c});
d[b].emplace_back((edge) {a, c});
}
cin >> Q >> K;
dfs(--N);
while (Q--) {
int x, y;
cin >> x >> y;
--x, --y;
cout << v[x] + v[y] << endl;
}
return 0;
}
| a.cc:9:2: error: expected ';' after struct definition
9 | }
| ^
| ;
a.cc: In function 'int main()':
a.cc:23:24: error: 'edge' was not declared in this scope; did you mean 'Edge'?
23 | d[a].emplace_back((edge) {b, c});
| ^~~~
| Edge
a.cc:24:29: error: expected ')' before '{' token
24 | d[b].emplace_back((edge) {a, c});
| ~ ^~
| )
a.cc:27:3: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
27 | dfs(--N);
| ^~~
| ffs
|
s791324586 | p03634 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define REP(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,q,k;
vector<P>edge[100005];
ll cheat[100005];
void dfs(int v,int u,ll sum){
cheat[v] = sum;
REP(i,edge[v].size()){
if(edge[v][i].fi == u) continue;
dfs(edge[v][i].fi,v,sum+edge[v][i].sc);
}
}
int main(){
cin >> n
REP(i,n-1){
int a,b,c; scanf("%d%d%d",&a,&b,&c);
edge[a].pb(mp(b,c));
edge[b].pb(mp(a,c));
}
cin >> q >> k;
dfs(k,-1,0LL)
REP(i,q){
cin >> a >> b;
cout << cheat[a]+cheat[b];
}
} | a.cc: In function 'int main()':
a.cc:30:17: error: expected ';' before 'for'
30 | cin >> n
| ^
| ;
a.cc:31:13: error: 'i' was not declared in this scope
31 | REP(i,n-1){
| ^
a.cc:14:30: note: in definition of macro 'REP'
14 | #define REP(i,x) for(int i=0;i<x;i++)
| ^
a.cc:37:22: error: expected ';' before 'for'
37 | dfs(k,-1,0LL)
| ^
| ;
|
s932311335 | p03634 | C++ | import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class Main {
static List <Edge>G[];
static int n, q, k, x[], y[];
static long path[];
static boolean used[];
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
n = scan.nextInt();
G = new List[n];
used = new boolean[n];
path = new long[n];
for(int i = 0;i < n;i++)G[i] = new LinkedList<>();
for(int i = 0;i < n-1;i++){
int a, b, c;
a = scan.nextInt();
b = scan.nextInt();
c = scan.nextInt();
G[a-1].add(new Edge(b-1, c));
G[b-1].add(new Edge(a-1, c));
}
q = scan.nextInt();
k = scan.nextInt();
x = new int[q]; y = new int[q];
for(int i = 0;i < q;i++){
x[i] = scan.nextInt();
y[i] = scan.nextInt();
}
used[k-1] = true;
search(k-1);
/*for(int i = 0;i < n;i++){
System.out.println(k+"番目から"+(i+1)+"番目までのコストは"+path[i]+"である");
}*/
for(int i = 0;i < q;i++){
long ans = path[x[i]-1]+path[y[i]-1];
System.out.println(ans);
}
}
static void search(int v){
for(int i = 0;i < G[v].size();i++){
Edge e = G[v].get(i);
if(!used[e.to]){
path[e.to] = path[v] + e.cost;
used[e.to] = true;
search(e.to);
}
}
return;
}
}
class Edge{
int to;
int cost;
Edge(int to, int cost){
this.to = to;
this.cost = cost;
}
} | a.cc:1:1: error: 'import' does not name a type
1 | import java.util.LinkedList;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.util.List;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.Scanner;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: expected unqualified-id before 'public'
5 | public class Main {
| ^~~~~~
a.cc:66:2: error: expected ';' after class definition
66 | }
| ^
| ;
a.cc: In constructor 'Edge::Edge(int, int)':
a.cc:63:14: error: request for member 'to' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
63 | this.to = to;
| ^~
a.cc:64:14: error: request for member 'cost' in '(Edge*)this', which is of pointer type 'Edge*' (maybe you meant to use '->' ?)
64 | this.cost = cost;
| ^~~~
|
s878618496 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
const int max_v = 100010;
const long infinite = 1000'0000'0000'0000;
long cost[max_v][max_v]; // e=(u,v) cost, if not exists, INF
long d[max_v]; // distance
bool used[max_v]; // flag
int V; // vertex count
void dijkstra(int s) {
fill(d, d + V, infinite);
fill(used, used + V, false);
d[s] = 0;
while(true) {
int v = -1;
// find minimum distance not used vertex
for(int u = 0; u < V; u++) {
if(!used[u] && (v == -1 || d[u] < d[v])) {
v = u;
}
}
if(v == -1) {
break;
}
used[v] = true;
for(int u = 0; u < V; u++) {
d[u] = min(d[u], d[v] + cost[v][u]);
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.precision(16);
int n;
cin >> n;
for(int i = 0; i <= n; i++) {
fill(cost[i], cost[i] + max_v, infinite);
}
int a, b, c;
for(int i = 0; i < n - 1; i++) {
cin >> a >> b >> c;
cost[a][b] = c;
cost[b][a] = c;
}
int q, k;
cin >> q >> k;
V = n + 1;
dijkstra(k);
int x, y;
for(int i = 0; i < q; i++) {
cin >> x >> y;
cout << d[x] + d[y] << endl;
}
return 0;
} | /tmp/cccBRRda.o: in function `dijkstra(int)':
a.cc:(.text+0xd): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0x32): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0x44): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0x62): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0xdf): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cccBRRda.o
a.cc:(.text+0xf8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s840968193 | p03634 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF 1<<29
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
const int max_v = 100010;
const long infinite = 1000'0000'0000'0000;
long cost[max_v][max_v]; // e=(u,v) cost, if not exists, INF
long d[max_v]; // distance
bool used[max_v]; // flag
int V; // vertex count
void dijkstra(int s) {
fill(d, d + V, infinite);
fill(used, used + V, false);
d[s] = 0;
while(true) {
int v = -1;
// find minimum distance not used vertex
for(int u = 0; u < V; u++) {
if(!used[u] && (v == -1 || d[u] < d[v])) {
v = u;
}
}
if(v == -1) {
break;
}
used[v] = true;
for(int u = 0; u < V; u++) {
d[u] = min(d[u], d[v] + cost[v][u]);
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout.precision(16);
int n;
cin >> n;
for(int i = 0; i <= n; i++) {
fill(cost[i], cost[i] + max_v, infinite);
}
int a, b, c;
for(int i = 0; i < n - 1; i++) {
cin >> a >> b >> c;
cost[a][b] = c;
cost[b][a] = c;
}
int q, k;
cin >> q >> k;
V = n + 1;
dijkstra(k);
int x, y;
for(int i = 0; i < q; i++) {
cin >> x >> y;
#if DEBUG
cout << "** RESULT **" << endl; // debug
_DDEBUG(x, y);
_DDEBUG(d[x], d[y]);
#endif
cout << d[x] + d[y] << endl;
}
return 0;
} | /tmp/cc1fp4X0.o: in function `dijkstra(int)':
a.cc:(.text+0xd): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0x1e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0x32): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0x44): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0x62): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `used' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0xc7): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0xdf): relocation truncated to fit: R_X86_64_PC32 against symbol `d' defined in .bss section in /tmp/cc1fp4X0.o
a.cc:(.text+0xf8): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.