submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s705029805
p04031
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N; cin>>N; int a[N]; int cost[200]={0}; for(int i=0;i<N;i++)cin>>a[N]; for(int i=-100;i<=100;i++){ for(int j=0;j<N;j++)cost[i+100]+=(a[j]-i)*(a[j]-i); } cout<<min_element(cost[0],cost[199])<<endl; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]': /usr/include/c++/14/bits/stl_algo.h:5562:12: required from 'constexpr _ForwardIterator std::__min_element(_ForwardIterator, _ForwardIterator, _Compare) [with _ForwardIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 5562 | if (__comp(__first, __result)) | ~~~~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5586:43: required from 'constexpr _FIter std::min_element(_FIter, _FIter) [with _FIter = int]' 5586 | return _GLIBCXX_STD_A::__min_element(__first, __last, | ^ a.cc:13:20: required from here 13 | cout<<min_element(cost[0],cost[199])<<endl; | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:16: error: invalid type argument of unary '*' (have 'int') 45 | { return *__it1 < *__it2; } | ^~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:25: error: invalid type argument of unary '*' (have 'int') 45 | { return *__it1 < *__it2; } | ^~~~~~
s178379815
p04031
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N; cin>>N; int a[N]; int cost[200]={0}; for(int i=0;i<N;i++)cin>>a[N]; for(int i=-100;i<=100;i++){ for(int j=0;j<N;j++)cost[i+100]+=(a[j]-i)*(a[j]-i); } cout<<min_element(cost.begin(),cost.end())<<endl; }
a.cc: In function 'int main()': a.cc:13:26: error: request for member 'begin' in 'cost', which is of non-class type 'int [200]' 13 | cout<<min_element(cost.begin(),cost.end())<<endl; | ^~~~~ a.cc:13:39: error: request for member 'end' in 'cost', which is of non-class type 'int [200]' 13 | cout<<min_element(cost.begin(),cost.end())<<endl; | ^~~
s607833363
p04031
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N; cin>>N; int a[N]; int cost[200]={0}; for(int i=0;i<N;i++)cin>>a[N]; for(int i=-100;i<=100;i++){ for(int j=0;j<N;j++)cost[i+100]+=(a[j]-i)*(a[j]-i); } cout<<cost.min()<<endl; }
a.cc: In function 'int main()': a.cc:13:14: error: request for member 'min' in 'cost', which is of non-class type 'int [200]' 13 | cout<<cost.min()<<endl; | ^~~
s372472771
p04031
C++
#include<iostream> #include<algorithm> using namespace std; int main(){ int N; cin>>N; int a[N]; int cost[200]={0}; for(int i=0;i<N;i++)cin>>a[N]; for(int i=-100;i<=100;i++){ for(int j=0;j<N;j++)cost+=(a[j]-i)*(a[j]-i); } cout<<cost.min()<<endl; }
a.cc: In function 'int main()': a.cc:11:29: error: incompatible types in assignment of 'int' to 'int [200]' 11 | for(int j=0;j<N;j++)cost+=(a[j]-i)*(a[j]-i); | ~~~~^~~~~~~~~~~~~~~~~~~ a.cc:13:14: error: request for member 'min' in 'cost', which is of non-class type 'int [200]' 13 | cout<<cost.min()<<endl; | ^~~
s399097892
p04031
Java
public class Main { public static void main(String[] args) { Scanner stdin =new Scanner(System.in); int n=stdin.nextInt(); int a[]=new int [n]; int i; for(i=0;i<n;i++){ a[i]=stdin.nextInt(); } int max=-300,min=300; for(i=0;i<n;i++){ if(max<a[i]) max=a[i]; if(min>a[i]) min=a[i]; } int min2=Integer.MAX_VALUE; int p=0; for(i=min;i<=max;i++){ p=0; for(int j=0;j<n;j++) p+=(a[j]-i)*(a[j]-i); if(p<min2) min2=p; } System.out.println(min2); } }
Main.java:3: error: cannot find symbol Scanner stdin =new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner stdin =new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s974523257
p04031
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<ll, int> P; #define MOD (1000000007ll) ll sq(ll x){ return x*x; } int main(void){ int n,i; ll a[123],tmp,ans=INFLL,mx=-INFLL,mn=INFLL,j; cin >> n; for(i=0; i<n; ++i){ cin >> a[i]; mn = min(mn,a[i]); mx = max(mx,a[i]); } for(j=min; j<max; ++j){ tmp = 0ll; for(i=0; i<n; ++i){ tmp += sq(a[i]-j); } ans = min(tmp,ans); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:15: error: cannot resolve overloaded function 'min' based on conversion to type 'll' {aka 'long long int'} 22 | for(j=min; j<max; ++j){ | ^~~ a.cc:22:21: error: invalid operands of types 'll' {aka 'long long int'} and '<unresolved overloaded function type>' to binary 'operator<' 22 | for(j=min; j<max; ++j){ | ~^~~~
s070444518
p04031
C++
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <vector> #define size_t int using namespace std; typedef unsigned long ul; typedef unsigned long long ull; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; std::cin >> n; vector<int> a(n,0); for (size_t i = 0; i < n; i++) { std::cin >> a[i]; } int c = accumulate(a.begin(),a.end(), 0); int c2 = 0; for (size_t i = 0; i < n; i++) { /* code */ c2 += a[i]*a[i]; } int alpha = c / n; int beta = alpha + 1; int ans = min(c2 - 2 * alpha * c + n * alpha * alpha,c2 - 2 * beta * c + n * beta * beta); std::cout << ans << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:26:11: error: 'accumulate' was not declared in this scope 26 | int c = accumulate(a.begin(),a.end(), 0); | ^~~~~~~~~~
s346004608
p04031
C
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <vector> #define size_t int using namespace std; typedef unsigned long ul; typedef unsigned long long ull; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; std::cin >> n; vector<int> a(n,0); for (size_t i = 0; i < n; i++) { std::cin >> a[i]; } int c = accumulate(a.begin(),a.end(), 0); int c2 = 0; for (size_t i = 0; i < n; i++) { /* code */ c2 += a[i]*a[i]; } int alpha = c / n; int beta = alpha + 1; int ans = min(c2 - 2 * alpha * c + n * alpha * alpha,c2 - 2 * beta * c + n * beta * beta); std::cout << ans << '\n'; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s426138665
p04031
C++
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <vector> #define size_t int using namespace std; typedef unsigned long ul; typedef unsigned long long ull; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; std::cin >> n; vector<int> a(n,0); for (size_t i = 0; i < n; i++) { std::cin >> a[i]; } int c = accumulate(a.begin(),a.end(), 0); int c2 = 0; for (size_t i = 0; i < n; i++) { /* code */ c2 += a[i]*a[i]; } int alpha = c / n; int beta = alpha + 1; int ans = min(c2 - 2 * alpha * c + n * alpha * alpha,c2 - 2 * beta * c + n * beta * beta); std::cout << ans << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:26:11: error: 'accumulate' was not declared in this scope 26 | int c = accumulate(a.begin(),a.end(), 0); | ^~~~~~~~~~
s172026051
p04031
C++
#include<math.h> using namespace std; int main() { // your code goes here int n,i,b,sum; double k; cin>>n; int a[n]; sum=0; for(i=0;i<n;i++) { cin>>a[i]; sum+=a[i]; } k=(double)sum/n; b=round(k); sum=0; for(i=0;i<n;i++) { sum+=(b-a[i])*(b-a[i]); } cout<<sum<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:9: error: 'cin' was not declared in this scope 8 | cin>>n; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<math.h> +++ |+#include <iostream> 2 | using namespace std; a.cc:23:9: error: 'cout' was not declared in this scope 23 | cout<<sum<<endl; | ^~~~ a.cc:23:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:23:20: error: 'endl' was not declared in this scope 23 | cout<<sum<<endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<math.h> +++ |+#include <ostream> 2 | using namespace std;
s073351763
p04031
Java
import java.util.Scanner; public class ProblemC { public static int max_a (int[] array) { int val = array[0]; for (int i = 1; i < array.length; i++) { val = Math.max(val, array[i]); } return val; } public static int min_a (int[] array) { int val = array[0]; for (int i = 1; i < array.length; i++) { val = Math.min(val, array[i]); } return val; } public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for (int i = 0; i < a.length; i++) { a[i] = sc.nextInt(); } int maxa = max_a(a); int mina = min_a(a); int min_cost = Integer.MAX_VALUE; for (int i = mina; i <= maxa; i++) { int cost = 0; for (int j = 0; j < n; j++) { cost += (i - a[j]) * (i - a[j]); } min_cost = Math.min(min_cost, cost); } System.out.println(min_cost); } }
Main.java:3: error: class ProblemC is public, should be declared in a file named ProblemC.java public class ProblemC { ^ 1 error
s035153941
p04031
C++
#include <cmath> #include <iostream> using namespace std; int main(void) { int N, a[100], cost, mincost = INT_MAX, max = 0, min = INT_MAX; cin >> N; for (int i = 0; i < N; i++) { cin >> a[i]; if (max < a[i]) max = a[i]; if (min > a[i]) min = a[i]; } for (int i = min; i <= max; i++) { cost = 0; for (int j = 0; j < N; j++) { cost += pow(a[j] - i, 2.0); } if (cost < mincost) mincost = cost; } cout << mincost << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:34: error: 'INT_MAX' was not declared in this scope 7 | int N, a[100], cost, mincost = INT_MAX, max = 0, min = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <iostream> +++ |+#include <climits> 3 | a.cc:11:9: error: parse error in template argument list 11 | if (max < a[i]) | ^~~~~~~~~~ a.cc:11:19: error: cannot resolve overloaded function 'max' based on conversion to type 'bool' 11 | if (max < a[i]) | ^ a.cc:12:16: error: overloaded function with no contextual type information 12 | max = a[i]; | ^ a.cc:13:13: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator>' 13 | if (min > a[i]) | ~~~~^~~~~~ a.cc:14:16: error: overloaded function with no contextual type information 14 | min = a[i]; | ^ a.cc:16:16: error: cannot resolve overloaded function 'min' based on conversion to type 'int' 16 | for (int i = min; i <= max; i++) { | ^~~ a.cc:16:23: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<=' 16 | for (int i = min; i <= max; i++) { | ~~^~~~~~
s798699743
p04031
C++
#include <iostream> using namespace std; int a[105]; int n, ll, rr; long res = 105 * 105; long check(long value) { long ret = 0; for (int i = 0; i < n; ++i) ret += (a[i] - value) * (a[i] - value); return ret; } int main() { ll = 105; rr = -105; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; if (a[i] < ll) ll = a[i]; if (a[i] > rr) rr = a[i]; } for (int i = -1000; i <= 1000 ++i) { long ret = check(i); if (ret < res) res = ret; } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:33:34: error: lvalue required as increment operand 33 | for (int i = -1000; i <= 1000 ++i) | ^~~~ a.cc:33:41: error: expected ';' before 'i' 33 | for (int i = -1000; i <= 1000 ++i) | ^ | ;
s239232991
p04031
C++
#include <iostream> #include <set> using namespace std; int n, a[110]; set<int> st; int ab, ad; inline p(int x, int y) { return (x-y)*(x-y); } int main() { cin >> n; int sum = 0; st.clear(); for (int i = 0; i < n; ++ i) { cin >> a[i]; if (st.find(a[i]) == st.end()) sum += a[i]; st.insert(a[i]); } int num = st.size(); if (sum % num) { ab = sum/num, ad = ab+1; } else { ab = sum/num, ad = ab; } int sum1=0, sum2=0; for (int i = 0; i < n; ++ i) { sum1 += p(a[i], ab); sum2 += p(a[i], ad); } cout << min(sum1, sum2) << endl; return 0; }
a.cc:9:8: error: ISO C++ forbids declaration of 'p' with no type [-fpermissive] 9 | inline p(int x, int y) { | ^
s970927354
p04031
C
#include<cstdio> #include<algorithm> using namespace std; int main() { int t; int a[110]; int sum; while(~scanf("%d",&t)) { sum=0; for(int i=0;i<t;i++) { scanf("%d",&a[i]); sum+=a[i]; } int ans=0; if(sum%t==0) { sum/=t; for(int i=0;i<t;i++) { ans+=(sum-a[i])*(sum-a[i]); } } else { sort(a,a+t); sum/=t; for(int i=0;i<t;i++) { ans+=(sum-a[i])*(sum-a[i]); } sum++;int res=0; for(int i=0;i<t;i++) { res+=(sum-a[i])*(sum-a[i]); } ans=min(res,ans); } printf("%d\n",ans); } return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s703288806
p04031
C
#include<stdio.h> #include<string.h> #include<iostream> #include<algorithm> using namespace std; int min(int x,int y) { return x>y?y:x; } int main() { int n; int a[205]; scanf("%d",&n); for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); int ans=80000; int sum; for(int i=a[0];i<a[n-1];i++) { sum=0; for(int j=0;j<n;j++) { sum+=(i-a[j])*(i-a[j]); } ans=min(ans,sum); } printf("%d\n",ans); }
main.c:3:9: fatal error: iostream: No such file or directory 3 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s854064749
p04031
C++
#include <stdio.h> int n; int m; int ans; int a[101]; int main(){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); m+=a[i]; } if(m>0){ m=(m*10/n+5)/10; }else if(m<0){ m=(m*10/n-5)/10; }else if(m==0){ m=(m*10/n)/10; } for(int i=0;i<n;i++){ if(a[i]<m){ ans+=(m-a[i])*(m-a[i]); }else if(a[i]>m){ ans+=(a[i]-m)*(a[i]-m); } } printf("%d",ans); return 0;
a.cc: In function 'int main()': a.cc:28:18: error: expected '}' at end of input 28 | return 0; | ^ a.cc:7:11: note: to match this '{' 7 | int main(){ | ^
s364090593
p04031
C++
#include <iostream> #include <vector> #include <map> #include <algorithm> #include <string> #include <cmath> #include <stack> #include <queue> #include <list> #include <set> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() #define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++) #define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++) #define INF 1010101010 #define MOD 1000000007 #define LL long long using Coord = pair<int, int>; int main() { int n; cin >> n; vector<int> an(n); for (auto& e: an) cin >> e; double sum = (double)accumulate(all(an), 0); int ave = (int)round(sum / n); int ans = 0; for (const auto e: an) { int diff = e - ave; ans += diff * diff; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:27:26: error: 'accumulate' was not declared in this scope 27 | double sum = (double)accumulate(all(an), 0); | ^~~~~~~~~~
s463549312
p04031
C++
#include <iostream> #include <vector> #include <map> #include <algorithm> #include <string> #include <cmath> #include <stack> #include <queue> #include <list> #include <set> using namespace std; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(), (x).end() #define itr(i, x) for(auto i = (x).begin(); i != (x).end(); i++) #define ritr(i, x) for(auto i = (x).rbegin(); i != (x).rend(); i++) #define INF 1010101010 #define MOD 1000000007 #define LL long long using Coord = pair<int, int>; int main() { int n; cin >> n; vector<int> an(n); for (auto& e: an) cin >> e; double sum = accumulate(all(an), 0); int ave = (int)round(sum / n); int ans = 0; for (const auto e: an) { int diff = e - ave; ans += diff * diff; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:27:18: error: 'accumulate' was not declared in this scope 27 | double sum = accumulate(all(an), 0); | ^~~~~~~~~~
s436387979
p04031
C++
import java.util.*; // ABC 43-C // http://abc043.contest.atcoder.jp/tasks/arc059_a public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] nums = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { nums[i] = in.nextInt(); sum += nums[i]; } int avg = sum / n; // Probably need to investigate avg + 1 too System.out.println(Math.min(cost(nums, avg), cost(nums, avg + 1))); } public static int cost(int[] nums, int avg) { int cost = 0; for (int i = 0; i < nums.length; i++) { cost += (nums[i] - avg) * (nums[i] - avg); } return cost; } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~
s378968379
p04031
C++
#include <iostream> #include<algorithm> using namespace std; int main() { int n,i,a[100],sum=0,num=0,res=0; cin >> n; for (i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } if (sum % n == 0) num = sum / n; else num = sum / n + 1; for (i = 0; i < n; i++) res += (int)pow((num - a[i]), 2); cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:29: error: 'pow' was not declared in this scope 20 | res += (int)pow((num - a[i]), 2); | ^~~
s767871790
p04031
C++
#include <iostream> #define FOR(i, begin, end) for(int i = (begin); i < (end); i++) #define REP(i, end) FOR(i, 0, end) using namespace std; int main(){ int size; cin >> size; int* p = new int[size]; REP(i, size) cin >> p[i]; int min, max; min = max = p[0]; int minAmount, maxAmount; //最小値、最大値がいくつあるか minAmount = maxAmount = 1; FOR(i, 1, size){ if(min > p[i]){ min = p[i]; minAmount = 0; } if(min == p[i]) minAmount++; if(max < p[i]){ max = p[i]; maxAmount = 0; } if(max == p[i]) maxAmount++; } int difference = max - min; //最小値と最大値の差 int target; //揃える数 if(difference%2 == 0) target = difference/2; else{ if(minAmount > maxAmount) target = difference/2; else target = difference/2+1; } target += min; int cost = 0; REP(i, size) cost += (int)pow(p[i] - target, 2); cout << cost << endl; }
a.cc: In function 'int main()': a.cc:49:30: error: 'pow' was not declared in this scope 49 | cost += (int)pow(p[i] - target, 2); | ^~~
s441762657
p04031
C++
#include <iostream> #include <vector> using namespace std; int main() { int N; int ave = 0, ans = 0; cin >> N; vector<int> a(N); for (int i = 0; i < N; i++) { cin >> a[i]; ave += a[i]; } ave = round(double(ave) / double(N)); for (int i = 0; i < N; i++) { ans += pow(a[i] - ave, 2); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:15: error: 'round' was not declared in this scope 19 | ave = round(double(ave) / double(N)); | ^~~~~ a.cc:23:24: error: 'pow' was not declared in this scope 23 | ans += pow(a[i] - ave, 2); | ^~~
s543014776
p04031
C++
#include <iostream> #include <algorithm> #define MAX 100 using namespace std; int a[MAX]; int main() { int n, minv, maxv; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; if (i == 0) { minv = a[i]; maxv = a[i]; } else { if (minv > a[i]) minv = a[i]; if (maxv < a[i]) maxv = a[i]; } } long long cost = 0, res = 9223372036854775807; for (int j = minv; j <= maxv; ++j) { if (cost != 0) { if (cost < res) res = cost; cost = 0; } for (int i = 0; i < n; ++i) { cost += (a[i] - j) * (a[i] - j); } } cout << (res == LONG_MAX ? 0 :res) << endl; return 0; }
a.cc: In function 'int main()': a.cc:35:25: error: 'LONG_MAX' was not declared in this scope 35 | cout << (res == LONG_MAX ? 0 :res) << endl; | ^~~~~~~~ a.cc:3:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <algorithm> +++ |+#include <climits> 3 | #define MAX 100
s058691040
p04031
C++
#include <iostream> #include <algorithm> #define MAX 100 using namespace std; int a[MAX]; int main() { int n, minv, maxv; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; if (i == 0) { minv = a[i]; maxv = a[i]; } else { if (minv > a[i]) minv = a[i]; if (maxv < a[i]) maxv = a[i]; } } long long cost = 0, res = LONG_MAX; for (int j = minv; j <= maxv; ++j) { if (cost != 0) { if (cost < res) res = cost; cost = 0; } for (int i = 0; i < n; ++i) { cost += (a[i] - j) * (a[i] - j); } } cout << (res == LONG_MAX ? 0 :res) << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:35: error: 'LONG_MAX' was not declared in this scope 23 | long long cost = 0, res = LONG_MAX; | ^~~~~~~~ a.cc:3:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <algorithm> +++ |+#include <climits> 3 | #define MAX 100
s502927202
p04031
C++
q
a.cc:1:1: error: 'q' does not name a type 1 | q | ^
s133945155
p04031
C
#include<stdio.h> #include<math.h> int main(void){ int N, a, i; unsigned long sum=0, ss=0, x; scanf("%d", &N); for(i = 0; i < N; i++){ scanf("%d", &a); sum += a; ss += a*a; } x = (int)floor(((double)sum)/N+0.5) printf("%lu\n", x*(N*x-2*sum)+ss); return 0; }
main.c: In function 'main': main.c:13:44: error: expected ';' before 'printf' 13 | x = (int)floor(((double)sum)/N+0.5) | ^ | ; 14 | printf("%lu\n", x*(N*x-2*sum)+ss); | ~~~~~~
s878823233
p04031
C
#include<stdio.h> #include<stdlib.h> #include<limits.h> int main(void){ int N, *a, i, j, dif; unsigned long sum, min=ULONG_MAX; scanf("%d", &N); a = (int *)malloc(N*sizeof(int)); for(i = 0; i < N; i++){ scanf("%d" a+i); } for(i = (-100); i <=100 ; i++){ sum = 0; for(j = 0; j < N; j++){ dif = a[j]-100; sum += (unsigned long)(dif*dif); } if(min > sum) min = sum; } printf("%lul/n", min); return 0; }
main.c: In function 'main': main.c:11:19: error: expected ')' before 'a' 11 | scanf("%d" a+i); | ~ ^~ | )
s784874756
p04031
C++
n = input() arr = map(int, raw_input().split()) if n == 1: print 0 else: mid = (arr[0] + arr[-1])/2 ans = 0 for e in arr: ans += (e-mid)**2 print ans
a.cc:1:1: error: 'n' does not name a type 1 | n = input() | ^
s421425398
p04031
C++
#include <iostream> using namespace std; int main(void){ int n, a[100], ans = 0; double sum = 0; cin >> n; for (int i = 0; i < n; i++){ cin >> a[i]; sum += a[i]; } sum /= n; sum = round(sum); for (int i = 0; i < n; i++){ ans += pow(((int)sum - a[i]), 2); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:15: error: 'round' was not declared in this scope 14 | sum = round(sum); | ^~~~~ a.cc:17:24: error: 'pow' was not declared in this scope 17 | ans += pow(((int)sum - a[i]), 2); | ^~~
s905648928
p04031
C++
//Be together #include <stdio.h> #include <stdlib.h> #include <math.h> int calcCost(int * array, int size, int y){ int sum = 0; for(int x = 0; x < size; x++){ sum += ((array[x] - y)*(array[x] - y)); } return sum; } int main(){ int n; scanf("%d",&n); int * arr = malloc(n*sizeof(int)); scanf("%d",&arr[0]); int min = arr[0]; int max = arr[0]; for(int i = 1; i < n; i++){ scanf("%d",&arr[i]); if(arr[i] < min){ min = arr[i]; }else if(arr[i] > max){ max = arr[i]; } } int lowestCost = 100000; int cost = 0; while(min <= max){ cost = calcCost(arr,n,min); if(cost < lowestCost){ lowestCost = cost; } min++; } printf("%d\n",lowestCost); return EXIT_SUCCESS; }
a.cc: In function 'int main()': a.cc:17:22: error: invalid conversion from 'void*' to 'int*' [-fpermissive] 17 | int * arr = malloc(n*sizeof(int)); | ~~~~~~^~~~~~~~~~~~~~~ | | | void*
s366572730
p04031
C++
#include <iostream> #include <vector> #include <cmath> #include <string> #include <algorithm> #include <numeric> using namespace std; vector<int> v; long long sum = INT_MAX; int n; long long cal(int k) { long long sum = 0; for (int i = 0; i < n; i++) { sum += pow(k - v[i], 2); } return sum; } int main() { cin >> n; for (int i = 0; i < n; i++) { int a = 0; cin >> a; v.push_back(a); } int max_v = *max_element(v.begin(), v.end()); int min_v = *min_element(v.begin(), v.end()); for (int i = min_v; i <= max_v; ++i) { sum = min(sum, cal(i)); } cout << sum << endl; return 0; }
a.cc:9:17: error: 'INT_MAX' was not declared in this scope 9 | long long sum = INT_MAX; | ^~~~~~~ a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 6 | #include <numeric> +++ |+#include <climits> 7 | using namespace std;
s458123108
p04031
C++
#include<iostream> using namespace std; int main() { int n,min,max; min = 100; max = -100; cin >> n; int *a=new int [n]; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] > max) { max = a[i]; } if (a[i] < min) { min = a[i]; } } if (min == max) { cout << 0 << endl; } else { double mid = (min + max) / 2.0; double b, c; b = modf(mid, &c); if (b != 0) { int count, countt; count = 0; countt = 0; int d = c + 1; for (int i = 0; i < n; i++) { if (a[i] == c) { count++; } if (a[i] == d) { countt++; } } if (count >= countt) { mid = c; } else { mid = d; } } int ans=0; for (int i = 0; i < n; i++) { double e = pow((a[i] - mid), 2); ans += e; } cout << ans << endl; } delete a; return 0; }
a.cc: In function 'int main()': a.cc:26:21: error: 'modf' was not declared in this scope 26 | b = modf(mid, &c); | ^~~~ a.cc:41:36: error: 'pow' was not declared in this scope 41 | double e = pow((a[i] - mid), 2); | ^~~
s535519675
p04031
C++
#define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define INF INT_MAX/3 #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define SET(a,c) memset(a,c,sizeof a) #define CLR(a) memset(a,0,sizeof a) #define PII pair<int,int> #define PCC pair<char,char> #define PIC pair<int,char> #define Pci pair<char,int> #define VS vector<string> #define VI vector<int> #define DEBUG(x) cout<<#x<<": "<<x<<endl #define MIN(a,b) (a>b?b:a) #define MAX(a,b) (a>b?a:b) #define PI 2*acos(0.0) #define INFILE() freopen("in0.txt","r",stdin) #define OUTFILE() freopen("out0.txt","w",stdout) #define IN scanf #define OUT(x) cout<<x<<endl #define LL long long #define ll long long #define ULL unsigned long long #define EPS 1e-14 #define FST first #define SEC second #include<iostream> using namespace std; int main() { // 入力 int N; cin >> N; int a[N]; REP(i,N){ cin >> a[i]; } int last_sum = INF; FOR(i,-100,101) { int sum = 0; REP(j, N){ sum += (i - a[j]) * (i - a[j]); } if(last_sum < sum) break; last_sum = sum; } OUT(last_sum); return 0; }
a.cc: In function 'int main()': a.cc:6:13: error: 'INT_MAX' was not declared in this scope 6 | #define INF INT_MAX/3 | ^~~~~~~ a.cc:46:18: note: in expansion of macro 'INF' 46 | int last_sum = INF; | ^~~ a.cc:34:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 33 | #include<iostream> +++ |+#include <climits> 34 |
s667196192
p04031
C++
#include<iostream> #include<vector> using namespace std; int main(int argc, char const *argv[]) { std::vector<int> v(100),costs(201); int n,i,k; cin>>n; for(i=0;i<n;i++){ cin>>v[i]; } for (i=-100; i <= 100; i++) { for (k = 0; k < n; i++) { costs[i+100]+=((i-v[k])*(i-v[k])); } } cout<<*min_element(costs.begin(),costs.end()); return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:20:10: error: 'min_element' was not declared in this scope 20 | cout<<*min_element(costs.begin(),costs.end()); | ^~~~~~~~~~~
s884081286
p04031
C++
#include<iostream> #include<vector> using namespace std; int main(int argc, char const *argv[]) { std::vector<int> v(100),costs(201); int n,i,k; cin>>n; for(i=0;i<n;i++){ cin>>v[i]; } for (i=-100; i <= 100; i++) { for (k = 0; k < n; i++) { costs[i+100]+=(i-v[k])**2; } } cout<<*costs.min_element(); return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:16:30: error: invalid type argument of unary '*' (have 'int') 16 | costs[i+100]+=(i-v[k])**2; | ^~ a.cc:20:16: error: 'class std::vector<int>' has no member named 'min_element' 20 | cout<<*costs.min_element(); | ^~~~~~~~~~~
s703889440
p04031
C++
#include <iostream> #include <vector> using namespace std; const int INF = 1e9 + 10; int main() { int N; cin >> N; vector<int> an(N); int l = INF, r = -INF, c; for (int i = 0; i < N; i++) { int a; cin >> a; an[i] = a; l = min(l, an[i]); r = max(r, an[i]); } int s = INF; for (int i = l; i <= r; i++) { int t = 0; for (int j = 0; j < N; j++) { t += (an[j] - i) * (an[j] - i); } s = min(s, t) } cout << s << endl; return 0; }
a.cc: In function 'int main()': a.cc:29:18: error: expected ';' before '}' token 29 | s = min(s, t) | ^ | ; 30 | } | ~
s050799931
p04031
C
#include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int loop; int N; int *a; int x, y; int sum; int best; scanf("%d", &N); a = malloc(sizeof(int)*N); best = INT_MAX; for (loop = 0; loop < N; loop++) { scanf("%d", &a[loop]); } for (x = -100; x <= 100; x++) { sum = 0; for (y = 0; y < N; y++) { sum += pow(x - a[y], 2); } if (sum < best) best = sum; } printf("%d", best); return 0; }
main.c: In function 'main': main.c:15:16: error: 'INT_MAX' undeclared (first use in this function) 15 | best = INT_MAX; | ^~~~~~~ main.c:4:1: note: 'INT_MAX' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>' 3 | #include<math.h> +++ |+#include <limits.h> 4 | main.c:15:16: note: each undeclared identifier is reported only once for each function it appears in 15 | best = INT_MAX; | ^~~~~~~
s013962640
p04031
C
#include<stdio.h> #include<stdlib.h> #include<math.h> int main() { int loop; int N; int *a; int x, y; int sum = 0; int best = 0; scanf("%d", &N); a = malloc(sizeof(int)*N); for (loop = 0; loop < N; loop++) { scanf("%d", &a[loop]); } for (x = 1, x <= 100; x++) { for (y = 0; y < N; y++) { sum += pow(x - a[y], 2); } if (sum < best) best = sum; } return 0; }
main.c: In function 'main': main.c:19:34: error: expected ';' before ')' token 19 | for (x = 1, x <= 100; x++) { | ^ | ;
s955556943
p04031
C++
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<cstring> #include<vector> using namespace std; #define INT(x) int x; scanf("%d",&x) #define INPUT(x) scanf("%d",&x) #define REP1(x,n) for(int x = 0; x < n; x++) #define REP2(x,s,e) for(int x = s; x <= e; x++) #define BR printf("\n") #define INF 2000000000 int rec(int A[],int N,int k){ int sum = 0; REP1(i,N) sum += (A[i]-k)*(A[i]-k); return sum; } int rec2(int A[],int N){ int mini = INF; for (int i = -100; i <= 100; i++) { mini = min(rec(A,N,i),min); } } int main(){ INT(N); A[100]; REP1(i,N) INPUT(A[i]); cout << rec2(A,N) << endl; return 0; }
a.cc: In function 'int rec2(int*, int)': a.cc:24:19: error: no matching function for call to 'min(int, <unresolved overloaded function type>)' 24 | mini = min(rec(A,N,i),min); | ~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:36: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const int&' 233 | min(const _Tp& __a, const _Tp& __b) | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:24:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 24 | mini = min(rec(A,N,i),min); | ~~~^~~~~~~~~~~~~~~~ a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type] 26 | } | ^ a.cc: In function 'int main()': a.cc:30:5: error: 'A' was not declared in this scope 30 | A[100]; | ^
s756875133
p04031
C++
#include<iostream> #include<cstdio> #include<string> #include<algorithm> #include<cstring> #include<vector> using namespace std; #define INT(x) int x; scanf("%d",&x) #define INPUT(x) scanf("%d",&x) #define REP1(x,n) for(int x = 0; x < n; x++) #define REP2(x,s,e) for(int x = s; x <= e; x++) #define BR printf("\n") #define INF 2000000000 int rec(int A[],int N,int k){ sum = 0; REP1(i,N) sum += (A[i]-k)*(A[i]-k); return sum; } int rec2(int A[],int N){ int mini = INF; for (int i = -100; i <= 100; i++) { mini = min(rec(A,N,i),min); } } int main(){ INT(N); A[100]; REP1(i,N) INPUT(A[i]); cout << rec2(A,N) << endl; return 0; }
a.cc: In function 'int rec(int*, int, int)': a.cc:16:5: error: 'sum' was not declared in this scope 16 | sum = 0; | ^~~ a.cc: In function 'int rec2(int*, int)': a.cc:24:19: error: no matching function for call to 'min(int, <unresolved overloaded function type>)' 24 | mini = min(rec(A,N,i),min); | ~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:36: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const int&' 233 | min(const _Tp& __a, const _Tp& __b) | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:24:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 24 | mini = min(rec(A,N,i),min); | ~~~^~~~~~~~~~~~~~~~ a.cc:26:1: warning: no return statement in function returning non-void [-Wreturn-type] 26 | } | ^ a.cc: In function 'int main()': a.cc:30:5: error: 'A' was not declared in this scope 30 | A[100]; | ^
s417002142
p04031
C++
#include <iostream> #include <vector> #include <cstdio> typedef long long ll; using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int main(void){ int n; cin >> n; vector<int> v(n); rep(i, n) cin >> v[i]; ll sum = 1e9; for (int i = -100; i <= 100 ; ++i){ ll tmp = 0; rep(j, n){ tmp += pow((i - v[j]), 2); } sum = min(tmp, sum); } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:32: error: 'pow' was not declared in this scope 16 | tmp += pow((i - v[j]), 2); | ^~~
s455819478
p04031
C++
#include <iostream> #include <vector> #include <cstdio> using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int main(void){ int n; cin >> n; vector<int> v(n); rep(i, n) cin >> v[i]; ll sum = 1e9; for (int i = -100; i <= 100 ; ++i){ ll tmp = 0; rep(j, n){ tmp += pow((i - v[j]), 2); } sum = min(tmp, sum); } cout << sum << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: 'll' was not declared in this scope 11 | ll sum = 1e9; | ^~ a.cc:13:19: error: expected ';' before 'tmp' 13 | ll tmp = 0; | ^~~~ | ; a.cc:15:25: error: 'tmp' was not declared in this scope; did you mean 'tm'? 15 | tmp += pow((i - v[j]), 2); | ^~~ | tm a.cc:15:32: error: 'pow' was not declared in this scope 15 | tmp += pow((i - v[j]), 2); | ^~~ a.cc:17:17: error: 'sum' was not declared in this scope 17 | sum = min(tmp, sum); | ^~~ a.cc:17:27: error: 'tmp' was not declared in this scope; did you mean 'tm'? 17 | sum = min(tmp, sum); | ^~~ | tm a.cc:19:17: error: 'sum' was not declared in this scope 19 | cout << sum << endl; | ^~~
s971075481
p04031
C++
#include <iostream> #include <numeric> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; long long int s = 0; int t; vector<int> x; for (int i = 0; i < n; i++) { cin >> t; x.push_back(t); } int m = INT_MAX; for (int i = -100; i < 101; i++) { m = min(m, accumulate(x.begin(), x.end(), 0, [&i](long int ss, int x) {return ss += (int)(pow(i - x, 2)); })); } cout << m << endl; }
a.cc: In function 'int main()': a.cc:18:17: error: 'INT_MAX' was not declared in this scope 18 | int m = INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <algorithm> +++ |+#include <climits> 5 | a.cc: In lambda function: a.cc:20:107: error: 'pow' was not declared in this scope 20 | m = min(m, accumulate(x.begin(), x.end(), 0, [&i](long int ss, int x) {return ss += (int)(pow(i - x, 2)); })); | ^~~
s475199134
p04031
C++
#include<iostream> #include<vector> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); int sum = 0; for(int i = 0; i < n; i++){ cin >> a[i]; sum += a[i]; } int min = INT_MAX; for(int p = 0; p <= 1; p++){ int ave = sum / n + p; int ans = 0; for(int i = 0; i < n; i++){ ans += (a[i] - ave) * (a[i] - ave); } if(min > ans) min = ans; } cout << min << endl; }
a.cc: In function 'int main()': a.cc:14:13: error: 'INT_MAX' was not declared in this scope 14 | int min = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include<vector> +++ |+#include <climits> 3 | using namespace std;
s772561975
p04031
C++
#include <string> #include <iostream> using namespace std; int main() { int a,e,f; cin >> a; int b[a]; int c = 0; double d=0,g=a; while (a > c) { cin >> b[c]; c = c + 1; } c = 0; while (a > c) { d = d + b[c]; c = c + 1; } d = d / g; if (d>=0)f = d + 0.5; else d = d*(-1), f = d + 0.5, f = f*(-1); c = 0; while (a > c) { e = e + (b[c] - f)*(b[c] - f); c = c + 1; } cout << e << endl;   return 0; }
a.cc:29:1: error: extended character   is not valid in an identifier 29 |   return 0; | ^ a.cc:29:1: error: extended character   is not valid in an identifier a.cc: In function 'int main()': a.cc:29:1: error: '\U00003000\U00003000return' was not declared in this scope 29 |   return 0; | ^~~~~~~~~~
s644615339
p04031
C++
#include <iostream> #include <string> #include <vector> using namespace std; int main(){ int n,a,sum=0,ave,ans=0,temp=0; vector<int> v; cin >> n; for(int i = 0; i < n; i++){ cin >> a; v.push_back(a); sum+=a; } ave=sum/n; for(int i = 0; i < n; i++){ ans += (v[i]-ave)*(v[i]-ave); } for(int i = 0; i < ; i++){ temp += (v[i]-ave+1)*(v[i]-ave+1); } if(ans > temp){ ans = temp; } temp = 0; for(int i = 0; i < ; i++){ temp += (v[i]-ave-1)*(v[i]-ave-1); } if(ans > temp)ans = temp; for(int i = 0; i < n; i++){ temp = 0; for(int j = 0; j < n; j++){ temp += (v[i]-v[j])*(v[i]-v[j]); } if(ans > temp){ ans = temp; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:22: error: expected primary-expression before ';' token 19 | for(int i = 0; i < ; i++){ | ^ a.cc:26:22: error: expected primary-expression before ';' token 26 | for(int i = 0; i < ; i++){ | ^
s387440429
p04031
C++
#include <iostream> #include <vector> #include <numeric> #include <algorithm> using namespace std; int main() { int N; cin >> N; int min, max, ans; vector<int> A; for (int i = 0; i < N; i++) { int tmp; cin >> tmp; A.push_back(tmp); } ans = INT_MAX; min = *min_element(A.begin(), A.end()); max = *max_element(A.begin(), A.end()); for (int j = min; j <= max; j++) { int tmp_ans = 0; for (int i = 0; i < N; i++) { tmp_ans += ((j - A[i]) * (j - A[i])); } if(ans > tmp_ans) ans = tmp_ans; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:11: error: 'INT_MAX' was not declared in this scope 19 | ans = INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <algorithm> +++ |+#include <climits> 5 |
s597340342
p04031
C++
#include <iostream> #include <string> #include <vector> using namespace std; int main(){ int n,a,sum=0,ave,ans=0,temp=0; vector<int> v; cin >> n; for(int i = 0; i < n; i++){ cin >> a; v.push_back(a); sum+=a; } ave=sun/n; for(int i = 0; i < n; i++){ ans += (v[i]-ave)*(v[i]-ave); } for(int i = 0; i < n; i++){ temp = 0; for(int j = 0; j < n; j++){ temp += (v[i]-v[j])*(v[i]-v[j]); } if(ans > temp){ ans = temp; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:7: error: 'sun' was not declared in this scope; did you mean 'sum'? 15 | ave=sun/n; | ^~~ | sum
s603950725
p04031
C++
#include <iostream> ##include <string> #include <vector> using namespace std; int main(){ int n,a,sum=0,ave,ans=0,temp=0; vector<int> v; cin >> n; for(int i = 0; i < n; i++){ cin >> a; v.push_back(a); sum+=a; } ave=sun/n; for(int i = 0; i < n; i++){ ans += (v[i]-ave)*(v[i]-ave); } for(int i = 0; i < n; i++){ temp = 0; for(int j = 0; j < n; j++){ temp += (v[i]-v[j])*(v[i]-v[j]); } if(ans > temp){ ans = temp; } } cout << ans << endl; return 0; }
a.cc:2:1: error: stray '##' in program 2 | ##include <string> | ^~ a.cc:2:3: error: 'include' does not name a type 2 | ##include <string> | ^~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h: In static member function 'static constexpr bool std::vector<_Tp, _Alloc>::_S_nothrow_relocate(std::true_type)': /usr/include/c++/14/bits/stl_vector.h:472:30: error: '__relocate_a' is not a member of 'std' 472 | return noexcept(std::__relocate_a(std::declval<pointer>(), | ^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In static member function 'static std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_S_do_relocate(pointer, pointer, pointer, _Tp_alloc_type&, std::true_type)': /usr/include/c++/14/bits/stl_vector.h:495:21: error: '__relocate_a' is not a member of 'std' 495 | return std::__relocate_a(__first, __last, __result, __alloc); | ^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In static member function 'static std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_S_relocate(pointer, pointer, pointer, _Tp_alloc_type&)': /usr/include/c++/14/bits/stl_vector.h:509:21: error: '__relocate_a' is not a member of 'std' 509 | return std::__relocate_a(__first, __last, __result, __alloc); | ^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In copy constructor 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&)': /usr/include/c++/14/bits/stl_vector.h:606:16: error: '__uninitialized_copy_a' is not a member of 'std' 606 | std::__uninitialized_copy_a(__x.begin(), __x.end(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In constructor 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)': /usr/include/c++/14/bits/stl_vector.h:628:16: error: '__uninitialized_copy_a' is not a member of 'std' 628 | std::__uninitialized_copy_a(__x.begin(), __x.end(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In constructor 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type)': /usr/include/c++/14/bits/stl_vector.h:649:20: error: '__uninitialized_move_a' is not a member of 'std' 649 | std::__uninitialized_move_a(__rv.begin(), __rv.end(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_M_allocate_and_copy(size_type, _ForwardIterator, _ForwardIterator)': /usr/include/c++/14/bits/stl_vector.h:1624:20: error: '__uninitialized_copy_a' is not a member of 'std' 1624 | std::__uninitialized_copy_a(__first, __last, __result, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag)': /usr/include/c++/14/bits/stl_vector.h:1697:18: error: '__uninitialized_copy_a' is not a member of 'std' 1697 | std::__uninitialized_copy_a(__first, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_type, const value_type&)': /usr/include/c++/14/bits/stl_vector.h:1709:16: error: '__uninitialized_fill_n_a' is not a member of 'std' 1709 | std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type)': /usr/include/c++/14/bits/stl_vector.h:1720:16: error: '__uninitialized_default_n_a' is not a member of 'std' 1720 | std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:72: /usr/include/c++/14/bits/vector.tcc: In member function 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&)': /usr/include/c++/14/bits/vector.tcc:257:20: error: '__uninitialized_copy_a' is not a member of 'std' 257 | std::__uninitialized_copy_a(__x._M_impl._M_start + size(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_assign(std::size_t, const value_type&)': /usr/include/c++/14/bits/vector.tcc:287:18: error: '__uninitialized_fill_n_a' is not a member of 'std' 287 | std::__uninitialized_fill_n_a(this->_M_impl._M_finish, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_assign_aux(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag)': /usr/include/c++/14/bits/vector.tcc:352:20: error: '__uninitialized_copy_a' is not a member of 'std' 352 | std::__uninitialized_copy_a(__mid, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(iterator, _Args&& ...)': /usr/include/c++/14/bits/vector.tcc:549:33: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 549 | __new_finish = std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:557:33: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 557 | __new_finish = std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_append(_Args&& ...)': /usr/include/c++/14/bits/vector.tcc:676:33: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 676 | __new_finish = std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_insert(iterator, size_type, const value_type&)': /usr/include/c++/14/bits/vector.tcc:719:24: error: '__uninitialized_move_a' is not a member of 'std' 719 | std::__uninitialized_move_a(__old_finish - __n, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:734:26: error: '__uninitialized_fill_n_a' is not a member of 'std' 734 | std::__uninitialized_fill_n_a(__old_finish, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:739:24: error: '__uninitialized_move_a' is not a member of 'std' 739 | std::__uninitialized_move_a(__position.base(), __old_finish, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:763:24: error: '__uninitialized_fill_n_a' is not a member of 'std' 763 | std::__uninitialized_fill_n_a(__new_start + __elems_before, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:769:28: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 769 | = std::__uninitialized_move_if_noexcept_a | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:775:28: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 775 | = std::__uninitialized_move_if_noexcept_a | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_default_append(size_type)': /usr/include/c++/14/bits/vector.tcc:821:22: error: '__uninitialized_default_n_a' is not a member of 'std' 821 | std::__uninitialized_default_n_a(this->_M_impl._M_finish, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:863:22: error: '__uninitialized_default_n_a' is not a member of 'std' 863 | std::__uninitialized_default_n_a(__new_start + __size, __n, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:894:26: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 894 | std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag)': /usr/include/c++/14/bits/vector.tcc:969:26: error: '__uninitialized_move_a' is not a member of 'std' 969 | std::__uninitialized_move_a(this->_M_impl._M_finish - __n, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:984:26: error: '__uninitialized_copy_a' is not a member of 'std' 984 | std::__uninitialized_copy_a(__mid, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:989:26: error: '__uninitialized_move_a' is not a member of 'std' 989 | std::__uninitialized_move_a(__position.base(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:1018:30: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 1018 | = std::__uninitialized_move_if_noexcept_a | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:1022:30: error: '__uninitialized_copy_a' is not a member of 'std' 1022 | = std::__uninitialized_copy_a(__first, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:1026:30: error: '_
s971452721
p04031
C++
#include <iostream> #include <math.h> using namespace std; int main(void){ int n; int max = 0; int min = 1000; int cost = 10000000; cin >> n; int arrray[n]; for(int i=0;i<n;i++){ cin >> arrray[i]; if(arrray[i] > max){ max = arrray[i]; } if(arrray[i] < min ){ min = arrray[i]; } } for(int i = min;i<=max;i++){ int tmpcost=0; for(int j=0;j<n;j++){ if(arrray[j] != i){ tmpcost += pow((arrray[j] - i),2); } } if(tmpcost < cost){ cost = tmpcost; } } cout << cost << endl; return 0; }
a.cc:21:21: error: extended character   is not valid in an identifier 21 | if(arrray[i] < min ){ | ^ a.cc: In function 'int main()': a.cc:21:21: error: expected ')' before '\U00003000' 21 | if(arrray[i] < min ){ | ~ ^~ | )
s959279405
p04031
C++
#include <iostream> #include <math.h> using namespace std; int main(void){ int n; int max = 0; int min = 1000; int cost = 10000000; cin >> n; int arrray[n]; for(int i=0;i<n;i++){ cin >> arrray[i]; if(arrray[i] > max){ max = arrray[i]; } if(arrray[i] < min ){ min = arrray[i]; } } for(int i = min;i<=max;i++){ int tmpcost=0; for(int j=0;j<n;j++){ if(arrray[j] != i){ tmpcost += pow((arrray[j] - i),2); } } if(tmpcost < cost){ cost = tmpcost; } } cout << cost << endl; }
a.cc:21:21: error: extended character   is not valid in an identifier 21 | if(arrray[i] < min ){ | ^ a.cc: In function 'int main()': a.cc:21:21: error: expected ')' before '\U00003000' 21 | if(arrray[i] < min ){ | ~ ^~ | )
s261863452
p04031
C++
#include <iostream> #include <string> #include <vector> using namespace std; int main(){ int n,a,sum=0,ave,ans=0; vector<int> v; cin >> n; for(int i = 0; i < n; i++){ cin >> a; v.push_back(a); sum+=a; } ave=sun/n; for(int i = 0; i < n; i++){ ans += (v[i]-ave)*(v[i]-ave); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:7: error: 'sun' was not declared in this scope; did you mean 'sum'? 15 | ave=sun/n; | ^~~ | sum
s950724315
p04031
C++
#include <iostream> ##include <string> #include <vector> using namespace std; int main(){ int n,a,sum=0,ave,ans=0; vector<int> v; cin >> n; for(int i = 0; i < n; i++){ cin >> a; v.push_back(a); sum+=a; } ave=sun/n; for(int i = 0; i < n; i++){ ans += (v[i]-ave)*(v[i]-ave); } cout << ans << endl; return 0; }
a.cc:2:1: error: stray '##' in program 2 | ##include <string> | ^~ a.cc:2:3: error: 'include' does not name a type 2 | ##include <string> | ^~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h: In static member function 'static constexpr bool std::vector<_Tp, _Alloc>::_S_nothrow_relocate(std::true_type)': /usr/include/c++/14/bits/stl_vector.h:472:30: error: '__relocate_a' is not a member of 'std' 472 | return noexcept(std::__relocate_a(std::declval<pointer>(), | ^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In static member function 'static std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_S_do_relocate(pointer, pointer, pointer, _Tp_alloc_type&, std::true_type)': /usr/include/c++/14/bits/stl_vector.h:495:21: error: '__relocate_a' is not a member of 'std' 495 | return std::__relocate_a(__first, __last, __result, __alloc); | ^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In static member function 'static std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_S_relocate(pointer, pointer, pointer, _Tp_alloc_type&)': /usr/include/c++/14/bits/stl_vector.h:509:21: error: '__relocate_a' is not a member of 'std' 509 | return std::__relocate_a(__first, __last, __result, __alloc); | ^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In copy constructor 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&)': /usr/include/c++/14/bits/stl_vector.h:606:16: error: '__uninitialized_copy_a' is not a member of 'std' 606 | std::__uninitialized_copy_a(__x.begin(), __x.end(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In constructor 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)': /usr/include/c++/14/bits/stl_vector.h:628:16: error: '__uninitialized_copy_a' is not a member of 'std' 628 | std::__uninitialized_copy_a(__x.begin(), __x.end(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In constructor 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type)': /usr/include/c++/14/bits/stl_vector.h:649:20: error: '__uninitialized_move_a' is not a member of 'std' 649 | std::__uninitialized_move_a(__rv.begin(), __rv.end(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'std::vector<_Tp, _Alloc>::pointer std::vector<_Tp, _Alloc>::_M_allocate_and_copy(size_type, _ForwardIterator, _ForwardIterator)': /usr/include/c++/14/bits/stl_vector.h:1624:20: error: '__uninitialized_copy_a' is not a member of 'std' 1624 | std::__uninitialized_copy_a(__first, __last, __result, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag)': /usr/include/c++/14/bits/stl_vector.h:1697:18: error: '__uninitialized_copy_a' is not a member of 'std' 1697 | std::__uninitialized_copy_a(__first, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_initialize(size_type, const value_type&)': /usr/include/c++/14/bits/stl_vector.h:1709:16: error: '__uninitialized_fill_n_a' is not a member of 'std' 1709 | std::__uninitialized_fill_n_a(this->_M_impl._M_start, __n, __value, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_vector.h: In member function 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type)': /usr/include/c++/14/bits/stl_vector.h:1720:16: error: '__uninitialized_default_n_a' is not a member of 'std' 1720 | std::__uninitialized_default_n_a(this->_M_impl._M_start, __n, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:72: /usr/include/c++/14/bits/vector.tcc: In member function 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&)': /usr/include/c++/14/bits/vector.tcc:257:20: error: '__uninitialized_copy_a' is not a member of 'std' 257 | std::__uninitialized_copy_a(__x._M_impl._M_start + size(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_assign(std::size_t, const value_type&)': /usr/include/c++/14/bits/vector.tcc:287:18: error: '__uninitialized_fill_n_a' is not a member of 'std' 287 | std::__uninitialized_fill_n_a(this->_M_impl._M_finish, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_assign_aux(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag)': /usr/include/c++/14/bits/vector.tcc:352:20: error: '__uninitialized_copy_a' is not a member of 'std' 352 | std::__uninitialized_copy_a(__mid, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_insert(iterator, _Args&& ...)': /usr/include/c++/14/bits/vector.tcc:549:33: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 549 | __new_finish = std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:557:33: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 557 | __new_finish = std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_realloc_append(_Args&& ...)': /usr/include/c++/14/bits/vector.tcc:676:33: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 676 | __new_finish = std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_fill_insert(iterator, size_type, const value_type&)': /usr/include/c++/14/bits/vector.tcc:719:24: error: '__uninitialized_move_a' is not a member of 'std' 719 | std::__uninitialized_move_a(__old_finish - __n, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:734:26: error: '__uninitialized_fill_n_a' is not a member of 'std' 734 | std::__uninitialized_fill_n_a(__old_finish, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:739:24: error: '__uninitialized_move_a' is not a member of 'std' 739 | std::__uninitialized_move_a(__position.base(), __old_finish, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:763:24: error: '__uninitialized_fill_n_a' is not a member of 'std' 763 | std::__uninitialized_fill_n_a(__new_start + __elems_before, | ^~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:769:28: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 769 | = std::__uninitialized_move_if_noexcept_a | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:775:28: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 775 | = std::__uninitialized_move_if_noexcept_a | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_default_append(size_type)': /usr/include/c++/14/bits/vector.tcc:821:22: error: '__uninitialized_default_n_a' is not a member of 'std' 821 | std::__uninitialized_default_n_a(this->_M_impl._M_finish, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:863:22: error: '__uninitialized_default_n_a' is not a member of 'std' 863 | std::__uninitialized_default_n_a(__new_start + __size, __n, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:894:26: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 894 | std::__uninitialized_move_if_noexcept_a( | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc: In member function 'void std::vector<_Tp, _Alloc>::_M_range_insert(iterator, _ForwardIterator, _ForwardIterator, std::forward_iterator_tag)': /usr/include/c++/14/bits/vector.tcc:969:26: error: '__uninitialized_move_a' is not a member of 'std' 969 | std::__uninitialized_move_a(this->_M_impl._M_finish - __n, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:984:26: error: '__uninitialized_copy_a' is not a member of 'std' 984 | std::__uninitialized_copy_a(__mid, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:989:26: error: '__uninitialized_move_a' is not a member of 'std' 989 | std::__uninitialized_move_a(__position.base(), | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:1018:30: error: '__uninitialized_move_if_noexcept_a' is not a member of 'std' 1018 | = std::__uninitialized_move_if_noexcept_a | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:1022:30: error: '__uninitialized_copy_a' is not a member of 'std' 1022 | = std::__uninitialized_copy_a(__first, __last, | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:1026:30: error: '_
s957777078
p04031
Java
import java.util.ArrayList; import java.util.List; import java.util.Scanner; import static java.lang.Math.round; public class Math{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int inputCount = sc.nextInt(); List<Integer> inputList = new ArrayList<Integer>(); for(int i=0;i<inputCount;i++){ inputList.add(sc.nextInt()); } //平均値を求める int sum = 0; for(Integer input : inputList){ sum += input; } int ave = (int)round((double)sum/(double)inputCount); //コスト計算 int cost = 0; for(Integer input : inputList){ cost += (ave - input)*(ave - input); } sc.close(); System.out.print(cost); } }
Main.java:6: error: class Math is public, should be declared in a file named Math.java public class Math{ ^ 1 error
s787611363
p04031
C++
#include <iostream> #include<string> #include<vector> using namespace std; int calCost(vector<int>& nums, int i){ int ans = 0; for (auto& elem : nums){ ans += (elem - i)*(elem - i); } return ans; } int main() { int N,t,max=-100,min=100,minCost=INT_MAX; vector<int> nums; cin >> N; for (int i = 0; i < N; ++i){ cin >> t; nums.push_back(t); if (t>max){ max = t; } if (t < min){ min = t; } } for (int i = min; i <= max; ++i){ int cost = calCost(nums, i); if (cost < minCost){ minCost = cost; } else{ break; } } cout << minCost << endl; cin >> t; return 0; }
a.cc: In function 'int main()': a.cc:14:42: error: 'INT_MAX' was not declared in this scope 14 | int N,t,max=-100,min=100,minCost=INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include<vector> +++ |+#include <climits> 4 | using namespace std;
s995346026
p04031
Java
import java.util.Arrays; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int num[] = new int[n]; int total = 0; for (int i = 0; i < n; i++) { int m = sc.nextInt(); num[i] = m; total += m; } float avg = (float)total / (float)n; Arrays.sort(num); int average; if (avg % 1 == 0) { average = (int)avg; } else { average = (int)avg + 1; } int median = n > 2 ? num[(n%2==0 ? n/2 + 1 : n/2)] : (n > 1 ? Math.min(num[0], num[1]) :num[0]); int criteria = average; if(average < median) { criteria = median; } int cost = 0; for (int i = 0; i < n; i++) { if(num[i] != criteria) { cost += Math.pow((num[i] - criteria), 2); } } System.out.println(cost); } }
Main.java:4: error: class C is public, should be declared in a file named C.java public class C { ^ 1 error
s400734331
p04031
Java
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Math { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int inputCount = sc.nextInt(); List<Integer> inputList = new ArrayList<Integer>(); for(int i=0;i<inputCount;i++){ inputList.add(sc.nextInt()); } //平均値を求める int sum = 0; for(Integer input : inputList){ sum += input; } int ave = (int)Math.ceil((double)sum/(double)inputCount); //コスト計算 int cost = 0; for(Integer input : inputList){ cost += (ave - input)*(ave - input); } System.out.print(cost); } }
Main.java:5: error: class Math is public, should be declared in a file named Math.java public class Math { ^ Main.java:21: error: cannot find symbol int ave = (int)Math.ceil((double)sum/(double)inputCount); ^ symbol: method ceil(double) location: class Math 2 errors
s656624652
p04031
C++
import numpy as np N = int(raw_input()) a = np.array(map(int, raw_input().split())) cost = [] for y in xrange(a.min(), a.max() + 1): cost.append(np.sum((a - y) ** 2)) print min(cost)
a.cc:1:1: error: 'import' does not name a type 1 | import numpy as np | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s302726718
p04031
C
#include<stdio.h> int main(void){ int s[102],a[12]; int i,n,t=0,c=0,g,h,r=0,e=0; for(i=0,I<n,i++){ scanf("%d",&s[i]); t+=s[i]; } g=t/n; h=t/n; for(i=0;i<n;i++){ r+=(s[i]-g)*(s[i]-g); e+=(s[i]-h)*(s[i]-h); } if(r>e)printf("%d\n",e); else printf("%d\n",r); return 0; }
main.c: In function 'main': main.c:5:9: error: 'I' undeclared (first use in this function) 5 | for(i=0,I<n,i++){ | ^ main.c:5:9: note: each undeclared identifier is reported only once for each function it appears in main.c:5:16: error: expected ';' before ')' token 5 | for(i=0,I<n,i++){ | ^ | ; main.c:5:16: error: expected expression before ')' token
s418874382
p04031
C
#include<stdio.h> int main(void){ int s[12],a[12]; int i,n,t=0,c=0,g,h,r=0,e=0; for(i=0,I<n,i++){ scanf("%d",&s[i]); t+=s[i]; } g=t/n; h=t/n; for(i=0;i<n;i++){ r+=(s[i]-g)*(s[i]-g); e+=(s[i]-h)*(s[i]-h); } if(r>e)printf("%d\n",e); else printf("%d\n",r); return 0; }
main.c: In function 'main': main.c:5:9: error: 'I' undeclared (first use in this function) 5 | for(i=0,I<n,i++){ | ^ main.c:5:9: note: each undeclared identifier is reported only once for each function it appears in main.c:5:16: error: expected ';' before ')' token 5 | for(i=0,I<n,i++){ | ^ | ; main.c:5:16: error: expected expression before ')' token
s182459012
p04031
Java
import java.util.*; import java.lang.Math; public class Main{ public static void main(String[] args){ Scanner x= new Scanner(System.in); int c= x.nextInt(); int[] arr = new int[c]; double a =0; for(int i =0;i<c;i++){ arr[i]=x.nextInt(); a += arr[i]; } int a1 = a/c; int a2 = a1 +1; int r1=0; for(int i =0;i<c;i++){ r1 += Math.pow(arr[i]-a1 , 2); } for(int i =0;i<c;i++){ r2 += Math.pow(arr[i]-a2 , 2); } System.out.prinln(Math.min(r1,r2)); } }
Main.java:15: error: incompatible types: possible lossy conversion from double to int int a1 = a/c; ^ Main.java:27: error: cannot find symbol r2 += Math.pow(arr[i]-a2 , 2); ^ symbol: variable r2 location: class Main Main.java:30: error: cannot find symbol System.out.prinln(Math.min(r1,r2)); ^ symbol: variable r2 location: class Main 3 errors
s209805321
p04031
C++
#define _CRT_SECURE_NO_WARNINGS #include <iostream> #include <iomanip> #include <sstream> #include <fstream> #include <string> #include <vector> #include <deque> #include <queue> #include <stack> #include <set> #include <map> #include <algorithm> #include <functional> #include <utility> #include <bitset> #include <cmath> #include <cstdlib> #include <ctime> #include <cstdio> using namespace std; int n, ave = 0; int a[110]; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; ave += a[i]; } ave /= n; int d, min = INT_MAX; for (int i = ave - 3; i <= ave + 3; ++i) { d = 0; for (int j = 0; j < n; ++j) d += (a[j] - i) * (a[j] - i); if (d < min) min = d; } cout << min << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:22: error: 'INT_MAX' was not declared in this scope 36 | int d, min = INT_MAX; | ^~~~~~~ a.cc:21:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 20 | #include <cstdio> +++ |+#include <climits> 21 |
s342518739
p04031
C++
n = int(raw_input()) a = map(int, raw_input().split()) sum = sum(a) if(sum >= 0): ave = int(float(sum) / n + 0.5) else: ave = int(float(sum) / n - 0.5) cost = 0 for item in a: cost += pow(abs(item - ave), 2) print cost,
a.cc:1:1: error: 'n' does not name a type 1 | n = int(raw_input()) | ^
s952491639
p04031
C++
#include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<bitset> #include<vector> #include<deque> #include<queue> #include<map> #include<set> #include<stack> #include<cmath> #include<iomanip> #include <functional> using namespace std; typedef long long ll; const int mod = 1000000007; const int INF = 1 << 28; const double EPS = 1e-10; //cout << fixed << std::setprecision(9) //memset(a, 0, sizeof(a)); //-------------------------- int main() { int n; int a[103]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; int ans = INT_MAX; for (int i = -100; i < 101; i++) { int sum = 0; for (int j = 0; j < n; j++) { sum += (i - a[j]) * (i - a[j]); } ans = std::min(ans, sum); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:33:19: error: 'INT_MAX' was not declared in this scope 33 | int ans = INT_MAX; | ^~~~~~~ a.cc:16:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 15 | #include <functional> +++ |+#include <climits> 16 | using namespace std;
s912129313
p04031
C
#include <iostream> using namespace std; int round(double); int main(){ int N; cin >> N; int n; int A=0,B=0; for(int i=0; i<N; i++){ cin >> n; A += n*n; B += n; } double x = (double)B/N; // cout << x << endl; // cout << round(x) << endl; int modify = round(x); cout << N*modify*modify - 2* modify * B + A << endl; return 0; } int round(double x){ double fraction = x - (int)x; if(fraction >= 0.5) return (int)x + 1; else return (int)x; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s661190802
p04031
C++
#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <ctime> #include <algorithm> #include <cstdlib> #include <utility> #include <vector> #include <iostream> #include <cstring> #include <set> #include <map> #include <string> namespace fastinput { /** Interface */ inline int readChar(); template <class T = int> inline T readInt(); template <class T> inline void writeInt(T x, char end = 0); inline void writeChar(int x); inline void writeWord(const char *s); /** Read */ static const int buf_size = 16384; inline int getChar() { static char buf[buf_size]; static int len = 0, pos = 0; if (pos == len) pos = 0, len = fread(buf, 1, buf_size, stdin); if (pos == len) return -1; return buf[pos++]; } inline int readChar() { int c = getChar(); while (c <= 32) c = getChar(); return c; } template <class T> inline T readInt() { int s = 1, c = readChar(); T x = 0; if (c == '-') s = -1, c = getChar(); while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar(); return s == 1 ? x : -x; } /** Write */ static int write_pos = 0; static char write_buf[buf_size]; inline void writeChar(int x) { if (write_pos == buf_size) fwrite(write_buf, 1, buf_size, stdout), write_pos = 0; write_buf[write_pos++] = x; } template <class T> inline void writeInt(T x, char end) { if (x < 0) writeChar('-'), x = -x; char s[24]; int n = 0; while (x || !n) s[n++] = '0' + x % 10, x /= 10; while (n--) writeChar(s[n]); if (end) writeChar(end); } inline void writeWord(const char *s) { while (*s) writeChar(*s++); } struct Flusher { ~Flusher() { if (write_pos) fwrite(write_buf, 1, write_pos, stdout), write_pos = 0; } } flusher; } using namespace fastinput; using namespace std; int main() { ::ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0); int n; cin >> n; vector <int> v(n); for (int i = 0; i < n; ++i) cin >> v[i]; int res = INT_MAX; for (int x = -100; x <= 100; ++x) { int cur = 0; for (int i = 0; i < n; ++i) { cur += abs(v[i] - x) * abs(v[i] - x); } res = min(res, cur); } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:106:19: error: 'INT_MAX' was not declared in this scope 106 | int res = INT_MAX; | ^~~~~~~ a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 11 | #include <map> +++ |+#include <climits> 12 | #include <string>
s211635907
p04032
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int n = s.size(); for(int i = 0; i < n; i++){ if(i < n-1 && s[i] == s[i+1]){ cout << i+1 << " " << i+2 << endl; return; }else if(i < n-2 && s[i] == s[i+2]){ cout << i+1 << " " << i+3 << endl; return; } } cout << "-1 -1" << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:7: error: return-statement with no value, in function returning 'int' [-fpermissive] 9 | return; | ^~~~~~ a.cc:12:7: error: return-statement with no value, in function returning 'int' [-fpermissive] 12 | return; | ^~~~~~
s338360490
p04032
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; for(int i = 0; i < s.size(); i++){ if(i < n-1 && s[i] == s[i+1]){ cout << i+1 << " " << i+2 << endl; return; }else if(i < n-2 && s[i] == s[i+2]){ cout << i+1 << " " << i+3 << endl; return; } } cout << "-1 -1" << endl; return 0; }
a.cc: In function 'int main()': a.cc:6:12: error: 'n' was not declared in this scope 6 | if(i < n-1 && s[i] == s[i+1]){ | ^ a.cc:8:7: error: return-statement with no value, in function returning 'int' [-fpermissive] 8 | return; | ^~~~~~ a.cc:11:7: error: return-statement with no value, in function returning 'int' [-fpermissive] 11 | return; | ^~~~~~
s314004337
p04032
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; string s; int n; int main() { cin >> s; n = s.size(); for (int i = 0; i < n - 1; ++i) for (int j = i + 1; j < i + 3 && j < n; ++j) if (s[j] == s[i]) { cout << i + 1 << ' ' << j + 1 < endl; return 0; } cout << "-1 -1" << endl; }
a.cc: In function 'int main()': a.cc:14:63: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 14 | cout << i + 1 << ' ' << j + 1 < endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:14:65: note: couldn't deduce template parameter '_Bi_iter' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:14:65: note: couldn't deduce template parameter '_Bi_iter' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:14:65: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 14 | cout << i + 1 << ' ' << j + 1 < endl; | ^~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Trai
s216138600
p04032
C++
# include <bits/stdc++.h> # define ll long long # define all(x) x.begin(), x.end() # define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) # define MOD 1000000007 using namespace std; int main(){ //fastio; vector<vector<int>> a(26); char tmp=getchar(); int n=0; while (tmp>='a'&&tmp<='z'){ a[tmp-'a'].push_back(n++); tmp=getchar(); } int x=-1,y=-1; bool found=false; for (auto poses:a){ sort(all(poses)); if (poses.size()<2) continue; for (int i=1;i<poses.size();i++){ int dis=poses[i]-poses[i-1]; if(dis==1) { x=poses[i-1];y=poses[i]; found=true; break; } else if(dis==2){ x=poses[i-2],y=poses[i]; found=true; break; } if (found) break; } cout<<x<<' '<<y<<'\n'; return 0; }
a.cc: In function 'int main()': a.cc:40:2: error: expected '}' at end of input 40 | } | ^ a.cc:9:11: note: to match this '{' 9 | int main(){ | ^
s826484452
p04032
C++
include <iostream> #include <string> using namespace std; typedef long long ll; int main(){ string S; cin >> S; for(ll i = 1; i < S.size(); i++){ if(S[i]==S[i-1]){ if(i==S.size() - 1){ cout << i - 1 << " " << i + 1 << endl; return 0; } else{ cout << i << " " << i + 1<< endl; return 0; } } } for(ll i = 2; i < S.size(); i++){ if(S[i]==S[i-2]){ cout << i - 1 << " " << i + 1 << endl; return 0; } } cout << -1 << " "<< -1 << endl; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/char_traits.h:50: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared 144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type 146 | static _GLIBCXX14_CONSTEXPR std::size_t | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared 150 | find(const char_type* __s, std::size_t __n, const char_type& __a); | ^~~ /usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared 153 | move(char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared 156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared 159 | assign(char_type* __s, std::size_t __n, char_type __a); | ^~~ /usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared 187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n) | ^~~ /usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)': /usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 189 | for (std::size_t __i = 0; __i < __n; ++__i) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:189:33: error: '__i' was not declared in this scope; did you mean '__n'? 189 | for (std::size_t __i = 0; __i < __n; ++__i) | ^~~ | __n /usr/include/c++/14/bits/char_traits.h: At global scope: /usr/include/c++/14/bits/char_traits.h:198:31: error: 'size_t' in namespace 'std' does not name a type 198 | _GLIBCXX14_CONSTEXPR std::size_t |
s641553500
p04032
C++
#include<bits/stdc++.h> using namespace std; int arr[1000 * 100 + 1][26]; vector<int > indexes[26]; int main() { string str; cin >> str; int n = str.length(); for(int i = 0; i < n; i++) { int curr = str[i] - 'a'; if(i > 0) { arr[i][curr] += (arr[i-1][curr] + 1); } else { arr[i][curr]++; } for(int k = indexes[curr].size() - 1; k >= 0; --k) { int it = indexes[k]; int len = i - it + 1; int totalChar = arr[i][curr] - arr[it][curr] + 1; if(totalChar >= len / 2) { cout << (it + 1) << " " << (i + 1) << endl; return 0; } } indexes[curr].push_back(i); } cout << "-1 -1" << endl; return 0; }
a.cc: In function 'int main()': a.cc:29:35: error: cannot convert 'std::vector<int>' to 'int' in initialization 29 | int it = indexes[k]; | ~~~~~~~~~^ | | | std::vector<int>
s657114051
p04032
C++
#include<bits/stdc++.h> using namespace std; int arr[1000 * 100 + 1][26]; vector<int > indexes[26]; int main() { string str; cin >> str; int n = str.length(); for(int i = 0; i < n; i++) { int curr = str[i] - 'a'; if(i > 0) { arr[i][curr] += (arr[i-1][curr] + 1); } else { arr[i][curr]++; } for(int k = indexes[curr].size() - 1; k >= 0; --k) { auto it = indexes[k]; int len = i - it + 1; int totalChar = arr[i][curr] - arr[it][curr] + 1; if(totalChar >= len / 2) { cout << (it + 1) << " " << (i + 1) << endl; return 0; } } indexes[curr].push_back(i); } cout << "-1 -1" << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:37: error: no match for 'operator-' (operand types are 'int' and 'std::vector<int>') 30 | int len = i - it + 1; | ~ ^ ~~ | | | | int std::vector<int> In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 30 | int len = i - it + 1; | ^~ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::complex<_Tp>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::complex<_Tp>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:30:39: note: 'std::vector<int>' is not derived from 'const std::complex<_Tp>' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:39: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:30:39: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::valarray<_Tp>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:30:39: note: mismatched types 'const std::valarray<_Tp>' and 'int' 30 | int len = i - it + 1; | ^~ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:30:39: note: 'std::vector<int>' is not derived from 'const std::valarray<_Tp>' 30 | int len = i - it + 1; | ^~ a.cc:31:59: error: no match for 'operator[]' (operand types are 'int [100001][26]' and 'std::vector<int>') 31 | int totalChar = arr[i][curr] - arr[it][curr] + 1; | ^ a.cc:35:45: error: no match for 'operator+' (operand types are 'std::vector<int>' and 'int') 35 | cout << (it + 1) << " " << (i + 1) << endl; |
s081606575
p04032
C++
const int N = 2e3 + 7, M = N * 3; int n; modint f[M][M<<1], ans; int main() { rd(n), rd(P), n *= 3; f[0][M] = 1; for (int i = 0; i < n; i++) for (int j = -i; j <= i; j++) { f[i+1][j+1+M] += f[i][j+M]; f[i+2][j-1+M] += f[i][j+M] * (i + 1); f[i+3][j+M] += f[i][j+M] * (i + 1) * (i + 2); } for (int j = 0; j <= n; j++) ans += f[n][j+M]; print(ans); return 0; }
a.cc:3:1: error: 'modint' does not name a type 3 | modint f[M][M<<1], ans; | ^~~~~~ a.cc: In function 'int main()': a.cc:5:9: error: 'rd' was not declared in this scope 5 | rd(n), rd(P), n *= 3; | ^~ a.cc:5:19: error: 'P' was not declared in this scope 5 | rd(n), rd(P), n *= 3; | ^ a.cc:6:9: error: 'f' was not declared in this scope 6 | f[0][M] = 1; | ^ a.cc:13:38: error: 'ans' was not declared in this scope 13 | for (int j = 0; j <= n; j++) ans += f[n][j+M]; | ^~~ a.cc:14:15: error: 'ans' was not declared in this scope 14 | print(ans); | ^~~ a.cc:14:9: error: 'print' was not declared in this scope; did you mean 'int'? 14 | print(ans); | ^~~~~ | int
s495447449
p04032
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<int> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); string s; cin >> s; if(s.length() == 2) { if(s[i] == s[i + 1]) cout << i + 1 << " " << i + 2 << endl; } else { for(int i = 0; i < s.length() - 2; i++) { if(s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]) { cout << i + 1 << " " << i + 3 << endl; return 0; } } } cout << "-1 -1" << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:22: error: 'i' was not declared in this scope 15 | if(s[i] == s[i + 1]) cout << i + 1 << " " << i + 2 << endl; | ^
s674989261
p04032
C++
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < n; ++i) using namespace std; typedef long long ll; typedef pair<int,int> P; const int INF=1001001001; int main(){ string s; cin>>s; int n; n=s.size(); vector<int>v(n); //bool check=false; ll ans=-1; if (n==2){ if (s[0]==s[1]){ cout<<0<<" "<<1; return 0; }else{ cout<<1-<<" "<<-1; return 0; } } for(int i=2;i<n;i++){ if (s[i]==s[i-1]){ cout<<i<<" "<<i+1; return 0; } if (s[i]==s[i-2]){ cout<<i-1<<" "<<i+1; return 0; } } cout<<-1<<" "<<-1; return 0; }
a.cc: In function 'int main()': a.cc:23:15: error: expected primary-expression before '<<' token 23 | cout<<1-<<" "<<-1; | ^~
s233291831
p04032
C++
#include <iostream> #include <stdio.h> #include <algorithm> #include <math.h> #include <list> #include <string> #include <map> #include <vector> #include <stack> #include <queue> #include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示 using namespace std; #define REPD(i, a, b) for (int i = (a); i < (b); ++i) #define REP(i, n) REPD(i, 0, n) typedef long long ll; #define fin(ans) cout << (ans) << '\n' /* */ int main() { string S; cin >> S; int l = S.length(); int st = -1,ed = -1; //DPクソもないけどoxoみたいな構造を探してやればいいらしい。そりゃそうだ if(l <= 2){ if(S[i] == S[i+1]){ cout << "1 2" << endl; }else{ cout << "-1 -1" << endl; } return 0; } REP(i,l-2){ //cout << S[i] << S[i + 1] << S[i + 2] << endl; if (S[i] == S[i + 1] || S[i] == S[i + 2] || S[i + 1] == S[i + 2]) { st = i+1; ed = i+3; break; } } cout << st << " " << ed << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:14: error: 'i' was not declared in this scope 28 | if(S[i] == S[i+1]){ | ^
s102340214
p04032
C++
#include<bits/stdc++.h> using namespace std; int main() { char a[100005]; gets(a); int n=strlen(a); int p=0; for(int i=0; i<n-2; i++) { if(a[i]==a[i+1] || a[i]==a[i+2] || a[i+1]==a[i+2]) { p=i+1; break; } } if(p != 0) printf("%d %d\n",p,p+2); else printf("-1 -1\n"); return 0; }
a.cc: In function 'int main()': a.cc:7:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 7 | gets(a); | ^~~~ | getw
s462350351
p04032
C++
#include"bits/stdc++.h" #include <string> using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; #define int ll const double PI = acos(-1.0); const int MOD = (int)pow(10, 9) + 7; #define YES(n) cout << ((n) ? "YES" : "NO") << endl; #define Yes(n) cout << ((n) ? "Yes" : "No") << endl; #define all(v) v.begin(), v.end() #define Ini(a) ll a; cin >> a; #define Ind(a) double a; cin >> a; #define Ins(a) string a; cin >> a; #define Inv(a,type,n) vector<type> a;a.reserve(n);for(ll i=0;i<n;++i){type tmp;cin>>tmp;a.emplace_back(tmp);} #define Out(Bool, T, F) cout << ((Bool) ? T : F) << endl; #define Sort(v) sort(all(v)); #define Rsort(v,type) sort(all(v),greater<type>()); ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } inline void finish() { cout << -1 << endl; exit(0); } template <typename T> inline void debug(vector<T> v) { if (v.size() == 0) { cout << "[]" << endl; return; } cout << "["; for (size_t i = 0; i < v.size() - 1; ++i) { cout << v[i] << ", "; } cout << v[v.size() - 1] << "]" << endl; } template <typename T, typename U> inline void debug(map<T, U> m) { if (m.size() == 0) { cout << "[]" << endl; return; } for (pair<T, U> p : m) { cout << "[" << p.first << ", " << p.second << "], "; } } class Pos { public: double x, y; Pos(double x, double y) { this->x = x; this->y = y; } Pos() { x = 0.0; y = 0.0; } bool isSamePos(Pos pos1, Pos pos2) { if (pos1.x == pos2.x && pos1.y == pos2.y) { return true; } return false; } }; class BitFlag { private: ull m_bitFlag; int m_size; ull m_upper; vector<ull> m_exponentiation; public: BitFlag(ull n) { if (n > 64) { throw std::exception(("ビットフラグは64bitまでしか対応してない 指定された数=" + to_string(n)).c_str()); } m_bitFlag = 0; m_size = n; m_upper = (int)pow(2, n) - 1; m_exponentiation.resize(n); for (ull i = 0; i < n; ++i) { m_exponentiation[i] = (ll)pow(2, i); } } void Set(ull n) { if (n > m_upper) { throw std::exception((to_string(n) + "は" + to_string(m_size) + "bitでは表現できない").c_str()); } m_bitFlag = n; } void Set(string s) { if (s.size() > (size_t)m_size) { throw std::exception(("\"" + s + "\"が" + to_string(m_size) + "bitよりも長いので無理").c_str()); } int i = s.size() - 1; m_bitFlag = 0; for (const char c : s) { if (c != '0') { m_bitFlag += m_exponentiation[i]; } i--; } } ll size() { return m_size; } bool operator[](int i) { if (i >= m_size) { throw std::exception(("指定した値が領域を超えている index=" + to_string(i) + " size=" + to_string(m_size)).c_str()); } return (m_bitFlag & m_exponentiation[i]) == 0 ? false : true; } BitFlag& operator++() { m_bitFlag++; if (m_bitFlag > m_upper) { m_bitFlag = 0; } return *this; } BitFlag operator++(signed) { BitFlag b = *this; m_bitFlag++; if (m_bitFlag > m_upper) { m_bitFlag = 0; } return b; } BitFlag& operator+=(const int n) { this->m_bitFlag += n; return *this; } BitFlag& operator-=(const int n) { this->m_bitFlag -= n; return *this; } BitFlag& operator+=(const BitFlag& b) { this->m_bitFlag += b.m_bitFlag; return *this; } BitFlag& operator-=(const BitFlag& b) { this->m_bitFlag -= b.m_bitFlag; return *this; } BitFlag operator+(int n) { m_bitFlag += n; return *this; } BitFlag operator-(int n) { m_bitFlag -= n; return *this; } BitFlag operator+(BitFlag& b) { this->m_bitFlag += b.m_bitFlag; return *this; } BitFlag operator-(BitFlag& b) { this->m_bitFlag -= b.m_bitFlag; return *this; } bool operator==(BitFlag& comp) { return comp.m_bitFlag == this->m_bitFlag ? true : false; } bool operator!=(BitFlag& comp) { return !(*this == comp); } friend ostream& operator<<(ostream& o, const BitFlag& b); }; ostream& operator<<(ostream& o, const BitFlag& b) { for (ll i = 0; i < b.m_size; ++i) { cout << ((b.m_bitFlag & b.m_exponentiation[i]) == 0 ? false : true); } return o; } class Mod { public: static inline ll Add(ll a, ll b) { return (a + b) % MOD; } static inline ll Sub(ll a, ll b) { ll ans = (a - b) % MOD; return (ans < 0) ? (ans + MOD) : ans; } static inline ll Mul(ll a, ll b) { return (a * b) % MOD; } static inline ll Div(ll a, ll b) { return (a % MOD) * modinv(b, MOD) % MOD; } }; inline double distance(Pos p1, Pos p2) { return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2)); } inline ull Kaijo(int n) { ull ans = 1; for (int i = 2; i <= n; ++i) { ans *= i; } return ans; } template <typename T> inline int GetKeta(T num) { return to_string(num).length(); } void Main(); inline void DebugMain() { while (true) { Main(); cout << endl; } } signed main() { bool debug = false; cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); if (debug) { cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl; } try { (debug) ? DebugMain() : Main(); } catch (exception& e) { cout << e.what() << endl; } return 0; } template <typename T> inline bool isExistArray(vector<T>& v, T& str) { if (v.size() == 0) { return false; } for (string& s : v) { if (s == str) { return true; } } return false; } inline int ctoi(char c) { return (int)c - 48; } inline int find(vector<int>& v, int n) { for (size_t i = 0; i < v.size(); ++i) { if (v[i] == n) { return i; } } return -1; } inline bool isSameArray(vector<int>& v1, vector<int>& v2) { for (size_t i = 0; i < v1.size(); ++i) { if (v1[i] != v2[i]) { return false; } } return true; } inline bool isSeisu(double n) { if (std::floor(n) == n) { return true; } return false; } int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } } int lcm(int a, int b) { return a * b / gcd(a, b); } inline ll Kiriage(ll a, ll b) { return (a + (b - 1)) / b; } template<class T> inline void container_sort(std::vector<T>& v) { std::sort(all(v)); } template<class T> inline void container_sort(std::list<T>& v) { v.sort(); } template<class T> inline void Unique(T& v) { container_sort(v); v.erase( std::unique( v.begin(), v.end()), v.end() ); } inline vector<bool> GetPrimeTable(int n) { vector<bool> primeTable(n + 1, true); int sqr = (int)sqrt(n); primeTable[0] = false; //0は素数じゃない primeTable[1] = false; //1は素数じゃない for (int i = 2; i <= sqr; ++i) { if (primeTable[i]) { for (size_t j = i + i; j < primeTable.size(); j += i) { primeTable[j] = false; } } } return primeTable; } inline vector<ll> GetPrimeNumbers(int n) { vector<bool> primeTable = GetPrimeTable(n); vector<ll> result; if (n < 2) { result; } result.reserve(n / 2); for (size_t i = 0; i < primeTable.size(); ++i) { if (primeTable[i]) { result.push_back(i); } } result.shrink_to_fit(); return result; } inline map<ll, ll> PrimeFact(ull n) { ull num = 2; map<ll, ll> result; while(true) { if (n % num == 0) { if (result.count(num) == 0) { result.insert(pair<ll, ll>{num, 1}); } else { result[num]++; } n /= num; } else { if (++num > sqrt(n)) { if (result.size() == 0 || n != 1) { result.insert(pair<ll, ll>{n, 1}); } return result; } } } } void recursive_comb(int* indexes, int s, int rest, std::function<void(int*)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } //foreach_comb(n, k, [](int*indexes){ //}); // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, std::function<void(int*)> f) { int* indexes = new int[k]; recursive_comb(indexes, n - 1, k, f); } inline void Main() { Ins(s); for (int i = 0; i < s.size() - 2; ++i) { if (s[i] == s[i + 1]) { cout << i + 1 << " " << i + 2; return; } if (s[i] == s[i + 2]) { cout << i + 1 << " " << i + 3; return; } } cout << "-1 -1"; }
a.cc: In constructor 'BitFlag::BitFlag(ull)': a.cc:96:126: error: no matching function for call to 'std::exception::exception(const char*)' 96 | throw std::exception(("ビットフラグは64bitまでしか対応してない 指定された数=" + to_string(n)).c_str()); | ^ In file included from /usr/include/c++/14/new:41, from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided a.cc: In member function 'void BitFlag::Set(ull)': a.cc:110:119: error: no matching function for call to 'std::exception::exception(const char*)' 110 | throw std::exception((to_string(n) + "は" + to_string(m_size) + "bitでは表現できない").c_str()); | ^ /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided a.cc: In member function 'void BitFlag::Set(std::string)': a.cc:117:119: error: no matching function for call to 'std::exception::exception(const char*)' 117 | throw std::exception(("\"" + s + "\"が" + to_string(m_size) + "bitよりも長いので無理").c_str()); | ^ /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided a.cc: In member function 'bool BitFlag::operator[](ll)': a.cc:135:139: error: no matching function for call to 'std::exception::exception(const char*)' 135 | throw std::exception(("指定した値が領域を超えている index=" + to_string(i) + " size=" + to_string(m_size)).c_str()); | ^ /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided
s767677953
p04032
C++
#include"bits/stdc++.h" #include <string> using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; #define int ll const double PI = acos(-1.0); const int MOD = (int)pow(10, 9) + 7; #define YES(n) cout << ((n) ? "YES" : "NO") << endl; #define Yes(n) cout << ((n) ? "Yes" : "No") << endl; #define all(v) v.begin(), v.end() #define Ini(a) ll a; cin >> a; #define Ind(a) double a; cin >> a; #define Ins(a) string a; cin >> a; #define Inv(a,type,n) vector<type> a;a.reserve(n);for(ll i=0;i<n;++i){type tmp;cin>>tmp;a.emplace_back(tmp);} #define Out(Bool, T, F) cout << ((Bool) ? T : F) << endl; #define Sort(v) sort(all(v)); #define Rsort(v,type) sort(all(v),greater<type>()); ll modinv(ll a, ll m) { ll b = m, u = 1, v = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } inline void finish() { cout << -1 << endl; exit(0); } template <typename T> inline void debug(vector<T> v) { if (v.size() == 0) { cout << "[]" << endl; return; } cout << "["; for (size_t i = 0; i < v.size() - 1; ++i) { cout << v[i] << ", "; } cout << v[v.size() - 1] << "]" << endl; } template <typename T, typename U> inline void debug(map<T, U> m) { if (m.size() == 0) { cout << "[]" << endl; return; } for (pair<T, U> p : m) { cout << "[" << p.first << ", " << p.second << "], "; } } class Pos { public: double x, y; Pos(double x, double y) { this->x = x; this->y = y; } Pos() { x = 0.0; y = 0.0; } bool isSamePos(Pos pos1, Pos pos2) { if (pos1.x == pos2.x && pos1.y == pos2.y) { return true; } return false; } }; class BitFlag { private: ull m_bitFlag; int m_size; ull m_upper; vector<ull> m_exponentiation; public: BitFlag(ull n) { if (n > 64) { throw exception(("ビットフラグは64bitまでしか対応してない 指定された数=" + to_string(n)).c_str()); } m_bitFlag = 0; m_size = n; m_upper = (int)pow(2, n) - 1; m_exponentiation.resize(n); for (ull i = 0; i < n; ++i) { m_exponentiation[i] = (ll)pow(2, i); } } void Set(ull n) { if (n > m_upper) { throw exception((to_string(n) + "は" + to_string(m_size) + "bitでは表現できない").c_str()); } m_bitFlag = n; } void Set(string s) { if (s.size() > (size_t)m_size) { throw exception(("\"" + s + "\"が" + to_string(m_size) + "bitよりも長いので無理").c_str()); } int i = s.size() - 1; m_bitFlag = 0; for (const char c : s) { if (c != '0') { m_bitFlag += m_exponentiation[i]; } i--; } } ll size() { return m_size; } bool operator[](int i) { if (i >= m_size) { throw exception(("指定した値が領域を超えている index=" + to_string(i) + " size=" + to_string(m_size)).c_str()); } return (m_bitFlag & m_exponentiation[i]) == 0 ? false : true; } BitFlag& operator++() { m_bitFlag++; if (m_bitFlag > m_upper) { m_bitFlag = 0; } return *this; } BitFlag operator++(signed) { BitFlag b = *this; m_bitFlag++; if (m_bitFlag > m_upper) { m_bitFlag = 0; } return b; } BitFlag& operator+=(const int n) { this->m_bitFlag += n; return *this; } BitFlag& operator-=(const int n) { this->m_bitFlag -= n; return *this; } BitFlag& operator+=(const BitFlag& b) { this->m_bitFlag += b.m_bitFlag; return *this; } BitFlag& operator-=(const BitFlag& b) { this->m_bitFlag -= b.m_bitFlag; return *this; } BitFlag operator+(int n) { m_bitFlag += n; return *this; } BitFlag operator-(int n) { m_bitFlag -= n; return *this; } BitFlag operator+(BitFlag& b) { this->m_bitFlag += b.m_bitFlag; return *this; } BitFlag operator-(BitFlag& b) { this->m_bitFlag -= b.m_bitFlag; return *this; } bool operator==(BitFlag& comp) { return comp.m_bitFlag == this->m_bitFlag ? true : false; } bool operator!=(BitFlag& comp) { return !(*this == comp); } friend ostream& operator<<(ostream& o, const BitFlag& b); }; ostream& operator<<(ostream& o, const BitFlag& b) { for (ll i = 0; i < b.m_size; ++i) { cout << ((b.m_bitFlag & b.m_exponentiation[i]) == 0 ? false : true); } return o; } class Mod { public: static inline ll Add(ll a, ll b) { return (a + b) % MOD; } static inline ll Sub(ll a, ll b) { ll ans = (a - b) % MOD; return (ans < 0) ? (ans + MOD) : ans; } static inline ll Mul(ll a, ll b) { return (a * b) % MOD; } static inline ll Div(ll a, ll b) { return (a % MOD) * modinv(b, MOD) % MOD; } }; inline double distance(Pos p1, Pos p2) { return sqrt(pow(p1.x - p2.x, 2) + pow(p1.y - p2.y, 2)); } inline ull Kaijo(int n) { ull ans = 1; for (int i = 2; i <= n; ++i) { ans *= i; } return ans; } template <typename T> inline int GetKeta(T num) { return to_string(num).length(); } void Main(); inline void DebugMain() { while (true) { Main(); cout << endl; } } signed main() { bool debug = false; cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << fixed << setprecision(15); if (debug) { cout << "\x1b[41m" << "Debug Mode このまま提出すると死" << endl; } try { (debug) ? DebugMain() : Main(); } catch (exception& e) { cout << e.what() << endl; } return 0; } template <typename T> inline bool isExistArray(vector<T>& v, T& str) { if (v.size() == 0) { return false; } for (string& s : v) { if (s == str) { return true; } } return false; } inline int ctoi(char c) { return (int)c - 48; } inline int find(vector<int>& v, int n) { for (size_t i = 0; i < v.size(); ++i) { if (v[i] == n) { return i; } } return -1; } inline bool isSameArray(vector<int>& v1, vector<int>& v2) { for (size_t i = 0; i < v1.size(); ++i) { if (v1[i] != v2[i]) { return false; } } return true; } inline bool isSeisu(double n) { if (std::floor(n) == n) { return true; } return false; } int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } } int lcm(int a, int b) { return a * b / gcd(a, b); } inline ll Kiriage(ll a, ll b) { return (a + (b - 1)) / b; } template<class T> inline void container_sort(std::vector<T>& v) { std::sort(all(v)); } template<class T> inline void container_sort(std::list<T>& v) { v.sort(); } template<class T> inline void Unique(T& v) { container_sort(v); v.erase( std::unique( v.begin(), v.end()), v.end() ); } inline vector<bool> GetPrimeTable(int n) { vector<bool> primeTable(n + 1, true); int sqr = (int)sqrt(n); primeTable[0] = false; //0は素数じゃない primeTable[1] = false; //1は素数じゃない for (int i = 2; i <= sqr; ++i) { if (primeTable[i]) { for (size_t j = i + i; j < primeTable.size(); j += i) { primeTable[j] = false; } } } return primeTable; } inline vector<ll> GetPrimeNumbers(int n) { vector<bool> primeTable = GetPrimeTable(n); vector<ll> result; if (n < 2) { result; } result.reserve(n / 2); for (size_t i = 0; i < primeTable.size(); ++i) { if (primeTable[i]) { result.push_back(i); } } result.shrink_to_fit(); return result; } inline map<ll, ll> PrimeFact(ull n) { ull num = 2; map<ll, ll> result; while(true) { if (n % num == 0) { if (result.count(num) == 0) { result.insert(pair<ll, ll>{num, 1}); } else { result[num]++; } n /= num; } else { if (++num > sqrt(n)) { if (result.size() == 0 || n != 1) { result.insert(pair<ll, ll>{n, 1}); } return result; } } } } void recursive_comb(int* indexes, int s, int rest, std::function<void(int*)> f) { if (rest == 0) { f(indexes); } else { if (s < 0) return; recursive_comb(indexes, s - 1, rest, f); indexes[rest - 1] = s; recursive_comb(indexes, s - 1, rest - 1, f); } } //foreach_comb(n, k, [](int*indexes){ //}); // nCkの組み合わせに対して処理を実行する void foreach_comb(int n, int k, std::function<void(int*)> f) { int* indexes = new int[k]; recursive_comb(indexes, n - 1, k, f); } inline void Main() { Ins(s); for (int i = 0; i < s.size() - 2; ++i) { if (s[i] == s[i + 1]) { cout << i + 1 << " " << i + 2; return; } if (s[i] == s[i + 2]) { cout << i + 1 << " " << i + 3; return; } } cout << "-1 -1"; }
a.cc: In constructor 'BitFlag::BitFlag(ull)': a.cc:96:121: error: no matching function for call to 'std::exception::exception(const char*)' 96 | throw exception(("ビットフラグは64bitまでしか対応してない 指定された数=" + to_string(n)).c_str()); | ^ In file included from /usr/include/c++/14/new:41, from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided a.cc: In member function 'void BitFlag::Set(ull)': a.cc:110:114: error: no matching function for call to 'std::exception::exception(const char*)' 110 | throw exception((to_string(n) + "は" + to_string(m_size) + "bitでは表現できない").c_str()); | ^ /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided a.cc: In member function 'void BitFlag::Set(std::string)': a.cc:117:114: error: no matching function for call to 'std::exception::exception(const char*)' 117 | throw exception(("\"" + s + "\"が" + to_string(m_size) + "bitよりも長いので無理").c_str()); | ^ /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided a.cc: In member function 'bool BitFlag::operator[](ll)': a.cc:135:134: error: no matching function for call to 'std::exception::exception(const char*)' 135 | throw exception(("指定した値が領域を超えている index=" + to_string(i) + " size=" + to_string(m_size)).c_str()); | ^ /usr/include/c++/14/bits/exception.h:67:5: note: candidate: 'constexpr std::exception::exception(std::exception&&)' 67 | exception(exception&&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:67:15: note: no known conversion for argument 1 from 'const char*' to 'std::exception&&' 67 | exception(exception&&) = default; | ^~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:5: note: candidate: 'constexpr std::exception::exception(const std::exception&)' 65 | exception(const exception&) = default; | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:65:15: note: no known conversion for argument 1 from 'const char*' to 'const std::exception&' 65 | exception(const exception&) = default; | ^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate: 'std::exception::exception()' 62 | exception() _GLIBCXX_NOTHROW { } | ^~~~~~~~~ /usr/include/c++/14/bits/exception.h:62:5: note: candidate expects 0 arguments, 1 provided
s977112311
p04032
C
#include<stdio.h> int main(){ char s[100001] = {'\0'}; scanf("%s", s); int size, i, flag; flag = -1; int a[26] = {0}; for(i = 0; s[i+1] != '\0'; i++){ if(s[i] == s[i+1]) break; if(s[i+2] == '\0') flag++; }; for(i = 0; s[i+2] != '\0'; i++){ if(s[i] == s[i+2]) break; if(s[i+3] == '\0') flag++; }; if(flag == 1){ printf("-1 -1\n") }else{ }; return 0; }
main.c: In function 'main': main.c:18:34: error: expected ';' before '}' token 18 | printf("-1 -1\n") | ^ | ; 19 | }else{ | ~
s302732150
p04032
C++
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const long long INF= 1e+18+1; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll> >vvl; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> T; const ll MOD=1000000007LL; string abc="abcdefghijklmnopqrstuvwxyz"; string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main(){ string s;cin>>s; rep(i,n-1){ if(s[i]==s[i+1]){ cout<<i+1<<" "<<i+2<<endl; return 0; } } rep(i,n-2){ if(s[i]==s[i+2]){ cout<<i+1<<" "<<i+3<<endl; return 0; } } cout<<-1<<" "<<-1<<endl; }
a.cc: In function 'int main()': a.cc:17:9: error: 'n' was not declared in this scope 17 | rep(i,n-1){ | ^ a.cc:5:43: note: in definition of macro 'rep' 5 | #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) | ^ a.cc:23:9: error: 'n' was not declared in this scope 23 | rep(i,n-2){ | ^ a.cc:5:43: note: in definition of macro 'rep' 5 | #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) | ^
s677140116
p04032
C++
#include<bits/stdc++.h> using namespace std; int main() { while(t--) { string s; cin>>s; int flag = 1; for(int i=0;i<s.length()-1;i++) { if(s[i]==s[i+1]) { cout<<i+1<<" "<<i+2<<endl; flag = 0; break; } else if((i<s.length()-2)&&(s[i]==s[i+2])) { cout<<i+1<<" "<<i+3<<endl; flag = 0; break; } } if(flag==1) { cout<<-1<<" "<<-1<<endl; } } }
a.cc: In function 'int main()': a.cc:5:11: error: 't' was not declared in this scope; did you mean 'tm'? 5 | while(t--) | ^ | tm
s292542064
p04032
C++
int main(){ string s; cin >> s; if (s.size()==2){ if (s.at(0)==s.at(1)){ cout << 1 << " " << 2 << endl; } else { cout << -1 << " " << -1 << endl; } return 0; } for (int i=0; i<s.size()-2; i++){ if (s.at(i)==s.at(i+1) || s.at(i+1)==s.at(i+2) || s.at(i+2)==s.at(i)){ cout << i+1 << " " << i+3 << endl; return 0; } } cout << -1 << " " << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:2:5: error: 'string' was not declared in this scope 2 | string s; | ^~~~~~ a.cc:3:5: error: 'cin' was not declared in this scope 3 | cin >> s; | ^~~ a.cc:3:12: error: 's' was not declared in this scope 3 | cin >> s; | ^ a.cc:6:13: error: 'cout' was not declared in this scope 6 | cout << 1 << " " << 2 << endl; | ^~~~ a.cc:6:38: error: 'endl' was not declared in this scope 6 | cout << 1 << " " << 2 << endl; | ^~~~ a.cc:8:13: error: 'cout' was not declared in this scope 8 | cout << -1 << " " << -1 << endl; | ^~~~ a.cc:8:40: error: 'endl' was not declared in this scope 8 | cout << -1 << " " << -1 << endl; | ^~~~ a.cc:14:13: error: 'cout' was not declared in this scope 14 | cout << i+1 << " " << i+3 << endl; | ^~~~ a.cc:14:42: error: 'endl' was not declared in this scope 14 | cout << i+1 << " " << i+3 << endl; | ^~~~ a.cc:18:5: error: 'cout' was not declared in this scope 18 | cout << -1 << " " << -1 << endl; | ^~~~ a.cc:18:32: error: 'endl' was not declared in this scope 18 | cout << -1 << " " << -1 << endl; | ^~~~
s864252882
p04032
C++
#include <iostream> int main() { string s; std::cin >> s; int i; for (i = 0; i < s.size() - 2; i++) { if (s[i] == s[i + 1] || s[i] == s[i + 2]) { break; } } if (i == s.size() - 2) std::cout << -1 << " " << -1; else std::cout << i << " " << i + 2; return 0; }
a.cc: In function 'int main()': a.cc:5:5: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:5:5: note: suggested alternatives: In file included from /usr/include/c++/14/iosfwd:41, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ In file included 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: /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:6:17: error: 's' was not declared in this scope 6 | std::cin >> s; | ^
s798071227
p04032
C++
#include <iostream> int main() { string s; std::cin >> s; int i; for (i = 0; i < s.size() - 2; i++) { if (s[i] == s[i + 1] || s[i] == s[i + 2]) { break; } } if (i == s.size() - 2) std::cout << -1 << " " << -1; else std::cout << i << " " << i + 2; return 0; }
a.cc: In function 'int main()': a.cc:5:5: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:5:5: note: suggested alternatives: In file included from /usr/include/c++/14/iosfwd:41, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ In file included 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: /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:6:17: error: 's' was not declared in this scope 6 | std::cin >> s; | ^
s337024514
p04032
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; for(int i = 1; i < s.size(); ++i) { if(s[i] == s[i-1]){ cout << i << " " << i+1 << "\n"; return 0; } } if(s.size() >= 3){ for(int i = 2; i < n; ++i){ if(s[i] == s[i-2]){ cout << i-1 << " " << i+1 << "\n"; return 0; } } } cout << "-1 -1\n"; }
a.cc: In function 'int main()': a.cc:17:28: error: 'n' was not declared in this scope 17 | for(int i = 2; i < n; ++i){ | ^
s516231543
p04032
Java
public class Main { public static void main(String[] args) { Scanner scn = new Scanner(System.in); String n = scn.next(); boolean feka = false; int nigger1=-1; int nigger2=-1; for(int i = 0;i<n.length()-2;i++) { if(n.charAt(i)==n.charAt(i+2)) { feka = true; nigger1=i+1; nigger2=i+3; break; } if(n.charAt(i)==n.charAt(i+1)) { feka = true; nigger1=i+1; nigger2=i+2; break; } } if(feka) { System.out.println(nigger1+" "+nigger2); }else System.out.println(nigger1+" "+nigger2); scn.close(); } }
Main.java:3: error: cannot find symbol Scanner scn = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner scn = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s125230705
p04032
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int n = s.length(); for(int i=0;i<n-3;i++){ if(s[i]==s[i+1]){ if(s[i]==s[i+3]){ cout << i+1 << " " << i+4 << endl; return 0; } else if(s[i]==s[i+2]){ cout << i+1 << " " << i+4 << endl; return 0; } } } if(n == 2 && s[0] == s[1]){ cout << 1 << " " << 2 << endl; return 0; } if(n==3 && s[0]== s[1] || s[1] == s[2]){ cout << 1 << " " << 3 << endl; return 0; } cout << "-1 -1" << endl; } #include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; int n = s.length(); if(s[n-1]==s[n]){ cout << n-1 << " " << n << endl; return 0; } for(int i=0;i<n-2;i++){ if(s[i]==s[i+1]){ cout << i+1 << " " << i+2 << endl; return 0; } } cout << "-1 -1" << endl; }
a.cc:38:5: error: redefinition of 'int main()' 38 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~
s250941307
p04032
C++
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; int idx[27], pre[27]; int main() { string s; cin>>s; int n =s.size(); vector<int> ans={-1, -1}; for (int i = 0; i < 26; ++i) { int minv1 = 0; int minv2 = INT_MAX; int idx1= 0; int idx2=0; int sum=0; int tmp=2*0-1; if (s[0] == 'a' + i) { tmp=2 * 1-1; sum++; } // if (tmp < minv1) { // minv2 = minv1; // idx2=idx1; // minv1 = tmp; // idx1 = 1; // } else if (tmp >= minv1 && tmp < minv2) { // minv2 = tmp; // idx2 = 1; // } for (int j = 2; j <= n; ++j) { if (s[j-1] == 'a' + i) { sum++; } if (2 * sum - j > minv1 && j-idx1 >= 2) { ans[0] = idx1+1; ans[1] = j; break; } else if (2 * sum - j > minv2 && j - idx2 >= 2) { ans[0] = idx2+1; ans[1] = j; break; } if (tmp < minv1) { minv2 = minv1; idx2=idx1; minv1 = tmp; idx1 = j-1; } else if (tmp >= minv1 && tmp < minv2) { minv2 = tmp; idx2 = j-1; } tmp = 2 *sum-j; } if (ans[0] >= 0) break; //{cout<<i<<endl; break;} } cout<<ans[0]<<" "<<ans[1]<<endl; // for (int i= 0; i < 26; ++i) { // idx[i] = 0; // pre[i] = 0; // int tmp = 0; // int sum=0; // if (s[0] == 'a' + i) { // tmp = 2 * 1 - 1; // sum++; // } else { // tmp = 2 * 0 - 1; // } // for (int j = 2; j <= n; ++j) { // if (s[j-1] == 'a' + i) { // sum++; // if (2*sum - j > pre[i]) { // ans[1] = j; // ans[0] = idx[i]+1; // break; // } // if (tmp < pre[i]) { // pre[i] = tmp; // idx[i] = j-1; // } // tmp = 2*sum - i; // } // } // if (ans[0] >= 0) break; // } // if (ans[0] < 0) cout<<"-1 -1"<<endl; // else cout<<ans[0]<<" "<<ans[1]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:15:17: error: 'INT_MAX' was not declared in this scope 15 | int minv2 = INT_MAX; | ^~~~~~~ a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include <algorithm> +++ |+#include <climits> 6 | using namespace std;
s498719453
p04032
C++
import java.io.BufferedReader; import java.io.InputStreamReader; class Main { public static void main(String[] args) throws java.lang.Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); Solver s = new Solver(); System.out.print(s.solve(br.readLine())); } } class Solver { String solve(String s) { for (int length = 2; length <= 3; length++) { for (int i = 0; i < s.length() + 1 - length; i++) { if (s.charAt(i) == s.charAt(i + length - 1)) { return "" + i + " " + (i + length - 1); } } } return "-1 -1"; } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.io.BufferedReader; | ^~~~~~ 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.io.InputStreamReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:15: error: expected ':' before 'static' 6 | public static void main(String[] args) throws java.lang.Exception { | ^~~~~~~ | : a.cc:6:33: error: 'String' has not been declared 6 | public static void main(String[] args) throws java.lang.Exception { | ^~~~~~ a.cc:6:42: error: expected ',' or '...' before 'args' 6 | public static void main(String[] args) throws java.lang.Exception { | ^~~~ a.cc:6:46: error: expected ';' at end of member declaration 6 | public static void main(String[] args) throws java.lang.Exception { | ^ | ; a.cc:6:48: error: 'throws' does not name a type 6 | public static void main(String[] args) throws java.lang.Exception { | ^~~~~~ a.cc:14:2: error: expected ';' after class definition 14 | } | ^ | ; a.cc:18:9: error: 'String' does not name a type 18 | String solve(String s) { | ^~~~~~ a.cc:30:2: error: expected ';' after class definition 30 | } | ^ | ;
s808310926
p04032
C++
#include<iostream> #include<string> using namespace std; int beki(int a,int b){ int ans=1; for(int i=0;i<b;i++){ ans=ans*a; } return ans; } int main(){ string a; cin>>a; int t=a.length(); for(int i-0;i<t-2;i++){ if(a[i]==a[i+1]){cout<<i<<" "<<i+1<<endl;return 0;} if(a[i]==a[i+2]){cout<<i<<" "<<i+2<<endl;return 0;} } if(a[t-2]==a[t-1]){cout<<t-2<<" "<<t-1<<endl;return 0;} cout<<-1<<" "<<-1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:10: error: expected ';' before '-' token 16 | for(int i-0;i<t-2;i++){ | ^ | ; a.cc:16:18: error: expected ')' before ';' token 16 | for(int i-0;i<t-2;i++){ | ~ ^ | ) a.cc:16:19: error: 'i' was not declared in this scope 16 | for(int i-0;i<t-2;i++){ | ^
s247393616
p04032
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ string s; cin>>s; int len=s.length(); int index=-1; for(int i=0;i<len-1;i++){ if(s[i]==s[i+1]){ index=i; break; } } if(index!=-1) cout<<index+1<<" "<<index+2; else{ for(int i=1;i<len-1;i++){ if(s[i-1]==s[i] && s[i]==s[i+1]){ index=i; break; } } if(index==-1)cout<<"-1 -1"; else cout<<i<<" "<<i+2; } }
a.cc: In function 'int main()': a.cc:25:20: error: 'i' was not declared in this scope 25 | else cout<<i<<" "<<i+2; | ^
s461398198
p04032
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ string s; cin>>s; int len=s.length(); int index=-1; for(int i=0;i<len-1;i++){ if(s[i]==s[i+1]){ index=i; break; } } if(index==-1)cout<<"-1 -1"; else cout<<i+1<<" "<<i+2; }
a.cc: In function 'int main()': a.cc:16:16: error: 'i' was not declared in this scope 16 | else cout<<i+1<<" "<<i+2; | ^
s113726470
p04032
C++
#include <bits/stdc++.h> using namespace std; long long m=1e9+7; long long fact[1000001],inv[1000001]; long long modRecursive(long long a,long long b,long long c) { if(b == 0) return 1; if(b%2 ==0) return modRecursive((a*a)%c,b/2,c); else return ((a%c)*(modRecursive((a*a)%c,b/2,c)))%c; } int main() { int main() { string S; cin >> S; for(int i = 0; i + 1 < S.size(); i++) { if(S[i] == S[i + 1]) { cout << i + 1 << " " << i + 2; return 0; } if(i + 2 < S.size() && S[i] == S[i + 2]) { cout << i + 1 << " " << i + 3; return 0; } } cout << "-1 -1"; return 0; } }
a.cc: In function 'int main()': a.cc:15:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 15 | int main() | ^~ a.cc:15:13: note: remove parentheses to default-initialize a variable 15 | int main() | ^~ | -- a.cc:15:13: note: or replace parentheses with braces to value-initialize a variable a.cc:16:1: error: a function-definition is not allowed here before '{' token 16 | { | ^
s189953550
p04032
C++
include<iostream> #include<string> #include<vector> #include<algorithm> #include<set> using namespace std; // cin>>n>>k; // cout<<n<<k<<endl; //string S[100]; int main(){ string moji;cin>>moji; bool flag=false; if (moji.size()==2){ if (moji[0]==moji[1]){ cout<<"1 2"<<endl; flag=true; } }else{ int now,middle,end; for(int i=0;i<moji.size()-2;i++){ now=i;middle=i+1;end=i+2; if (moji[now]==moji[middle]){ cout<<now+1<<" "<<end+1<<endl; flag=true;break; }else if(moji[now]==moji[end]){ cout<<now+1<<" "<<end+1<<endl; flag=true;break; }else if(moji[middle]==moji[end]){ cout<<now+1<<" "<<end+1<<endl; flag=true;break; } } } if (flag==false){ cout<<-1<<" "<<-1<<endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from a.cc:2: /usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type 68 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~~~~~ /usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 40 | #include <cwchar> // For mbstate_t +++ |+#include <cstddef> 41 | In file included from /usr/include/c++/14/bits/char_traits.h:50: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/14/cwchar:44, from /usr/include/c++/14/bits/postypes.h:40: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared 144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type 146 | static _GLIBCXX14_CONSTEXPR std::size_t | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared 150 | find(const char_type* __s, std::size_t __n, const char_type& __a); | ^~~ /usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared 153 | move(char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared 156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n); | ^~~ /usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared 159 | assign(char_type* __s, std::size_t __n, char_type __a); | ^~~ /usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared 187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n) | ^~~ /usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)': /usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 189 | for (std::size_t __i = 0; __i < __n; ++__i) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/bits/char_traits.h:189:33: error: '__i' was not declared in this scope; did you mean '__n'? 189 | for (std::size_t __i = 0; __i < __n; ++__i) | ^~~ | __n /usr/include/c++/14/bits/char_traits.h: At global scope: /usr/include/c++/14/bits/char_traits.h:198:31: error: 'size_t' in namespace 'std' does not name a type 198 | _GLIBCXX14_CONSTEXPR std::size_t |
s841580402
p04032
C++
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <cstdlib> #include <iomanip> #include <cmath> #include <ctime> #include <map> #include <set> #include <queue> #include <stack> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define INF 0x3f3f3f3f3f #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; ll gcd(ll a,ll b){ return b?gcd(b,a%b):a; } bool cmp(int x,int y) { return x>y; } ; ; int main() { std::ios::sync_with_stdio(false); cin.tie(); ; string s; cin>>s; ;i<s.size()-;i++){ ]){ cout<<i+<<<<endl; flag=; break; } &&s[i]==s[i+]){ cout<<i+<<<<endl; flag=; break; } } if(!flag) cout<<-<<<<endl; ; }
a.cc: In function 'int main()': a.cc:42:7: error: 'i' was not declared in this scope 42 | ;i<s.size()-;i++){ | ^ a.cc:42:18: error: expected primary-expression before ';' token 42 | ;i<s.size()-;i++){ | ^ a.cc:54:10: error: 'flag' was not declared in this scope 54 | if(!flag) | ^~~~ a.cc:55:13: error: expected primary-expression before '<<' token 55 | cout<<-<<<<endl; | ^~ a.cc:55:15: error: expected primary-expression before '<<' token 55 | cout<<-<<<<endl; | ^~
s453211827
p04032
C++
#include<bits/stdc++.h> using namespace std; int cnt[50]; int pos[50][100002]; char str[100002]; int main(){ // Init for(int i=0;i<50;i++){cnt[i]=0;} // Input cin>>str; for(int i=0;i<strlen(str);i++){ pos[str[i]-'a'][cnt[str[i]-'a']++]=i; } // Solve for(int i='a';i<='z';i++){ int lk=i-'a'; for(int j=0;j+1<cnt[lk];j++){ int len = pos[lk][j+1] - pos[lk][j]+1; if(len/2 < 2){ cout<<pos[lk][j]+1<<" "<<pos[lk][j+1]+1<<endl; return(0); } else break; } } } cout<<"-1 -1"<<endl; return(0); }
a.cc:33:9: error: 'cout' does not name a type 33 | cout<<"-1 -1"<<endl; | ^~~~ a.cc:34:9: error: expected unqualified-id before 'return' 34 | return(0); | ^~~~~~ a.cc:35:1: error: expected declaration before '}' token 35 | } | ^
s222527070
p04032
C++
#include<bits/stdc++.h> using namespace std; int cnt[50]; int pos[50][100002]; char str[100002]; int main(){ // Init for(int i=0;i<50;i++){cnt[i]=0;} // Input cin>>str; for(int i=0;i<strlen(str);i++){ pos[str[i]-'a'][cnt[str[i]-'a']++]=i; } // Solve for(int i='a';i<='z';i++){ int lk=i-'a'; for(int j=0;j+1<cnt[lk];j++){ int len = pos[lk][j+1] - pos[lk][j]+1; if(len/2 < 2){ cout<<pos[lk][j]+1<<" "<<pos[lk][k]+1<<endl; return(0); } else break; } } } cout<<"-1 -1"<<endl; return(0); }
a.cc: In function 'int main()': a.cc:25:74: error: 'k' was not declared in this scope 25 | cout<<pos[lk][j]+1<<" "<<pos[lk][k]+1<<endl; | ^ a.cc: At global scope: a.cc:33:9: error: 'cout' does not name a type 33 | cout<<"-1 -1"<<endl; | ^~~~ a.cc:34:9: error: expected unqualified-id before 'return' 34 | return(0); | ^~~~~~ a.cc:35:1: error: expected declaration before '}' token 35 | } | ^