submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s565352050
p03633
C
#include <stdio.h> int main(void) { int n=0,i=0,r=0,tmp=0; scanf("%d",&n); __int64 t[200]; t[0]=1; for (i=1;i<n+1;++i) { scanf("%d",&t[i]); if(t[i]>t[i-1]){ tmp=t[i]; t[i]=t[i-1]; t[i-1]=tmp; } int x=t[i]*t[i-1]; r=t[i]%t[i-1]; while(r!=0){ t[i]=t[i-1]; t[i-1]=r; r=t[i]%t[i-1]; } t[i]=x/t[i-1]; } printf("%d", t[n]); }
main.c: In function 'main': main.c:9:1: error: unknown type name '__int64'; did you mean '__int64_t'? 9 | __int64 t[200]; | ^~~~~~~ | __int64_t
s200101811
p03633
C++
def gcd(a, b): if a < b: a, b = b, a if b == 0: return a else: return gcd(b, a%b) def lcm(a, b): return a // gcd(a, b) * b N = input() V = 1 for i in range(int(N)): T = input() V = lcm(V, int(T)) print(V)
a.cc:1:1: error: 'def' does not name a type 1 | def gcd(a, b): | ^~~
s631468852
p03633
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define _abs(x)((x) < 0 ? (x) * -1 : (x)) #define _max(x, y)(max(0, max((x), (y)))) #define _min(x, y)(max(0, min((x), (y)))) int main() { //freopen("in.txt", "r", stdin); //freopen("out.txt", "w", stdout); //freopen("debug.txt", "w", stderr); cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<ll> odd; ll evenMax = 0; ll oddMax = 0; ll t; bool isNo = true; int i; for (i = 0; i < n; i++) { cin >> t; if (t % 2 == 0) { evenMax = max(evenMax, t); } else { odd.push_back(t); oddMax = max(oddMax, t); } } len = odd.size(); if (0 < evenMax) { while (isNo) { isNo = false; for (i = 0; i < len; i++) { if (evenMax % odd[i] != 0) { isNo = true; break; } } if (isNo) evenMax += evenMax; } cout << evenMax << endl; } else { while (isNo) { isNo = false; for (i = 0; i < len; i++) { if (oddMax % odd[i] != 0) { isNo = true; break; } } if (isNo) oddMax += oddMax; } cout << oddMax << endl; } return 0; }
a.cc: In function 'int main()': a.cc:44:5: error: 'len' was not declared in this scope 44 | len = odd.size(); | ^~~
s028363588
p03633
C++
#include <iostream> #include <stdio.h> #include <string> #include <cstdlib> #include <cmath> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <time.h> #define int long long #define US unsigned using namespace std; const double PI = acos(-1.0); int max_n(int ary[], int length) { int max = ary[0]; for (int i = 1; i < length; i++) if (max < ary[i]) max = ary[i]; return max; } int max_o(int ary[], int length) { int max; max = max_n(ary, length); for (int i = 0; i < length; i++) { if (ary[i] == max) return i; } return -1; } int min_n(int ary[], int length) { int min = ary[0]; for (int i = 1; i < length; i++) if (min > ary[i]) min = ary[i]; return min; } int min_o(int ary[], int length) { int min; min = min_n(ary, length); for (int i = 0; i < length; i++) { if (ary[i] == min) return i; } return -1; } int gcm(int a, int b) { int result = a; int k = 0; int n = b; do { k = result % n; result = n; n = k; } while (k != 0); return result; } int gcm_n(int ary[], int length) { int g = ary[0]; for (int i = 0; i < length; i++) g = gcm(g, ary[i]); return g; } int lcm(int a, int b) { int g, n; g = gcm(a, b); n = gcm(a, g); a = a / n; b = b / (g / n); return a*b; } int lcm_n(int ary[], int length) { int l = ary[0]; for (int i = 0; i < length; i++) l = lcm(l, ary[i]); return l; } long main() { int n, t[100]; cin >> n; for (int i = 0; i < n; i++) cin >> t[i]; cout << lcm_n(t, n) << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s090843862
p03633
C++
#include <iostream> #include <stdio.h> #include <string> #include <cstdlib> #include <cmath> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <time.h> #define int long long #define US unsigned using namespace std; const double PI = acos(-1.0); int max_n(int ary[], int length) { int max = ary[0]; for (int i = 1; i < length; i++) if (max < ary[i]) max = ary[i]; return max; } int max_o(int ary[], int length) { int max; max = max_n(ary, length); for (int i = 0; i < length; i++) { if (ary[i] == max) return i; } return -1; } int min_n(int ary[], int length) { int min = ary[0]; for (int i = 1; i < length; i++) if (min > ary[i]) min = ary[i]; return min; } int min_o(int ary[], int length) { int min; min = min_n(ary, length); for (int i = 0; i < length; i++) { if (ary[i] == min) return i; } return -1; } int gcm(int a, int b) { int result = a; int k = 0; int n = b; do { k = result % n; result = n; n = k; } while (k != 0); return result; } int gcm_n(int ary[], int length) { int g = ary[0]; for (int i = 0; i < length; i++) g = gcm(g, ary[i]); return g; } int lcm(int a, int b) { int g, n; g = gcm(a, b); n = gcm(a, g); a = a / n; b = b / (g / n); return a*b; } int lcm_n(int ary[], int length) { int l = ary[0]; for (int i = 0; i < length; i++) l = lcm(l, ary[i]); return l; } short main() { int n, t[100]; cin >> n; for (int i = 0; i < n; i++) cin >> t[i]; cout << lcm_n(t, n) << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s965463895
p03633
C++
#include<bits/stdc++.h> using namespace std; typedef unsigned long long int ull; ull gcd(ull a, ull b) { if (b==0) return a; return gcd(b, a%b); } ull findlcm(ull arr[], ull n) { ull ans = arr[0]; for (int i=1; i<n; i++){ ull g=gcd(arr[i], ans) ; ans = (arr[i]/g)*; } return ans; } int main() { ull n,a[105],ans; cin>>n; for(int i=0;i<n;i++) cin>>a[i]; ans=findlcm(a,n); cout<<ans<<endl; return 0; }
a.cc: In function 'ull findlcm(ull*, ull)': a.cc:17:26: error: expected primary-expression before ';' token 17 | ans = (arr[i]/g)*; | ^
s108760122
p03633
C++
#include <iostream> #include <stdio.h> #include <string> #include <cstdlib> #include <cmath> #include <algorithm> #include <string.h> #include <vector> #include <queue> #include <stack> #include <set> #include <map> #include <time.h> #define int long long #define US unsigned using namespace std; const double PI = acos(-1.0); int max_n(int ary[], int length) { int max = ary[0]; for (int i = 1; i < length; i++) if (max < ary[i]) max = ary[i]; return max; } int max_o(int ary[], int length) { int max; max = max_num(ary, length); for (int i = 0; i < length; i++) { if (ary[i] == max) return i; } return -1; } int min_n(int ary[], int length) { int min = ary[0]; for (int i = 1; i < length; i++) if (min > ary[i]) min = ary[i]; return min; } int min_o(int ary[], int length) { int min; min = min_num(ary, length); for (int i = 0; i < length; i++) { if (ary[i] == min) return i; } return -1; } int gcm(int a, int b) { int result = a; int k = 0; int n = b; do { k = result % n; result = n; n = k; } while (k != 0); return result; } int gcm_n(int ary[], int length) { int g = ary[0]; for (int i = 0; i < length; i++) g = gcm(g, ary[i]); return g; } int lcm(int a, int b) { int g, n; g = gcm(a, b); n = gcm(a, g); a = a / n; b = b / (g / n); return a*b; } int lcm_n(int ary[], int length) { int l = ary[0]; for (int i = 0; i < length; i++) l = lcm(l, ary[i]); return l; } short main() { int n, t[100]; cin >> n; for (int i = 0; i < n; i++) cin >> t[i]; cout << lcm_n(t, n) << endl; return 0; }
a.cc: In function 'long long int max_o(long long int*, long long int)': a.cc:28:15: error: 'max_num' was not declared in this scope; did you mean 'max_n'? 28 | max = max_num(ary, length); | ^~~~~~~ | max_n a.cc: In function 'long long int min_o(long long int*, long long int)': a.cc:44:15: error: 'min_num' was not declared in this scope; did you mean 'min_n'? 44 | min = min_num(ary, length); | ^~~~~~~ | min_n At global scope: cc1plus: error: '::main' must return 'int'
s401952759
p03633
C++
#pragma region ヘッダー #define _CRT_SECURE_NO_WARNINGS #ifdef _____MY_DEBUG_____ #define VS_ENDPAUSE() (system("pause")) #define DEBUG_OUT(...) (printf(__VA_ARGS__)) #else #define VS_ENDPAUSE() #define DEBUG_OUT(...) #endif #include <stdio.h> #include <string.h> #include <iostream> #include <math.h> #include <cmath> #include <vector> #include <algorithm> #include <string> using namespace std; typedef signed char int8; typedef signed short int16; typedef signed int int32; typedef signed long long int64; typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned int uint32; typedef unsigned long long uint64; #define int int64 #ifndef INT8_MIN #define INT8_MIN (-127) #endif #ifndef INT8_MAX #define INT8_MAX ( 128) #endif #ifndef UINT8_MAX #define UINT8_MAX ( 255) #endif #ifndef INT16_MIN #define INT16_MIN (-32768) #endif #ifndef INT16_MAX #define INT16_MAX ( 32767) #endif #ifndef UINT16_MAX #define UINT16_MAX ( 65535) #endif #ifndef INT32_MIN #define INT32_MIN (-2147483648) // -2 * 10^9 #endif #ifndef INT32_MAX #define INT32_MAX ( 2147483647) // 2 * 10^9 #endif #ifndef UINT32_MAX #define UINT32_MAX ( 4294967295) // 4 * 10^9 #endif #ifndef INT64_MIN #define INT64_MIN (-9223372036854775808) // -9 * 10^18 #endif #ifndef INT64_MAX #define INT64_MAX ( 9223372036854775807) // 9 * 10^18 #endif #ifndef UINT64_MAX #define UINT64_MAX ( 18446744073709551615) // 18 * 10^18 #endif void func(void); #pragma endregion int32 main(void) { func(); VS_ENDPAUSE(); return 0; } uint64 gcd(uint64 a, uint64 b) { uint64 tmp; if(b > a){ swap(a, b); } while(b > 0){ tmp = a % b; a = b; b = tmp; } return a; } void func(void) { //DEBUG_OUT("----\n"); int N; cin >> N; if(N==1){ int tmp; cin >> tmp; cout << tmp << endl; return; } int ggd; int prev; uint64 mul = 0; cin >> prev; mul = prev; for(int i=1; i<N; i++){ int tmp; cin >> tmp; ggd = getGgd(prev, tmp); prev = ggd; mul *= tmp / ggd;; prev = mul; } DEBUG_OUT("-----\n"); cout << mul << endl; return; }
a.cc: In function 'void func()': a.cc:111:15: error: 'getGgd' was not declared in this scope 111 | ggd = getGgd(prev, tmp); | ^~~~~~
s836773731
p03633
C++
import math as m from functools import reduce n=int(input()) l=[] def f(a,b): return int(a*b/m.gcd(a,b)) for i in range(n): l.add(int(input())) print(reduce(f,l))
a.cc:1:1: error: 'import' does not name a type 1 | import math as m | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s725094120
p03633
C++
import math def lcm(x, y): return int(x * y) // math.gcd(x, y)) n = int(input()) t = [i for i in range(n)] for i in range(n): t[i] = int(input()) ans = t[0] for i in range(1, n): ans = lcm(ans, t[i]) print(int(ans))
a.cc:1:1: error: 'import' does not name a type 1 | import math | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s935171017
p03633
C++
#include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #include<bits/stdc++.h> using namespace std; long long n,m[101],ans; int gcd(int x , int y) { if(!y) return x; else return gcd(y , x%y); } int main() { cin>>n; if(n==1) { cin>>m[1] cout<<m[1]; return 0; } for(int i=1;i<=n;i++) { cin>>m[i]; ans=max(m[i],ans); } for(int i=1;i<=n;i++) { if(!(ans%m[i])) continue; ans=ans/gcd(ans,m[i])*m[i]; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:70:26: error: expected ';' before 'cout' 70 | cin>>m[1] | ^ | ; 71 | cout<<m[1]; | ~~~~
s297294922
p03633
C++
#include <iostream> #include "string.h" #include <vector> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; unsigned long long gcd(unsigned long long a,unsigned long long b){ if(b == 0) return a; return gcd(b,a % b); } unsigned long long lcm(unsigned long long a,unsigned long long b){ if(a == b) return a; return a / g * b; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vector<unsigned long long> T(N); for(int i = 0;i < N;i++) cin >> T[i]; unsigned long long tmp ; if(N == 1){ cout << T[0] << endl; return 0; }else{ if(T[0] > T[1]) tmp = lcm(T[0],T[1]); else if(T[0] < T[1]) tmp = lcm(T[1],T[0]); else tmp = T[0]; for(int i = 2;i < N;i++){ if(tmp > T[i]) tmp = lcm(tmp,T[i]); else if(tmp < T[i]) tmp = lcm(T[i],tmp); } } if(tmp == 0) cout << T[0] << endl; else cout << tmp << endl; return 0; }
a.cc: In function 'long long unsigned int lcm(long long unsigned int, long long unsigned int)': a.cc:17:21: error: 'g' was not declared in this scope 17 | return a / g * b; | ^
s312183375
p03633
C
#include<stdio.h> int main(void){ int N,i,m,c=1; scanf("%d",&N); int T[N]; for(i=0;i<N;i++){ scanf("%d",&T[i]); } m=T[0]; for(i=0;i<N:i++){ if(m<T[i]){ m=T[i]; } } for(i=0;i<N;i++){ if(m%T[i]){ c++; m*=c; } } printf("%d\n",m); return 0; }
main.c: In function 'main': main.c:10:12: error: expected ';' before ':' token 10 | for(i=0;i<N:i++){ | ^ | ;
s725228829
p03633
C
#include <stdio.h> int main(void) { int N,i; long long T[100],ans[99],a,b,n; scanf("%d",&N); for (i = 0; i < N; i++) { scanf("%lld",&T[i]); } a = T[0]; b = T[1]; x = a * b; for (n = 2;;n++) { if ((a % n == 0) && (b % n == 0)) { a /= n; b /= n; } else if (n > a || n > b) { break; } } ans[0] = x / b; for (i = 1; i < N - 1; i++) { a = ans[i - 1]; b = T[i + 1]; x = a * b; for (n = 2;;n++) { if ((a % n == 0) && (b % n == 0)) { a /= n; b /= n; } else if (n > a || n > b) { break; } } ans[i] = x / b; } printf("%lld\n",ans[N - 2]); return 0; }
main.c: In function 'main': main.c:12:5: error: 'x' undeclared (first use in this function) 12 | x = a * b; | ^ main.c:12:5: note: each undeclared identifier is reported only once for each function it appears in
s909801174
p03633
C++
int main() { long long N,T[105],k=0,r; for(long long i=0;i<N;i++) { cin>>T[i]; for(long long j=1;j<=1000000000000000000;j++) { for(long long i=0;i<N;i++) { if(j%T[i]==0) { k++; if(k==N) { r=j; cout<<r; return 0; } } } } } return 0; }
a.cc: In function 'int main()': a.cc:6:17: error: 'cin' was not declared in this scope 6 | cin>>T[i]; | ^~~ a.cc:17:37: error: 'cout' was not declared in this scope 17 | cout<<r; | ^~~~
s700843774
p03633
C++
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cstdlib> using namespace std; typedef long long ll; int lu(int m,int n){ int t; if(m<n) { m=m+n; n=m-n; m=m-n; } while(n!=0) { t=m%n; m=n; n=; } return m; } int zheng(int a,int b){ return a/lu(a,b)*b; } int main() { int N; ll s,a[105]; while (~scanf("%d",&N)){ s=1; for(int i=1;i<=N;i++){ scanf("%I64d",&a[i]); s=zheng(s,a[i]); } printf("%I64d\n",s); } return 0; }
a.cc: In function 'int lu(int, int)': a.cc:23:19: error: expected primary-expression before ';' token 23 | n=; | ^
s498552786
p03633
Java
import java.util.Scanner; public class Main3 { public static void main(String[] args) { Scanner stdIn=new Scanner(System.in); int length=stdIn.nextInt(); int time[]=new int[length]; for(int i=0;i<length;i++){ time[i]=stdIn.nextInt(); } for(int i=0;i<length;i++){ for(int j=0;j<length-1;j++){ int k; if(time[j]>time[j+1]){ k=time[j+1]; time[j+1]=time[j]; time[j]=k; } } } long ans=1; for(int i=0;i<length;i++){ if(Judge(i,time,length)) ans*=time[i]; } System.out.println(ans); } public static boolean Judge(int i,int time[],int length){ for(int j=i+1;j<length;j++){ if(time[j]%time[i]==0) return false; } return true; } }
Main.java:2: error: class Main3 is public, should be declared in a file named Main3.java public class Main3 { ^ 1 error
s805028443
p03633
C++
#include<cstdio> #include<iostream> using namespace std; long long gcd(long long a, long long b) { while (b) { long long tmp = a % b; a = b; b = tmp; } return a; } int main() { int n; long double s[100 + 5]; while (cin>>n && n) { memset(s, 0, sizeof s); for (int i = 0; i < n; i++) cin >> s[i]; long double w = s[0] / gcd(s[0], s[1])* s[1]; for (int i = 2; i < n; i++) { w = w / gcd(w, s[i]) * s[i]; } printf("%.Lf\n", w); } return 0; }
a.cc: In function 'int main()': a.cc:20:9: error: 'memset' was not declared in this scope 20 | memset(s, 0, sizeof s); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<iostream> +++ |+#include <cstring> 3 | using namespace std;
s988370314
p03633
Java
import java.util.*; public class Main2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); long[] T = new long[num]; for(int i = 0; i<num; i++) { T[i] = sc.nextLong(); } if(num == 1) { System.out.println(T[0]); return; } for(int i = 0; i<num-1; i++){ long m = T[i]; long n = T[i+1]; T[i+1] = lcm(m, n); } System.out.println(T[num-1]); } public static long gcd(long m, long n) { if(m < n) return gcd(n, m); if(n == 0) return m; return gcd(n, m % n); } public static long lcm(long m, long n) { return m * n / gcd(m, n); } }
Main.java:2: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s076354020
p03633
Java
import java.util.*; public class Main2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); long[] T = new long[num]; for(int i = 0; i<num; i++) { T[i] = sc.nextLong(); } if(num == 1) { System.out.println(T[0]); return; } for(int i = 0; i<num-1; i++){ long m = T[i]; long n = T[i+1]; T[i+1] = lcm(m, n); } System.out.println(T[num-1]); } public static long gcd(long m, long n) { if(m < n) return gcd(n, m); if(n == 0) return m; return gcd(n, m % n); } public static long lcm(long m, long n) { return m * n / gcd(m, n); } }
Main.java:2: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s825418683
p03633
C++
// C++ program to find LCM of n elements #include <bits/stdc++.h> #include<stdio.h> using namespace std; typedef long long int ll; // Utility function to find GCD of 'a' and 'b' long long int gcd(long long int a, long long int b) { if (b==0) return a; return gcd(b, a%b); } // Returns LCM of array elements ll findlcm(long long int arr[], int n) { // Initialize result ll ans = arr[0]; // ans contains LCM of arr[0],..arr[i] // after i'th iteration, for (int i=1; i<n; i++) ans = ( ((arr[i]*ans)) / (gcd(arr[i], ans)) ); return ans; } // Driver Code int main() { int i,s,l=0; scanf("%d",&s); long long int arr[s],p,maxi=0; for(i=0;i<s;i++) { scanf("%lld",&arr[i]); if(arr[i]>1000000000) { if(arr[i]>=maxi){ maxi=arr[i] p=arr[i]; l=-1; } } } if(l==-1) printf("%lld",p); else{ int n = sizeof(arr)/sizeof(arr[0]); printf("%lld", findlcm(arr, n));} return 0; }
a.cc: In function 'int main()': a.cc:42:26: error: expected ';' before 'p' 42 | maxi=arr[i] | ^ | ; 43 | p=arr[i]; | ~
s894181498
p03633
Java
import java.util.*; public class Main2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); long[] T = new long[num]; for(int i = 0; i<num; i++) { T[i] = sc.nextLong(); } if(num == 1) { System.out.println(T[0]); return; } for(int i = 0; i<num-1; i++){ long m = T[i]; long n = T[i+1]; T[i+1] = lcm(m, n); } System.out.println(T[num-1]); } private static long gcd(long m, long n) { if(m < n) return gcd(n, m); if(n == 0) return m; return gcd(n, m % n); } private static long lcm(long m, long n) { return m * n / gcd(m, n); } }
Main.java:2: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s762524254
p03633
C++
#include <iostream> using namespace std; int main() { int n; cin >> n; long int t[100]; for(int i=0;i<n;i++){ cin >> t[i]; } sort(t,t+n); long int ans = t[n-1]; long int a, b, r; for(int i=0;i<n-1;i++){ if(ans%t[i]!=0){ a = ans; b = t[i]; r = a%b; while(r != 0){ a = b; b = r; r = a%b; } ans = (ans*t[i])/b; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:9: error: 'sort' was not declared in this scope; did you mean 'short'? 10 | sort(t,t+n); | ^~~~ | short
s891389918
p03633
C++
#include<iostream> using namespace std; long long N,T[105],k=0,r; int main() { for(long long i=0;i<N;i++) { cin>>T[i]; for(long long j=0;j<=T[N-1];j++) { if(j%T[i]==0) { k++; } if(k==N) { r=j; cout<<r; break; } } } return 0;
a.cc: In function 'int main()': a.cc:24:18: error: expected '}' at end of input 24 | return 0; | ^ a.cc:5:1: note: to match this '{' 5 | { | ^
s189587369
p03633
C++
#include<iostream> #include<string> #include<numeric> using namespace std; unsigned long long d[2000]; int main() { int n, s = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> d[i]; s += i; } for (int i = 0; i < n; i++) { for (int j = 0; j < (n / pow(2, i + 1)) - 1; j++) { unsigned long long r, a, b, x; a = d[2 * j]; b = d[2 * j + 1]; r = a % b; x = a * b; while (r != 0) { a = b; b = r; r = a % b; } d[j] = x / b; } } unsigned long long r, a, b, x; a = d[0]; b = d[n - 1]; r = a % b; x = a * b; while (r != 0) { a = b; b = r; r = a % b; } cout << x / b << endl; }
a.cc: In function 'int main()': a.cc:21:42: error: 'pow' was not declared in this scope 21 | for (int j = 0; j < (n / pow(2, i + 1)) - 1; j++) | ^~~
s240171131
p03633
C++
#include<iostream> #include<string> #include<numeric> using namespace std; unsigned long long d[2000]; int lcm(int x, int y) { if (x == 0 || y == 0) // 引数チェック { fprintf(stderr, "引数エラーです。\n"); return 0; } return (x * y / std::gcd(x, y)); } int main() { int n, s = 0; cin >> n; for (int i = 0; i < n; i++) { cin >> d[i]; s += i; } for (int i = 0; i < n; i++) { for (int j = 0; j < (n / pow(2, i + 1)) - 1; j++) { unsigned long long r, a, b, x; a = d[2 * j]; b = d[2 * j + 1]; r = a % b; x = a * b; while (r != 0) { a = b; b = r; r = a % b; } d[j] = x / b; } } unsigned long long r, a, b, x; a = d[0]; b = d[n - 1]; r = a % b; x = a * b; while (r != 0) { a = b; b = r; r = a % b; } cout << x / b << endl; }
a.cc: In function 'int main()': a.cc:31:42: error: 'pow' was not declared in this scope 31 | for (int j = 0; j < (n / pow(2, i + 1)) - 1; j++) | ^~~
s851926453
p03633
C++
import urllib.request from bs4 import BeautifulSoup import re import sys import os import time import subprocess import datetime def gcd(a, b): if a < b: c = a a = b b = c r = a % b while r > 0: a = b b = r r = a % b return b # ll gcd(ll a, ll b) { # if (a < b) # swap(a, b); # ll r = a % b; # # while (r) { # a = b; # b = r; # r = a % b; # } # # return b; # } N = int(input()) a = [] for i in range(N): a.append(int(input())) # a = list(map(int, input().split())) ans = a[0] for i in range(N): if i == 0: continue g = gcd(ans, a[i]) ans = ans * a[i] // g print(ans)
a.cc:26:7: error: invalid preprocessing directive #ll 26 | # ll gcd(ll a, ll b) { | ^~ a.cc:27: error: unterminated #if 27 | # if (a < b) a.cc:1:1: error: 'import' does not name a type 1 | import urllib.request | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s964714973
p03633
C
#include <stdio.h> #include <stdlib.h> long long int gcd(long long int a, long long int b) { long long int tmp; while (a % b != 0) { tmp = b; b = a % b; a = tmp; } return b; } long main3() { long long int num_n; long long int i, j; long long int res = 1; long *clock; scanf("%d\n", &num_n); clock = (long long int *) malloc(sizeof(long long int *) * num_n); // fflush(stdin); for (i = 0; i < num_n; i++) { scanf("%lld\n", &clock[i]); // fflush(stdin); } for (i = 0; i < num_n; i++) { res *= (clock[i]/gcd(res,clock[i])); } printf("%lld",res); fflush(stdout); return 0; }
main.c: In function 'main3': main.c:27:15: error: assignment to 'long int *' from incompatible pointer type 'long long int *' [-Wincompatible-pointer-types] 27 | clock = (long long int *) malloc(sizeof(long long int *) * num_n); | ^
s496049339
p03633
C++
5 2 5 10 1000000000000000000 1000000000000000000
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 | ^
s856927543
p03633
C++
#include<algorithm> using namespace std; long long T[100]; int main() { int N; long long MaxValue = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> T[i]; MaxValue = max(MaxValue, T[i]); } long long count = MaxValue; bool check = true; while (true) { for (int i = 0; i < N; i++) { if ((count % T[i]) != 0) { check = false; break; } } if (check) { cout << count << endl; return 0; } check = true; count += MaxValue; } }
a.cc: In function 'int main()': a.cc:11:9: error: 'cin' was not declared in this scope 11 | cin >> N; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<algorithm> +++ |+#include <iostream> 2 | a.cc:32:25: error: 'cout' was not declared in this scope 32 | cout << count << endl; | ^~~~ a.cc:32:25: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:32:42: error: 'endl' was not declared in this scope 32 | cout << count << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<algorithm> +++ |+#include <ostream> 2 |
s677053110
p03633
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i, n) for(int i = 0; i < (n); i++) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) typedef long long ll; int n; ll t[105]; ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; } int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> n; ll l = 1; FOR(i, n) { cin >> t; l = lcm(l, t); } cout << l << endl; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:21:21: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'll [105]' {aka 'long long int [105]'}) 21 | cin >> t; | ~~~ ^~ ~ | | | | | ll [105] {aka long long int [105]} | std::istream {aka std::basic_istream<char>} 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>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'll*' {aka 'long long int*'} 21 | cin >> t; | ^ /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>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'short int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(short int)((ll*)(& t))' to 'short int&' /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>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'short unsigned int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(short unsigned int)((ll*)(& t))' to 'short unsigned int&' /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>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(int)((ll*)(& t))' to 'int&' /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>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'unsigned int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(unsigned int)((ll*)(& t))' to 'unsigned int&' /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>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(long int)((ll*)(& t))' to 'long int&' /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>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long unsigned int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(long unsigned int)((ll*)(& t))' to 'long unsigned int&' /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>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long long int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(long long int)((ll*)(& t))' to 'long long int&' /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>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: invalid conversion from 'll*' {aka 'long long int*'} to 'long long unsigned int' [-fpermissive] 21 | cin >> t; | ^ | | | ll* {aka long long int*} a.cc:21:24: error: cannot bind rvalue '(long long unsigned int)((ll*)(& t))' to 'long long unsigned int&' /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>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:21:24: error: cannot bind non-const lvalue reference of type 'void*&' to an rvalue of type 'void*' 21 | cin >> t; | ^ /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 'll [105]' {aka 'long long int [105]'} 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 'll [105]' {aka 'long long int [105]'} 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 'll [105]' {aka 'long long int [105]'} to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /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 'll [105]' {aka 'long long int [105]'} to 'std::basic_istream<char>::__istream
s024810335
p03633
C++
struct prime { ll prime_number, amo; prime(ll prime_number, ll amo) :prime_number(prime_number), amo(amo) {}; }; class prime_enum { public: vector<prime> p; void enum_prime(ll n) { p.clear(); for (ll i = 2; i * i <= n; i += 2) { if (n % i) continue; n /= i; p.emplace_back(i, 1); while (n % i == 0) { n /= i; p.back().amo++; } } if (1 < n) p.emplace_back(n, 1); } }; struct Long2 { ll x, y; Long2() {} Long2(ll x, ll y) :x(x), y(y) {} bool operator<(const Long2& other) const { if (x != other.x) return x < other.x; return y < other.y; } bool operator>(const Long2& other) const { if (x != other.x) return x > other.x; return y > other.y; } }; int main() { int n; ll t; vector<Long2> primes; prime_enum p; scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%lld", &t); p.enum_prime(t); for (prime prim : p.p) primes.emplace_back(prim.prime_number, prim.amo); } sort(primes.begin(), primes.end()); ll res = 1; for (int i = 0; i < primes.size() - 1; i++) { if (primes[i].x == primes[i + 1].x) continue; for (int j = 0; j < primes[i].y; j++) res *= primes[i].x; } for (int i = 0; i < primes.back().y; i++) res *= primes.back().x; printf("%lld\n", res); }
a.cc:2:9: error: 'll' does not name a type 2 | ll prime_number, amo; | ^~ a.cc:3:17: error: expected ')' before 'prime_number' 3 | prime(ll prime_number, ll amo) :prime_number(prime_number), amo(amo) {}; | ~ ^~~~~~~~~~~~~ | ) a.cc:7:9: error: 'vector' does not name a type 7 | vector<prime> p; | ^~~~~~ a.cc:8:25: error: 'll' has not been declared 8 | void enum_prime(ll n) { | ^~ a.cc: In member function 'void prime_enum::enum_prime(int)': a.cc:9:17: error: 'p' was not declared in this scope 9 | p.clear(); | ^ a.cc:10:22: error: 'll' was not declared in this scope 10 | for (ll i = 2; i * i <= n; i += 2) { | ^~ a.cc:10:32: error: 'i' was not declared in this scope 10 | for (ll i = 2; i * i <= n; i += 2) { | ^ a.cc: At global scope: a.cc:26:9: error: 'll' does not name a type 26 | ll x, y; | ^~ a.cc:28:17: error: expected ')' before 'x' 28 | Long2(ll x, ll y) :x(x), y(y) {} | ~ ^~ | ) a.cc: In member function 'bool Long2::operator<(const Long2&) const': a.cc:31:21: error: 'x' was not declared in this scope 31 | if (x != other.x) | ^ a.cc:31:32: error: 'const struct Long2' has no member named 'x' 31 | if (x != other.x) | ^ a.cc:32:42: error: 'const struct Long2' has no member named 'x' 32 | return x < other.x; | ^ a.cc:33:24: error: 'y' was not declared in this scope 33 | return y < other.y; | ^ a.cc:33:34: error: 'const struct Long2' has no member named 'y' 33 | return y < other.y; | ^ a.cc: In member function 'bool Long2::operator>(const Long2&) const': a.cc:36:21: error: 'x' was not declared in this scope 36 | if (x != other.x) | ^ a.cc:36:32: error: 'const struct Long2' has no member named 'x' 36 | if (x != other.x) | ^ a.cc:37:42: error: 'const struct Long2' has no member named 'x' 37 | return x > other.x; | ^ a.cc:38:24: error: 'y' was not declared in this scope 38 | return y > other.y; | ^ a.cc:38:34: error: 'const struct Long2' has no member named 'y' 38 | return y > other.y; | ^ a.cc: In function 'int main()': a.cc:43:9: error: 'll' was not declared in this scope 43 | ll t; | ^~ a.cc:44:9: error: 'vector' was not declared in this scope 44 | vector<Long2> primes; | ^~~~~~ a.cc:44:21: error: expected primary-expression before '>' token 44 | vector<Long2> primes; | ^ a.cc:44:23: error: 'primes' was not declared in this scope; did you mean 'prime'? 44 | vector<Long2> primes; | ^~~~~~ | prime a.cc:46:9: error: 'scanf' was not declared in this scope 46 | scanf("%d", &n); | ^~~~~ a.cc:48:32: error: 't' was not declared in this scope 48 | scanf("%lld", &t); | ^ a.cc:50:37: error: 'class prime_enum' has no member named 'p' 50 | for (prime prim : p.p) | ^ a.cc:51:50: error: 'struct prime' has no member named 'prime_number' 51 | primes.emplace_back(prim.prime_number, prim.amo); | ^~~~~~~~~~~~ a.cc:51:69: error: 'struct prime' has no member named 'amo' 51 | primes.emplace_back(prim.prime_number, prim.amo); | ^~~ a.cc:53:9: error: 'sort' was not declared in this scope; did you mean 'short'? 53 | sort(primes.begin(), primes.end()); | ^~~~ | short a.cc:54:11: error: expected ';' before 'res' 54 | ll res = 1; | ^~~~ | ; a.cc:59:25: error: 'res' was not declared in this scope 59 | res *= primes[i].x; | ^~~ a.cc:62:17: error: 'res' was not declared in this scope 62 | res *= primes.back().x; | ^~~ a.cc:63:26: error: 'res' was not declared in this scope 63 | printf("%lld\n", res); | ^~~ a.cc:63:9: error: 'printf' was not declared in this scope 63 | printf("%lld\n", res); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | struct prime {
s628271499
p03633
Java
package com.hhs.xgn.atcoder.abc070; import java.math.BigInteger; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner s = new Scanner(System.in); while(s.hasNext()){ int n=s.nextInt(); BigInteger mul=BigInteger.ONE; BigInteger mul2; BigInteger[] arr=new BigInteger[n]; for(int i=0;i<n;i++){ arr[i]=s.nextBigInteger(); mul2=mul.multiply(arr[i]); mul=arr[i].gcd(mul); mul=mul2.divide(mul); } System.out.println(mul); } } }
Main.java:6: error: class C is public, should be declared in a file named C.java public class C { ^ 1 error
s598309379
p03633
C++
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<algorithm> #include<queue> #include<stack> using namespace std; const int maxn=1e18+5; int n; int t[maxn]; int main() { scanf("%d",&n); while(n--) { for(int i=0;i<n;i++) scanf("%d",&t[i]); int u,v,r,s,i,d; scanf("%u%u",&u,&v); while(u !=0 && v!= 0) { d=u*v; while(v!=0) { r=u%v; u=v; v=r; } printf("%u %u\n",u,d/u); scanf("%u%u",&u,&v); }
a.cc:10:20: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow] 10 | const int maxn=1e18+5; | ~~~~^~ a.cc:12:7: error: size of array 't' exceeds maximum object size '9223372036854775807' 12 | int t[maxn]; | ^~~~ a.cc: In function 'int main()': a.cc:44:6: error: expected '}' at end of input 44 | } | ^ a.cc:17:9: note: to match this '{' 17 | { | ^ a.cc:44:6: error: expected '}' at end of input 44 | } | ^ a.cc:14:1: note: to match this '{' 14 | { | ^
s900027115
p03633
Java
import java.util.*; public class C{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); long[] t=new long [n];int i;long max_GCD; for(i=0;i<n;i++){ t[i]=sc.nextLong(); } System.out.println(max_gcd(t)); } static long gcd(long a,long b){ long x,tmp,ans,r; x = a * b; if(a<b){ tmp = a; a = b; b = tmp; } r = a % b; while(r!=0){ a = b; b = r; r = a % b; } ans=(long)x/b; return ans; } static long max_gcd(long[] x){ int i; int len=x.length; long s=gcd(x[0],x[1]); for(i=2;i<len;i++){ s=gcd(x[i],s); } return s; } }
Main.java:2: error: class C is public, should be declared in a file named C.java public class C{ ^ 1 error
s886687610
p03633
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int n=scanner.nextInt(); long[] array = new long[n]; long ans=-1; for(int i=0;i<n;i++){ array[i]=scanner.nextLong(); } for(int i=0;i<n-1;i++){ array[i+1]=(lcm(array[i],array[i+1])); } ans = array[n-1]; System.out.println(ans); } private static long lcm(long m, long n) { return m * n / gcd(m, n); } private static long gcd(long m, long n) { if(m < n) return gcd(n, m); if(n == 0) return m; return gcd(n, m % n); }
Main.java:25: error: reached end of file while parsing } ^ 1 error
s264536075
p03633
C++
#include<cstdio> int main(){ int n; scanf("%d",&n); int a[n]; long long int m; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } b[0]=a[0]; for(int i=0;i<n;i++){ int x; if(a[i+1]>=m)x=m; else x=a[i+1]; for(int j=x;j>=1;j--){ if((a[i+1]%j==0)&&(m%j==0)){ m=a[i+1]*m/j; break; } } } printf("%lli",m); return 0; }
a.cc: In function 'int main()': a.cc:10:9: error: 'b' was not declared in this scope 10 | b[0]=a[0]; | ^
s837851539
p03633
C
#include <stdio.h> int main(void) {   int N,i,j;  long T[100],ans[99]; scanf("%d",&N); for (i = 0; i < N; i++) { scanf("%ld",&T[i]); } for (j = 1;;j++) { if ((T[0] * j) % T[1] == 0) { ans[0] = T[0] * j; break; } } for (i = 1; i < N - 1; i++) { for (j = 1;;j++) { if ((ans[i - 1] * j) % T[i + 1] == 0) { ans[i] = ans[i - 1] * j; break; } } } printf("%ld\n",&ans[N - 2]); return 0; }
main.c: In function 'main': main.c:4:1: error: stray '\343' in program 4 | <U+3000> int N,i,j; | ^~~~~~~~ main.c:5:3: error: stray '\343' in program 5 | <U+3000>long T[100],ans[99]; | ^~~~~~~~
s934017271
p03633
C++
#include <iostream> #include <algorithm> using namespace std; unsigned long long getGcd(unsigned long long a, unsigned long long b) { unsigned long long c; while (b) { c = a % b; a = b; b = c; } return a; } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<unsigned long long> v; unsigned long long t; cin >> t; unsigned long long gcd = t; unsigned long long prod = t; for (int i = 1; i < n; ++i) { cin >> t; gcd = getGcd(gcd, t); if (t % prod == 0) { prod = t; } else { prod *= t; } } cout << prod / gcd; return 0; }
a.cc: In function 'int main()': a.cc:25:5: error: 'vector' was not declared in this scope 25 | vector<unsigned long long> v; | ^~~~~~ a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 2 | #include <algorithm> +++ |+#include <vector> 3 | a.cc:25:12: error: expected primary-expression before 'unsigned' 25 | vector<unsigned long long> v; | ^~~~~~~~
s929971314
p03633
C++
#include<cstdio> int main(){ int n; scanf("%d",&n); int a[n]; double b[n]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } b[0]=a[0]; for(int i=0;i<n;i++){ int x; if(a[i+1]>=b[i])x=b[i]; else x=a[i+1]; for(int j=x;j>=1;j--){ if((a[i+1]%j==0)&&(b[i]%j==0)){ b[i+1]=a[i+1]*b[i]/j; break; } } } printf("%f",b[n-1]); return 0; }
a.cc: In function 'int main()': a.cc:17:48: error: invalid operands of types 'double' and 'int' to binary 'operator%' 17 | if((a[i+1]%j==0)&&(b[i]%j==0)){ | ~~~~^~ | | | | | int | double
s704538393
p03633
C++
#include<iostream> #include<algorithm> using namespace std; long long T[100]; int gcd(int x, int y) { int r; while ((r = x % y) != 0) { x = y; y = r; } return y; } int main() { int N; cin >> N; for (int i = 0; i < N; i++) { cin >> T[i]; } int Ans = 1; for (int i = 0; i < N; i++) { Ans = gcd(T[i], Ans); } cout << Ans << endl return 0; }
a.cc: In function 'int main()': a.cc:32:28: error: expected ';' before 'return' 32 | cout << Ans << endl | ^ | ; 33 | return 0; | ~~~~~~
s141199340
p03633
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; long long gcd(long long a,long long b) { if(b == 0) return a; return gcd(b,a%b); } int main() { int N; while(~scanf("%d",&N)) { long long a[200]; for(int i=0;i<N;++i) { scanf("%lld",&a[i]); } long long k; sort(a,a+N); temp = a[0]; for(int i=1;i<N;++i) { if(a[i]>=temp && a[i]%temp == 0) { temp=a[i]; } else { k = gcd(temp,a[i]); temp = temp*a[i]/k; } } printf("%lld\n",temp); } }
a.cc: In function 'int main()': a.cc:23:17: error: 'temp' was not declared in this scope; did you mean 'tm'? 23 | temp = a[0]; | ^~~~ | tm
s952048966
p03633
C++
#include<bits/stdc++.h> using namespace std; #define ll long long ll gcd(ll a, ll b) { if(b==0) return a; else return gcd(b, a%b); } ll lcm(ll a, ll b) { ll gc = gcd(a,b); ll ret; if(a%gc==0){ ret = (a/gc)*b; } else{ ret = (b/gc)*a; } } int main() { ll n; cin>>n; ll arr[n]; for(int i=0; i<n; i++){ cin>>arr[i]; } ll ans = arr[0]; for(int i=1; i<n; i++){ ans = lcm(ans, arr[i]); } cout<<ans<<endl; ] return 0; }
a.cc: In function 'long long int lcm(long long int, long long int)': a.cc:19:1: warning: no return statement in function returning non-void [-Wreturn-type] 19 | } | ^ a.cc: In function 'int main()': a.cc:33:1: error: expected primary-expression before ']' token 33 | ] return 0; | ^
s791017810
p03633
C++
#include<cstdio> long long n,a[101],Min,Max; long long gcd(long long x,long long y) {if(!y) return x; else return gcd(y,x%y); } long long lcm(long long x,long long y) {long long z; z=gcd(x,y); return x*y/z; } int main() {scanf("%lld",&n); memset(a,0,sizeof(a)); for(int i=1;i<=n;i++)scanf("%lld",&a[i]); Max=gcd(a[1],a[2]); for(int i=3;i<=n;i++)Max=gcd(Max,a[i]); //printf("%lld\n",Max); Min=lcm(a[1],a[2]); for(int i=1;i<=n;i++)Min=lcm(Min,a[i]); printf("%lld\n",Min); return 0; }
a.cc: In function 'int main()': a.cc:14:1: error: 'memset' was not declared in this scope 14 | memset(a,0,sizeof(a)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<cstdio> +++ |+#include <cstring> 2 | long long n,a[101],Min,Max;
s582397636
p03633
C++
#include <iostream> #include <array> #include <map> #include <algorithm> #include <cmath> #include <vector> #include <fstream> #include <string> #include <random> #include <queue> #include <iomanip> using namespace std; using ll = unsigned long long int; const double M_PI = 3.14159265358979323846; ll gcd(ll a, ll b) { if (a == 0) { return b; } return gcd(b%a,a); } int main() { ll n,res,g; cin >> n >> g; res = g; for (int i = 1; i < n; i++) { ll a; cin >> a; g = gcd(res, a); res /= g; res *= a; //cout << "g: " << g << endl; //cout << "res: " << res << endl; } cout << res << endl; }
In file included from /usr/include/c++/14/cmath:47, from a.cc:5: a.cc:16:14: error: expected unqualified-id before numeric constant 16 | const double M_PI = 3.14159265358979323846; | ^~~~
s690129874
p03633
C++
#include <iostream> #include <algorithm> #include <numeric> using namespace std; #define ll unsigned long long ll times[101]; ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int main() { ll n; cin >> n; for (int i = 0; i < n; ++i) cin >> times[i]; cout << ll(accumulate(times, times + n, ll(1), lcm)) << '\n'; }
a.cc: In function 'int main()': a.cc:6:12: error: expected primary-expression before 'unsigned' 6 | #define ll unsigned long long | ^~~~~~~~ a.cc:29:13: note: in expansion of macro 'll' 29 | cout << ll(accumulate(times, times + n, ll(1), lcm)) << '\n'; | ^~
s979969220
p03633
C++
#include<iostream> using namespace std; _int64 gcd(_int64 i,_int64 j) { _int64 c,temp; _int64 tempi=i,tempj=j; if(j>i) { temp=j; j=i; i=temp; } while(j) { c=i%j; i=j; j=c; } return tempi/i*tempj; } int main() { /*int t; cin>>t; double x1,y1,x2,y2,x3,y3; double a,k; while(t--) { cin>>x1>>y1>>x2>>y2>>x3>>y3; a=(y2-y1)/((x2-x1)*(x2-x1)); k=(y3-y2)/(x3-x2); }*/ int n; _int64 t; while(cin>>n) { _int64 k=1; while(n--) { cin>>t; k=gcd(k,t); } cout<<k<<endl; } return 0; }
a.cc:3:1: error: '_int64' does not name a type 3 | _int64 gcd(_int64 i,_int64 j) | ^~~~~~ a.cc: In function 'int main()': a.cc:35:9: error: '_int64' was not declared in this scope 35 | _int64 t; | ^~~~~~ a.cc:38:23: error: expected ';' before 'k' 38 | _int64 k=1; | ^~ | ; a.cc:41:30: error: 't' was not declared in this scope 41 | cin>>t; | ^ a.cc:42:25: error: 'k' was not declared in this scope 42 | k=gcd(k,t); | ^ a.cc:42:27: error: 'gcd' was not declared in this scope 42 | k=gcd(k,t); | ^~~ a.cc:44:23: error: 'k' was not declared in this scope 44 | cout<<k<<endl; | ^
s585784047
p03633
C
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll g(ll a,ll b) { if(b==0) return a; else return g(b,a%b); } int main() { int n; cin>>n; ll a[n]; for(int i=0;i<n;i++) cin>>a[i]; ll x,lcm, gcd=a[0]; for(int i=0;i<n;i++) { x=gcd; gcd=g(a[i],gcd); lcm=(x*a[i])/gcd; } cout<<lcm; return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s632463879
p03633
C++
#include <iostream> #include <algorithm> #include <string> #include <cstdio> #include <cmath> #include <stack> #include <cstring> #include <vector> #include <set> #include <map> #include <queue> #include <numeric> #include <bits/stdc++.h> __int128 gcd(__int128 a, __int128 b) { while (b) { long long t = a; a = b; b = t % b; } return a; } __int128 lcm(__int128 a, __int128 b) { return a * b / gcd(a, b); } int main() { __int128 n; std::vector<long long > v(n); for (size_t i = 0; i < v.size(); i++) { std::cin >> v[i]; } __int128 l = lcm(v[0], v[1]); for (size_t i = 2; i < v.size(); i++) { l = lcm(l, v[i]); } std::cout << l << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:47:19: error: ambiguous overload for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '__int128') 47 | std::cout << l << std::endl; | ~~~~~~~~~ ^~ ~ | | | | | __int128 | std::ostream {aka std::basic_ostream<char>} In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char) [with _CharT = char; _Traits = char_traits<char>]' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char) [with _Traits = char_traits<char>]' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char) [with _Traits = char_traits<char>]' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: candidate: 'std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char) [with _Traits = char_traits<char>]' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~
s656726459
p03633
C++
#include<iostream> #include<cstdio> #include<vector> #include<string> #include<functional> #include<queue> #include<algorithm> #include<complex> #include<cstdlib> #include<cctype> #define DBG cout << '!' << endl; #define REP(i,n) for(int i = 0;i < (n);i++) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cout << v[i] << ' ';cout << endl << endl;} #define SHOW2d(v,i,j) {for(int a = 0;a < i;a++){for(int b = 0;b < j;b++)cout << v[a][b] << ' ';cout << endl;}cout << endl;} #define ALL(v) v.begin(),v.end() using namespace std; typedef long long ll; typedef vector<int> iv; typedef vector<iv> iiv; typedef vector<string> sv; ll gcd(ll a,ll b) { if(a<b) { ll tmp = a;a = b;b = tmp; } if(b == 0) return a; else return gcd(b,a%b); } ll function(ll a,ll b) { ll ret = gcd(a,b); return a/ret*b; } int main() { int n; cin >> n; ll num[n]; cin >> num[0]; ll ret = num[0]; for(int i = 1;i < n;i++) { cin >> num[i]; ret = function(ret,num[i]); } cout << ret << endl; return 0; }
a.cc: In function 'int main()': a.cc:60:23: error: reference to 'function' is ambiguous 60 | ret = function(ret,num[i]); | ^~~~~~~~ In file included from /usr/include/c++/14/functional:59, from a.cc:5: /usr/include/c++/14/bits/std_function.h:111:11: note: candidates are: 'template<class _Signature> class std::function' 111 | class function; | ^~~~~~~~ a.cc:41:4: note: 'll function(ll, ll)' 41 | ll function(ll a,ll b) | ^~~~~~~~
s472152417
p03633
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long ans = 1; for(int i = 0; i < N; i++) { long t = sc.nextLong(); long u = gcd(t, ans); ans = t * (ans / u); } System.out.println(ans); } public static long gcd(long a, long b) { if(b == 0) return a; return gcd(b, a % b); } }
Main.java:8: error: cannot find symbol for(int i = 0; i < N; i++) { ^ symbol: variable N location: class Main 1 error
s147591487
p03633
C++
#include <iostream> using namespace std; long long int a[110]; int main () { int n; cin>>n; long long int maxi=0; for (int i=0; i<n; i++) { cin>>a[i]; if (a[i]>maxi) {maxi=a[i];} } long long int p=maxi; while (0==0) { int br=0; for (int i=0; i<n; i++) { if (maxi%a[i]==0) {br++;} else {break;} } if (br==n) {cout<<maxi; return 0;} maxi=maxi+p; }
a.cc: In function 'int main()': a.cc:24:2: error: expected '}' at end of input 24 | } | ^ a.cc:6:13: note: to match this '{' 6 | int main () { | ^
s407564658
p03633
C++
//code by 27. #include<stdio.h> #include<cstdio> #include<iostream> #include<algorithm> #include<string> #include<math.h> #include<vector> #include<queue> #include<map> #include<stack> #include<fstream> #include<stdlib.h> #include<set> #include<cassert> #include<climits> #include<cmath> #include<memory.h> #include<conio.h> #include<windows.h> #include<ctime> using namespace std; long long gcd(long long a,long long b) { long long t1=a; long long t2=b; while(t1!=0) { if(t1<t2)swap(t1,t2); t1=t1%t2; } return t2; } int main() { int n; cin>>n; long long s; cin>>s; long long t; for(int i=2;i<=n;i++) { cin>>t; s=s/gcd(s,t)*t; } cout<<s; return 0; }
a.cc:19:9: fatal error: conio.h: No such file or directory 19 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s327995140
p03634
C++
#include <bits/stdc++.h> using namespace std; struct edge{long long to, cost;}; typedef pair<long long,long long > P; struct graph{ long long V; vector<vector<edge> > G; vector<long long> d; graph(long long n){ init(n); } void init(long long n){ V = n; G.resize(V); d.resize(V); for(int i=1;i<V;i++){ d[i] = INF; } } void add_edge(long long s, long long t,long long cost){ edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(long long s){ for(int i=1;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(); long long 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 N;cin>>N; graph g(N); vector<int>A(N-1); vector<int>B(N-1); vector<int>C(N-1); for(int i=0;i<N-1;i++){ cin>>A[i]>>B[i]>>C[i]; g.add_edge(A[i]-1,B[i]-1,C[i]); } int Q,K;cin>>Q>>K; g.dijkstra(K); vector<int>x(Q); vector<int>y(Q); long long ans=0; for(int i=0;i<Q;i++){ cin>>x[i]>>y[i]; ans+=g.d[x[i]-1]+g.d[y[i]-1]; } cout<<ans<<endl; }
a.cc: In member function 'void graph::init(long long int)': a.cc:17:14: error: 'INF' was not declared in this scope 17 | d[i] = INF; | ^~~ a.cc: In member function 'void graph::dijkstra(long long int)': a.cc:27:14: error: 'INF' was not declared in this scope 27 | d[i] = INF; | ^~~
s836866534
p03634
C++
#include <bits/stdc++.h> using namespace std; struct edge{long long to, cost;}; typedef pair<long long,long long > P; struct graph{ long long V; vector<vector<edge> > G; vector<long long> d; graph(long long n){ init(n); } void init(long long n){ V = n; G.resize(V); d.resize(V); REP(i,V){ d[i] = INF; } } void add_edge(long long s, long long t,long long cost){ edge e; e.to = t, e.cost = cost; G[s].push_back(e); } void dijkstra(long long s){ REP(i,V){ 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 N;cin>>N; graph g(N); vector<int>A(N-1); vector<int>B(N-1); vector<int>C(N-1); for(int i=0;i<N-1;i++){ cin>>A[i]>>B[i]>>C[i]; g.add_edge(A[i]-1,B[i]-1,C[i]); } int Q,K;cin>>Q>>K; g.dijkstra(K); vector<int>x(Q); vector<int>y(Q); long long ans=0; for(int i=0;i<Q;i++){ cin>>x[i]>>y[i]; ans+=g.d[x[i]-1]+g.d[y[i]-1]; } cout<<ans<<endl; }
a.cc: In member function 'void graph::init(long long int)': a.cc:16:9: error: 'i' was not declared in this scope 16 | REP(i,V){ | ^ a.cc:16:5: error: 'REP' was not declared in this scope 16 | REP(i,V){ | ^~~ a.cc: In member function 'void graph::dijkstra(long long int)': a.cc:26:9: error: 'i' was not declared in this scope 26 | REP(i,V){ | ^ a.cc:26:5: error: 'REP' was not declared in this scope 26 | REP(i,V){ | ^~~ a.cc:34:7: error: 'll' was not declared in this scope 34 | ll v = p.second; | ^~ a.cc:35:12: error: 'v' was not declared in this scope 35 | if(d[v]<p.first) continue; | ^ a.cc:36:22: error: 'v' was not declared in this scope 36 | for(auto e : G[v]){ | ^
s646766511
p03634
C++
#include <bits/stdc++.h> using namespace std;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); REP(i,V){ 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){ REP(i,V){ 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 N;cin>>N; graph g(N); vector<int>A(N-1); vector<int>B(N-1); vector<int>C(N-1); for(int i=0;i<N-1;i++){ cin>>A[i]>>B[i]>>C[i]; g.add_edge(A[i]-1,B[i]-1,C[i]); } int Q,K;cin>>Q>>K; g.dijkstra(K); vector<int>x(Q); vector<int>y(Q); long long ans=0; for(int i=0;i<Q;i++){ cin>>x[i]>>y[i]; ans+=g.d[x[i]-1]+g.d[y[i]-1]; } cout<<ans<<endl; }
a.cc:2:33: error: 'll' does not name a type 2 | using namespace std;struct edge{ll to, cost;}; | ^~ a.cc:3:14: error: 'll' was not declared in this scope 3 | typedef pair<ll,ll> P; | ^~ a.cc:3:17: error: 'll' was not declared in this scope 3 | typedef pair<ll,ll> P; | ^~ a.cc:3:19: error: template argument 1 is invalid 3 | typedef pair<ll,ll> P; | ^ a.cc:3:19: error: template argument 2 is invalid a.cc:5:3: error: 'll' does not name a type 5 | ll V; | ^~ a.cc:7:10: error: 'll' was not declared in this scope 7 | vector<ll> d; | ^~ a.cc:7:12: error: template argument 1 is invalid 7 | vector<ll> d; | ^ a.cc:7:12: error: template argument 2 is invalid a.cc:8:11: error: expected ')' before 'n' 8 | graph(ll n){ | ~ ^~ | ) a.cc:11:13: error: 'll' has not been declared 11 | void init(ll n){ | ^~ a.cc:19:17: error: 'll' has not been declared 19 | void add_edge(ll s, ll t, ll cost){ | ^~ a.cc:19:23: error: 'll' has not been declared 19 | void add_edge(ll s, ll t, ll cost){ | ^~ a.cc:19:29: error: 'll' has not been declared 19 | void add_edge(ll s, ll t, ll cost){ | ^~ a.cc:24:17: error: 'll' has not been declared 24 | void dijkstra(ll s){ | ^~ a.cc: In member function 'void graph::init(int)': a.cc:12:5: error: 'V' was not declared in this scope 12 | V = n; | ^ a.cc:14:7: error: request for member 'resize' in '((graph*)this)->graph::d', which is of non-class type 'int' 14 | d.resize(V); | ^~~~~~ a.cc:15:9: error: 'i' was not declared in this scope 15 | REP(i,V){ | ^ a.cc:15:5: error: 'REP' was not declared in this scope 15 | REP(i,V){ | ^~~ a.cc: In member function 'void graph::add_edge(int, int, int)': a.cc:21:7: error: 'struct edge' has no member named 'to' 21 | e.to = t, e.cost = cost; | ^~ a.cc:21:17: error: 'struct edge' has no member named 'cost' 21 | e.to = t, e.cost = cost; | ^~~~ a.cc: In member function 'void graph::dijkstra(int)': a.cc:25:9: error: 'i' was not declared in this scope 25 | REP(i,V){ | ^ a.cc:25:11: error: 'V' was not declared in this scope 25 | REP(i,V){ | ^ a.cc:25:5: error: 'REP' was not declared in this scope 25 | REP(i,V){ | ^~~ a.cc:28:6: error: invalid types 'int[int]' for array subscript 28 | d[s] = 0; | ^ a.cc:30:19: error: expression list treated as compound expression in functional cast [-fpermissive] 30 | que.push(P(0,s)); | ^ a.cc:33:7: error: 'll' was not declared in this scope 33 | ll v = p.second; | ^~ a.cc:34:12: error: 'v' was not declared in this scope 34 | if(d[v]<p.first) continue; | ^ a.cc:34:17: error: request for member 'first' in 'p', which is of non-class type 'P' {aka 'int'} 34 | if(d[v]<p.first) continue; | ^~~~~ a.cc:35:22: error: 'v' was not declared in this scope 35 | for(auto e : G[v]){ | ^ a.cc:38:34: error: expression list treated as compound expression in functional cast [-fpermissive] 38 | que.push(P(d[e.to],e.to)); | ^ a.cc: In function 'int main()': a.cc:46:12: error: no matching function for call to 'graph::graph(int&)' 46 | graph g(N); | ^ a.cc:4:8: note: candidate: 'graph::graph()' 4 | struct graph{ | ^~~~~ a.cc:4:8: note: candidate expects 0 arguments, 1 provided a.cc:4:8: note: candidate: 'graph::graph(const graph&)' a.cc:4:8: note: no known conversion for argument 1 from 'int' to 'const graph&' a.cc:4:8: note: candidate: 'graph::graph(graph&&)' a.cc:4:8: note: no known conversion for argument 1 from 'int' to 'graph&&' a.cc:61:13: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript 61 | ans+=g.d[x[i]-1]+g.d[y[i]-1]; | ^ a.cc:61:25: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript 61 | ans+=g.d[x[i]-1]+g.d[y[i]-1]; | ^
s618973046
p03634
C++
//////////////////////////////////////////////////////////////////////////////// // Give me AC!!! // //////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <random> #include <cmath> #include <limits> #include <iostream> #include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> using namespace std; namespace mp = boost::multiprecision; using namespace mp; using ull = __int128; using ll = long long; using cll = cpp_int; using Graph = vector<vector<int>>; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) //xにはvectorなどのコンテナ #define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい #define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく #define MAX(x) *max_element(ALL(x)) //最大値を求める #define MIN(x) *min_element(ALL(x)) //最小値を求める #define PQ priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>> #define PB push_back //vectorヘの挿入 #define MP make_pair //pairのコンストラクタ #define F first //pairの一つ目の要素 #define S second //pairの二つ目の要素 #define coutY cout<<"YES"<<endl #define couty cout<<"Yes"<<endl #define coutN cout<<"NO"<<endl #define coutn cout<<"No"<<endl #define coutdouble(a,b) cout << fixed << setprecision(a) << double(b) ; #define vi(a,b) vector<int> a(b) #define vl(a,b) vector<ll> a(b) #define vs(a,b) vector<string> a(b) #define vll(a,b,c) vector<vector<ll>> a(b, vector<ll>(c)); #define intque(a) queue<int> a; #define llque(a) queue<ll> a; #define intque2(a) priority_queue<int, vector<int>, greater<int>> a; #define llque2(a) priority_queue<ll, vector<ll>, greater<ll>> a; #define pushback(a,b) a.push_back(b) #define mapii(M1) map<int, int> M1; #define cou(v,x) count(v.begin(), v.end(), x) #define mapll(M1) map<ll,ll> M1; #define mapls(M1) map<ll, string> M1; #define mapsl(M1) map<string, ll> M1; #define twolook(a,l,r,x) lower_bound(a+l, a+r, x) - a #define sor(a) sort(a.begin(), a.end()) #define rever(a) reverse(a.begin(),a.end()) #define rep(i,a) for(ll i=0;i<a;i++) #define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i] #define vcout(n) for(ll i=0;i<ll(n.size());i++) cout<<n[i] #define vcin2(n) rep(i,ll(n.size())) rep(j,ll(n.at(0).size())) cin>>n[i][j] //const ll mod = 998244353; //const ll MOD = 998244353; const ll MOD = 1000000007; const ll mod = 1000000007; constexpr ll MAX = 5000000; //const ll _max = 9223372036854775807; const ll _max = 1223372036854775807; const INF = 2000000000000000000; ll fac[MAX],finv[MAX],inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 long long 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; } int modPow(long long a, long long n, long long p) { if (n == 0) return 1; // 0乗にも対応する場合 if (n == 1) return a % p; if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p; long long t = modPow(a, n / 2, p); return (t * t) % p; } ll clocks(ll a,ll b,ll c){ return a*3600+b*60+c; } ll divup(ll b,ll d){ if(b%d==0){ return b/d; } else{ return b/d+1; } } struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) { } }; using Graphw = vector<vector<Edge>>; ll zero(ll a){ return max(ll(0),a); } template< typename T > struct FormalPowerSeries : vector< T > { using vector< T >::vector; using P = FormalPowerSeries; using MULT = function< P(P, P) >; static MULT &get_mult() { static MULT mult = nullptr; return mult; } static void set_fft(MULT f) { get_mult() = f; } void shrink() { while(this->size() && this->back() == T(0)) this->pop_back(); } P operator+(const P &r) const { return P(*this) += r; } P operator+(const T &v) const { return P(*this) += v; } P operator-(const P &r) const { return P(*this) -= r; } P operator-(const T &v) const { return P(*this) -= v; } P operator*(const P &r) const { return P(*this) *= r; } P operator*(const T &v) const { return P(*this) *= v; } P operator/(const P &r) const { return P(*this) /= r; } P operator%(const P &r) const { return P(*this) %= r; } P &operator+=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < r.size(); i++) (*this)[i] += r[i]; return *this; } P &operator+=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] += r; return *this; } P &operator-=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < r.size(); i++) (*this)[i] -= r[i]; shrink(); return *this; } P &operator-=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] -= r; shrink(); return *this; } P &operator*=(const T &v) { const int n = (int) this->size(); for(int k = 0; k < n; k++) (*this)[k] *= v; return *this; } P &operator*=(const P &r) { if(this->empty() || r.empty()) { this->clear(); return *this; } assert(get_mult() != nullptr); return *this = get_mult()(*this, r); } P &operator%=(const P &r) { return *this -= *this / r * r; } P operator-() const { P ret(this->size()); for(int i = 0; i < this->size(); i++) ret[i] = -(*this)[i]; return ret; } P &operator/=(const P &r) { if(this->size() < r.size()) { this->clear(); return *this; } int n = this->size() - r.size() + 1; return *this = (rev().pre(n) * r.rev().inv(n)).pre(n).rev(n); } P pre(int sz) const { return P(begin(*this), begin(*this) + min((int) this->size(), sz)); } P operator>>(int sz) const { if(this->size() <= sz) return {}; P ret(*this); ret.erase(ret.begin(), ret.begin() + sz); return ret; } P operator<<(int sz) const { P ret(*this); ret.insert(ret.begin(), sz, T(0)); return ret; } P rev(int deg = -1) const { P ret(*this); if(deg != -1) ret.resize(deg, T(0)); reverse(begin(ret), end(ret)); return ret; } P diff() const { const int n = (int) this->size(); P ret(max(0, n - 1)); for(int i = 1; i < n; i++) ret[i - 1] = (*this)[i] * T(i); return ret; } P integral() const { const int n = (int) this->size(); P ret(n + 1); ret[0] = T(0); for(int i = 0; i < n; i++) ret[i + 1] = (*this)[i] / T(i + 1); return ret; } // F(0) must not be 0 P inv(int deg = -1) const { assert(((*this)[0]) != T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1) / (*this)[0]}); for(int i = 1; i < deg; i <<= 1) { ret = (ret + ret - ret * ret * pre(i << 1)).pre(i << 1); } return ret.pre(deg); } // F(0) must be 1 P log(int deg = -1) const { assert((*this)[0] == 1); const int n = (int) this->size(); if(deg == -1) deg = n; return (this->diff() * this->inv(deg)).pre(deg - 1).integral(); } P sqrt(int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; if((*this)[0] == T(0)) { for(int i = 1; i < n; i++) { if((*this)[i] != T(0)) { if(i & 1) return {}; if(deg - i / 2 <= 0) break; auto ret = (*this >> i).sqrt(deg - i / 2) << (i / 2); if(ret.size() < deg) ret.resize(deg, T(0)); return ret; } } return P(deg, 0); } P ret({T(1)}); T inv2 = T(1) / T(2); for(int i = 1; i < deg; i <<= 1) { ret = (ret + pre(i << 1) * ret.inv(i << 1)) * inv2; } return ret.pre(deg); } // F(0) must be 0 P exp(int deg = -1) const { assert((*this)[0] == T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1)}); for(int i = 1; i < deg; i <<= 1) { ret = (ret * (pre(i << 1) + T(1) - ret.log(i << 1))).pre(i << 1); } return ret.pre(deg); } P pow(int64_t k, int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; for(int i = 0; i < n; i++) { if((*this)[i] != T(0)) { T rev = T(1) / (*this)[i]; P C(*this * rev); P D(n - i); for(int j = i; j < n; j++) D[j - i] = C[j]; D = (D.log() * k).exp() * (*this)[i].pow(k); P E(deg); if(i * k > deg) return E; auto S = i * k; for(int j = 0; j + S < deg && j < D.size(); j++) E[j + S] = D[j]; return E; } } return *this; } T eval(T x) const { T r = 0, w = 1; for(auto &v : *this) { r += w * v; w *= x; } return r; } }; //aはbの何乗以下かを満たす数の内最大の物,(a,10)はaの桁数 ll expless(ll a,ll b){ ll k=0; ll o=1; while(a>=o){ k++; o=o*b; } return k; } //aをb進法で表す //b進法のaを10進法に直す ll tenbase(ll a,ll b){ ll c=expless(a,10); ll ans=0; ll k=1; for(int i=0;i<c;i++){ ans+=(a%10)*k; k=k*b; a=a/10; } return ans; } vector<pair<long long, long long> > prime_factorize(long long N) { vector<pair<long long, long long> > res; for (long long a = 2; a * a <= N; ++a) { if (N % a != 0) continue; long long ex = 0; // 指数 // 割れる限り割り続ける while (N % a == 0) { ++ex; N /= a; } // その結果を push res.push_back({a, ex}); } // 最後に残った数について if (N != 1) res.push_back({N, 1}); return res; } ll atll(ll a,ll b){ b++; ll c=expless(a,10); ll d=c-b; ll f=1; for(int i=0;i<d;i++){ f=f*10; } a=(a/f); return a%10; } //aがbで何回割り切るか ll exp(ll a,ll b){ ll ans=0; while(a%b==0){ a=a/b; ans++; } return ans; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int X[6]={1,1,0,-1,-1,0}; const int Y[6]={0,1,1,0,-1,-1}; template<typename T> vector<T> smallest_prime_factors(T n) { vector<T> spf(n + 1); for (int i = 0; i <= n; i++) spf[i] = i; for (T i = 2; i * i <= n; i++) { // 素数だったら if (spf[i] == i) { for (T j = i * i; j <= n; j += i) { // iを持つ整数かつまだ素数が決まっていないなら if (spf[j] == j) { spf[j] = i; } } } } return spf; } vector<pair<ll,ll>> factolization(ll x, vector<ll> &spf) { vector<pair<ll,ll>> ret; ll p; ll z; while (x != 1) { p=(spf[x]); z=0; while(x%p==0){ z++; x /= p; } ret.push_back({p, z}); } return ret; } vector<bool> is; vector<long long int> prime_(ll n){ is.resize(n+1, true); is[0] = false; is[1] = false; vector<long long int> primes; for (int i=2; i<=n; i++) { if (is[i] == true){ primes.push_back(i); for (int j=i*2; j<=n; j+=i){ is[j] = false; } } } return primes; } vector<ll> dijkstra(ll f,ll n,vector<vector<vector<ll>>>& edge){ //最短経路としてどの頂点が確定済みかをチェックする配列 vector<ll> confirm(n,false); //それぞれの頂点への最短距離を保存する配列 //始点は0,始点以外はINFで最短距離を初期化する vector<ll> mincost(n,INF);mincost[f]=0; //確定済みの頂点の集合から伸びる辺を伝ってたどり着く頂点の始点からの距離を短い順に保存するPriority queue PQ mincand;mincand.push({mincost[f],f}); //mincandの要素がゼロの時、最短距離を更新できる頂点がないことを示す while(!mincand.empty()){ //最短距離でたどり着くと思われる頂点を取り出す vector<ll> next=mincand.top();mincand.pop(); //すでにその頂点への最短距離が確定済みの場合は飛ばす if(confirm[next[1]]) continue; //確定済みではない場合は確定済みにする confirm[next[1]]=true; //その確定済みの頂点から伸びる辺の情報をとってくる(参照の方が速い)、lは辺の本数 vector<vector<ll>>& v=edge[next[1]];ll l=SIZE(v); REP(i,l){ //辺の先が確定済みなら更新する必要がない((✳︎2)があれば十分なので(✳︎1)は実はいらない) if(confirm[v[i][0]]) continue; //(✳︎1) //辺の先のmincost以上の場合は更新する必要がない(辺の先が確定済みの時は満たす) if(mincost[v[i][0]]<=next[0]+v[i][1]) continue; //(✳︎2) //更新 mincost[v[i][0]]=next[0]+v[i][1]; //更新した場合はその頂点が(確定済みでない頂点の中で)最短距離になる可能性があるのでmincandに挿入 mincand.push({mincost[v[i][0]],v[i][0]}); } } return mincost; } ll so(ll a){ ll ans=0; if(a==0){ return 0; } while(a%2==0){ a/=2; ans++; } return ans; } ll HOM(ll n,ll r){ return COM(n+r-1,r); } ll binary(ll bina){ ll ans = 0; for (ll i = 0; bina>0 ; i++) { ans = ans+(bina%2)*pow(10,i); bina = bina/2; } return ans; } class UnionFind { public: vector<ll> parent; //parent[i]はiの親 vector<ll> siz; //素集合のサイズを表す配列(1で初期化) map<ll,vector<ll>> group;//素集合ごとに管理する連想配列(keyはそれぞれの素集合の親、valueはその素集合の要素の配列) //コンストラクタ UnionFind(ll n):parent(n),siz(n,1){ //全ての要素の根が自身であるとして初期化 for(ll i=0;i<n;i++){parent[i]=i;} } //データxの属する木の根を取得(経路圧縮も行う) ll root(ll x){ if(parent[x]==x) return x; return parent[x]=root(parent[x]);//代入式の値は代入した変数の値なので、経路圧縮できる } //xとyの木を併合 void unite(ll x,ll y){ ll rx=root(x);//xの根 ll ry=root(y);//yの根 if(rx==ry) return;//同じ木にある時 //小さい集合を大きい集合へと併合(ry→rxへ併合) if(siz[rx]<siz[ry]) swap(rx,ry); siz[rx]+=siz[ry]; parent[ry]=rx;//xとyが同じ木にない時はyの根ryをxの根rxにつける } //xとyが属する木が同じかを判定 bool same(ll x,ll y){ ll rx=root(x); ll ry=root(y); return rx==ry; } //xの素集合のサイズを取得 ll size(ll x){ return siz[root(x)]; } //素集合をそれぞれグループ化 void grouping(ll n){ //経路圧縮を先に行う REP(i,n)root(i); //mapで管理する(デフォルト構築を利用) REP(i,n)group[parent[i]].PB(i); } }; vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N/i != i) res.push_back(N/i); } } // 小さい順に並び替える sort(res.begin(), res.end()); return res; } vector<ll> zaatu(vector<ll> a,ll n){ map<ll,ll> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]] = 0; } // 小さい値から順に番号を付けていく ll num = 0; for (auto x : mp) { mp[x.first] = num; num++; } vector<ll> ans; for(int i=0;i<n;i++){ ans.push_back(mp[a[i]]); } return ans; } ll vectorcheck(vector<ll> t,ll key){ auto iter = lower_bound(ALL(t), key); auto iter2 = upper_bound(ALL(t), key); if((iter-t.begin())!=(iter2-t.begin())){ return 1; } else{ return 0; } } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(10); ll n; cin>>n; vector<vector<vector<ll>>> edge(n); for(int i=0;i<n-1;i++){ ll a,b,c; cin>>a>>b>>c; edge[a-1].PB({b-1,c}); edge[b-1].PB({a-1,c}); } ll q,k; cin>>q>>k; k--; vector<ll> mincost=dijkstra(k,n,edge); for(int i=0;i<q;i++){ ll a,b; cin>>a>>b; a--; b--; cout<<mincost.at(a)+mincost.at(b)<<endl; } }
a.cc:10:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 10 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s628786358
p03634
C++
//////////////////////////////////////////////////////////////////////////////// // Give me AC!!! // //////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <random> #include <cmath> #include <limits> #include <iostream> #include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> using namespace std; namespace mp = boost::multiprecision; using namespace mp; using ull = __int128; using ll = long long; using cll = cpp_int; using Graph = vector<vector<int>>; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) //xにはvectorなどのコンテナ #define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい #define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく #define MAX(x) *max_element(ALL(x)) //最大値を求める #define MIN(x) *min_element(ALL(x)) //最小値を求める #define PQ priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>> #define PB push_back //vectorヘの挿入 #define MP make_pair //pairのコンストラクタ #define F first //pairの一つ目の要素 #define S second //pairの二つ目の要素 #define coutY cout<<"YES"<<endl #define couty cout<<"Yes"<<endl #define coutN cout<<"NO"<<endl #define coutn cout<<"No"<<endl #define coutdouble(a,b) cout << fixed << setprecision(a) << double(b) ; #define vi(a,b) vector<int> a(b) #define vl(a,b) vector<ll> a(b) #define vs(a,b) vector<string> a(b) #define vll(a,b,c) vector<vector<ll>> a(b, vector<ll>(c)); #define intque(a) queue<int> a; #define llque(a) queue<ll> a; #define intque2(a) priority_queue<int, vector<int>, greater<int>> a; #define llque2(a) priority_queue<ll, vector<ll>, greater<ll>> a; #define pushback(a,b) a.push_back(b) #define mapii(M1) map<int, int> M1; #define cou(v,x) count(v.begin(), v.end(), x) #define mapll(M1) map<ll,ll> M1; #define mapls(M1) map<ll, string> M1; #define mapsl(M1) map<string, ll> M1; #define twolook(a,l,r,x) lower_bound(a+l, a+r, x) - a #define sor(a) sort(a.begin(), a.end()) #define rever(a) reverse(a.begin(),a.end()) #define rep(i,a) for(ll i=0;i<a;i++) #define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i] #define vcout(n) for(ll i=0;i<ll(n.size());i++) cout<<n[i] #define vcin2(n) rep(i,ll(n.size())) rep(j,ll(n.at(0).size())) cin>>n[i][j] //const ll mod = 998244353; //const ll MOD = 998244353; const ll MOD = 1000000007; const ll mod = 1000000007; constexpr ll MAX = 5000000; //const ll _max = 9223372036854775807; const ll _max = 1223372036854775807; const INF = 2000000000000000000; ll fac[MAX],finv[MAX],inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 long long 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; } int modPow(long long a, long long n, long long p) { if (n == 0) return 1; // 0乗にも対応する場合 if (n == 1) return a % p; if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p; long long t = modPow(a, n / 2, p); return (t * t) % p; } ll clocks(ll a,ll b,ll c){ return a*3600+b*60+c; } ll divup(ll b,ll d){ if(b%d==0){ return b/d; } else{ return b/d+1; } } struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) { } }; using Graphw = vector<vector<Edge>>; ll zero(ll a){ return max(ll(0),a); } template< typename T > struct FormalPowerSeries : vector< T > { using vector< T >::vector; using P = FormalPowerSeries; using MULT = function< P(P, P) >; static MULT &get_mult() { static MULT mult = nullptr; return mult; } static void set_fft(MULT f) { get_mult() = f; } void shrink() { while(this->size() && this->back() == T(0)) this->pop_back(); } P operator+(const P &r) const { return P(*this) += r; } P operator+(const T &v) const { return P(*this) += v; } P operator-(const P &r) const { return P(*this) -= r; } P operator-(const T &v) const { return P(*this) -= v; } P operator*(const P &r) const { return P(*this) *= r; } P operator*(const T &v) const { return P(*this) *= v; } P operator/(const P &r) const { return P(*this) /= r; } P operator%(const P &r) const { return P(*this) %= r; } P &operator+=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < r.size(); i++) (*this)[i] += r[i]; return *this; } P &operator+=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] += r; return *this; } P &operator-=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < r.size(); i++) (*this)[i] -= r[i]; shrink(); return *this; } P &operator-=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] -= r; shrink(); return *this; } P &operator*=(const T &v) { const int n = (int) this->size(); for(int k = 0; k < n; k++) (*this)[k] *= v; return *this; } P &operator*=(const P &r) { if(this->empty() || r.empty()) { this->clear(); return *this; } assert(get_mult() != nullptr); return *this = get_mult()(*this, r); } P &operator%=(const P &r) { return *this -= *this / r * r; } P operator-() const { P ret(this->size()); for(int i = 0; i < this->size(); i++) ret[i] = -(*this)[i]; return ret; } P &operator/=(const P &r) { if(this->size() < r.size()) { this->clear(); return *this; } int n = this->size() - r.size() + 1; return *this = (rev().pre(n) * r.rev().inv(n)).pre(n).rev(n); } P pre(int sz) const { return P(begin(*this), begin(*this) + min((int) this->size(), sz)); } P operator>>(int sz) const { if(this->size() <= sz) return {}; P ret(*this); ret.erase(ret.begin(), ret.begin() + sz); return ret; } P operator<<(int sz) const { P ret(*this); ret.insert(ret.begin(), sz, T(0)); return ret; } P rev(int deg = -1) const { P ret(*this); if(deg != -1) ret.resize(deg, T(0)); reverse(begin(ret), end(ret)); return ret; } P diff() const { const int n = (int) this->size(); P ret(max(0, n - 1)); for(int i = 1; i < n; i++) ret[i - 1] = (*this)[i] * T(i); return ret; } P integral() const { const int n = (int) this->size(); P ret(n + 1); ret[0] = T(0); for(int i = 0; i < n; i++) ret[i + 1] = (*this)[i] / T(i + 1); return ret; } // F(0) must not be 0 P inv(int deg = -1) const { assert(((*this)[0]) != T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1) / (*this)[0]}); for(int i = 1; i < deg; i <<= 1) { ret = (ret + ret - ret * ret * pre(i << 1)).pre(i << 1); } return ret.pre(deg); } // F(0) must be 1 P log(int deg = -1) const { assert((*this)[0] == 1); const int n = (int) this->size(); if(deg == -1) deg = n; return (this->diff() * this->inv(deg)).pre(deg - 1).integral(); } P sqrt(int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; if((*this)[0] == T(0)) { for(int i = 1; i < n; i++) { if((*this)[i] != T(0)) { if(i & 1) return {}; if(deg - i / 2 <= 0) break; auto ret = (*this >> i).sqrt(deg - i / 2) << (i / 2); if(ret.size() < deg) ret.resize(deg, T(0)); return ret; } } return P(deg, 0); } P ret({T(1)}); T inv2 = T(1) / T(2); for(int i = 1; i < deg; i <<= 1) { ret = (ret + pre(i << 1) * ret.inv(i << 1)) * inv2; } return ret.pre(deg); } // F(0) must be 0 P exp(int deg = -1) const { assert((*this)[0] == T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1)}); for(int i = 1; i < deg; i <<= 1) { ret = (ret * (pre(i << 1) + T(1) - ret.log(i << 1))).pre(i << 1); } return ret.pre(deg); } P pow(int64_t k, int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; for(int i = 0; i < n; i++) { if((*this)[i] != T(0)) { T rev = T(1) / (*this)[i]; P C(*this * rev); P D(n - i); for(int j = i; j < n; j++) D[j - i] = C[j]; D = (D.log() * k).exp() * (*this)[i].pow(k); P E(deg); if(i * k > deg) return E; auto S = i * k; for(int j = 0; j + S < deg && j < D.size(); j++) E[j + S] = D[j]; return E; } } return *this; } T eval(T x) const { T r = 0, w = 1; for(auto &v : *this) { r += w * v; w *= x; } return r; } }; //aはbの何乗以下かを満たす数の内最大の物,(a,10)はaの桁数 ll expless(ll a,ll b){ ll k=0; ll o=1; while(a>=o){ k++; o=o*b; } return k; } //aをb進法で表す //b進法のaを10進法に直す ll tenbase(ll a,ll b){ ll c=expless(a,10); ll ans=0; ll k=1; for(int i=0;i<c;i++){ ans+=(a%10)*k; k=k*b; a=a/10; } return ans; } vector<pair<long long, long long> > prime_factorize(long long N) { vector<pair<long long, long long> > res; for (long long a = 2; a * a <= N; ++a) { if (N % a != 0) continue; long long ex = 0; // 指数 // 割れる限り割り続ける while (N % a == 0) { ++ex; N /= a; } // その結果を push res.push_back({a, ex}); } // 最後に残った数について if (N != 1) res.push_back({N, 1}); return res; } ll atll(ll a,ll b){ b++; ll c=expless(a,10); ll d=c-b; ll f=1; for(int i=0;i<d;i++){ f=f*10; } a=(a/f); return a%10; } //aがbで何回割り切るか ll exp(ll a,ll b){ ll ans=0; while(a%b==0){ a=a/b; ans++; } return ans; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int X[6]={1,1,0,-1,-1,0}; const int Y[6]={0,1,1,0,-1,-1}; template<typename T> vector<T> smallest_prime_factors(T n) { vector<T> spf(n + 1); for (int i = 0; i <= n; i++) spf[i] = i; for (T i = 2; i * i <= n; i++) { // 素数だったら if (spf[i] == i) { for (T j = i * i; j <= n; j += i) { // iを持つ整数かつまだ素数が決まっていないなら if (spf[j] == j) { spf[j] = i; } } } } return spf; } vector<pair<ll,ll>> factolization(ll x, vector<ll> &spf) { vector<pair<ll,ll>> ret; ll p; ll z; while (x != 1) { p=(spf[x]); z=0; while(x%p==0){ z++; x /= p; } ret.push_back({p, z}); } return ret; } vector<bool> is; vector<long long int> prime_(ll n){ is.resize(n+1, true); is[0] = false; is[1] = false; vector<long long int> primes; for (int i=2; i<=n; i++) { if (is[i] == true){ primes.push_back(i); for (int j=i*2; j<=n; j+=i){ is[j] = false; } } } return primes; } vector<ll> dijkstra(ll f,ll n,vector<vector<vector<ll>>>& edge){ //最短経路としてどの頂点が確定済みかをチェックする配列 vector<ll> confirm(n,false); //それぞれの頂点への最短距離を保存する配列 //始点は0,始点以外はINFで最短距離を初期化する vector<ll> mincost(n,INF);mincost[f]=0; //確定済みの頂点の集合から伸びる辺を伝ってたどり着く頂点の始点からの距離を短い順に保存するPriority queue PQ mincand;mincand.push({mincost[f],f}); //mincandの要素がゼロの時、最短距離を更新できる頂点がないことを示す while(!mincand.empty()){ //最短距離でたどり着くと思われる頂点を取り出す vector<ll> next=mincand.top();mincand.pop(); //すでにその頂点への最短距離が確定済みの場合は飛ばす if(confirm[next[1]]) continue; //確定済みではない場合は確定済みにする confirm[next[1]]=true; //その確定済みの頂点から伸びる辺の情報をとってくる(参照の方が速い)、lは辺の本数 vector<vector<ll>>& v=edge[next[1]];ll l=SIZE(v); REP(i,l){ //辺の先が確定済みなら更新する必要がない((✳︎2)があれば十分なので(✳︎1)は実はいらない) if(confirm[v[i][0]]) continue; //(✳︎1) //辺の先のmincost以上の場合は更新する必要がない(辺の先が確定済みの時は満たす) if(mincost[v[i][0]]<=next[0]+v[i][1]) continue; //(✳︎2) //更新 mincost[v[i][0]]=next[0]+v[i][1]; //更新した場合はその頂点が(確定済みでない頂点の中で)最短距離になる可能性があるのでmincandに挿入 mincand.push({mincost[v[i][0]],v[i][0]}); } } return mincost; } ll so(ll a){ ll ans=0; if(a==0){ return 0; } while(a%2==0){ a/=2; ans++; } return ans; } ll HOM(ll n,ll r){ return COM(n+r-1,r); } ll binary(ll bina){ ll ans = 0; for (ll i = 0; bina>0 ; i++) { ans = ans+(bina%2)*pow(10,i); bina = bina/2; } return ans; } class UnionFind { public: vector<ll> parent; //parent[i]はiの親 vector<ll> siz; //素集合のサイズを表す配列(1で初期化) map<ll,vector<ll>> group;//素集合ごとに管理する連想配列(keyはそれぞれの素集合の親、valueはその素集合の要素の配列) //コンストラクタ UnionFind(ll n):parent(n),siz(n,1){ //全ての要素の根が自身であるとして初期化 for(ll i=0;i<n;i++){parent[i]=i;} } //データxの属する木の根を取得(経路圧縮も行う) ll root(ll x){ if(parent[x]==x) return x; return parent[x]=root(parent[x]);//代入式の値は代入した変数の値なので、経路圧縮できる } //xとyの木を併合 void unite(ll x,ll y){ ll rx=root(x);//xの根 ll ry=root(y);//yの根 if(rx==ry) return;//同じ木にある時 //小さい集合を大きい集合へと併合(ry→rxへ併合) if(siz[rx]<siz[ry]) swap(rx,ry); siz[rx]+=siz[ry]; parent[ry]=rx;//xとyが同じ木にない時はyの根ryをxの根rxにつける } //xとyが属する木が同じかを判定 bool same(ll x,ll y){ ll rx=root(x); ll ry=root(y); return rx==ry; } //xの素集合のサイズを取得 ll size(ll x){ return siz[root(x)]; } //素集合をそれぞれグループ化 void grouping(ll n){ //経路圧縮を先に行う REP(i,n)root(i); //mapで管理する(デフォルト構築を利用) REP(i,n)group[parent[i]].PB(i); } }; vector<long long> enum_divisors(long long N) { vector<long long> res; for (long long i = 1; i * i <= N; ++i) { if (N % i == 0) { res.push_back(i); // 重複しないならば i の相方である N/i も push if (N/i != i) res.push_back(N/i); } } // 小さい順に並び替える sort(res.begin(), res.end()); return res; } vector<ll> zaatu(vector<ll> a,ll n){ map<ll,ll> mp; for (int i = 0; i < n; i++) { cin >> a[i]; mp[a[i]] = 0; } // 小さい値から順に番号を付けていく ll num = 0; for (auto x : mp) { mp[x.first] = num; num++; } vector<ll> ans; for(int i=0;i<n;i++){ ans.push_back(mp[a[i]]); } return ans; } ll vectorcheck(vector<ll> t,ll key){ auto iter = lower_bound(ALL(t), key); auto iter2 = upper_bound(ALL(t), key); if((iter-t.begin())!=(iter2-t.begin())){ return 1; } else{ return 0; } } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(10); }
a.cc:10:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 10 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s309039895
p03634
C++
#include<stdio.h> #include<iostream> #include<vector> #include<math.h> #include<queue> #include<map> #include<algorithm> #include<string.h> #include<functional> #include<limits.h> #include<stdlib.h> #include<cmath> #include<cstring> #include<set> #include<climits> #include<bitset> using namespace std; #define intmax INT_MAX #define lmax LONG_MAX #define uintmax UINT_MAX #define ulmax ULONG_MAX #define llmax LLONG_MAX #define ll long long #define rep(i,a,N) for((i)=(a);(i)<(N);(i)++) #define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--) #define llfor ll i,j #define sc(a) cin>>a #define pr(a) cout<<a<<endl #define pY puts("YES") #define pN puts("NO") #define py puts("Yes") #define pn puts("No") #define pnn printf("\n") #define pb(b) push_back(b) #define all(a) a.begin(),a.end() #define llvec vector<vector<ll>> #define charvec vector<vector<char>> #define llpvec vector<pair<ll,ll>> #define size_(a,b) (a,vector<ll>(b)) #define S 21 llfor;//////////////////////////////////////////////////////////// vector<vector<pair<ll,ll>>>path; vector<ll>dis; void dfs(ll a){ for(i,0,path[a].size()){ if(dis[path[a][i].first]!=1e18)continue; dis[path[a][i].first]=dis[a]+path[a][i].second; //cout<<a<<" "<<path[a][i].first<<" "<<dis[path[a][i].first]<<endl; dfs(path[a][i].first); } } int main(){ ll n; cin>>n; ll a,b,c; path.resize(n); dis.resize(n,1e18); rep(i,0,n-1){ cin>>a>>b>>c; a--;b--; path[a].pb(make_pair(b,c)); path[b].pb(make_pair(a,c)); } ll q,k; cin>>q>>k; k--; dis[k]=0; dfs(k); //pnn;rep(i,0,n)cout<<i<<" "<<dis[i]<<endl;pnn; rep(i,0,q){ cin>>a>>b; a--;b--; ll ans=dis[a]+dis[b]; pr(ans); } return 0;}
a.cc: In function 'void dfs(long long int)': a.cc:46:24: error: expected ';' before ')' token 46 | for(i,0,path[a].size()){ | ^ | ; a.cc:46:22: warning: ignoring return value of 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<long long int, long long int>; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int]', declared with attribute 'nodiscard' [-Wunused-result] 46 | for(i,0,path[a].size()){ | ~~~~~~~~~~~~^~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:992:7: note: declared here 992 | size() const _GLIBCXX_NOEXCEPT | ^~~~ a.cc:52:1: error: expected primary-expression before '}' token 52 | } | ^ a.cc:51:3: error: expected ';' before '}' token 51 | } | ^ | ; 52 | } | ~ a.cc:52:1: error: expected primary-expression before '}' token 52 | } | ^ a.cc:51:3: error: expected ')' before '}' token 51 | } | ^ | ) 52 | } | ~ a.cc:46:5: note: to match this '(' 46 | for(i,0,path[a].size()){ | ^ a.cc:52:1: error: expected primary-expression before '}' token 52 | } | ^
s074927828
p03634
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <map> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll INF = 1 << 30; struct Edge { int to; int cost; }; int main() { int n; vector<vector<Edge>> ab(n); for (int i = 0; i < n - 1; i++) { ll a, b, c; cin >> a >> b >> c; a--; b--; ab[a].emplace_back(b, c); ab[b].emplace_back(a, c); } ll q, k; cin >> q >> k; k--; vector<P> xy; for (int i = 0; i < q; i++) { ll x, y; cin >> x >> y; xy.emplace_back(x, y); } priority_queue<P, vector<P>, greater<P>> Q; Q.push(make_pair(k, 0)); vector<ll> dist(n + 5, INF); while (!Q.empty()) { auto item = Q.top(); Q.pop(); for (int i = 0; i < (int)ab[item.first].size(); i++) { ll temp_to = ab[item.first][i].to; ll temp_cost = ab[item.first][i].cost; if (dist[temp_to] <= dist[item.first] + temp_cost) { continue; } dist[temp_to] = dist[item.first] + temp_cost; Q.emplace(dist[temp_to], temp_to); } } for (int i = 0; i < q; i++) { cout << dist[xy[i].first] + dist[xy[i].second] << 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/string:43, 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:2: /usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Edge; _Args = {long long int&, long long int&}; _Tp = Edge]': /usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Edge; _Args = {long long int&, long long int&}; _Tp = Edge; allocator_type = std::allocator<Edge>]' 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 = {long long int&, long long int&}; _Tp = Edge; _Alloc = std::allocator<Edge>; reference = Edge&]' 117 | _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 118 | std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:29:27: required from here 29 | ab[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 'Edge::Edge(long long int&)' a.cc:13:8: note: candidate: 'Edge::Edge()' 13 | struct Edge | ^~~~ a.cc:13:8: note: candidate expects 0 arguments, 1 provided a.cc:13:8: note: candidate: 'constexpr Edge::Edge(const Edge&)' a.cc:13:8: note: no known conversion for argument 1 from 'long long int' to 'const Edge&' a.cc:13:8: note: candidate: 'constexpr Edge::Edge(Edge&&)' a.cc:13:8: note: no known conversion for argument 1 from 'long long int' to 'Edge&&'
s785792458
p03634
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <queue> #include <map> using namespace std; typedef long long ll; typedef pair<ll, ll> P; const ll INF = 1 << 30; struct Edge { int to; int cost; }; int main() { int n; vector<vector<Edge>> ab(n); for (int i = 0; i < n - 1; i++) { ll a, b, c; cin >> a >> b >> c; a--; b--; ab[a].emplace_back(b, c); ab[b].emplace_back(a, c); } ll q, k; cin >> q >> k; k--; vector<P> xy; for (int i = 0; i < q; i++) { ll x, y; cin >> x >> y; xy.emplace_back(x, y); } priority_queue<P, vector<P>, greater<P>> Q; Q.push(make_pair(k, 0)); vector<ll> dist(n + 5, INF); while (!Q.empty()) { auto item = Q.top(); Q.pop(); for (int i = 0; i < ab[item.first].size(); i++) { ll temp_to = ab[item.first][i].to; ll temp_cost = ab[item.first][i].cost; if (dist[temp_to] <= dist[item.first] + temp_cost) { continue; } dist[temp_to] = dist[item.first] + temp_cost; Q.emplace(dist[temp_to], temp_to); } } for (int i = 0; i < q; i++) { cout << dist[xy[i].first] + dist[xy[i].second] << 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/string:43, 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:2: /usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = Edge; _Args = {long long int&, long long int&}; _Tp = Edge]': /usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = Edge; _Args = {long long int&, long long int&}; _Tp = Edge; allocator_type = std::allocator<Edge>]' 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 = {long long int&, long long int&}; _Tp = Edge; _Alloc = std::allocator<Edge>; reference = Edge&]' 117 | _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 118 | std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:29:27: required from here 29 | ab[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 'Edge::Edge(long long int&)' a.cc:13:8: note: candidate: 'Edge::Edge()' 13 | struct Edge | ^~~~ a.cc:13:8: note: candidate expects 0 arguments, 1 provided a.cc:13:8: note: candidate: 'constexpr Edge::Edge(const Edge&)' a.cc:13:8: note: no known conversion for argument 1 from 'long long int' to 'const Edge&' a.cc:13:8: note: candidate: 'constexpr Edge::Edge(Edge&&)' a.cc:13:8: note: no known conversion for argument 1 from 'long long int' to 'Edge&&'
s650465253
p03634
C++
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long ll; #define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> void dfs(ll cur,ll d, vector<vector<pair<ll,ll>>> &adj, vector<ll> &distances){ distances[cur] =d; for(auto p:adj[cur]) if(!distances[p.first]) dfs(p.first,d+p.second,adj,distances); } int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; vector<vector<pair<ll,ll>>> adj(n+1); for(ll i=0;i<n-1;i++){ ll a,b,c; cin>>x>>y>>w; adj[x].push_back({y,w}); adj[y].push_back({x,w}); } ll q,k; cin>>q>>k; vector<ll> distances(n+1); distances[k]=-1; for(ll i=0;i<q;i++){ ll x,y; cin>>a>>b; cout<<distances[a]+distances[b]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:25:10: error: 'x' was not declared in this scope 25 | cin>>x>>y>>w; | ^ a.cc:25:13: error: 'y' was not declared in this scope 25 | cin>>x>>y>>w; | ^ a.cc:25:16: error: 'w' was not declared in this scope 25 | cin>>x>>y>>w; | ^ a.cc:35:10: error: 'a' was not declared in this scope 35 | cin>>a>>b; | ^ a.cc:35:13: error: 'b' was not declared in this scope 35 | cin>>a>>b; | ^
s570965887
p03634
C++
#include<bits/stdc++.h> using namespace std; long long N; long long a, b; long long c; long long tree[10005][10005]; long long dist[100005]; int main(){ cin>>N; for(long long i=0; i<N-1; i++){ cin>>a>>b>>c; a--;b--; tree[a][b] = c; tree[b][a] = c; dist[i] = -1; } for(long long i=0; i<=N; i++){ dist[i] = -1; } long long Q,K; cin>>Q>>K; K--; dist[K] = 0; queue<long long> que; que.push(K); while(!que.empty()){ long long v; v = que.front(); que.pop(); for(long long i=0;i<N;i++){ if(tree[v][i] && dist[i]<0) { que.push(i); dist[i] = dist[v] + tree[v][i]; } } } for(long longi = 0; i < Q; i++){ long longx, y; cin >> x >> y; x--;y--; cout << dist[x]+dist[y] << endl; } }
a.cc: In function 'int main()': a.cc:39:25: error: 'i' was not declared in this scope 39 | for(long longi = 0; i < Q; i++){ | ^ a.cc:41:16: error: 'x' was not declared in this scope 41 | cin >> x >> y; | ^
s393704335
p03634
C++
#include<bits/stdc++.h> using namespace std; int N; int a, b; long long c; long long tree[10005][10005]; long long dist[100005]; int main(){ cin>>N; for(int i=0; i<N-1; i++){ cin>>a>>b>>c; a--;b--; tree[a][b] = c; tree[b][a] = c; dist[i] = -1; } for(int i=1; i<=N; i++){ dist[i] = -1; } int Q,K; cin>>Q>>K; K--; dist[K] = 0; queue<int> que; que.push(K);cout<<"------------------------1"<<endl; while(!que.empty()){ int v; v = que.front(); que.pop(); for(int i=0;i<N;i++){ if(tree[v][i] && dist[i]<0) { que.push(i); dist[i] = dist[v] + tree[v][i]; } } cout<<endl; } long long ans; for(long long i = 0; i < Q; i++){ int x, y; cin >> x >> y; x--;y--; cout <<<< dist[x]+dist[y] << endl; } }
a.cc: In function 'int main()': a.cc:44:16: error: expected primary-expression before '<<' token 44 | cout <<<< dist[x]+dist[y] << endl; | ^~
s613958082
p03634
C++
#include<bits/stdc++.h> using namespace std; int N; int a, b; long long c; long long tree[100005][100005]; long long dist[100005]; int main(){ cin>>N; for(int i=0; i<N-1; i++){ cout<<i<<endl; cin>>a>>b>>c; a--;b--; tree[a][b] = c; tree[b][a] = c; } int Q, K; cin >> Q >> K; K--; dist[K] = 0; queue<int> que; que.push(K); while(!que.empty()){ int v; v = que.front(); que.pop(); for(int i=0;i<N-1;i++){ if(tree[v][i]) dist[i] = dist[v] + tree[v][i]; que.push(i); } } long long ans; for(long long i = 0; i < Q; i++){ int x, y; cin >> x >> y; x--;y--; cout << dist[x]+dist[y] << endl; } }
/tmp/ccjP7J4c.o: in function `main': a.cc:(.text+0x17b): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o a.cc:(.text+0x217): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o a.cc:(.text+0x260): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o a.cc:(.text+0x327): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o a.cc:(.text+0x342): relocation truncated to fit: R_X86_64_PC32 against symbol `dist' defined in .bss section in /tmp/ccjP7J4c.o collect2: error: ld returned 1 exit status
s051192085
p03634
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr long long MOD = 1000000007; constexpr long long INF = 1LL << 60 const long double PI = acosl(-1.0); constexpr long double EPS = 1e-11; template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } 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 (ll 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 (ll 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(){ ll n; cin >> n; graph g(n); for (ll i = 0; i < n - 1; i++) { ll a, b, c; cin >> a >> b >> c; a--; b--; g.add_edge(a, b, c); } ll q,k; cin >> q >> k; k--; g.dijkstra(k); for (ll i = 0; i < q;i++){ ll x, y; cin >> x >> y; x--; y--; cout << g.d[x] + g.d[y] << endl; } }
a.cc:6:1: error: expected ',' or ';' before 'const' 6 | const long double PI = acosl(-1.0); | ^~~~~
s546361443
p03634
C++
#include <bits/stdc++.h> using namespace std; #define int long long int INF = 1e9+7; typedef pair<int,int> P; signed main(){ int N; cin >> N; vector<vector<P>>road(N); for(int i = 0; i < N-1; i++) { int a,b,c; cin >> a >> b >> c; a--;b--; road[a].push_back({b,c}); road[b].push_back({a,c}); } int Q,K; cin >> Q >> K; K--; priority_queue<int,vector<int>,greater<int>> que; vector<int>cnt(N,INF); cnt[K] = 0; que.push({0,K}); while(!que.empty()) { P x = que.top(); que.pop(); if(cnt[x.second] < x.first) { continue; } for(int i = 0; i < road[x.second].size(); i++) { if(cnt[road[x.second][i].first] > x.first+road[x.second][i].second) { cnt[road[x.second][i].first] = x.first+road[x.second][i].second; que.push({cnt[road[x.second][i].first],road[x.second][i].first}); } } } for(int i = 0; i < Q; i++) { int x,y; cin >> x >> y; x--;y--; cout << cnt[x]+cnt[y] << endl; } }
a.cc: In function 'int main()': a.cc:23:13: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::push(<brace-enclosed initializer list>)' 23 | que.push({0,K}); | ~~~~~~~~^~~~~~~ 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:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&' {aka 'const long long 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 = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&&' {aka 'long long int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:25:22: error: conversion from 'const __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'const long long int'} to non-scalar type 'P' {aka 'std::pair<long long int, long long int>'} requested 25 | P x = que.top(); | ~~~~~~~^~ a.cc:33:25: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::push(<brace-enclosed initializer list>)' 33 | que.push({cnt[road[x.second][i].first],road[x.second][i].first}); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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 = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&' {aka 'const long long 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 = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&&' {aka 'long long int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~
s874190791
p03634
C++
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> P; signed main(){ int N; cin >> N; vector<vector<P>>road(N); for(int i = 0; i < N-1; i++) { int a,b,c; cin >> a >> b >> c; a--;b--; road[a].push_back({b,c}); road[b].push_back({a,c}); } int Q,K; cin >> Q >> K; K--; priority_queue<int,vector<int>,greater<int>> que; vector<int>cnt(N,INF); cnt[K] = 0; que.push({0,K}); while(!que.empty()) { P x = que.top(); que.pop(); if(cnt[x.second] < x.first) { continue; } for(int i = 0; i < road[x.second].size(); i++) { if(cnt[road[x.second][i].first] > x.first+road[x.second][i].second) { cnt[road[x.second][i].first] = x.first+road[x.second][i].second; que.push({cnt[road[x.second][i].first],road[x.second][i].first}); } } } for(int i = 0; i < Q; i++) { int x,y; cin >> x >> y; x--;y--; cout << cnt[x]+cnt[y] << endl; } }
a.cc: In function 'int main()': a.cc:20:22: error: 'INF' was not declared in this scope 20 | vector<int>cnt(N,INF); | ^~~ a.cc:22:13: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::push(<brace-enclosed initializer list>)' 22 | que.push({0,K}); | ~~~~~~~~^~~~~~~ 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:736:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&' {aka 'const long long 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 = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&&' {aka 'long long int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~ a.cc:24:22: error: conversion from 'const __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'const long long int'} to non-scalar type 'P' {aka 'std::pair<long long int, long long int>'} requested 24 | P x = que.top(); | ~~~~~~~^~ a.cc:32:25: error: no matching function for call to 'std::priority_queue<long long int, std::vector<long long int>, std::greater<long long int> >::push(<brace-enclosed initializer list>)' 32 | que.push({cnt[road[x.second][i].first],road[x.second][i].first}); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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 = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&' {aka 'const long long 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 = long long int; _Sequence = std::vector<long long int>; _Compare = std::greater<long long int>; value_type = long long 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<long long int, std::vector<long long int>, std::greater<long long int> >::value_type&&' {aka 'long long int&&'} 744 | push(value_type&& __x) | ~~~~~~~~~~~~~^~~
s228826621
p03634
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(x) x.begin(), x.end() #define mod 1000000007 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); rep(i,V){ 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){ rep(i,V){ 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(){ ll n; cin >> n; graph g(n); rep(i, n-1){ ll a, b, c; cin >> a >> b >> c; a--; b--; g.add_edge(a,b,c); } ll q, k; cin >> q >> k; k--; g.dijkstra(k); rep(i, q){ ll x, y; cin >> x >> y; x--; y--; cout << g.d[x]+g.d[y] << endl; } return 0; }
a.cc: In member function 'void graph::init(ll)': a.cc:24:14: error: 'INF' was not declared in this scope 24 | d[i] = INF; | ^~~ a.cc: In member function 'void graph::dijkstra(ll)': a.cc:36:14: error: 'INF' was not declared in this scope 36 | d[i] = INF; | ^~~
s668995094
p03634
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(x) x.begin(), x.end() #define mod 1000000007 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); REP(i,V){ 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){ REP(i,V){ 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(){ ll n; cin >> n; graph g(n); rep(i, n-1){ ll a, b, c; cin >> a >> b >> c; a--; b--; g.add_edge(a,b,c); } ll q, k; cin >> q >> k; k--; g.dijkstra(k); rep(i, q){ ll x, y; cin >> x >> y; x--; y--; cout << g.d[x]+g.d[y] << endl; } return 0; }
a.cc: In member function 'void graph::init(ll)': a.cc:23:9: error: 'i' was not declared in this scope 23 | REP(i,V){ | ^ a.cc:23:5: error: 'REP' was not declared in this scope 23 | REP(i,V){ | ^~~ a.cc: In member function 'void graph::dijkstra(ll)': a.cc:35:9: error: 'i' was not declared in this scope 35 | REP(i,V){ | ^ a.cc:35:5: error: 'REP' was not declared in this scope 35 | REP(i,V){ | ^~~
s357971588
p03634
C++
#include<bits/stdc++.h> using namespace std; int n,k; map<pair<int,int>,long long int> mp; vector<int> v[100005]; long long int d[100005]; void solve(int now,int before,long long int dis){ if(now==before){ for(auto u:v[now]){ d[u]=mp[make_pair(min(now,u),max(now,u))]; solve(u,now,mp[make_pair(min(now,u),max(now,u))]); } } else{ for(auto u:v[now]){ if(u!=before){ if(d[u]>dis+mp[make_pair(min(now,u),max(now,u))]){ d[u]=dis+mp[make_pair(min(now,u),max(now,u))]; solve(u,now,dis+mp[make_pair(min(tmp,u),max(tmp,u))]); }} } } } int main(){ cin >> n; int a,b,c; for(int i=0;i<n-1;i++){ cin >> a >> b >> c; v[a].push_back(b); v[b].push_back(a); mp[make_pair(min(a,b),max(a,b))]=c; } int q; cin >> q >> k; for(int i=1;i<=n;i++)d[i]=1e18; solve(k,k,0); for(int i=0;i<q;i++){ int x,y; cin >> x >> y; cout << d[x]+d[y] << endl; } }
a.cc: In function 'void solve(int, int, long long int)': a.cc:19:54: error: 'tmp' was not declared in this scope; did you mean 'tm'? 19 | solve(u,now,dis+mp[make_pair(min(tmp,u),max(tmp,u))]); | ^~~ | tm
s771102258
p03634
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=n-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(),(x).end() using ll=long long; using vl=vector<ll>; using vvl=vector<vector<ll>>; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[8]={1,0,-1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; using Graph = vector<vector<int>>; double nCk(int n, int k) { double res=1.0; for(int i=0; i<n; i++){ res*=0.5;} for(int i=0; i<k; i++){ res*=(double)(n-i); res/=(double)(k-i); } return res;} 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); rep(i,V){ 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){ rep(i,V){ 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)); } } } } }; class UnionFind { public: int par[100005]; int depth[100005]; int nGroup[100005]; UnionFind(int n) { init(n); } void init(int n) { for(int i=0; i<n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } int root(int x) { if(par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if(x == y) return; if(depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if(depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n; cin>>n; graph g(n); rep(i,n-1){ ll a,b,c; cin>>a>>b>>c; g.add_edge(a-1,b-1,c); g.add_edge(b-1,a-1,c); } ll q,k; cin>>q>>k; g.dijkstra(k-1); rep(i,q){ ll x,y; cin>>x>>y; cout << di[x-1]+di[y-1] << endl;} }
a.cc: In function 'int main()': a.cc:159:9: error: 'di' was not declared in this scope; did you mean 'i'? 159 | cout << di[x-1]+di[y-1] << endl;} | ^~ | i
s773770660
p03634
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=n-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(),(x).end() using ll=long long; using vl=vector<ll>; using vvl=vector<vector<ll>>; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[8]={1,0,-1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; using Graph = vector<vector<int>>; double nCk(int n, int k) { double res=1.0; for(int i=0; i<n; i++){ res*=0.5;} for(int i=0; i<k; i++){ res*=(double)(n-i); res/=(double)(k-i); } return res;} 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); rep(i,V){ 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){ rep(i,V){ 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)); } } } } }; class UnionFind { public: int par[100005]; int depth[100005]; int nGroup[100005]; UnionFind(int n) { init(n); } void init(int n) { for(int i=0; i<n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } int root(int x) { if(par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if(x == y) return; if(depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if(depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n; cin>>n; graph g(n); rep(i,n-1){ ll a,b,c; cin>>a>>b>>c; g.add_edge(a-1,b-1,c); g.add_edge(b-1,a-1,c); } ll q,k; cin>>q>>k; g.dijkstra(k-1); rep(i,q){ ll x,y; cin>>x>>y; cout << dist[x-1]+dist[y-1] << endl;} }
a.cc: In function 'int main()': a.cc:159:9: error: 'dist' was not declared in this scope 159 | cout << dist[x-1]+dist[y-1] << endl;} | ^~~~
s667797399
p03634
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=n-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(),(x).end() using ll=long long; using vl=vector<ll>; using vvl=vector<vector<ll>>; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[8]={1,0,-1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; using Graph = vector<vector<int>>; double nCk(int n, int k) { double res=1.0; for(int i=0; i<n; i++){ res*=0.5;} for(int i=0; i<k; i++){ res*=(double)(n-i); res/=(double)(k-i); } return res;} 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); rep(i,V){ 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){ rep(i,V){ 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)); } } } } }; class UnionFind { public: int par[100005]; int depth[100005]; int nGroup[100005]; UnionFind(int n) { init(n); } void init(int n) { for(int i=0; i<n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } int root(int x) { if(par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if(x == y) return; if(depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if(depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n; cin>>n; ll dp[n][n]={}; rep(i,n-1){ ll a,b,c; cin>>a>>b>>c; dp[a-1]b-1]=c; dp[b-1][a-1]=c;} rep(i,n){ rep(j,n){ if(dp[i][j]==0){ dp[i][j]=INF;} }} ll q,k; cin>>q>>k; rep(i,q){ ll x,y; cin>>x>>y; cout << dp[x-1][k-1]+dp[y-1][k-1] << endl;} }
a.cc: In function 'int main()': a.cc:152:8: error: expected ';' before 'b' 152 | dp[a-1]b-1]=c; | ^ | ;
s050967889
p03634
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(ll i=0;i<n;i++) #define repl(i,l,r) for(ll i=(l);i<(r);i++) #define per(i,n) for(ll i=n-1;i>=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define all(x) (x).begin(),(x).end() using ll=long long; using vl=vector<ll>; using vvl=vector<vector<ll>>; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[8]={1,0,-1,0,1,1,-1,-1}; const ll dx[8]={0,-1,0,1,1,-1,1,-1}; using Graph = vector<vector<int>>; double nCk(int n, int k) { double res=1.0; for(int i=0; i<n; i++){ res*=0.5;} for(int i=0; i<k; i++){ res*=(double)(n-i); res/=(double)(k-i); } return res;} 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); rep(i,V){ 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){ rep(i,V){ 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)); } } } } }; class UnionFind { public: int par[100005]; int depth[100005]; int nGroup[100005]; UnionFind(int n) { init(n); } void init(int n) { for(int i=0; i<n; i++) { par[i] = i; depth[i] = 0; nGroup[i] = 1; } } int root(int x) { if(par[x] == x) { return x; } else { return par[x] = root(par[x]); } } bool same(int x, int y) { return root(x) == root(y); } void unite(int x, int y) { x = root(x); y = root(y); if(x == y) return; if(depth[x] < depth[y]) { par[x] = y; nGroup[y] += nGroup[x]; nGroup[x] = 0; } else { par[y] = x; nGroup[x] += nGroup[y]; nGroup[y] = 0; if(depth[x] == depth[y]) depth[x]++; } } }; const ll MAX = 510000; ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; 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; } } // 二項係数計算 ll COM(ll n, ll k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } int main() { ll n; cin>>n; ll dp[n][n]={}; rep(i,n-1){ ll a,b,c; cin>>a>>b>>c; dp[a-1]b-1]=c; dp[b-1][a-1]=c;} rep(i,n){ rep(j,n){ if(dp[i][j]==0){ dp[i][j]=INF;} }} for(int k=0;k<n;k++){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++)dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]); } } ll q,k; cin>>q>>k; rep(i,q){ ll x,y; cin>>x>>y; cout << dp[x-1][k-1]+dp[y-1][k-1] << endl;} }
a.cc: In function 'int main()': a.cc:152:8: error: expected ';' before 'b' 152 | dp[a-1]b-1]=c; | ^ | ;
s926066330
p03634
C++
#include <bits/stdc++.h> #include <vector> # include <cstdint> #define FOR(i,l,r) for(int i=(l);i<(r);++i) #define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--) #define rep(i,n) FOR(i,0,n) #define rrep(i,n) RFOR(i,n-1,0) #define int long long using namespace std; const int MX = 1e6; const int inf = 1e9; const int mod = 998244353; using ll = long long; using P = pair<ll, ll>; double PI = acos(-1); int n; int a, b, c; vector<vector<P>> to(MX); int q,k; int x[MX], y[MX]; int visit[MX]; int dep[MX]; void dfs(int v, int depth) { if(visit[v]==1) return; visit[v] = 1; dep[v] = depth; for(auto u: to[v]) { dfs(u.first, depth+u.second); } } signed main(){ cin >> n; rep(i,n-1) { cin >> a >> b >> c; to[a].push_back({b,c}); to[b].push_back({a,c}); } cin >> q >> k; dfs(k,0); rep(i, q) { cin >> x[i] >> y[i]; cout << dep[x[i]]+dep[y[i]] << endl; } return 0; }
a.cc: In function 'void dfs(long long int, long long int)': a.cc:27:8: error: reference to 'visit' is ambiguous 27 | if(visit[v]==1) return; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80, from a.cc:1: /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:23:5: note: 'long long int visit [1000000]' 23 | int visit[MX]; | ^~~~~ a.cc:28:5: error: reference to 'visit' is ambiguous 28 | visit[v] = 1; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:23:5: note: 'long long int visit [1000000]' 23 | int visit[MX]; | ^~~~~
s195640966
p03634
C++
#include "bits/stdc++.h" using namespace std; using ll = long long; using Pii = pair<int, int>; using Pll = pair<ll, ll>; #define rep(i, begin, n) for (int i = begin; i < n; i++) #define repe(i, begin, n) for (int i = begin; i <= n; i++) #define repr(i, begin, n) for (int i = begin; i > begin - n; i--) #define repre(i, begin, end) for (int i = begin; i >= end; i--) template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } const int inf = 1000000007; const int MOD = 1000000007; const long long INF = 1000000000000000007; // ------------------------------------------------------- #include "bits/stdc++.h" using namespace std; const long long INF = 1000000000000000007; // ------------------------------------------------------- // 少し多めに確保すること // ぴったりだと正しく動かないので注意 const long long MAX_V = 1010101; struct edge { long long to, cost; }; using Pll = pair<long long, long long>; long long V; vector<edge> Graph[MAX_V]; long long dist[MAX_V]; void dijkstra(long long s) { priority_queue<Pll, vector<Pll>, greater<Pll>> que; // 0-indexedと1-indexedの両方に対応 fill(dist, dist + MAX_V, INF); dist[s] = 0; que.push(Pll(0, s)); while (!que.empty()) { auto elem = que.top(); que.pop(); auto cv = elem.second; if (elem.first > dist[cv]) { continue; } for (auto e : Graph[cv]) { if (dist[e.to] > dist[cv] + e.cost) { dist[e.to] = dist[cv] + e.cost; que.push(Pll(dist[e.to], e.to)); } } } } ll N; ll Q, K; int main() { cin >> N; V = N; rep(i, 1, N) { ll a, b, c; cin >> a >> b >> c; Graph[a].push_back(edge{b, c}); Graph[b].push_back(edge{a, c}); } cin >> Q >> K; dijkstra(K); vector<ll> ans; rep(i, 0, Q) { ll x, y; cin >> x >> y; ans.push_back(dist[x] + dist[y]); } for (auto e : ans) { cout << e << "\n"; } }
a.cc:38:17: error: redefinition of 'const long long int INF' 38 | const long long INF = 1000000000000000007; | ^~~ a.cc:31:17: note: 'const long long int INF' previously defined here 31 | const long long INF = 1000000000000000007; | ^~~
s003036966
p03634
C++
#include<bits/stdc++.h> #define rep(i,N) for(int i=0;i<(N);i++) #define FOR(i,a,b) for(int i=(a);i<(b);i++) using namespace std; const long long MOD = 1e9 + 7; const long long INF = 1e12; const int inf = 1e9; const int mod = 1e9+7; typedef long long ll; typedef pair<ll,int> P; typedef set<int> S; ll n,q,k; vector<ll> to[100010]; map<pair<int,int>, ll> mli; map<int, ll> ans; void solve(int i, int p, ll now){ for(auto u : to[i]){ if(i == p) continue; now += mli[{i,u}]; ans[u] = now; solve(u,i,now); } } int main(){ cout << fixed << setprecision(10); int n; cin >> n; rep(i,n){ int a,b; ll c; cin >> a >> b >> c; a--; b--; mli[{a,b}] = c; mli[{b,a}] = c; to[a].push_back(b); to[b].push_back(a); } cin >> q >> k; k--; solve(0,-1,k); rep(i,q){ int x,y; cin >> x >> y; x--; y--; cout << mli[x] + mli[y] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:20: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, long long int>' and 'int') 45 | cout << mli[x] + mli[y] << endl; | ^ In file included from /usr/include/c++/14/map:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:1: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = long long int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, long long int> >; mapped_type = long long int; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, long long int>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = long long int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, long long int> >; mapped_type = long long int; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, long long int>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ a.cc:45:29: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, long long int>' and 'int') 45 | cout << mli[x] + mli[y] << endl; | ^ /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = long long int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, long long int> >; mapped_type = long long int; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, long long int>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = long long int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, long long int> >; mapped_type = long long int; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, long long int>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s262297138
p03634
C++
#include <iostream> #include <iomanip> #include<math.h> #include<list> #include <algorithm> #include<set> #include<vector> #include<math.h> #include<map> #include<string> #include <numeric> #include <queue> #include <sstream> #include <bitset> #include<stack> using namespace std; using ll = long long; using vll = vector<long long>; using sll = set<long long>; template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } template<typename T> map<T, T> getPrimeFactor(T n) { map<T, T> res; for (T i = 2; i * i <= n; ++i) { while (n % i == 0) { res[i] ++; n /= i; } } if (n != 1) res[n] = 1; return res; } template<typename T> bool IsPrimeNumber(T num) { if (num <= 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2) { if (num % i == 0) { return false; } } return true; } long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } #define rep(i,s,e) for(ll i=s;i<e;i++) #define repeq(i,s,e) for(ll i=s;i<=e;i++) int main() { ll N; std::cin >> N; vector<map<ll, ll>> dic(N+1); rep(i, 1, N) { ll a, b, c; std::cin >> a >> b >> c; dic[a][b] = c; dic[b][a] = c; } ll Q, K; std::cin >> Q >> K; vll cost(N+1, LLONG_MAX); cost[K] = 0; vector<bool> isVisited(N + 1, false); priority_queue<pair<ll, ll>> pq; pq.push({ 0,K }); while (!pq.empty()) { if (!isVisited[pq.top().second]) { isVisited[pq.top().second] = true; ll c = pq.top().first; ll pos = pq.top().second; pq.pop(); for (auto itr = dic[pos].begin(); itr != dic[pos].end(); itr++) { if (c + itr->second < cost[itr->first]) { cost[itr->first] = c + itr->second; pq.push({ cost[itr->first],itr->first }); } } } } rep(i, 0, Q) { ll x, y; std::cin >> x >> y; std::cout << cost[x] + cost[y] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:90:23: error: 'LLONG_MAX' was not declared in this scope 90 | vll cost(N+1, LLONG_MAX); | ^~~~~~~~~ a.cc:16:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 15 | #include<stack> +++ |+#include <climits> 16 |
s904560761
p03634
C++
#include<bits/stdc++.h> #define all(x) (x).begin(),(x).end() #define rep(i,n) for(ll i=0;i<(ll)(n);i++) using namespace std; typedef long long ll; struct edge{ ll v,cost; }; int main(){ ll n; cin>>n; vector<vector<edge>> adj(n); ll a,b,c; rep(i,n-1){ cin>>a>>b>>c; a--,b--; adj[a].push_back((edge){b,c}); adj[b].push_back((edge){a,c}); } ll q,k; cin>>q>>k; k--; vector<ll> dist(n,-1); queue<ll> q; q.push(k); dist[k]=0; while(!q.empty()){ ll now=q.front(); q.pop(); rep(i,adj[now].size()){ if(dist[adj[now][i].v]==-1){ dist[adj[now][i].v]=dist[now]+adj[now][i].cost; q.push(adj[now][i].v); } } } ll x,y; rep(i,q){ cin>>x>>y; cout<<dist[x]+dist[y]<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:26:15: error: conflicting declaration 'std::queue<long long int> q' 26 | queue<ll> q; | ^ a.cc:22:8: note: previous declaration as 'll q' 22 | ll q,k; | ^ a.cc:27:7: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'} 27 | q.push(k); | ^~~~ a.cc:29:14: error: request for member 'empty' in 'q', which is of non-class type 'll' {aka 'long long int'} 29 | while(!q.empty()){ | ^~~~~ a.cc:30:18: error: request for member 'front' in 'q', which is of non-class type 'll' {aka 'long long int'} 30 | ll now=q.front(); | ^~~~~ a.cc:31:11: error: request for member 'pop' in 'q', which is of non-class type 'll' {aka 'long long int'} 31 | q.pop(); | ^~~ a.cc:35:19: error: request for member 'push' in 'q', which is of non-class type 'll' {aka 'long long int'} 35 | q.push(adj[now][i].v); | ^~~~
s690498154
p03634
C++
#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll,ll>; ll INF = 1145141919810364; template <typename T> class edge { public: T cost, to, from; edge(T from, T to, T cost) : from(from), to(to), cost(cost) {} }; template <typename T> class Graph { public: vector<vector<edge<T>>> graph; Graph(T n, vector<T> from, vector<T> to, bool no_direction, vector<T> cost) { graph.resize(n); for (int i = 0; i < from.size(); i++) { edge<T> params(from[i], to[i], cost[i]); graph[from[i]].emplace_back(params); if (no_direction) { swap(params.from, params.to); graph[to[i]].emplace_back(params); } } } vector<ll> shortest_path; void Dijkstra(ll start) { shortest_path.resize(graph.size(), INF); shortest_path[start] = 0; priority_queue<P, vector<P>, greater<P>> que; que.emplace(0, start); while (!que.empty()) { P p = que.top(); que.pop(); ll v = p.second; if (shortest_path[v] < p.first) continue; for (int i = 0; i < graph[v].size(); i++) { ll k = graph[v][i].to; ll l = graph[v][i].cost; if (shortest_path[k] > shortest_path[v] + l) { shortest_path[k] = shortest_path[v] + l; que.push(P(shortest_path[k], k)); } } } } vector<vector<T>> Shortest_path; void Warshall_Froyd() { Shortest_path.resize(graph.size(), vector<T>(graph.size(), INF)); for (int i = 0; i < graph.size(); i++) { for (int j = 0; j < graph[i].size(); j++) { ll To = graph[i][j].to; ll Cost = graph[i][j].cost; Shortest_path[i][To] = Cost; } } for (int k = 0; k < graph.size(); k++) { for (int i = 0; i < graph.size(); i++) { for (int j = 0; j < graph.size(); j++) { Shortest_path[i][j] = min(Shortest_path[k][j] + Shortest_path[i][k], Shortest_path[i][j]); } } } } vector<T> dpath(T t) { vector<T> path; for (; t != INF; t = shortest_path[t]) path.emplace_back(t); reverse(path.begin(), path.end()); return path; } }; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n; cin >> n; vector<ll> from(n - 1), to(n - 1), cost(n - 1); ll q,k; for(ll i = 0; i < n - 1; i++){ cin >> from[i] >> to[i] >> cost[i]; from[i]--; to[i]--; } Graph<ll> g(n,from,to,true, cost); cin >> q >> k; g.Dijkstra(k - 1); g.Warshall_Froyd(); for(ll i = 0; i < q; i++){ ll x,y; cin >> x >> y; x--; y--; cout << g.Shortest_path[x][k - 1] + g.shortest_path[y] << endl; }
a.cc: In function 'int main()': a.cc:118:2: error: expected '}' at end of input 118 | } | ^ a.cc:96:11: note: to match this '{' 96 | int main(){ | ^
s240023549
p03634
C++
#include <bits/stdc++.h> using namespace std; // def #define debug(x) cout << #x << ": " << x << endl #define out(x) cout << x << endl #define repeat(i, a, b) for (int i = (a); i < (b); i++) #define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define revrep(i, n) for (int i = (n)-1; i >= 0; i--) #define foreach(e, v) for (auto &e : v) #define all(x) (x).begin(), (x).end() #define CYES cout << "Yes" << endl #define CNO cout << "No" << endl #define SPC(x) cout << fixed << setprecision(x) #define ZERO(a) memset(a, 0, sizeof(a)) #define MINUS(a) memset(a, 0xff, sizeof(a)) typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<vector<int>> vii; typedef vector<ll> vl; typedef vector<vector<ll>> vll; typedef pair<int, int> P; typedef vector<P> vp; typedef vector<vector<P>> vpp; typedef complex<ld> Point; const int MOD = 1e9 + 7; const int INF = 1e9; const int MAX_V = 1e5 + 5; const int MAX_N = 1e5 + 5; const double PI = acos(-1); template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } struct mint { // Preparation: MOD is alrejady defined. ll value; mint(ll value = 0) : value((value % MOD + MOD) % MOD) {} mint pow(ll t) const { if (!t) return 1; mint a = pow(t >> 1); a *= a; if (t & 1) a *= *this; return a; } mint pow(mint m) const { return pow(m.value); } mint inv() const { ll a = value, b = MOD, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= MOD; return u; } mint &operator+=(const mint a) { if ((value += a.value) >= MOD) value -= MOD; return *this; } mint &operator-=(const mint a) { if ((value += MOD - a.value) >= MOD) value -= MOD; return *this; } mint &operator*=(const mint a) { (value *= a.value) %= MOD; return *this; } mint &operator/=(const mint a) { return (*this) *= a.inv(); } mint operator+(const mint a) const { mint res(*this); return res += a; } mint operator-(const mint a) const { mint res(*this); return res -= a; } mint operator*(const mint a) const { mint res(*this); return res *= a; } mint operator/(const mint a) const { mint res(*this); return res /= a; } }; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } // make vector of divisor O(sqrt(n)) vector<long long> divisor(long long n) { vector<long long> res; for (long long i = 1; i * i <= n; i++) { if (n % i == 0) { res.push_back(i); if (i != n / i) res.push_back(n / i); } } return res; } bool is_prime(long long n) { for (long long i = 2; i * i <= n; i++) { if (n % i == 0) return false; } return n != 1; // exclude 1 } // factorization O(sqrt(n)) map<long long, long long> prime_factor(long long n) { map<long long, long long> res; for (long long i = 2; i * i <= n; i++) { while (n % i == 0) { ++res[i]; n /= i; } } if (n != 1) res[n] = 1; return res; } // https://qiita.com/drken/items/cce6fc5c579051e64fab // UnionFind<int> uf(n); template <class Abel> struct UnionFind { vector<int> par; vector<int> rank; vector<int> size; vector<Abel> diff_weight; UnionFind(int n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); } void init(int n = 1, Abel SUM_UNITY = 0) { par.resize(n); rank.resize(n); size.resize(n); diff_weight.resize(n); for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, size[i] = 1, diff_weight[i] = SUM_UNITY; } int root(int x) { if (par[x] == x) { return x; } else { int r = root(par[x]); diff_weight[x] += diff_weight[par[x]]; // path compression return par[x] = r; } } // returns size of connected-tree number int get_size(int x) { return size[root(x)]; } Abel weight(int x) { root(x); return diff_weight[x]; } bool is_same(int x, int y) { return root(x) == root(y); } bool merge(int x, int y, Abel w) { w += weight(x); w -= weight(y); x = root(x); y = root(y); if (x == y) return false; if (rank[x] < rank[y]) swap(x, y), w = -w; if (rank[x] == rank[y]) ++rank[x]; par[y] = x; size[x] = size[y] = size[x] + size[y]; diff_weight[y] = w; return true; } Abel diff(int x, int y) { return weight(y) - weight(x); } }; long long fac[MAX_N], finv[MAX_N], inv[MAX_N]; // テーブルを作る前処理 from: https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX_N; 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; } } // 二項係数計算 long long 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; } // factorial long long fact(int n) { if (n == 1) return fac[n] = 1; if (fac[n]) return fac[n]; return fac[n] = (fact(n - 1) * n) % MOD; } long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(long long a, long long b) { return a / gcd(a, b) * b; } long long modpow(long long m, long long p) { if (p == 0) return 1; if (p % 2) return m * modpow(m, p - 1) % MOD; else { long res = modpow(m, p / 2); return res * res % MOD; } } int main() { int n; cin >> n; vi a(n), b(n), c(n); vii graph(n); vii cost(n, vl(n)); rep(i, n - 1) { cin >> a[i] >> b[i] >> c[i]; a[i]--, b[i]--; graph[a[i]].push_back(b[i]); graph[b[i]].push_back(a[i]); cost[a[i]][b[i]] = c[i]; cost[b[i]][a[i]] = c[i]; } int q, k; cin >> q >> k; k--; vector<ll> dist(n, -1); queue<int> que; auto bfs = [&](int x) { dist[x] = 0; que.push(x); while (!que.empty()) { int v = que.front(); que.pop(); for (int nv : graph[v]) { if (dist[nv] != -1) continue; dist[nv] = dist[v] + cost[v][nv]; que.push(nv); } } }; bfs(k); rep(i, q) { int ta, tb; cin >> ta >> tb; ta--, tb--; out(dist[ta] + dist[tb]); } }
a.cc: In function 'int main()': a.cc:252:22: error: no matching function for call to 'std::vector<std::vector<int> >::vector(int&, vl)' 252 | vii cost(n, vl(n)); | ^ 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:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 707 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed: a.cc:252:22: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<long long int>') 252 | vii cost(n, vl(n)); | ^ /usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]' 678 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<std::vector<int> >' 678 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<std::vector<int> >&&' 659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m) | ~~~~~~~~~^~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::false_type = std::false_type]' 640 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >; std::true_type = std::true_type]' 635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; std::__type_identity_t<_Alloc> = std::allocator<std::vector<int> >]' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<std::vector<int> >&' 624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 620 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 601 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; value_type = std::vector<int>; allocator_type = std::allocator<std::vector<int> >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'vl' {aka 'std::vector<long long int>'} to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'} 569 | vector(size_type __n, const value_type& __value, | ~~~~~~~~~~~~~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<int> >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'vl' {aka 'std::vector<long long int>'} to 'const std::vector<std::vector<int> >::allocator_type&' {aka 'const std::allocator<std::vector<int> >&'} 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; allocator_type = std::allocator<std::vector<int> >]' 542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 531 | vector() = default; | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
s064571767
p03634
Java
import java.util.*; public class Main { static List<int[]>[] to; static long[] dist; static int n; public static void main(String[] args) throws Exception { // Your code here! Scanner sc = new Scanner(System.in); n = sc.nextInt(); // to: 隣接リスト(無向) to = new List[n]; for (int i = 0; i < n; i++) { to[i] = new ArrayList<long[]>(); } for (int i = 0; i < n - 1; i++) { int p = sc.nextInt() - 1; int q = sc.nextInt() - 1; int dis = sc.nextInt(); to[p].add(new int[]{q, dis}); to[q].add(new int[]{p, dis}); } // 点kから各点までの距離を計算 int query = sc.nextInt(); int k = sc.nextInt() - 1; long[] distK = calcDist(k); // p→k→qの最短距離を出力 while (query-- > 0) { int p = sc.nextInt() - 1; int q = sc.nextInt() - 1; System.out.println(distK[p] + distK[q]); } } public static long[] calcDist(int p) { dist = new long[n]; dfs(p, 0, -1); return dist; } // 頂点pと隣接する点に自分の値+距離を配る public static void dfs(int p, long d, int par) { dist[p] = d; for (int[] q : to[p]) { if (q[0] == par) continue; dfs(q[0], d + q[1], p); } } }
Main.java:16: error: incompatible types: ArrayList<long[]> cannot be converted to List<int[]> to[i] = new ArrayList<long[]>(); ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s780792314
p03634
C++
vector<int> dist; void dfs( int now, int ago, int depth ){ dist[now] = depth; for( int i = 0; i < G[now].size(); i++ ){ int next = G[now][i].to; if( next == ago ) continue; dfs( next, now, depth + G[now][i].cost ); } } int main(){ cin >> N; G.resize(N); dist.resize(N, -1); for(int i = 1; i < N; i++){ int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b; G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c}); } int Q; cin >> Q; cin >> K; --K; dfs(K, -1, 0); for( int i = 0; i < Q; i++ ){ int x, y; scanf("%d%d", &x, &y); --x; --y; cout << dist[x] + dist[y] << '\n'; } }
a.cc:2:1: error: 'vector' does not name a type 2 | vector<int> dist; | ^~~~~~ a.cc: In function 'void dfs(int, int, int)': a.cc:5:3: error: 'dist' was not declared in this scope 5 | dist[now] = depth; | ^~~~ a.cc:6:23: error: 'G' was not declared in this scope 6 | for( int i = 0; i < G[now].size(); i++ ){ | ^ a.cc: In function 'int main()': a.cc:14:3: error: 'cin' was not declared in this scope 14 | cin >> N; | ^~~ a.cc:14:10: error: 'N' was not declared in this scope 14 | cin >> N; | ^ a.cc:15:3: error: 'G' was not declared in this scope 15 | G.resize(N); dist.resize(N, -1); | ^ a.cc:15:16: error: 'dist' was not declared in this scope 15 | G.resize(N); dist.resize(N, -1); | ^~~~ a.cc:17:18: error: 'scanf' was not declared in this scope 17 | int a, b, c; scanf("%d%d%d", &a, &b, &c); --a; --b; | ^~~~~ a.cc:18:20: error: 'edge' was not declared in this scope 18 | G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c}); | ^~~~ a.cc:18:52: error: expected ')' before '{' token 18 | G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c}); | ~ ^ | ) a.cc:21:10: error: 'K' was not declared in this scope 21 | cin >> K; --K; | ^ a.cc:24:15: error: 'scanf' was not declared in this scope 24 | int x, y; scanf("%d%d", &x, &y); --x; --y; | ^~~~~ a.cc:25:5: error: 'cout' was not declared in this scope 25 | cout << dist[x] + dist[y] << '\n'; | ^~~~
s827647261
p03634
C++
#include<bits/stdc++.h> using namespace std; using lint = long long; vector<lint> dist; const lint INF = 1e18; struct edge{lint to, cost;}; vector<edge> G[100010]; void dfs(lint now, lint ago, lint depth){ dist[now] = depth; for(lint i = 0; i < G[now].size(); i++){ lint next = G[now][i].to; if(next == ago) continue; dfs(next, now, depth + G[now][i].cost); } } signed main(){ lint N; cin >> N; for(lint i = 1; i < N; i++){ lint a, b, c; scanf("%d%d", &a, &b, &c) --a; --b; G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c}); } dist.resize(N, 0); lint Q, K; cin >> Q >> K; dfs(K - 1, -1, 0); for(lint i = 0; i < Q; i++){ lint x, y; scanf("%d%d", &x, &y); lint ans = dist[x - 1] + dist[y - 1]; cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:22:24: error: lvalue required as decrement operand 22 | lint a, b, c; scanf("%d%d", &a, &b, &c) --a; --b; | ~~~~~^~~~~~~~~~~~~~~~~~~~
s823129385
p03634
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1LL<<62 #define inf 1000000007 ll n,q,k,dx[100010]; vector<pair<ll,ll>>a[100010]; void dep(ll now){ if(now!=k&&a[now].size()==1){ return ; } for(ll i=0;i<a[i].size();i++){ ll next=a[i].first; } } int main() { cin>>n; for(ll i=0;i<n-1;i++){ ll x,y,c; cin>>x>>y>>c; x--;y--; a[x].push_back(make_pair(y,c)); a[y].push_back(make_pair(x,c)); } cin>>q>>k; k--; dep(k); // your code goes here return 0; }
a.cc: In function 'void dep(ll)': a.cc:13:30: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'first' 13 | ll next=a[i].first; | ^~~~~
s573377970
p03634
C++
import java.util.ArrayList; import java.util.BitSet; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; public class Main { static final long INF = 10000000000000000L; static int n; static List<Node>[] Edge; public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = Integer.parseInt(sc.next()); Edge = new ArrayList[n]; for(int i = 0 ;i < n ;i++) { Edge[i] = new ArrayList<>(); } for(int i = 0 ;i < n-1 ;i++) { int a = Integer.parseInt(sc.next()); int b = Integer.parseInt(sc.next()); int cost = Integer.parseInt(sc.next()); Edge[a-1].add(new Node(b-1,cost)); Edge[b-1].add(new Node(a-1,cost)); } int q = Integer.parseInt(sc.next()); int k = Integer.parseInt(sc.next()); long []d = dijkstra(k-1); for(int i = 0 ; i < q ;i++) { int x = Integer.parseInt(sc.next())-1; int y = Integer.parseInt(sc.next())-1; long ans = d[x] + d[y]; System.out.println(ans); } } static long[] dijkstra(int s){ Queue <Pos> que = new PriorityQueue<Pos>(); long[]d = new long [n]; //頂点sからの距離 for(int i = 0 ; i < n ;i++) { d[i] = INF; } BitSet used = new BitSet(n); que.add(new Pos(0,s)); //初期値を代入、自身の距離は0 d[s] = 0 ; while(!que.isEmpty()) { Pos p = que.poll(); // int v = p.getTo(); if(used.get(p.getTo())) { continue; } used.set(p.getTo()); for(Node e : Edge[v]) { if(d[e.getTo()] > d[v] + e.getCost()) { d[e.getTo()] = (long)( d[v] + e.getCost()); que.add(new Pos(d[e.getTo()],e.getTo())); } } } return d; } } class Pos implements Comparable<Pos>{ private long cost; private int to; public Pos (long cost, int to) { this.cost = cost; this.to = to; } public long getCost() { return cost; } public int getTo() { return to; } public void setCost(long cost) { this.cost = cost; } public void setTo(int to) { this.to = to; } @Override public int compareTo(Pos o) { return Long.compare(cost, o.cost); } } class Node{ private int to; private int cost; public Node(int to, int cost) { this.to = to; this.cost = cost; } public int getTo() { return to; } public int getCost() { return cost; } public void setTo(int to) { this.to = to; } public void setCost(int cost) { this.cost = cost; } }
a.cc:106:1: error: stray '@' in program 106 | @Override | ^ a.cc:2:1: error: 'import' does not name a type 2 | import java.util.ArrayList; | ^~~~~~ 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.BitSet; | ^~~~~~ 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.List; | ^~~~~~ 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.PriorityQueue; | ^~~~~~ 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.Queue; | ^~~~~~ 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.Scanner; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: expected unqualified-id before 'public' 9 | public class Main { | ^~~~~~ a.cc:80:22: error: expected initializer before 'Comparable' 80 | class Pos implements Comparable<Pos>{ | ^~~~~~~~~~ a.cc:113:8: error: expected ':' before 'int' 113 | private int to; | ^~~~ | : a.cc:114:8: error: expected ':' before 'int' 114 | private int cost; | ^~~~ | : a.cc:116:7: error: expected ':' before 'Node' 116 | public Node(int to, int cost) { | ^~~~~ | : a.cc:121:7: error: expected ':' before 'int' 121 | public int getTo() { | ^~~~ | : a.cc:125:7: error: expected ':' before 'int' 125 | public int getCost() { | ^~~~ | : a.cc:129:7: error: expected ':' before 'void' 129 | public void setTo(int to) { | ^~~~~ | : a.cc:133:7: error: expected ':' before 'void' 133 | public void setCost(int cost) { | ^~~~~ | : a.cc:136:2: error: expected ';' after class definition 136 | } | ^ | ; a.cc: In constructor 'Node::Node(int, int)': a.cc:117:14: error: request for member 'to' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?) 117 | this.to = to; | ^~ a.cc:118:14: error: request for member 'cost' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?) 118 | this.cost = cost; | ^~~~ a.cc: In member function 'void Node::setTo(int)': a.cc:130:14: error: request for member 'to' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?) 130 | this.to = to; | ^~ a.cc: In member function 'void Node::setCost(int)': a.cc:134:14: error: request for member 'cost' in '(Node*)this', which is of pointer type 'Node*' (maybe you meant to use '->' ?) 134 | this.cost = cost; | ^~~~
s402135006
p03634
C++
#include <iostream> #include <vector> using namespace std; using Edge = pair<int, long long>; using Graph = vector<vector<Edge> >; void dfs(const Graph &G, int v, int p, long long sum, vector<long long> &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(){ int N; cin >> N; Graph G(N); for(int i=0; i<N-1; i++){ int a, b; long long c; 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; vector<long long> dist(N, 0); rec(G, K, -1, 0, dist); for(int i=0; i<Q; i++){ int x, y; cin >> x >> y; --x, --y; cout << dist[x] + dist[y] <<endl; } }
a.cc: In function 'void dfs(const Graph&, int, int, long long int, std::vector<long long int>&)': a.cc:12:5: error: 'rec' was not declared in this scope 12 | rec(G, e.first, v, sum+e.second, dist); | ^~~ a.cc: In function 'int main()': a.cc:29:3: error: 'rec' was not declared in this scope 29 | rec(G, K, -1, 0, dist); | ^~~
s766653316
p03634
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define sz(x) int(x.size()) using namespace std; typedef long long ll; // const int INF = 1e8; const ll INF = 1LL << 60; typedef pair<int, int> P; struct edge { ll to, cost; }; ll N; vector<vector<edge>> G; ll dp[100100]; void dfs(ll v, ll par = -1) { for (ll i = 0; i < G[v].size(); i++) { ll next = G[v][i].to, next_cost = G[v][i].cost; if (next != par) { dp[next] = dp[v] + next_cost; dfs(next, v, d + next_cost); } } } int main() { cin >> N; G.resize(N); rep(i, N - 1) { ll a, b, c; cin >> a >> b >> c; a--; b--; G[a].push_back({b, c}); G[b].push_back({a, c}); } ll Q, K; cin >> Q >> K; K--; dfs(K); // rep(i, N) { // cout << i << " " << dp[i] << endl; // } // return 0; // x -> K -> y の最短路 rep(i, Q) { ll x, y; cin >> x >> y; x--; y--; cout << dp[x] + dp[y] << endl; } }
a.cc: In function 'void dfs(ll, ll)': a.cc:23:26: error: 'd' was not declared in this scope 23 | dfs(next, v, d + next_cost); | ^
s943662610
p03634
C++
#include <iostream> #include <vector> #include <queue> using namespace std; static const int64_t INF = numeric_limits<int>::max(); int main() { int64_t N, Q, K; cin >> N; vector<vector<int64_t>> cost(N, vector<int64_t>(N, INF)); for (int64_t i = 0, a, b, c; i < N - 1; i++) { cin >> a >> b >> c; cost[a - 1][b - 1] = cost[b - 1][a - 1] = c; } cin >> Q >> K; vector<bool> visited(N, false); vector<int64_t> dis(N, 0); queue<int64_t> q; visited[K - 1] = true; q.push(K - 1); while (!q.empty()) { int64_t t = q.front(); q.pop(); visited[t] = true; for (int64_t i = 0; i < N; i++) { if (cost[t][i] == INF || visited[i]) continue; q.push(i); dis[i] = dis[t] + cost[t][i]; } } for (int64_t i = 0, x, y; i < Q; i++) { cin >> x >> y; cout << dis[x - 1] + dis[y - 1] << endl; } }
a.cc:5:28: error: 'numeric_limits' was not declared in this scope 5 | static const int64_t INF = numeric_limits<int>::max(); | ^~~~~~~~~~~~~~ a.cc:5:43: error: expected primary-expression before 'int' 5 | static const int64_t INF = numeric_limits<int>::max(); | ^~~
s642396520
p03634
C++
#include <cstdio> #include<iostream> #include<map> #include<algorithm> #include<vector> #include <cmath> #include <iomanip> #include <regex> using namespace std; using ll = long long; vector<vector<pair<ll,ll>>> v(N); vector<ll> dist(N); void dfs(ll cur, ll par,ll point=0){ dist[cur] = point; // cout<<"cur:"<<cur<<", par:"<<par<<endl; for(ll i=0;i<v[cur].size();i++){ ll next = v[cur][i].first; ll next_point = v[cur][i].second+point; // cout<<"next:"<<next<<endl; if(next!=par){ dfs(next,cur,next_point); } } return; } int main(){ long N; cin>>N; for(ll i=0;i<N-1;i++){ ll a,b,c; cin>>a>>b>>c; a--;b--; v[a].push_back(make_pair(b,c)); v[b].push_back(make_pair(a,c)); } ll Q,K; cin>>Q>>K; K--; ll x[Q],y[Q]; for(ll i=0;i<Q;i++){ ll _x,_y; cin>>_x>>_y; _x--;_y--; x[i] = _x; y[i] = _y; } dfs(K,-1); for(ll i=0;i<Q;i++){ cout<<dist[x[i]]+dist[y[i]]<<"\n"; } }
a.cc:11:31: error: 'N' was not declared in this scope 11 | vector<vector<pair<ll,ll>>> v(N); | ^ a.cc:12:17: error: 'N' was not declared in this scope 12 | vector<ll> dist(N); | ^
s442790911
p03634
C++
#include <cstdio> #include<iostream> #include<map> #include<algorithm> #include<vector> #include <cmath> #include <iomanip> #include <regex> using namespace std; using ll = long long; vector<vector<pair<ll,ll>>> v; vector<ll> dist; void dfs(ll cur, ll par,ll point=0){ dist[cur] = point; // cout<<"cur:"<<cur<<", par:"<<par<<endl; for(ll i=0;i<v[cur].size();i++){ ll next = v[cur][i].first; ll next_point = v[cur][i].second+point; // cout<<"next:"<<next<<endl; if(next!=par){ dfs(next,cur,next_point); } } return; } int main(){ long N; cin>>N; v(N); dist(N); for(ll i=0;i<N-1;i++){ ll a,b,c; cin>>a>>b>>c; a--;b--; v[a].push_back(make_pair(b,c)); v[b].push_back(make_pair(a,c)); } ll Q,K; cin>>Q>>K; K--; ll x[Q],y[Q]; for(ll i=0;i<Q;i++){ ll _x,_y; cin>>_x>>_y; _x--;_y--; x[i] = _x; y[i] = _y; } dfs(K,-1); for(ll i=0;i<Q;i++){ cout<<dist[x[i]]+dist[y[i]]<<"\n"; } }
a.cc: In function 'int main()': a.cc:30:6: error: no match for call to '(std::vector<std::vector<std::pair<long long int, long long int> > >) (long int&)' 30 | v(N); | ~^~~ a.cc:31:9: error: no match for call to '(std::vector<long long int>) (long int&)' 31 | dist(N); | ~~~~^~~
s050854564
p03634
C++
d[e.to] = d[v] + e.cost;
a.cc:1:17: error: 'd' does not name a type 1 | d[e.to] = d[v] + e.cost; | ^
s429766815
p03634
C++
#include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> #include <iostream> #include <string> #include <cmath> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORR(i,a,b)for(ll i=(a);i<=(b);i++) #define repR(i,n) for(ll i=n;i>=0;i--) #define all(v)(v).begin(),(v).end() #define rall(v)(v).rbegin(),(v).rend() #define F first #define S second #define pb push_back #define pu push #define COUT(x) cout<<(x)<<endl #define PQ priority_queue<ll> #define PQR priority_queue<ll,vector<ll>,greater<ll>> #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define mp make_pair #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define sz(x) (int)(x).size() typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MOD = 1000000007LL; const ll INF = 1LL << 60; using vll = vector<ll>; using vb = vector<bool>; using vvb = vector<vb>; using vvll = vector<vll>; using vstr = vector<string>; using pll = pair<ll, ll>; using vc = vector<char>; using vvc = vector<vc>; ll dx[4]={0,1,0,-1}; ll dy[4]={1,0,-1,0}; struct edge{ ll to,cost;}; int main(){ ll n; cin>>n; vector<vector<edge>> e(n,vector<edge>(0)); rep(i,n-1){ ll a,b,c; cin>>a>>b>>c; a--; b--; edge k; k.to=b; k.cost=c; e[a].pb(k); k.to=a; e[b].pb(k); } ll q,k; cin>>q>>k; vll l(n,INF); queue<ll> que; k--; l[k]=0; que.pu(k); while(sz(que)){ ll h=que.front(); que.pop(); for(auto y:e[h]){ if(l[y.F]!=INF) continue; l[y.F]=y.S+l[h]; que.pu(y.F); } } rep(i,q){ ll a,b; cin>>a>>b; a--; b--; COUT(l[a]+l[b]); } }
a.cc: In function 'int main()': a.cc:15:11: error: 'struct edge' has no member named 'first' 15 | #define F first | ^~~~~ a.cc:70:14: note: in expansion of macro 'F' 70 | if(l[y.F]!=INF) continue; | ^ a.cc:15:11: error: 'struct edge' has no member named 'first' 15 | #define F first | ^~~~~ a.cc:71:11: note: in expansion of macro 'F' 71 | l[y.F]=y.S+l[h]; | ^ a.cc:16:11: error: 'struct edge' has no member named 'second' 16 | #define S second | ^~~~~~ a.cc:71:16: note: in expansion of macro 'S' 71 | l[y.F]=y.S+l[h]; | ^ a.cc:15:11: error: 'struct edge' has no member named 'first' 15 | #define F first | ^~~~~ a.cc:72:16: note: in expansion of macro 'F' 72 | que.pu(y.F); | ^
s717001894
p03634
C++
#include<bits/stdc++.h> #include<unordered_set> #include<unordered_map> #include <iostream> #include <string> #include <cmath> using namespace std; #define ll long long #define rep(i, n) for (ll i = 0; i < (n); i++) #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define FORR(i,a,b)for(ll i=(a);i<=(b);i++) #define repR(i,n) for(ll i=n;i>=0;i--) #define all(v)(v).begin(),(v).end() #define rall(v)(v).rbegin(),(v).rend() #define F first #define S second #define pb push_back #define pu push #define COUT(x) cout<<(x)<<endl #define PQ priority_queue<ll> #define PQR priority_queue<ll,vector<ll>,greater<ll>> #define YES(n) cout << ((n) ? "YES" : "NO" ) << endl #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define mp make_pair #define maxs(x,y) (x = max(x,y)) #define mins(x,y) (x = min(x,y)) #define sz(x) (int)(x).size() typedef pair<int,int> pii; typedef pair<ll,ll> pll; const ll MOD = 1000000007LL; const ll INF = 1LL << 60; using vll = vector<ll>; using vb = vector<bool>; using vvb = vector<vb>; using vvll = vector<vll>; using vstr = vector<string>; using pll = pair<ll, ll>; using vc = vector<char>; using vvc = vector<vc>; ll dx[4]={0,1,0,-1}; ll dy[4]={1,0,-1,0}; struck edge{ ll to,cost;}; int main(){ ll n; cin>>n; vector<vector<edge>> e(n,vector<edge>(0)); rep(i,n-1){ ll a,b,c; cin>>a>>b>>c; a--; b--; edge k; k.to=b; k.cost=c; e[a].pb(k); k.to=a; e[b].pb(k); } ll q,k; cin>>q>>k; vll l(n,INF); queue<ll> que; k--; l[k]=0; que.pu(k); while(sz(que)){ ll h=que.front(); que.pop(); for(auto y:e[h]){ if(l[y.F]!=INF) continue; l[y.F]=y.S+l[h]; que.pu(y.F); } } rep(i,q){ ll a,b; cin>>a>>b; a--; b--; COUT(l[a]+l[b]); } }
a.cc:42:1: error: 'struck' does not name a type; did you mean 'struct'? 42 | struck edge{ ll to,cost;}; | ^~~~~~ | struct a.cc: In function 'int main()': a.cc:46:17: error: 'edge' was not declared in this scope 46 | vector<vector<edge>> e(n,vector<edge>(0)); | ^~~~ a.cc:46:17: error: template argument 1 is invalid a.cc:46:17: error: template argument 2 is invalid a.cc:46:21: error: template argument 1 is invalid 46 | vector<vector<edge>> e(n,vector<edge>(0)); | ^~ a.cc:46:21: error: template argument 2 is invalid a.cc:46:39: error: template argument 2 is invalid 46 | vector<vector<edge>> e(n,vector<edge>(0)); | ^ a.cc:46:43: error: expression list treated as compound expression in initializer [-fpermissive] 46 | vector<vector<edge>> e(n,vector<edge>(0)); | ^ a.cc:52:9: error: expected ';' before 'k' 52 | edge k; | ^~ | ; a.cc:53:5: error: 'k' was not declared in this scope 53 | k.to=b; | ^ a.cc:55:6: error: invalid types 'int[long long int]' for array subscript 55 | e[a].pb(k); | ^ a.cc:57:6: error: invalid types 'int[long long int]' for array subscript 57 | e[b].pb(k); | ^ a.cc:69:17: error: invalid types 'int[long long int]' for array subscript 69 | for(auto y:e[h]){ | ^
s392647925
p03634
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; #define all(x) (x).begin(), (x).end() ll inf = LLONG_MAX; long double pi = M_PI; void Yes() {cout << "Yes" << endl;} void No() {cout << "No" << endl;} void YES() {cout << "YES" << endl;} void NO() {cout << "NO" << endl;} //幅優先探索 //全て添字で扱うこと vll bfs(ll n, vector<vector<vll>> &next, ll start) { vll ans(n, 0); queue<vll> task; task.push({0, start}); vll seen(n, 0); seen[start] = 1; ll depth = 0; while (task.size() > 0) { for (ll j = 0; j < next[task.front()[1]].size(); j++) { if (seen[next[task.front()[1]][j][1]] == 0) { ans[next[task.front()[1]][j][1]] = ans[task.front()[1]] + next[task.front()[1]][j][0]; task.push(next[task.front()[1]][j]); seen[next[task.front()[1]][j][1]] = 1; } } task.pop(); } } return ans } int main() { ll n; cin >> n; vector<vector<vll>> next(n, vector<vll>(0)); for (ll i = 0; i < n - 1; i++) { ll a, b, c; cin >> a >> b >> c; next[a - 1].push_back({c, b - 1}); next[b - 1].push_back({c, a - 1}); } ll q, k; cin >> q >> k; vll ans = bfs(n, next, k - 1); for (ll i = 0; i < q; i++) { ll x, y; cin >> x >> y; cout << ans[x - 1] + ans[y - 1] << endl; } }
a.cc: In function 'vll bfs(ll, std::vector<std::vector<std::vector<long long int> > >&, ll)': a.cc:36:3: warning: no return statement in function returning non-void [-Wreturn-type] 36 | } | ^ a.cc: At global scope: a.cc:37:3: error: expected unqualified-id before 'return' 37 | return ans | ^~~~~~ a.cc:38:1: error: expected declaration before '}' token 38 | } | ^
s063201160
p03634
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<ll> vll; #define all(x) (x).begin(), (x).end() ll inf = LLONG_MAX; long double pi = M_PI; void Yes() {cout << "Yes" << endl;} void No() {cout << "No" << endl;} void YES() {cout << "YES" << endl;} void NO() {cout << "NO" << endl;} //幅優先探索 //全て添字で扱うこと vll bfs(ll n, vector<vector<vll>> &next, ll start) { vll ans(n, 0); queue<vll> task; task.push({0, start}); vll seen(n, 0); seen[start] = 1; ll depth = 0; while (task.size() > 0) { for (ll j = 0; j < next[task.front()[1]].size(); j++) { if (seen[next[task.front()[1]][j][1]] == 0) { ans[next[task.front()[1]][j][1]] = ans[task.front()[1]] + next[task.front()[1]][j][0]; task.push(next[task.front()[1]][j]); seen[next[task.front()[1]][j][1]] = 1; } } task.pop(); } } return; ans } int main() { ll n; cin >> n; vector<vector<vll>> next(n, vector<vll>(0)); for (ll i = 0; i < n - 1; i++) { ll a, b, c; cin >> a >> b >> c; next[a - 1].push_back({c, b - 1}); next[b - 1].push_back({c, a - 1}); } ll q, k; cin >> q >> k; vll ans = bfs(n, next, k - 1); for (ll i = 0; i < q; i++) { ll x, y; cin >> x >> y; cout << ans[x - 1] + ans[y - 1] << endl; } }
a.cc: In function 'vll bfs(ll, std::vector<std::vector<std::vector<long long int> > >&, ll)': a.cc:36:3: warning: no return statement in function returning non-void [-Wreturn-type] 36 | } | ^ a.cc: At global scope: a.cc:37:3: error: expected unqualified-id before 'return' 37 | return; ans | ^~~~~~ a.cc:37:11: error: 'ans' does not name a type 37 | return; ans | ^~~ a.cc:38:1: error: expected declaration before '}' token 38 | } | ^
s851666838
p03634
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll MOD = 1000000007; const ll INF = 9999999999; template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;} template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;} template<class T> inline T powerM(T a,T b){if (b==0) return 1; T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; } int N,Q,K; vector<vector<pair<int,int>>> G; // グラフ vector<ll> Dis; // 頂点Kからの距離 vector<bool> seen; void dfs(int v){ seen.at(v) = true; for (auto p : G.at(v)){ auto nv = p.first; auto distance = p.second; if (seen.at(nv)) continue; // 既に訪れていればスキップ Dis.at(nv) = Dis.at(v) + distance; dfs(nv); } } int main() { cin >>N; G.assign(N, vector<int>()); rep(i,N-1){ int a,b,c; cin >>a >>b >>c; a--; b--; G.at(a).push_back(make_pair(b,c)); G.at(b).push_back(make_pair(a,c)); } cin >>Q >>K; seen.assign(N, false); Dis.assign(N, -1); K--; Dis.at(K) = 0; dfs(K); rep(i, Q){ int a,b; cin >>a >>b; a--; b--; cout <<Dis.at(a) + Dis.at(b) <<endl; } }
a.cc: In function 'int main()': a.cc:32:11: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::assign(int&, std::vector<int>)' 32 | G.assign(N, vector<int>()); | ~~~~~~~~^~~~~~~~~~~~~~~~~~ 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:828:9: note: candidate: 'template<class _InputIterator, class> void std::vector<_Tp, _Alloc>::assign(_InputIterator, _InputIterator) [with <template-parameter-2-2> = _InputIterator; _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]' 828 | assign(_InputIterator __first, _InputIterator __last) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:828:9: note: template argument deduction/substitution failed: a.cc:32:11: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>') 32 | G.assign(N, vector<int>()); | ~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:808:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(size_type, const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; size_type = long unsigned int; value_type = std::vector<std::pair<int, int> >]' 808 | assign(size_type __n, const value_type& __val) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:808:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<std::vector<std::pair<int, int> > >::value_type&' {aka 'const std::vector<std::pair<int, int> >&'} 808 | assign(size_type __n, const value_type& __val) | ~~~~~~~~~~~~~~~~~~^~~~~ /usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate: 'void std::vector<_Tp, _Alloc>::assign(std::initializer_list<_Tp>) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >]' 855 | assign(initializer_list<value_type> __l) | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:855:7: note: candidate expects 1 argument, 2 provided
s979949879
p03634
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i=0; i<(int)(n); i++) #define all(v) v.begin(), v.end() using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll MOD = 1000000007; const ll INF = 9999999999; template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;} template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;} template<class T> inline T powerM(T a,T b){if (b==0) return 1; T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; } int N,Q,K; vector<vector<pair<int>>> G; // グラフ vector<ll> Dis; // 頂点Kからの距離 vector<bool> seen; void dfs(int v){ seen.at(v) = true; for (auto p : G.at(v)){ auto nv = p.first; auto distance = p.second; if (seen.at(nv)) continue; // 既に訪れていればスキップ Dis.at(nv) = Dis.at(v) + distance; dfs(nv); } } int main() { cin >>N; G.assign(N, vector<int>()); rep(i,N-1){ int a,b,c; cin >>a >>b >>c; a--; b--; G.at(a).push_back(make_pair(b,c)); G.at(b).push_back(make_pair(a,c)); } cin >>Q >>K; seen.assign(N, false); Dis.assign(N, -1); K--; Dis.at(K) = 0; dfs(K); rep(i, Q){ int a,b; cin >>a >>b; a--; b--; cout <<Dis.at(a) + Dis.at(b) <<endl; } }
a.cc:15:20: error: wrong number of template arguments (1, should be 2) 15 | vector<vector<pair<int>>> G; // グラフ | ^~~ 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, from a.cc:1: /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:15:23: error: template argument 1 is invalid 15 | vector<vector<pair<int>>> G; // グラフ | ^~ a.cc:15:23: error: template argument 2 is invalid a.cc:15:25: error: template argument 1 is invalid 15 | vector<vector<pair<int>>> G; // グラフ | ^ a.cc:15:25: error: template argument 2 is invalid a.cc: In function 'void dfs(int)': a.cc:21:19: error: request for member 'at' in 'G', which is of non-class type 'int' 21 | for (auto p : G.at(v)){ | ^~ a.cc: In function 'int main()': a.cc:32:5: error: request for member 'assign' in 'G', which is of non-class type 'int' 32 | G.assign(N, vector<int>()); | ^~~~~~ a.cc:36:7: error: request for member 'at' in 'G', which is of non-class type 'int' 36 | G.at(a).push_back(make_pair(b,c)); | ^~ a.cc:37:7: error: request for member 'at' in 'G', which is of non-class type 'int' 37 | G.at(b).push_back(make_pair(a,c)); | ^~
s177747793
p03634
Java
import java.util.*; public class Main { private static final long INF = 1_000_000_000_000_000_000L; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); List<List<Dst>> from = new ArrayList<>(); for (int i = 0; i < N; i++) { from.add(new ArrayList<>()); } for (int i = 0; i < N-1; i++) { int a = sc.nextInt(); int b = sc.nextInt(); a--; b--; int c = sc.nextInt(); from.get(a).add(new Dst(b,c)); from.get(b).add(new Dst(a,c)); } int Q = sc.nextInt(); int K = sc.nextInt(); K--; PriorityQueue<Dst> pq = new PriorityQueue<>((a,b)->{ if (a.cost == b.cost) { return 0; } return a.cost > b.cost ? 1 : -1; }); long[] cost = new long[N]; Arrays.fill(cost, INF); pq.offer(new Dst(K,0)); while (!pq.isEmpty()) { now = pq.poll(); if (cost[now.to] <= 0) continue; cost[now.to] = -now.cost; for (Dst p : from.get(now.to)) { long newCost = now.cost+p.cost; if (cost[p.to] > 0 && newCost < cost[p.to]) { cost[p.to] = newCost; pq.offer(new Dst(p.to,newCost)); } } } StringBuilder ans = new StringBuilder(); for (int i = 0; i < Q; i++) { int x = sc.nextInt(); int y = sc.nextInt(); x--; y--; ans.append(-(cost[x]+cost[y])).append('\n'); } System.out.print(ans.toString()); } private static class Dst { private final int to; private final long cost; Dst(int to, long cost) { this.to = to; this.cost = cost; } } }
Main.java:37: error: cannot find symbol now = pq.poll(); ^ symbol: variable now location: class Main Main.java:38: error: cannot find symbol if (cost[now.to] <= 0) continue; ^ symbol: variable now location: class Main Main.java:39: error: cannot find symbol cost[now.to] = -now.cost; ^ symbol: variable now location: class Main Main.java:39: error: cannot find symbol cost[now.to] = -now.cost; ^ symbol: variable now location: class Main Main.java:41: error: cannot find symbol for (Dst p : from.get(now.to)) { ^ symbol: variable now location: class Main Main.java:42: error: cannot find symbol long newCost = now.cost+p.cost; ^ symbol: variable now location: class Main 6 errors