submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s818696282
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,cont = 0,res = 0; cin>>n; int vals[n]; for (int k = 0; k <n;k++){ cin >> vals[k]; cont += vals[k]; } //cout<<cont<<endl; cont = round((float)cont/(float)n); //cout<<cont<<endl; for (int k = 0; k <n;k++){ res += (cont-vals[k])*(cont-vals[k]); } cout << res << endl; return 0; }#include<bits/stdc++.h> using namespace std; int main(){ int n,cont = 0,res = 0; cin>>n; int vals[n]; for (int k = 0; k <n;k++){ cin >> vals[k]; cont += vals[k]; } //cout<<cont<<endl; cont = round((float)cont/(float)n); //cout<<cont<<endl; for (int k = 0; k <n;k++){ res += (cont-vals[k])*(cont-vals[k]); } cout << res << endl; return 0; }
a.cc:20:2: error: stray '#' in program 20 | }#include<bits/stdc++.h> | ^ a.cc:20:3: error: 'include' does not name a type 20 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:23:5: error: redefinition of 'int main()' 23 | int main(){ | ^~~~ a.cc:4:5: note: 'int main()' previously defined here 4 | int main(){ | ^~~~
s791474349
p04025
C++
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #define INF 1000000000 #define MOD 1000000007 using namespace std; int main() { int n; int a[105]; int cost; int minv = INF; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < 105; i++) { for (int j = 0; j < n; j++) { cost += (a[j] - i) * (a[j] - i) } minv = min(cost, minv); } cout << minv << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:44: error: expected ';' before '}' token 26 | cost += (a[j] - i) * (a[j] - i) | ^ | ; 27 | } | ~
s258689617
p04025
C++
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); cin.sync_with_stdio(0); int n; cin >> n; vector<int> a(n); for(auto& x : a) cin >> x; int mn = *min_element(a.begin(), a.end()); int mx = *max_element(a.begin(), a.end()); ll ans = 0; ll sum = 0, sum2 = 0; for(auto x : a) sum += x, sum2 += x * x; for(int x = mn; x <= mx; ++x) { ll v = 3ll * x * x - x * sum; ans = (x == mn) ? v : min(ans, v); } cout << sum2 + ans; }
a.cc: In function 'int main()': a.cc:12:3: error: 'll' was not declared in this scope 12 | ll ans = 0; | ^~ a.cc:13:5: error: expected ';' before 'sum' 13 | ll sum = 0, sum2 = 0; | ^~~~ | ; a.cc:14:19: error: 'sum' was not declared in this scope 14 | for(auto x : a) sum += x, sum2 += x * x; | ^~~ a.cc:14:29: error: 'sum2' was not declared in this scope 14 | for(auto x : a) sum += x, sum2 += x * x; | ^~~~ a.cc:16:7: error: expected ';' before 'v' 16 | ll v = 3ll * x * x - x * sum; | ^~ | ; a.cc:17:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 17 | ans = (x == mn) ? v : min(ans, v); | ^~~ | abs a.cc:17:23: error: 'v' was not declared in this scope 17 | ans = (x == mn) ? v : min(ans, v); | ^ a.cc:19:11: error: 'sum2' was not declared in this scope 19 | cout << sum2 + ans; | ^~~~ a.cc:19:18: error: 'ans' was not declared in this scope; did you mean 'abs'? 19 | cout << sum2 + ans; | ^~~ | abs
s288113943
p04025
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { cin.tie(0); cin.sync_with_stdio(0); int n; cin >> n; vector<int> a(n); for(auto& x : a) cin >> x; int mn = min_element(a.begin(), a.end()); int mx = max_element(a.begin(), a.end()); int ans = 0; int sum = 0, sum2 = 0; for(auto x : a) sum += x, sum2 += x * x; for(int x = mn; x <= mn; ++x) { int v = 3 * x * x - x * sum; ans = (x == mn) ? v : min(ans, v); } cout << sum2 + ans; }
a.cc: In function 'int main()': a.cc:15:23: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization 15 | int mn = min_element(a.begin(), a.end()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ | | | __gnu_cxx::__normal_iterator<int*, std::vector<int> > a.cc:16:23: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization 16 | int mx = max_element(a.begin(), a.end()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ | | | __gnu_cxx::__normal_iterator<int*, std::vector<int> >
s563136941
p04025
C++
#include<iostream> #include<algorithm> #include<cmath> using namespace std; #define MAXN 105 int n,a[MAXN]; int solve(){ int totalcost; int cost=INT_MAX; for(int i=a[0];i<a[n];++i){ totalcost=0; for(int j=1;j<=n;++j){ totalcost+=(a[j]-i)*(a[j]-i); } cost=min(cost,totalcost); } return cost; } int main(){ cin>>n; for(int i=1;i<=n;++i) cin>>a[i]; sort(a+1,a+n+1); cout<<solve()<<endl; return 0; }
a.cc: In function 'int solve()': a.cc:9:18: error: 'INT_MAX' was not declared in this scope 9 | int cost=INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include<cmath> +++ |+#include <climits> 4 | using namespace std;
s249975910
p04025
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int mn = 105; int a[mn]; int main() { int n, i, l = 1 << 30, r = -(1 << 30); scanf("%d", &n); for(i = 1; i <= n; i++) scanf("%d", &a[#include<cstdio> #include<cstring> #include<algorithm> using namespace std; const int mn = 105; int a[mn]; int main() { int n, i, l = 1 << 30, r = -(1 << 30); scanf("%d", &n); for(i = 1; i <= n; i++) scanf("%d", &a[i]), l = min(l, a[i]), r = max(r, a[i]); int ans = 1 << 30, sum; for(int j = l; j <= r; j++) { sum = 0; for(i = 1; i <= n; i++) sum += (a[i] - j) * (a[i] - j); ans = min(ans, sum); } printf("%d\n", ans); } i]), l = min(l, a[i]), r = max(r, a[i]); int ans = 1 << 30, sum; for(int j = l; j <= r; j++) { sum = 0; for(i = 1; i <= n; i++) sum += (a[i] - j) * (a[i] - j); ans = min(ans, sum); } printf("%d\n", ans); }
a.cc:12:32: error: stray '#' in program 12 | scanf("%d", &a[#include<cstdio> | ^ a.cc: In function 'int main()': a.cc:12:33: error: 'include' was not declared in this scope 12 | scanf("%d", &a[#include<cstdio> | ^~~~~~~ a.cc:12:41: error: 'cstdio' was not declared in this scope; did you mean 'stdin'? 12 | scanf("%d", &a[#include<cstdio> | ^~~~~~ | stdin a.cc:15:1: error: expected primary-expression before 'using' 15 | using namespace std; | ^~~~~ a.cc:12:48: error: expected ']' before 'using' 12 | scanf("%d", &a[#include<cstdio> | ^ | ] ...... 15 | using namespace std; | ~~~~~ a.cc:18:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 18 | int main() | ^~ a.cc:18:9: note: remove parentheses to default-initialize a variable 18 | int main() | ^~ | -- a.cc:18:9: note: or replace parentheses with braces to value-initialize a variable a.cc:19:1: error: a function-definition is not allowed here before '{' token 19 | { | ^ a.cc:34:2: error: expected ';' before ']' token 34 | i]), l = min(l, a[i]), r = max(r, a[i]); | ^ | ;
s513492686
p04025
C++
#include <iostream> #include <algorithm> #include <array> #include <cmath> #include <string> using namespace std; long long main() { long long n,sum=0; cin>>n; long long input[n]={0}; for(long long i=0;i<n;i++){ cin>>input[i]; sum=sum+input[i]; } long long midpt = (double)ceil(double(sum)/n); long long cost=0; for(long long i=0;i<n;i++){ cost=cost+(input[i]-midpt)*(input[i]-midpt); } cout<<cost<<endl; return 0; }
cc1plus: error: '::main' must return 'int'
s913221369
p04025
C++
//include //------------------------------------------ #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> using namespace std; //conversion //------------------------------------------ inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} //math //------------------------------------------- template<class T> inline T sqr(T x) {return x*x;} //typedef //------------------------------------------ typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long ll; //container util //------------------------------------------ #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define MP make_pair #define SZ(a) int((a).size()) #define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort((c).begin(),(c).end()) //repetition //------------------------------------------ #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) //constant //-------------------------------------------- const double EPS = 1e-10; const double PI = acos(-1.0); //clear memory #define CLR(a) memset((a), 0 ,sizeof(a)) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; int main() { int N; int a[100]; int min = 10000000; cin >> N; REP(i, N) cin >> a[i]; for(int j = -100; j <= 100; j++) { int cost = 0; for(int i = 0;i < N; i++){ cost += (a[i] - j) * (a[i] - j); } if(cost < min) min = cost; } else cout << min; return 0; }
a.cc: In function 'int main()': a.cc:85:5: error: 'else' without a previous 'if' 85 | else cout << min; | ^~~~
s797545816
p04025
C++
#include <cstdio> #include <vector> using namespace std; int main() { int no_of_elements; scanf("%d", &no_of_elements); vector <int> A(no_of_elements + 1); double sum = 0; for(int i = 1; i <= no_of_elements; i++) { scanf("%d", &A[i]); sum += a_i; } float mean = sum/no_of_elements; int int_mean = mean; if(mean - int_mean >= 0.5) int_mean++; int cost = 0; for(int i = 1; i <= no_of_elements; i++) cost += (A[i] - int_mean)*(A[i] - int_mean); printf("%d\n", cost); return 0; }
a.cc: In function 'int main()': a.cc:17:16: error: 'a_i' was not declared in this scope 17 | sum += a_i; | ^~~
s211964833
p04025
Java
public static void main(String[] args){ Scanner in=new Scanner(System.in); int N=in.nextInt(); int[] arr=new int[N]; for (int i=0;i<N;i++){ arr[i]=in.nextInt(); } int change=200*200*100; for (int i=-100;i<=100;i++){ int temp=0; for (int j=0;j<N;j++){ temp+=(i-arr[j])*(i-arr[j]); } if (temp<change){ change=temp; } } System.out.print(change); }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args){ ^ (use --enable-preview to enable unnamed classes) 1 error
s396657047
p04025
C++
#include <iostream> using namespace std; int main(){ int n,k[112345],sum=0,ans=0; cin>>n; for(int i=0;i<n;i++){ cin>>k[i]; sum+=k[i]; } if(sum%n==0) ave=sum/n; else ave=sum/n+1; for(int i=0;i<n;i++){ ans+=(k[i]-ave)*(k[i]-ave); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:10:16: error: 'ave' was not declared in this scope 10 | if(sum%n==0) ave=sum/n; | ^~~ a.cc:11:8: error: 'ave' was not declared in this scope 11 | else ave=sum/n+1; | ^~~ a.cc:14:16: error: 'ave' was not declared in this scope 14 | ans+=(k[i]-ave)*(k[i]-ave); | ^~~
s405592817
p04025
C++
#include<iostream> #include<algorithm> using namespace std; int main() { int a; cin >> a; int a[100]; for (int i = 0;i < n;i++)cin >> a[i]; int sq[201]; for (int i = 0;i <= 100;i++)sq[i] = i * i; int m = 1000000; sort(a, a + n); for (int i = a[0];i <= a[n - 1];i++) { int cost = 0; for (int j = 0;j < n;j++) { cost += sq[abs(a[j] - i]; } m = min(cost, m); } }
a.cc: In function 'int main()': a.cc:8:13: error: conflicting declaration 'int a [100]' 8 | int a[100]; | ^ a.cc:6:13: note: previous declaration as 'int a' 6 | int a; | ^ a.cc:9:28: error: 'n' was not declared in this scope 9 | for (int i = 0;i < n;i++)cin >> a[i]; | ^ a.cc:9:42: error: invalid types 'int[int]' for array subscript 9 | for (int i = 0;i < n;i++)cin >> a[i]; | ^ a.cc:13:21: error: 'n' was not declared in this scope 13 | sort(a, a + n); | ^ a.cc:14:23: error: invalid types 'int[int]' for array subscript 14 | for (int i = a[0];i <= a[n - 1];i++) { | ^ a.cc:17:41: error: invalid types 'int[int]' for array subscript 17 | cost += sq[abs(a[j] - i]; | ^
s277762172
p04025
C++
#include<iostream> #include<algorithm> #include<vector> #define lamba ios::sync_with_stdio(0), cin.tie(0), cout.tie(0) #define all(x) x.begin(), x.end() using namespace std; const int zyan = 1e2 + 1; int n, a[105], mn = zyan, mx = -zyan; int fast() { cin >> n; for(int i=1;i<=n;i++){ cin >> a[i]; mn = min(mn, a[i]); mx = max(mx, a[i]); } /* int checker = 0; for(int i=2;i<=n;i++){ if(a[i] == a[1])checker++; } if(checker == n-1){ cout << 0; return 0; }*/ int mid = (mn + mx) % 2 + (mn + mx) >> 1; int res = 0; for(int i=1;i<=n;i++){ if(mid == a[i])continue; else res += (a[i] * a[i]) - (a[i] * mid) - (mid * a[i]) + (mid * mid); } cout << res; } int main(){ lamba; cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i]; } ll ans = 1e18; for (int j = -4000; j <= 4000; ++j) { int cur = 0; for (int i = 1; i <= n; ++i) { cur += (a[i] - j) * 1ll * (a[i] - j); } ans = min(ans, cur); } cout << ans; return 0; }
a.cc: In function 'int fast()': a.cc:44:1: warning: no return statement in function returning non-void [-Wreturn-type] 44 | } | ^ a.cc: In function 'int main()': a.cc:55:9: error: 'll' was not declared in this scope; did you mean 'all'? 55 | ll ans = 1e18; | ^~ | all a.cc:62:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 62 | ans = min(ans, cur); | ^~~ | abs a.cc:65:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 65 | cout << ans; | ^~~ | abs
s114141695
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], c[199], d, e, f, N; cin >> N; for(int i = 0; i < 100; i++)a[i] = 0; for(int j = 0; j < 100; j++)b[j] = 0; for(int k = 0; k < 200; k++)c[k] = 0; for(int l = 0; l < N; l++){ cin >> a[l]; if(l == 0){ d = a[l]; e = a[l]; } if(d > a[l]){ d = a[l]; } if(e < a[l]){ e = a[l]; } } for(int m = d; m =< e; m++){ for(int n = 0; n < N; n++){ b[n] = (a[n] - m)*(a[n] - m); c[m+100] += b[n]; if(m == d){ f = c[m+100]; }if(f > c[m]){ f = c[m+100]; } } } cout << f << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:20: error: expected primary-expression before '<' token 22 | for(int m = d; m =< e; m++){ | ^
s691799138
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], e[99], N, c, d, f, g, p; cin >> N; for(int m = 0; m < N; m++)e[m] = 0; for(int h = 0; h < N; h++)b[h] = 0; for(int i = 0; i < N; i++){ a[i] = 0; cin >> a[i]; } for( int o = 0; o < N; j++){ f = a[o];g = a[o] if(o = 0){ g = f; p = f; }if(g < f){ g = f; }if(p > f){ p = f; } } for( int j = 0; j < N; j++){ for( int k = g; k < p; k++){ for(int n = 0; n < N; n++){ b[n] = (a[n] - k)*(a[n] - k); } } for( int l = 0; l < N; l++){ c += b[l]; } if( j == 0){ d = c; } else if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:25: error: 'j' was not declared in this scope 12 | for( int o = 0; o < N; j++){ | ^ a.cc:13:20: error: expected ';' before 'if' 13 | f = a[o];g = a[o] | ^ | ; 14 | if(o = 0){ | ~~
s175882269
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], e[99], N, c, d; for(int m = 0; m < N; m++)e[m] = 0; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( int j = 0; j < N; j++){ for( int k = -100; k < 101; k++){ for(int n = 0; n < N; n++){ (a[n] - k)*(a[n] - k) = b[n]; } } for( int l = 0; l < N; l++){ c += b[l]; } if( j == 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:14: error: lvalue required as left operand of assignment 15 | (a[n] - k)*(a[n] - k) = b[n]; | ~~~~~~~~~~^~~~~~~~~~~
s998537276
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], e[99], N, c, d; for(int m = 0; m < N; m++)e[m] = 0; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( int j = 0; j < N; j++){ for( int k = -100; k < 101; k++){ (a[j] - k)*(a[j] - k) = b[j]; } for( int l = 0; l < N; l++){ c += b[l]; } if( j == 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:14: error: lvalue required as left operand of assignment 14 | (a[j] - k)*(a[j] - k) = b[j]; | ~~~~~~~~~~^~~~~~~~~~~
s747263181
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], e[99], N, c, d; for(int m = 0; m < N; m++)e[m] = 0; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( int k = -100; k < 101; k++){ for( int j = 0; j < N; j++){ (a[j] - k)*(a[j] - k) = b[j]; } for( int l = 0; l < N; l++){ c += b[l]; } if( l == 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:14: error: lvalue required as left operand of assignment 14 | (a[j] - k)*(a[j] - k) = b[j]; | ~~~~~~~~~~^~~~~~~~~~~ a.cc:19:7: error: 'l' was not declared in this scope 19 | if( l == 0){ | ^
s890429959
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], N, c, d; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( int k = -100; k < 101; k++){ for( int j = 0; j < N; j++){ (a[j] - k)*(a[j] - k) = b[j] } for( int l = 0; l < N; l++){ c += b[l]; } if( l = 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:14: error: lvalue required as left operand of assignment 13 | (a[j] - k)*(a[j] - k) = b[j] | ~~~~~~~~~~^~~~~~~~~~~ a.cc:18:6: error: 'l' was not declared in this scope 18 | if( l = 0){ | ^
s564074726
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], b, N, c; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( int k = -100; k < 101; k++){ for( int j = 0; j < N; j++){ (a[j] - k)*(a[j] - k) = b[j] } for( int l = 0; l < N; l++){ c += b[l]; } if( l = 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:4:20: error: conflicting declaration 'int b' 4 | int a[99], b[99], b, N, c; | ^ a.cc:4:13: note: previous declaration as 'int b [99]' 4 | int a[99], b[99], b, N, c; | ^ a.cc:13:14: error: lvalue required as left operand of assignment 13 | (a[j] - k)*(a[j] - k) = b[j] | ~~~~~~~~~~^~~~~~~~~~~ a.cc:18:6: error: 'l' was not declared in this scope 18 | if( l = 0){ | ^ a.cc:19:2: error: 'd' was not declared in this scope 19 | d = c; | ^ a.cc:21:6: error: 'd' was not declared in this scope 21 | if( d > c){ | ^ a.cc:25:10: error: 'd' was not declared in this scope 25 | cout << d << endl; | ^
s837002057
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], b, N, c; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( int k = -100; k < 101; k++){ for( int j = 0; j < N; j++){ (a[j] - k)*(a[j] - k) = b[j] } for( int l = 0; l < N; l++){ c += b[l]; } if( l = 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:4:20: error: conflicting declaration 'int b' 4 | int a[99], b[99], b, N, c; | ^ a.cc:4:13: note: previous declaration as 'int b [99]' 4 | int a[99], b[99], b, N, c; | ^ a.cc:13:14: error: lvalue required as left operand of assignment 13 | (a[j] - k)*(a[j] - k) = b[j] | ~~~~~~~~~~^~~~~~~~~~~ a.cc:18:6: error: 'l' was not declared in this scope 18 | if( l = 0){ | ^ a.cc:19:2: error: 'd' was not declared in this scope 19 | d = c; | ^ a.cc:21:6: error: 'd' was not declared in this scope 21 | if( d > c){ | ^ a.cc:25:10: error: 'd' was not declared in this scope 25 | cout << d << endl; | ^
s282630200
p04025
C++
#include<bits/stdc++.h> using namespace std; int main(){ int a[99], b[99], b, N, c; for(int h = 0; h < N; h++)b[h] = 0; cin >> N; for(int i = 0; i < N; i++){ a[i]= 0; cin >> a[i]; } for( k = -100; k < 101; k++){ for( j = 0; j < N; j++){ (a[j] - k)*(a[j] - k) = b[j] } for( l = 0; l < N; l++){ c += b[l]; } if( l = 0){ d = c; } if( d > c){ d = c; } } cout << d << endl; return 0; }
a.cc: In function 'int main()': a.cc:4:20: error: conflicting declaration 'int b' 4 | int a[99], b[99], b, N, c; | ^ a.cc:4:13: note: previous declaration as 'int b [99]' 4 | int a[99], b[99], b, N, c; | ^ a.cc:11:7: error: 'k' was not declared in this scope 11 | for( k = -100; k < 101; k++){ | ^ a.cc:12:8: error: 'j' was not declared in this scope 12 | for( j = 0; j < N; j++){ | ^ a.cc:15:7: error: 'l' was not declared in this scope 15 | for( l = 0; l < N; l++){ | ^ a.cc:18:6: error: 'l' was not declared in this scope 18 | if( l = 0){ | ^ a.cc:19:2: error: 'd' was not declared in this scope 19 | d = c; | ^ a.cc:21:6: error: 'd' was not declared in this scope 21 | if( d > c){ | ^ a.cc:25:10: error: 'd' was not declared in this scope 25 | cout << d << endl; | ^
s454026679
p04025
C++
#include <bits/stdc++.h> #define INF (1<<21) using namespace std; int main(){ int n, tmp = 0; int v[210] = {} long long ans = INF; cin >> n; for(int i = 0; i < n; i++) cin >> v[i]; for(int i = 0; i < 101; i++){ long long sum = 0; for(int j = 0; j < n; j++){ sum += (i - v[j]) * (i - v[j]); } ans = min(ans, sum); } if(tmp/n == abs(v[0]) && tmp%n == 0) ans = 0; if(ans == INF) ans = 0; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:3: error: expected ',' or ';' before 'long' 9 | long long ans = INF; | ^~~~ a.cc:17:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 17 | ans = min(ans, sum); | ^~~ | abs a.cc:19:40: error: 'ans' was not declared in this scope; did you mean 'abs'? 19 | if(tmp/n == abs(v[0]) && tmp%n == 0) ans = 0; | ^~~ | abs a.cc:20:6: error: 'ans' was not declared in this scope; did you mean 'abs'? 20 | if(ans == INF) ans = 0; | ^~~ | abs a.cc:21:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 21 | cout << ans << endl; | ^~~ | abs
s583731622
p04025
C++
#include "bits/stdc++.h" #define fi first #define se second #define pb push_back #define mp make_pair #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define all(s) s.begin(), s.end() using namespace std; typedef long long int ll; typedef pair<int,int> P; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; const int MX = 100005, INF = 1001001001; const ll LINF = 1e18; const double eps = 1e-10; const ll mod = 1e9+7; int n; vi a; int main() { cin >> n; a.resize(n); rep(i,n) cin >> a[i]; double s=0; rep(i,n) s+= a[i]; s 1/= (double)n; int m = s + 0.5; int ans = 0; rep(i,n) ans += (a[i]-m)*(a[i]-m); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:31:6: error: expected ';' before numeric constant 31 | s 1/= (double)n; | ^~ | ;
s549089500
p04025
C++
#include<iostream> #include<algorithm> #include <string> #include<cstdio> #include<stack> #include<cstring> #include<vector> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define EREP(i,n) for(int i=(n-1);i>=0;--i) #define D(n,retu) REP(i,n){cin>>retu[i];} #define mod 1000000007 using namespace std; typedef long long int ll; template<typename T> void fill_all(T& arr, const T& v) { arr = v; } template<typename T, typename ARR> void fill_all(ARR& arr, const T& v) { for (auto& i : arr) { fill_all(i, v); } } //------------------変数-----------------------// ll n, a[100],k,cnt=547283908723495053; string str; //-------------------関数----------------------// int main() { cin >> n; REP(i, n) { cin >> a[i]; } for (int i = -200; i <=200; i++) { ll mini=0; REP(j, n) { mini += pow(a[j]-i, 2); } cnt = min(cnt, mini); } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:39:33: error: 'pow' was not declared in this scope 39 | mini += pow(a[j]-i, 2); | ^~~
s847992624
p04025
C++
#include <iostream> using namespace std; typedef unsigned long long u64; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; int a[n]; for (int i = 0; i < n; ++i) { cin >> a[i]; } int cost_min = -1; for (int i = -100; i <= 100; ++i) { int cost = 0; for (int j = 0; j < n; ++j) { cost += abs(i-a[j]); } if (cost_min == -1) { cost_min = cost; } else cost_min = min(cost, cost_min); } } cout << cost_min << endl; return 0; }
a.cc:27:3: error: 'cout' does not name a type 27 | cout << cost_min << endl; | ^~~~ a.cc:28:3: error: expected unqualified-id before 'return' 28 | return 0; | ^~~~~~ a.cc:29:1: error: expected declaration before '}' token 29 | } | ^
s432898277
p04025
C++
#include<cstdio> #include<vector> #include<iostream> #include<cstdio> using namespace std; const int big=(1<<30); int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);} int main(void){ int n,ans=big,i,q,gen,j; vector<int> a; cin>>N; for(i=0;i<n;i++){ scanf("%d",&q); a.push_back(q); } for(i=-100;i<101;i++){ gen=0; for(j=0;j<n;j++){ gen+=(a[j]-i)*(a[j]-i); } ans=min(ans,gen); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:11:14: error: 'N' was not declared in this scope 11 | cin>>N; | ^
s857934183
p04025
C++
#include<cstdio> #include<vector> #include<iostream> #include<cstdio> using namespace std; const int big=(1<<30); int gcd(int a,int b){if(a<b){swap(a,b);}if(b==0){return a;}return gcd(a%b,b);} int main(void){ int N,ans=big,i,q,gen,j; vector<int> a; cin>>N; for(i=0;i<n;i++){ scanf("%d",&q); a.push_back(q); } for(i=-100;i<101;i++){ gen=0; for(j=0;j<n;j++){ gen+=(a[j]-i)*(a[j]-i); } ans=min(ans,gen); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:12:19: error: 'n' was not declared in this scope 12 | for(i=0;i<n;i++){ | ^ a.cc:18:27: error: 'n' was not declared in this scope 18 | for(j=0;j<n;j++){ | ^
s518112099
p04025
C++
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { int n; double sum = 0; int[] a = new int[100]; n = int.Parse(Console.ReadLine()); a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); for(int i = 0; i < n; i++) { sum += a[i]; } sum /= n; long sum2 = 0, sum3 = 0; for(int i = 0; i < n; i++) { sum2 += (long)Math.Pow(a[i] - Math.Floor(sum), 2); sum3 += (long)Math.Pow(a[i] - Math.Ceiling(sum), 2); } if (sum3 < sum2) sum2 = sum3; Console.WriteLine(sum2); } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Linq; | ^~~~~~ a.cc:4:7: error: expected nested-name-specifier before 'System' 4 | using System.Text; | ^~~~~~ a.cc:5:7: error: expected nested-name-specifier before 'System' 5 | using System.Threading.Tasks; | ^~~~~~ a.cc:11:26: error: 'string' has not been declared 11 | static void Main(string[] args) | ^~~~~~ a.cc:11:35: error: expected ',' or '...' before 'args' 11 | static void Main(string[] args) | ^~~~ a.cc:32:6: error: expected ';' after class definition 32 | } | ^ | ; a.cc: In static member function 'static void ConsoleApplication1::Program::Main(int*)': a.cc:15:16: error: structured binding declaration cannot have type 'int' 15 | int[] a = new int[100]; | ^~ a.cc:15:16: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:15:16: error: empty structured binding declaration a.cc:15:19: error: expected initializer before 'a' 15 | int[] a = new int[100]; | ^ a.cc:16:17: error: expected primary-expression before 'int' 16 | n = int.Parse(Console.ReadLine()); | ^~~ a.cc:17:13: error: 'a' was not declared in this scope 17 | a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); | ^ a.cc:17:17: error: 'Console' was not declared in this scope 17 | a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); | ^~~~~~~ a.cc:17:54: error: expected primary-expression before 'int' 17 | a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); | ^~~ a.cc:26:31: error: 'Math' was not declared in this scope 26 | sum2 += (long)Math.Pow(a[i] - Math.Floor(sum), 2); | ^~~~
s867427757
p04025
Java
import java.io.*; import java.util.*; import java.math.BigInteger; public class C1A{ public static void main(String[] args) { InputReader in = new InputReader(System.in); PrintWriter w = new PrintWriter(System.out); int n=in.nextInt(); int[] a=new int[n]; long avg=0; for(int i=0;i<n;i++){ a[i]=in.nextInt(); avg=avg+a[i]; } avg=(long)Math.round(avg*1.0/n); long c=0; for(int i=0;i<n;i++){ c=c+(long)Math.pow(a[i]-avg,2); } w.println(c); w.close(); } static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { this.stream = stream; } public int snext() { if (snumChars == -1) throw new InputMismatchException(); if (curChar >= snumChars) { curChar = 0; try { snumChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (snumChars <= 0) return -1; } return buf[curChar++]; } public int nextInt() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public long nextLong() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } int sgn = 1; if (c == '-') { sgn = -1; c = snext(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = snext(); } while (!isSpaceChar(c)); return res * sgn; } public int[] nextIntArray(int n) { int a[] = new int[n]; for (int i = 0; i < n; i++) { a[i] = nextInt(); } return a; } public String readString() { int c = snext(); while (isSpaceChar(c)) { c = snext(); } StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isSpaceChar(c)); return res.toString(); } public String nextLine() { int c = snext(); while (isSpaceChar(c)) c = snext(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = snext(); } while (!isEndOfLine(c)); return res.toString(); } public boolean isSpaceChar(int c) { if (filter != null) return filter.isSpaceChar(c); return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
Main.java:4: error: class C1A is public, should be declared in a file named C1A.java public class C1A{ ^ 1 error
s616224044
p04025
C++
#include <bits/stdc++.h> 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 x1 = sum/a; int x2 = sum/a + 1; int ans1 = 0; int ans2 = 0; for(int i=0;i<n;i++){ ans1 += pow(a[i] - x1,2); ans2 += pow(a[i] - x2,2); } cout << min(ans1,ans2) << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:21: error: no match for 'operator/' (operand types are 'int' and 'std::vector<int>') 14 | int x1 = sum/a; | ~~~^~ | | | | int std::vector<int> In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/complex:430:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const complex<_Tp>&, const complex<_Tp>&)' 430 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:430:5: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::complex<_Tp>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/complex:439:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const complex<_Tp>&, const _Tp&)' 439 | operator/(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:439:5: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::complex<_Tp>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/complex:448:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const _Tp&, const complex<_Tp>&)' 448 | operator/(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:448:5: note: template argument deduction/substitution failed: a.cc:14:22: note: 'std::vector<int>' is not derived from 'const std::complex<_Tp>' 14 | int x1 = sum/a; | ^ 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:408:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__divides, typename _Dom1::value_type>::result_type> std::operator/(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 408 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:408:5: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/bits/valarray_after.h:408:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__divides, typename _Dom1::value_type>::result_type> std::operator/(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 408 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:408:5: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/bits/valarray_after.h:408:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__divides, typename _Dom1::value_type>::result_type> std::operator/(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 408 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:408:5: note: template argument deduction/substitution failed: a.cc:14:22: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/bits/valarray_after.h:408:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__divides, typename _Dom1::value_type>::result_type> std::operator/(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 408 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:408:5: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/bits/valarray_after.h:408:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__divides, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__divides, typename _Dom1::value_type>::result_type> std::operator/(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 408 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:408:5: note: template argument deduction/substitution failed: a.cc:14:22: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/valarray:1199:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__divides, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__divides, _Tp>::result_type> std::operator/(const valarray<_Tp>&, const valarray<_Tp>&)' 1199 | _DEFINE_BINARY_OPERATOR(/, __divides) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1199:1: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::valarray<_Tp>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/valarray:1199:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__divides, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__divides, _Tp>::result_type> std::operator/(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1199 | _DEFINE_BINARY_OPERATOR(/, __divides) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1199:1: note: template argument deduction/substitution failed: a.cc:14:22: note: mismatched types 'const std::valarray<_Tp>' and 'int' 14 | int x1 = sum/a; | ^ /usr/include/c++/14/valarray:1199:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__divides, _Tp>::result_type> std::operator/(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1199 | _DEFINE_BINARY_OPERATOR(/, __divides) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1199:1: note: template argument deduction/substitution failed: a.cc:14:22: note: 'std::vector<int>' is not derived from 'const std::valarray<_Tp>' 14 | int x1 = sum/a; | ^ a.cc:15:21: error: no match for 'operator/' (operand types are 'int' and 'std::vector<int>') 15 | int x2 = sum/a + 1; | ~~~^~ | | | | int std::vector<int> /usr/include/c++/14/complex:430:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const complex<_Tp>&, const complex<_Tp>&)' 430 | operator/(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:430:5: note: template argument deduction/substitution failed: a.cc:15:22: note: mismatched types 'const std::complex<_Tp>' and 'int' 15 | int x2 = sum/a + 1; | ^ /usr/include/c++/14/complex:439:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const complex<_Tp>&, const _Tp&)' 439 | operator/(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:439:5: note: template argument deduction/substitution failed: a.cc:15:22: note: mismatched types 'const std::complex<_Tp>' and 'int' 15 | int x2 = sum/a + 1; | ^ /usr/include/c++/14/complex:448:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator/(const _Tp&, const complex<_Tp>&)' 448 | operator/(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:448:5: note: template argument deduction/substitution failed: a.cc:15:22: note: 'std::vector<int>' is not derived from 'const std::complex<_Tp>' 15 | int x2 = sum/a + 1; | ^ /usr/include/c++/14/bits/valarray_after.h:408:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__divides, typename _Dom1::value_type>::result_type> std::operator/(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 408 | _DEFINE_EXPR_BINARY_OPERATOR(/, struct std::__divides) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:408:5: note: template argument deduction/substitution failed: a.cc:15:22: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 15 | int x2 = sum/a + 1; | ^ /usr/include/c++/14/bits/valarray_after.h:408:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__divides, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__d
s677205867
p04025
Java
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); List<Integer> list = IntStream.range(0, N).mapToObj(x -> sc.nextInt()) .sorted((a, b) -> Integer.compare(b, a)) .collect(Collectors.toCollection(ArrayList::new)); int max=list.get(0); int min=list.get(list.size()-1); int sum=0; boolean firstOrnot=true; for (int i = min; i < max; i++) { int sumInter=0; for (int j = 0; j < list.size(); j++) { sumInter+=Math.pow(list.get(j)-i, 2); } if (firstOrnot) { firstOrnot=false; sum=sumInter; }else { if (sumInter<sum) { sum=sumInter; } } } System.out.println(sum); } }
Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:6: error: cannot find symbol List<Integer> list = IntStream.range(0, N).mapToObj(x -> sc.nextInt()) ^ symbol: class List location: class Main Main.java:6: error: cannot find symbol List<Integer> list = IntStream.range(0, N).mapToObj(x -> sc.nextInt()) ^ symbol: variable IntStream location: class Main Main.java:8: error: cannot find symbol .collect(Collectors.toCollection(ArrayList::new)); ^ symbol: variable Collectors location: class Main Main.java:8: error: cannot find symbol .collect(Collectors.toCollection(ArrayList::new)); ^ symbol: class ArrayList location: class Main 6 errors
s944970117
p04025
Java
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); List<Integer> list = IntStream.range(0, N).mapToObj(x -> sc.nextInt()) .sorted((a, b) -> Integer.compare(b, a)) .collect(Collectors.toCollection(ArrayList::new)); int max=list.get(0); int min=list.get(list.size()-1); int sum=0; boolean firstOrnot=true; for (int i = min; i < max; i++) { int sumInter=0; for (int j = 0; j < list.size(); j++) { sumInter+=Math.pow(list.get(j)-i, 2); } if (firstOrnot) { firstOrnot=false; sum=sumInter; }else { if (sumInter<sum) { sum=sumInter; } } } System.out.println(sum); } }
Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:6: error: cannot find symbol List<Integer> list = IntStream.range(0, N).mapToObj(x -> sc.nextInt()) ^ symbol: class List location: class Main Main.java:6: error: cannot find symbol List<Integer> list = IntStream.range(0, N).mapToObj(x -> sc.nextInt()) ^ symbol: variable IntStream location: class Main Main.java:8: error: cannot find symbol .collect(Collectors.toCollection(ArrayList::new)); ^ symbol: variable Collectors location: class Main Main.java:8: error: cannot find symbol .collect(Collectors.toCollection(ArrayList::new)); ^ symbol: class ArrayList location: class Main 6 errors
s640323885
p04025
C++
#include <bits/stdc++.h> using namespace std; inline int square(int x) { return x * x; } int N; int A[100]; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d", &A[i]); int sum = 0; for (int i = 0; i < N; i++) sum += A[i]; int avg1 = sum / N, avg2 = avg1 + 1; int res1 = 0; for (int i = 0; i < N; i++) res1 += square(avg1 - A[i]); int res2 = 0; for (int i = 0; i < N; i++) res2 += square(avg2 - A[i]); printf("%d". min(res1, res2)); return 0; }
a.cc: In function 'int main()': a.cc:25:18: error: request for member 'min' in '"%d"', which is of non-class type 'const char [3]' 25 | printf("%d". min(res1, res2)); | ^~~
s216575533
p04025
C++
#include <bits/stdc++> using namespace std; inline int square(int x) { return x * x; } int N; int A[100]; int main() { scanf("%d", &N); for (int i = 0; i < N; i++) scanf("%d", &A[i]); int sum = 0; for (int i = 0; i < N; i++) sum += A[i]; int avg1 = sum / N, avg2 = avg1 + 1; int res1 = 0; for (int i = 0; i < N; i++) res1 += square(avg1 - A[i]); int res2 = 0; for (int i = 0; i < N; i++) res2 += square(avg2 - A[i]); printf("%d". min(res1, res2)); return 0; }
a.cc:1:10: fatal error: bits/stdc++: No such file or directory 1 | #include <bits/stdc++> | ^~~~~~~~~~~~~ compilation terminated.
s267018422
p04025
C++
#include<iostream> #include<cstdio> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) #define INF INT_MAX/2 int N; int a[100]; int main() { cin >> N; rep(i, 0, N) cin >> a[i]; int ans = INF; rep(x, -100, 101) { int sm = 0; rep(i, 0, N) sm += abs(x - a[i])*abs(x - a[i]); ans = min(ans, sm); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:5:13: error: 'INT_MAX' was not declared in this scope 5 | #define INF INT_MAX/2 | ^~~~~~~ a.cc:12:19: note: in expansion of macro 'INF' 12 | int ans = INF; | ^~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include<cstdio> +++ |+#include <climits> 3 | using namespace std;
s257353896
p04025
C++
#include<iostream> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) #define INF INT_MAX/2 int N; int a[100]; int main() { cin >> N; rep(i, 0, N) cin >> a[i]; int ans = INF; rep(x, -100, 101) { int sm = 0; rep(i, 0, N) sm += abs(x - a[i])*abs(x - a[i]); ans = min(ans, sm); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:4:13: error: 'INT_MAX' was not declared in this scope 4 | #define INF INT_MAX/2 | ^~~~~~~ a.cc:10:19: note: in expansion of macro 'INF' 10 | int ans = INF; | ^~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s694019876
p04025
C++
f( chk[x][y][z] ) return dt[x][y][z]; chk[x][y][z] = 1; int &ret = dt[x][y][z] = 0; if( y < st.size() ) { if( z == 0 ) { ret += dp(x+1, y+1, 0), ret%=MOD; ret += dp(x+1, y, z+1), ret%=MOD; } else { ret += dp(x+1, y, z+1), ret%=MOD; ret += dp(x+1, y, z+1), ret%=MOD; } } else { ret += dp(x+1, y, z+1), ret %= MOD; ret += dp(x+1, y, z+1), ret %= MOD; } if( z > 0 ) ret += dp(x+1, y, z-1), ret%=MOD; else if( y > 0 ) ret += dp(x+1, y-1, 0), ret%=MOD; else ret += dp(x+1, 0, 0), ret%=MOD; return ret; } int main() { cin>>n>>st; cout<<dp(0,0,0); return 0; }
a.cc:1:2: error: expected constructor, destructor, or type conversion before '(' token 1 | f( chk[x][y][z] ) return dt[x][y][z]; | ^ a.cc:2:5: error: 'chk' does not name a type 2 | chk[x][y][z] = 1; | ^~~ a.cc:3:16: error: 'dt' was not declared in this scope 3 | int &ret = dt[x][y][z] = 0; | ^~ a.cc:3:19: error: 'x' was not declared in this scope 3 | int &ret = dt[x][y][z] = 0; | ^ a.cc:3:22: error: 'y' was not declared in this scope 3 | int &ret = dt[x][y][z] = 0; | ^ a.cc:3:25: error: 'z' was not declared in this scope 3 | int &ret = dt[x][y][z] = 0; | ^ a.cc:5:5: error: expected unqualified-id before 'if' 5 | if( y < st.size() ) | ^~ a.cc:18:5: error: expected unqualified-id before 'else' 18 | else | ^~~~ a.cc:24:5: error: expected unqualified-id before 'if' 24 | if( z > 0 ) ret += dp(x+1, y, z-1), ret%=MOD; | ^~ a.cc:25:5: error: expected unqualified-id before 'else' 25 | else if( y > 0 ) ret += dp(x+1, y-1, 0), ret%=MOD; | ^~~~ a.cc:26:5: error: expected unqualified-id before 'else' 26 | else ret += dp(x+1, 0, 0), ret%=MOD; | ^~~~ a.cc:27:5: error: expected unqualified-id before 'return' 27 | return ret; | ^~~~~~ a.cc:28:1: error: expected declaration before '}' token 28 | } | ^ a.cc: In function 'int main()': a.cc:32:5: error: 'cin' was not declared in this scope 32 | cin>>n>>st; | ^~~ a.cc:32:10: error: 'n' was not declared in this scope 32 | cin>>n>>st; | ^ a.cc:32:13: error: 'st' was not declared in this scope; did you mean 'std'? 32 | cin>>n>>st; | ^~ | std a.cc:33:5: error: 'cout' was not declared in this scope 33 | cout<<dp(0,0,0); | ^~~~ a.cc:33:11: error: 'dp' was not declared in this scope 33 | cout<<dp(0,0,0); | ^~
s526630083
p04025
C++
#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; int main() { int N; cin >> N; vector <int> A(N+5); for (int i = 0; i < N; i++) { int m; cin >> m; A.push_back(m); } int sigma = 0; for (int i = 0; i < N; i++) { sigma += A.at(i); } int m1; m1 = sigma/N; int cost1 = 0; for (int i = 0; i < N; i++){ cost1 +=(A.at(i) - m1)*(A.at(i) -m1); } int cost2 = 0; for (int i = 0; i < N; i++) { cost2 += (A.at(i) - m1 + 1)*(A.at(i) - m1 +1); } int cost3 = 0; for (int i = 0; i < N; i++) { cost3 += (A.at(i) - m1 -1)*(A.at(i) - m1 -1); } int cost = min(cost1, cost2); int cost = min(cost, cost3); cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:9: error: redeclaration of 'int cost' 37 | int cost = min(cost, cost3); | ^~~~ a.cc:36:9: note: 'int cost' previously declared here 36 | int cost = min(cost1, cost2); | ^~~~
s641563826
p04025
C++
#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; int main() { int N; cin >> N; vector <int> A(N+5); for (int i = 0; i < N; i++) { int m; cin >> m; A.push_back(m); } int sigma = 0; for (int i = 0; i < N; i++) { sigma += A.at(i); } int m1; m1 = sigma/N; int cost1 = 0; for (int i = 0; i < N; i++){ cost1 +=(A.at(i) - m1)*(A.at(i) -m1); } int cost2 = 0; for (int i = 0; i < N; i++) { cost2 += (A.at(i) - m1 + 1)*(A.at(i) - m1 +1); } int cost3 = 0; for (int i = 0; i < N; i++) { cost3 += (A.at(i) - m1 -1)*(A.at(i) - m1 -1); } int cost = min(cost1, cost2); int cost = min(cost, cost3); cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:9: error: redeclaration of 'int cost' 37 | int cost = min(cost, cost3); | ^~~~ a.cc:36:9: note: 'int cost' previously declared here 36 | int cost = min(cost1, cost2); | ^~~~
s379571971
p04025
C++
#include <iostream> #include <vector> #include <cmath> using namespace std; int ave(vector<int>& v) { long long sum = 0; for (auto x : v) { sum += x; } return static_cast<int>(ceil(static_cast<double>(sum) / v.size())); } int main() { int n; vector<int> a; cin >> n; for (int i = 0; i < n; ++i) { int x; cin >> x; a.push_back(x); } const int average = ave(a); cerr << "average: " << average << endl; int cost = 0; for (auto x : a) { cost += (average - x) * (average - x); } cout << cost << endl; return
a.cc: In function 'int main()': a.cc:38:9: error: expected primary-expression at end of input 38 | return | ^ a.cc:38:9: error: expected ';' at end of input 38 | return | ^ | ; a.cc:38:9: error: expected '}' at end of input a.cc:17:1: note: to match this '{' 17 | { | ^
s311144729
p04025
C++
#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<math.h> #include<string.h> #include<conio.h> int main() { int n; int numbers[100]; int all=0; int avg; int value1=0, value2=0; scanf("%d\n", &n); for (int i = 0; i < n-1; i++) { scanf("%d ", &numbers[i]); all += numbers[i]; } scanf("%d", &numbers[n - 1]); all += numbers[n - 1]; avg = all / n; for (int i = 0; i < n; i++) { value1 += (numbers[i]-avg)*(numbers[i] - avg); value2 += (numbers[i] - avg-1)*(numbers[i] - avg-1); } if (value1 < value2) printf("%d", value1); else printf("%d", value2); return 0; }
a.cc:6:9: fatal error: conio.h: No such file or directory 6 | #include<conio.h> | ^~~~~~~~~ compilation terminated.
s223374829
p04025
Java
import java.io.*; import java.util.*; public class C_test { BufferedReader br; PrintWriter out; StringTokenizer st; boolean eof; static final int P = 1_000_000_007; int[] getSums(int from, int to, int c) { int[] a = new int[to - from + 1]; Arrays.fill(a, 1); int[] ret = new int[c + 1]; for (int i = 0; i <= c; i++) { if (i != 0) { for (int j = from; j <= to; j++) { a[j - from] = (int) ((long) a[j - from] * j % P); } } for (int j = 0; j <= to - from; j++) { ret[i] = (ret[i] + a[j]) % P; } } return ret; } void solve() throws IOException { int n = 400; int c = 400; int[] dp = new int[c + 1]; dp[0] = 1; int[] low = new int[n]; int[] high = new int[n]; for (int i = 0; i < n; i++) { low[i] = 1; } for (int i = 0; i < n; i++) { high[i] = 400; } for (int i = 0; i < n; i++) { int[] sums = getSums(low[i], high[i], c); int[] nxt = new int[c + 1]; for (int from = 0; from <= c; from++) { for (int to = from; to <= c; to++) { nxt[to] += (int)((long)dp[from] * sums[to - from] % P); nxt[to] %= P; } } dp = nxt; } out.println(dp[c]); } C_test() throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); out = new PrintWriter(System.out); solve(); out.close(); } public static void main(String[] args) throws IOException { new C_test(); } String nextToken() { while (st == null || !st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (Exception e) { eof = true; return null; } } return st.nextToken(); } String nextString() { try { return br.readLine(); } catch (IOException e) { eof = true; return null; } } int nextInt() throws IOException { return Integer.parseInt(nextToken()); } long nextLong() throws IOException { return Long.parseLong(nextToken()); } double nextDouble() throws IOException { return Double.parseDouble(nextToken()); } }
Main.java:4: error: class C_test is public, should be declared in a file named C_test.java public class C_test { ^ 1 error
s980710594
p04025
Java
import java.util.Scanner; public class R59 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int[] a = new int[n]; for(int i = 0; i < n; i++) a[i] = s.nextInt(); long min = Long.MAX_VALUE; for(int i = -100; i <= 100; i++) { long total = 0; for(int j = 0; j < n; j++) { long diff = Math.abs(i - a[j]); total += diff * diff; } min = Math.min(min, total); } System.out.println(min); } }
Main.java:4: error: class R59 is public, should be declared in a file named R59.java public class R59 { ^ 1 error
s339671175
p04025
C++
#include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #define N 100 using namespace std; int main() { int n; scanf("%d", &n); int a[n]; int sum = 0; for (int i = 0; i < n; i++) { scanf("%d",&a[i]); sum += a[i]; } int target = ceil((float)sum/n); int res = 0; for (int i = 0; i < n; i++) { res += (a[i] - target) * (a[i] - target); } printf('%d\n', res); return 0; }
a.cc:38:12: warning: multi-character character constant [-Wmultichar] 38 | printf('%d\n', res); | ^~~~~~ a.cc: In function 'int main()': a.cc:38:12: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 38 | printf('%d\n', res); | ^~~~~~ | | | int In file included from /usr/include/c++/14/cstdio:42, from /usr/include/c++/14/ext/string_conversions.h:45, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from a.cc:7: /usr/include/stdio.h:363:43: note: initializing argument 1 of 'int printf(const char*, ...)' 363 | extern int printf (const char *__restrict __format, ...); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
s301427071
p04025
C++
#include <iostream> #include <vector> using namespace std; int main() { int n; cin >> n; vector<int> a(n); double sum = 0; for (int i = 0; i < n; i++) { cin >> a[i]; sum = sum + a[i]; } sum = (double)sum / (double)n; //cout << sum << endl; int ansl = floor(sum); int ansh = ansl + 1; int el = 0; int eh = 0; for (int i = 0; i < n; i++) { el = el + (a[i] - ansl)*(a[i] - ansl); eh = eh + (a[i] - ansh)*(a[i] - ansh); } int cost = 0; if (el > eh) { //anshのが優秀 cout << eh << endl; } else cout << el << endl; return 0; }
a.cc: In function 'int main()': a.cc:18:20: error: 'floor' was not declared in this scope 18 | int ansl = floor(sum); | ^~~~~
s348848792
p04025
C++
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; Scanner in = new Scanner(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { public void solve(int testNumber, Scanner in, PrintWriter out) { int n = in.nextInt(); int[] a = new int[n]; int sum = 0; for (int i = 0; i < n; i++) { int ai = in.nextInt(); a[i] = ai; sum += ai; } int y = (int) Math.ceil((sum * 1.0d) / n); int cost = 0; for (int i = 0; i < n; i++) { cost += (y - a[i]) * (y - a[i]); } out.println(cost); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.OutputStream; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ 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.InputStream; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.PrintWriter; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.Scanner; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:11:1: error: expected unqualified-id before 'public' 11 | public class Main { | ^~~~~~
s053734762
p04025
Java
public class Main { public static void main(String[] args) { Solver solver = new Solver(); } static class Solver { IO io; public Solver() { this.io = new IO(); try { solve(); } finally { io.close(); } } /****************************** START READING HERE ********************************/ void solve() { int n = io.nextInt(); int[] a = new int[n]; for (int i=0; i<n; i++) { a[i] = io.nextInt(); } long mincost = Long.MAX_VALUE; for (int val=-100; val<=100; val++) { long cost = 0; for (int i=0; i<n; i++) { cost += (a[i] - val) * (a[i] - val); } mincost = Math.min(cost, mincost); } io.println(mincost); } /************************** UTILITY CODE BELOW THIS LINE **************************/ class Point { int y; int x; public Point(int y, int x) { this.y = y; this.x = x; } } class IDval implements Comparable<IDval> { int id; long val; public IDval(int id, long val) { this.val = val; this.id = id; } @Override public int compareTo(IDval o) { if (this.val < o.val) return -1; if (this.val > o.val) return 1; return this.id - o.id; } } private List<Integer>[] toGraph(IO io, int n) { List<Integer>[] g = new ArrayList[n+1]; for (int i=1; i<=n; i++) g[i] = new ArrayList<>(); for (int i=1; i<=n-1; i++) { int a = io.nextInt(); int b = io.nextInt(); g[a].add(b); g[b].add(a); } return g; } private class IO extends PrintWriter { private InputStreamReader r; private static final int BUFSIZE = 1 << 15; private char[] buf; private int bufc; private int bufi; private StringBuilder sb; public IO() { super(new BufferedOutputStream(System.out)); r = new InputStreamReader(System.in); buf = new char[BUFSIZE]; bufc = 0; bufi = 0; sb = new StringBuilder(); } private void fillBuf() throws IOException { bufi = 0; bufc = 0; while(bufc == 0) { bufc = r.read(buf, 0, BUFSIZE); if(bufc == -1) { bufc = 0; return; } } } private boolean pumpBuf() throws IOException { if(bufi == bufc) { fillBuf(); } return bufc != 0; } private boolean isDelimiter(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f'; } private void eatDelimiters() throws IOException { while(true) { if(bufi == bufc) { fillBuf(); if(bufc == 0) throw new RuntimeException("IO: Out of input."); } if(!isDelimiter(buf[bufi])) break; ++bufi; } } public String next() { try { sb.setLength(0); eatDelimiters(); int start = bufi; while(true) { if(bufi == bufc) { sb.append(buf, start, bufi - start); fillBuf(); start = 0; if(bufc == 0) break; } if(isDelimiter(buf[bufi])) break; ++bufi; } sb.append(buf, start, bufi - start); return sb.toString(); } catch(IOException e) { throw new RuntimeException("IO.next: Caught IOException."); } } public int nextInt() { try { int ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextInt: Invalid int."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextInt: Invalid int."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -214748364) throw new RuntimeException("IO.nextInt: Invalid int."); ret *= 10; ret -= (int)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextInt: Invalid int."); } else { throw new RuntimeException("IO.nextInt: Invalid int."); } ++bufi; } if(positive) { if(ret == -2147483648) throw new RuntimeException("IO.nextInt: Invalid int."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextInt: Caught IOException."); } } public long nextLong() { try { long ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextLong: Invalid long."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextLong: Invalid long."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -922337203685477580L) throw new RuntimeException("IO.nextLong: Invalid long."); ret *= 10; ret -= (long)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextLong: Invalid long."); } else { throw new RuntimeException("IO.nextLong: Invalid long."); } ++bufi; } if(positive) { if(ret == -9223372036854775808L) throw new RuntimeException("IO.nextLong: Invalid long."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextLong: Caught IOException."); } } public double nextDouble() { return Double.parseDouble(next()); } } } }
Main.java:79: error: cannot find symbol private class IO extends PrintWriter { ^ symbol: class PrintWriter location: class Solver Main.java:67: error: cannot find symbol private List<Integer>[] toGraph(IO io, int n) { ^ symbol: class List location: class Solver Main.java:80: error: cannot find symbol private InputStreamReader r; ^ symbol: class InputStreamReader location: class Solver.IO Main.java:97: error: cannot find symbol private void fillBuf() throws IOException { ^ symbol: class IOException location: class Solver.IO Main.java:109: error: cannot find symbol private boolean pumpBuf() throws IOException { ^ symbol: class IOException location: class Solver.IO Main.java:120: error: cannot find symbol private void eatDelimiters() throws IOException { ^ symbol: class IOException location: class Solver.IO Main.java:15: error: cannot find symbol io.close(); ^ symbol: method close() location: variable io of type Solver.IO Main.java:35: error: cannot find symbol io.println(mincost); ^ symbol: method println(long) location: variable io of type Solver.IO Main.java:68: error: cannot find symbol List<Integer>[] g = new ArrayList[n+1]; ^ symbol: class List location: class Solver Main.java:68: error: cannot find symbol List<Integer>[] g = new ArrayList[n+1]; ^ symbol: class ArrayList location: class Solver Main.java:69: error: cannot find symbol for (int i=1; i<=n; i++) g[i] = new ArrayList<>(); ^ symbol: class ArrayList location: class Solver Main.java:88: error: cannot find symbol super(new BufferedOutputStream(System.out)); ^ symbol: class BufferedOutputStream location: class Solver.IO Main.java:89: error: cannot find symbol r = new InputStreamReader(System.in); ^ symbol: class InputStreamReader location: class Solver.IO Main.java:154: error: cannot find symbol } catch(IOException e) { ^ symbol: class IOException location: class Solver.IO Main.java:199: error: cannot find symbol } catch(IOException e) { ^ symbol: class IOException location: class Solver.IO Main.java:244: error: cannot find symbol } catch(IOException e) { ^ symbol: class IOException location: class Solver.IO 16 errors
s690441379
p04025
Java
import java.io.*; import java.util.*; public class B { public static void main(String[] args) { Solver solver = new Solver(); } static class Solver { IO io; public Solver() { this.io = new IO(); try { solve(); } finally { io.close(); } } /****************************** START READING HERE ********************************/ void solve() { String s = io.next(); io.println(); } /************************** UTILITY CODE BELOW THIS LINE **************************/ class Point { int y; int x; public Point(int y, int x) { this.y = y; this.x = x; } } class IDval implements Comparable<IDval> { int id; long val; public IDval(int id, long val) { this.val = val; this.id = id; } @Override public int compareTo(IDval o) { if (this.val < o.val) return -1; if (this.val > o.val) return 1; return this.id - o.id; } } private List<Integer>[] toGraph(IO io, int n) { List<Integer>[] g = new ArrayList[n+1]; for (int i=1; i<=n; i++) g[i] = new ArrayList<>(); for (int i=1; i<=n-1; i++) { int a = io.nextInt(); int b = io.nextInt(); g[a].add(b); g[b].add(a); } return g; } private class IO extends PrintWriter { private InputStreamReader r; private static final int BUFSIZE = 1 << 15; private char[] buf; private int bufc; private int bufi; private StringBuilder sb; public IO() { super(new BufferedOutputStream(System.out)); r = new InputStreamReader(System.in); buf = new char[BUFSIZE]; bufc = 0; bufi = 0; sb = new StringBuilder(); } private void fillBuf() throws IOException { bufi = 0; bufc = 0; while(bufc == 0) { bufc = r.read(buf, 0, BUFSIZE); if(bufc == -1) { bufc = 0; return; } } } private boolean pumpBuf() throws IOException { if(bufi == bufc) { fillBuf(); } return bufc != 0; } private boolean isDelimiter(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f'; } private void eatDelimiters() throws IOException { while(true) { if(bufi == bufc) { fillBuf(); if(bufc == 0) throw new RuntimeException("IO: Out of input."); } if(!isDelimiter(buf[bufi])) break; ++bufi; } } public String next() { try { sb.setLength(0); eatDelimiters(); int start = bufi; while(true) { if(bufi == bufc) { sb.append(buf, start, bufi - start); fillBuf(); start = 0; if(bufc == 0) break; } if(isDelimiter(buf[bufi])) break; ++bufi; } sb.append(buf, start, bufi - start); return sb.toString(); } catch(IOException e) { throw new RuntimeException("IO.next: Caught IOException."); } } public int nextInt() { try { int ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextInt: Invalid int."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextInt: Invalid int."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -214748364) throw new RuntimeException("IO.nextInt: Invalid int."); ret *= 10; ret -= (int)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextInt: Invalid int."); } else { throw new RuntimeException("IO.nextInt: Invalid int."); } ++bufi; } if(positive) { if(ret == -2147483648) throw new RuntimeException("IO.nextInt: Invalid int."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextInt: Caught IOException."); } } public long nextLong() { try { long ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextLong: Invalid long."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextLong: Invalid long."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -922337203685477580L) throw new RuntimeException("IO.nextLong: Invalid long."); ret *= 10; ret -= (long)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextLong: Invalid long."); } else { throw new RuntimeException("IO.nextLong: Invalid long."); } ++bufi; } if(positive) { if(ret == -9223372036854775808L) throw new RuntimeException("IO.nextLong: Invalid long."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextLong: Caught IOException."); } } public double nextDouble() { return Double.parseDouble(next()); } } } }
Main.java:4: error: class B is public, should be declared in a file named B.java public class B { ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s720792076
p04025
C++
#include <iostream> #include <sstream> #include <algorithm> #include <string> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <stack> #include <memory> #include <complex> #include <numeric> #include <cstdio> #include <iomanip> #include <cmath> #define REP(i,m,n) for(int i=int(m);i<int(n);i++) #define EACH(i,c) for (auto &(i): c) #define all(c) begin(c),end(c) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define SORT(c) sort(begin(c),end(c)) #define pb emplace_back #define MP make_pair #define SZ(a) int((a).size()) #ifdef LOCAL #define DEBUG(s) cout << (s) << endl #define dump(x) cerr << #x << " = " << (x) << endl #define BR cout << endl; #else #define DEBUG(s) do{}while(0) #define dump(x) do{}while(0) #define BR #endif using namespace std; using UI = unsigned int; using UL = unsigned long; using LL = long long int; using ULL = unsigned long long; using VI = vector<int>; using VVI = vector<VI>; using VLL = vector<LL>; using VS = vector<string>; using PII = pair<int,int>; using VP = vector<PII>; //struct edge {int from, to, cost;}; constexpr double EPS = 1e-10; constexpr double PI = acos(-1.0); constexpr int INF = INT_MAX; template<class T> inline T sqr(T x) {return x*x;} int main() { int n; cin >> n; int sum = 0; VI a(n); REP(i,0,n) { cin >> a[i]; sum += a[i]; } int dst = round(1.0*sum/n); int ans = 0; REP(i,0,n) { ans += (a[i] - dst) * (a[i] - dst); } cout << ans << endl; return 0; }
a.cc:53:21: error: 'INT_MAX' was not declared in this scope 53 | constexpr int INF = INT_MAX; | ^~~~~~~ a.cc:17:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 16 | #include <cmath> +++ |+#include <climits> 17 |
s119572662
p04025
Java
import java.io.*; import java.util.*; public class A { public static void main(String[] args) { Solver solver = new Solver(); } static class Solver { IO io; public Solver() { this.io = new IO(); try { solve(); } finally { io.close(); } } /****************************** START READING HERE ********************************/ void solve() { int n = io.nextInt(); int[] a = new int[n]; for (int i=0; i<n; i++) { a[i] = io.nextInt(); } long mincost = Long.MAX_VALUE; for (int val=-100; val<=100; val++) { long cost = 0; for (int i=0; i<n; i++) { cost += (a[i] - val) * (a[i] - val); } mincost = Math.min(cost, mincost); } io.println(mincost); } /************************** UTILITY CODE BELOW THIS LINE **************************/ class Point { int y; int x; public Point(int y, int x) { this.y = y; this.x = x; } } class IDval implements Comparable<IDval> { int id; long val; public IDval(int id, long val) { this.val = val; this.id = id; } @Override public int compareTo(IDval o) { if (this.val < o.val) return -1; if (this.val > o.val) return 1; return this.id - o.id; } } private List<Integer>[] toGraph(IO io, int n) { List<Integer>[] g = new ArrayList[n+1]; for (int i=1; i<=n; i++) g[i] = new ArrayList<>(); for (int i=1; i<=n-1; i++) { int a = io.nextInt(); int b = io.nextInt(); g[a].add(b); g[b].add(a); } return g; } private class IO extends PrintWriter { private InputStreamReader r; private static final int BUFSIZE = 1 << 15; private char[] buf; private int bufc; private int bufi; private StringBuilder sb; public IO() { super(new BufferedOutputStream(System.out)); r = new InputStreamReader(System.in); buf = new char[BUFSIZE]; bufc = 0; bufi = 0; sb = new StringBuilder(); } private void fillBuf() throws IOException { bufi = 0; bufc = 0; while(bufc == 0) { bufc = r.read(buf, 0, BUFSIZE); if(bufc == -1) { bufc = 0; return; } } } private boolean pumpBuf() throws IOException { if(bufi == bufc) { fillBuf(); } return bufc != 0; } private boolean isDelimiter(char c) { return c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f'; } private void eatDelimiters() throws IOException { while(true) { if(bufi == bufc) { fillBuf(); if(bufc == 0) throw new RuntimeException("IO: Out of input."); } if(!isDelimiter(buf[bufi])) break; ++bufi; } } public String next() { try { sb.setLength(0); eatDelimiters(); int start = bufi; while(true) { if(bufi == bufc) { sb.append(buf, start, bufi - start); fillBuf(); start = 0; if(bufc == 0) break; } if(isDelimiter(buf[bufi])) break; ++bufi; } sb.append(buf, start, bufi - start); return sb.toString(); } catch(IOException e) { throw new RuntimeException("IO.next: Caught IOException."); } } public int nextInt() { try { int ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextInt: Invalid int."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextInt: Invalid int."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -214748364) throw new RuntimeException("IO.nextInt: Invalid int."); ret *= 10; ret -= (int)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextInt: Invalid int."); } else { throw new RuntimeException("IO.nextInt: Invalid int."); } ++bufi; } if(positive) { if(ret == -2147483648) throw new RuntimeException("IO.nextInt: Invalid int."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextInt: Caught IOException."); } } public long nextLong() { try { long ret = 0; eatDelimiters(); boolean positive = true; if(buf[bufi] == '-') { ++bufi; if(!pumpBuf()) throw new RuntimeException("IO.nextLong: Invalid long."); positive = false; } boolean first = true; while(true) { if(!pumpBuf()) break; if(isDelimiter(buf[bufi])) { if(first) throw new RuntimeException("IO.nextLong: Invalid long."); break; } first = false; if(buf[bufi] >= '0' && buf[bufi] <= '9') { if(ret < -922337203685477580L) throw new RuntimeException("IO.nextLong: Invalid long."); ret *= 10; ret -= (long)(buf[bufi] - '0'); if(ret > 0) throw new RuntimeException("IO.nextLong: Invalid long."); } else { throw new RuntimeException("IO.nextLong: Invalid long."); } ++bufi; } if(positive) { if(ret == -9223372036854775808L) throw new RuntimeException("IO.nextLong: Invalid long."); ret = -ret; } return ret; } catch(IOException e) { throw new RuntimeException("IO.nextLong: Caught IOException."); } } public double nextDouble() { return Double.parseDouble(next()); } } } }
Main.java:4: error: class A is public, should be declared in a file named A.java public class A { ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s470293869
p04025
C++
import static java.lang.Math.*; import static java.util.Arrays.*; import java.util.*; import java.io.*; public class Main { void solve() { int N = sc.nextInt(); int[] a = sc.nextIntArray(N); int ans = Integer.MAX_VALUE; for (int c = -100; c <= 100; c++) { int y = check(a, c); ans = Math.min(ans, y); } out.println(ans); } int check(int [] a, int c) { int res = 0; for (int x : a) res += (x - c) * (x - c); return res; } static void tr(Object... os) { System.err.println(deepToString(os)); } static void tr(int[][] as) { for (int[] a : as) tr(a); } void print(int[] a) { out.print(a[0]); for (int i = 1; i < a.length; i++) out.print(" " + a[i]); out.println(); } public static void main(String[] args) throws Exception { new Main().run(); } MyScanner sc = null; PrintWriter out = null; public void run() throws Exception { sc = new MyScanner(System.in); out = new PrintWriter(System.out); for (;sc.hasNext();) { solve(); out.flush(); } out.close(); } class MyScanner { String line; BufferedReader reader; StringTokenizer tokenizer; public MyScanner(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public void eat() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { line = reader.readLine(); if (line == null) { tokenizer = null; return; } tokenizer = new StringTokenizer(line); } catch (IOException e) { throw new RuntimeException(e); } } } public String next() { eat(); return tokenizer.nextToken(); } public String nextLine() { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } public boolean hasNext() { eat(); return (tokenizer != null && tokenizer.hasMoreElements()); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } } }
a.cc:1:1: error: 'import' does not name a type 1 | import static java.lang.Math.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import static java.util.Arrays.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.*; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.*; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: expected unqualified-id before 'public' 6 | public class Main { | ^~~~~~
s334558906
p04026
C++
/* vrrtll==???>;::::~~~~~~......`.`````````````````````...-?777!_.._?7u,~~~::::;>>??=lllttrrzu rtll==??>>;::::~~~~......`.`````````````````` ..J77!`````````...`..._T,~~~~:::;;>??==lttrrv tll=??>>;:::~~~~......``````````````````..J7^ ` `` ` `` .,```````...._4,.~~~::;;>>?===lttr l=???>;;::~~~......`````HTSu,.`` `..J7! ` `` .J"~N```````````..?&.~~~~::;;>>?==llt =??>;;::~~~~.....``````.@????7SJ.?= ` ` `` .J=....J; ``````````..h..~~~~::;;>??=ll ?>>;::~~~~.....````````.D?>>?>?>?8+.`` `.J"_......_b` ````````.S_.~~~~::;;>??=l >;;::~~~~....``````````.C>??>>>?>>>?8J.` ```..Y~..........J; ` ` ``````` G...~~~~::;>??= ;;::~~~....```````` `..W1>>?>>>>?>>>>>?S,.`.7^.............-N`` ` ``````` 6...~~~~::;>?? ;:~~~~....``````` ..7` d??>>?>?>>?>>?>>1udMgggNNNNggJ.......([ `````.L...~~~~::;>? :~~~.....`````` .7` `K>?>?>>>>>>+ugNMMMB""7<!~~<?7TWMNNa,..w.` ` ` ` `````,)....~~:::;> ~~~....``````.J^ ` #>>?>>>?jgMMM9=_................-?TMMa,b` ` ` ` ````(,...~~~~:;; ~~~....``` .7`` ` @?>>?1uMM#=.........................(TMNa...... ` ``````4....~~~::; ~~~...`` .=`` ` ` .b>>jgNH".................`.............?HNmx??17TYY9SA+(..L....~~~:: ~....` ,^`` ` ` .b+dN#^............6..-(,-...`............(HMm+>>>>>?>>????zOM_.~~~:: .... .=``` `` ` ...JNMM^..........`..._n.(MMN,....`..`.........?MNe<>>?>??>????d^...~~~: ~...v```` ` ..-Z""!_..(M@_........`........?7MMMMp.................-TNN+?>>>????1d4-..-(Jk9 ..(^`...zY"!_........(MD..............`......JMMMMp....`..`..`......./MNx>??>>?1d!.h7=~(??= (v_`,R_.............(NF..(/..(&,...`..........?MMMM;..................(MMs>>?1&T"!``....(1= t..`` 4,...........(N@....?,(NMNR_.....`..`....(WMM$..`....`..`..`....._HMe7=```````....~_1 ...````.4,........-dM:.....(7MMMNR-.....................`............(.?^ `` ``````....~~~ ...``````,4,....`.(NF........(MMMMb..`....--................`....(.7! ` ````....~~: ..````` ` `.5J_...JMt.........?NMMM[...`.HH5._(J7[...`...`...--?^` ` `````....~~~: ...````` ` ` 7a,.dM{....`...../MMMN......(J=` .>......._(/= ` ` `````...~~~: ....```` `` (4MN{..........._7"^...(/^ `.C....-(J=` ` ` ```....~~~: ....````` ` JdM[...`...`........`_3.. ..?!..(-7! ` ` ``````....~~~:: r...`````` ` ``(CJMb..............`......__..-(?^ ` ` `````....~~::; J/...````` ` `,3>+MN-.`..`...`..........._(J=`` ` ` ```````....~~~::; _j,..`.```` ``.5>>?dNb...`......`......_-?'` ` `````....~~~::;; ~~j,..```````.D??>>>MM/....`........(-=` ` ` ` ```````...~~~:::;> ~~~j,...````.E??>??>?MN-.........(J= ` ` ` ``````....~~~~::;?? :~~~?,...``.@>?>?>>??dMN_....-(?^ ` ` ` ` ````````...~~~~:;;>?? ::~~~?/....K??????>>?>dMN-_(7! ` ` ` ````````....~~~:::>>??l ;:::~~/e.(K==?????????<dM"! ` ` ` ` `` ``````...~~~~:::;>??=l @TT_beginner */ #include "bits/stdc++.h" using namespace std; #define ok1 cerr<<"ok1\n"; #define ok2 cerr<<"ok2\n"; #define M LLONG_MAX #define rep(i,n) for(ll i=0;i<n;++i) #define REP(i,s,n) for(ll i=(s);i<(n);++i) #define repr(i,n) for(ll i=n-1;i>=0;--i) #define REPR(i,s,n) for(ll i=(s);i>=(n);--(i)) #define all(a) (a).begin(),(a).end() #define reall(a) (a).rbegin(),(a).rend() #define pb emplace_back //emplace_backの方が速いが使い慣れてないため #define DOUBLE fixed << setprecision(15) #define fi first #define se second #define mp make_pair #define mt make_tuple #define out(x, y) ((x) < 0 || h <= (x) || (y) < 0 || w <= (y)) #define TO_STRING(VariableName) # VariableName #define debug(x) cerr<<TO_STRING(x)<<" is: "<<x<<" "<<endl; const double pi = acos(-1.0L); typedef vector<int> vi; typedef vector<string> vs; typedef long long ll; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vll> vvll; typedef vector<char> vc; typedef vector<double> vd; typedef vector<bool> vb; typedef deque<ll> dll; typedef pair<ll, ll> P; typedef tuple<ll, ll, ll> TLL; typedef vector<P> vP; typedef vector<TLL> vTLL; const ll mod = 1e9 + 7; //const ll mod = 998244353; ll dx[8] = { -1,0,1,0,1,1,-1,-1 }; ll dy[8] = { 0,-1,0,1,1,-1,1,-1 }; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template<class A, class B> ostream& operator<<(ostream& ost, const pair<A, B>&p) { ost << "{ " << p.first << ", " << p.second << " }"; return ost; } template<class T> ostream& operator<<(ostream& ost, const vector<T>&v) { ost << "{ "; for (int i = 0; i<v.size(); i++) { if (i)ost << ", "; ost << v[i]; } ost << " }"; return ost; } template<class A, class B> ostream& operator<<(ostream& ost, const map<A, B>&v) { ost << "{ "; for (auto p : v) { ost << "{ " << p.first << ", " << p.second << " }"; } ost << " }"; return ost; } void debugs() { std::cerr << "\n"; } template <class T, class... Args> void debugs(const T &x, const Args &... args) { std::cerr << x << " "; debugs(args...); } bool out_check(ll a, ll b) { return (0 <= a && a < b); } double pitagoras(ll a, ll b, ll c, ll d) { double dx = a - b, dy = c - d; return pow(dx * dx + dy * dy, 0.5); } ll modpow(ll a, ll b, ll mo = mod) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mo; }a = a * a%mo; b >>= 1; }return c; } void Yes(bool x) { cout << ((x) ? "Yes\n" : "No\n"); } void YES(bool x) { cout << ((x) ? "YES\n" : "NO\n"); } void yes(bool x) { cout << ((x) ? "yes\n" : "no\n"); } void Yay(bool x) { cout << ((x) ? "Yay!\n" : ":(\n"); } void OK(bool x) { cout << ((x) ? "OK!\n" : "NG\n"); } //* ll n, m, d, e, l, r, k, h, w, Q, ans, ret = M; bool flag = false, flag2 = false, flag3 = false; string s, t, u; //* /* For AtCoder Only #include "atcoder/all" using namespace atcoder; //*/ int main() { //cin.tie(0); ios::sync_with_stdio(false);//not interactive cin >> s; n = s.size(); vvll c(26, vll(n, 0)); 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; } } puts("-1 -1"); return 0; } char nc = s[i] - 'a'; c[nc][i]++; if (!i) { rep(j, 26)c[j][i] += c[j][i - 1]; }
a.cc:152:13: error: 'i' was not declared in this scope 152 | char nc = s[i] - 'a'; | ^ a.cc:153:1: error: 'c' does not name a type; did you mean 'vc'? 153 | c[nc][i]++; | ^ | vc a.cc:154:1: error: expected unqualified-id before 'if' 154 | if (!i) { | ^~
s097308221
p04026
C++
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") ///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native") #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> /* zet: find_by_order(k): k-stat [k > 0] order_of_key(k) : {el < k} gp_hash_table<key, val, custom_hash> rope<T>: iterators: mutable_begin, .. methods : erase, insert, substr, .. */ #define all(x) (x).begin(), (x).end() #define size(x) (int)((x).size()) #define em_back emplace_back using namespace std; using namespace __gnu_cxx; using namespace __gnu_pbds; using ll = long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; template<typename T> using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; mt19937 eng(chrono::steady_clock::now().time_since_epoch().count()); bool check(string& s) { static int let['z' - 'a' + 1]; memset(let, 0, sizeof let); for (char c : s) { let[c - 'a']++; if (let[c - 'a'] * 2 > size(s)) { return true; } } return false; } void solve() { string s; cin >> s; for (int i = 0; i < size(s); ++i) { for (int j = i + 1; j < size(j) && j - i + 1 < 4; ++j) { string t = s.substr(i, j - i + 1); if (check(t)) { cout << i + 1 << " " << j + 1 << "\n"; return; } } } cout << "-1 -1\n"; } int main() { ios::sync_with_stdio(0); cout.tie(0), cin.tie(0); int z = 1; /// cin >> z; while (z--) { solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:22:27: error: request for member 'size' in 'j', which is of non-class type 'int' 22 | #define size(x) (int)((x).size()) | ^~~~ a.cc:72:33: note: in expansion of macro 'size' 72 | for (int j = i + 1; j < size(j) && j - i + 1 < 4; ++j) { | ^~~~
s211114793
p04026
C++
b#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 100010; int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); string s; cin >> s ; for(int i = 0;i<s.size() - 1;++i){ if(s[i] == s[i+1]){ cout << i + 1 << ' ' << i+2 << endl; return 0; } if(i < s.size() - 2 && s[i] == s[i+2]){ cout << i + 1 << ' ' << i+3 << endl; return 0; } } cout << "-1 -1" << endl; return 0; }
a.cc:1:2: error: stray '#' in program 1 | b#include <bits/stdc++.h> | ^ a.cc:1:1: error: 'b' does not name a type 1 | b#include <bits/stdc++.h> | ^ a.cc: In function 'int main()': a.cc:7:9: error: 'ios' has not been declared 7 | ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); | ^~~ a.cc:7:38: error: 'cin' was not declared in this scope 7 | ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); | ^~~ a.cc:7:50: error: 'cout' was not declared in this scope 7 | ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); | ^~~~ a.cc:8:9: error: 'string' was not declared in this scope 8 | string s; | ^~~~~~ a.cc:9:16: error: 's' was not declared in this scope 9 | cin >> s ; | ^ a.cc:12:56: error: 'endl' was not declared in this scope 12 | cout << i + 1 << ' ' << i+2 << endl; | ^~~~ a.cc:16:56: error: 'endl' was not declared in this scope 16 | cout << i + 1 << ' ' << i+3 << endl; | ^~~~ a.cc:20:28: error: 'endl' was not declared in this scope 20 | cout << "-1 -1" << endl; | ^~~~
s364314415
p04026
C++
#include <iostream> #include<string> using namespace std; int main() { string s; int mark = 0; for (int i = 0; i <= s.length()-1; i++) { if (s[i] == s[i + 1] && i + 1 < s.length()) { mark = 1; cout << i + 1 << " " << i + 2 << endl; break; } else if (s[i] == s[i + 2] && i + 2 < s.length()) { cout << i + 1 << " " << i + 3 << endl; mark = 1; break; } } if (mark == 0) cout << -1 << " " << -1 << endl; } }
a.cc:26:1: error: expected declaration before '}' token 26 | } | ^
s750246838
p04026
C++
#include <bits/stdc++.h> using namespace std; #define ll long long ll dp[5009]; ll a[5000]; int main() { string s;cin>>s; for(int i=0;i<s.size();i++){ set<char>ss; ss.insert(s[i]); if(i+1<s.size()){ ss.insert(s[i+1]); if(ss.size()==1){ cout<<i+1<<" "<<i+2; return 0; } } if(i+2<s.size()){ ss.insert(s[i+2]);
a.cc: In function 'int main()': a.cc:22:26: error: expected '}' at end of input 22 | ss.insert(s[i+2]); | ^ a.cc:21:24: note: to match this '{' 21 | if(i+2<s.size()){ | ^ a.cc:22:26: error: expected '}' at end of input 22 | ss.insert(s[i+2]); | ^ a.cc:11:31: note: to match this '{' 11 | for(int i=0;i<s.size();i++){ | ^ a.cc:22:26: error: expected '}' at end of input 22 | ss.insert(s[i+2]); | ^ a.cc:9:1: note: to match this '{' 9 | { | ^
s837493034
p04026
C++
#include<bits/stdc++.h> using namespace std; char a[100005]; int p[60][100005],len[30],n; void f(char a,int k){ int s; if('a' <= a && a <= 'z') s = a - 'a' + 1; if('A' <= a && a <= 'Z') s = a - 'A' + 27; p[s][++len[s]] = k; } signed main(){ // freopen("date.in","r",stdin); // freopen("date.out","w",stdout); gets(a); n = strlen(a) - 1; for(int i = 1; i <= n; i++) f(a[i],i); for(int i = 1; i <= 52; i++){ for(int j = 2; j <= len[i]; j++){ if(p[i][j] - p[i][j - 1] <= 2){ printf("%d %d",p[i][j - 1],p[i][j]); return 0; } } } printf("-1 -1"); }
a.cc: In function 'int main()': a.cc:14:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 14 | gets(a); | ^~~~ | getw
s548508864
p04026
C++
#define _CRT_SECURE_NO_WARNINGS #pragma warning(disable: 4244) // 最悪をします #include <iostream> #include <cmath> #include <algorithm> #include <vector> #include <numeric> #include <queue> #include <stack> #include <map> #include <set> #include <string> #include <functional> #include <list> #include <random> #include <time.h> #include <iomanip> #include <assert.h> #include <numeric> #include <sstream> #define BIT(nr) (1UL << (nr)) #define int long long //#define ll long long #define double long double #define mod 1000000007 #define MAXN (int)1e+5 * 2+1 #define LL_MAX 9223372036854775807 //ない環境用 #define LL_HALFMAX 9223372036854775807 / 2 //ない環境用 #define MIN -(9223372036854775807 / 2) #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() #define REPS(i,x) for(int i=1;i<=(int)(x);i++) #define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--) #define RREPS(i,x) for(int i=((int)(x));i>0;i--) #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define mp make_pair template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; } template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; } using namespace std; //デバッグ用カッコの有無 #ifdef DEBUG template <class T>ostream &operator<<(ostream &o, const vector<T>&v) { o << "{"; for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? ", " : "") << v[i]; o << "}"; return o; } #endif // DEBUG template <class T>ostream &operator<<(ostream &o, const vector<T>&v) { for (int i = 0; i<(int)v.size(); i++)o << (i>0 ? " " : "") << v[i]; return o; } int dx[4] = { 0, 1, 0, -1 }; // x軸方向への変位 int dy[4] = { 1, 0, -1, 0 }; // y軸方向への変位 int dxp[4] = { 0, 1 }; // x軸方向への変位(正のみ) int dyp[4] = { 1, 0 }; // y軸方向への変位(負のみ) using Weight = int; using Flow = int; struct Edge { int src, dst; // libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持 int rev; Weight weight; Flow cap; Edge() : src(0), dst(0), weight(0) {} Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {} }; using Edges = std::vector<Edge>; using Graph = std::vector<Edges>; using Array = std::vector<Weight>; using Matrix = std::vector<Array>; void add_edge(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); g[b].emplace_back(b, a, w); } void add_arc(Graph& g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); } // 辺がメンバに src と dst を持つ隣接リスト表記のグラフをダンプ(https://hello-world-494ec.firebaseapp.com/) に投げることを想定 template <typename T> void dump_graph(T G) { int V = G.size(); int E = 0; ostringstream os; for (auto es : G) { for (auto e : es) { E++; os << e.src << " " << e.dst << "\n"; } } cout << V << " " << E << "\n"; cout << os.str() << "\n"; } // グリッドからグラフを構築 // @pre: gはノード数H*Wのグラフ void create_from_grid(Graph& g, int h, int w, vector<string>& mapData, char wall) { //グラフ構築 O(HW) rep(y, h) { rep(x, w) { if (mapData[y][x] == wall) { continue; } int id = y * w + x; //右と下(変位が正)のみ見る(辺の重複を回避するため) rep(i, 2) { int nx = x + dxp[i]; int ny = y + dyp[i]; int nid = ny * w + nx; if (nx < 0 || nx >= w) { continue; } if (ny < 0 || ny >= h) { continue; } if (mapData[ny][nx] != wall) { add_edge(g, id, nid); } } } } } // マスに重みが定義されるグリッドから重み付きグラフを構築、ダイクストラなどをするとき始点のこすとは入らないことに注意 // @pre: gはノード数H*Wのグラフ void create_weighted_from_grid(Graph& g, int h, int w, vector<vector<int>>& mapData) { //グラフ構築 O(HW) rep(y, h) { rep(x, w) { int id = y * w + x; // こんどは全方向見る(行きと帰りで重みが違うはず) rep(i, 4) { int nx = x + dx[i]; int ny = y + dy[i]; int nid = ny * w + nx; if (nx < 0 || nx >= w) { continue; } if (ny < 0 || ny >= h) { continue; } // 移動先のコストを足す add_arc(g, id, nid, mapData[ny][nx]); } } } } // グリッドにおいて座標をグラフのノード番号に変換する int point_to_node_num(int x, int y, int W) { return y * W + x; } struct uf_tree { std::vector<int> parent; int __size; uf_tree(int size_) : parent(size_, -1), __size(size_) {} void unite(int x, int y) { if ((x = find(x)) != (y = find(y))) { if (parent[y] < parent[x]) std::swap(x, y); parent[x] += parent[y]; parent[y] = x; __size--; } } bool is_same(int x, int y) { return find(x) == find(y); } int find(int x) { return parent[x] < 0 ? x : parent[x] = find(parent[x]); } int size(int x) { return -parent[find(x)]; } int size() { return __size; } }; //!!!問題をちゃんと読む!!! //!!!問題をちゃんと読め!!! //!!!問題は読みましたか?!!! template <signed M, unsigned T> struct mod_int { constexpr static signed MODULO = M; constexpr static unsigned TABLE_SIZE = T; signed x; mod_int() : x(0) {} mod_int(long long y) : x(static_cast<signed>(y >= 0 ? y % MODULO : MODULO - (-y) % MODULO)) {} mod_int(signed y) : x(y >= 0 ? y % MODULO : MODULO - (-y) % MODULO) {} mod_int& operator+=(const mod_int& rhs) { if ((x += rhs.x) >= MODULO) x -= MODULO; return *this; } mod_int& operator-=(const mod_int& rhs) { if ((x += MODULO - rhs.x) >= MODULO) x -= MODULO; return *this; } mod_int& operator*=(const mod_int& rhs) { x = static_cast<signed>(1LL * x * rhs.x % MODULO); return *this; } mod_int& operator/=(const mod_int& rhs) { x = static_cast<signed>((1LL * x * rhs.inv().x) % MODULO); return *this; } mod_int operator-() const { return mod_int(-x); } mod_int operator+(const mod_int& rhs) const { return mod_int(*this) += rhs; } mod_int operator-(const mod_int& rhs) const { return mod_int(*this) -= rhs; } mod_int operator*(const mod_int& rhs) const { return mod_int(*this) *= rhs; } mod_int operator/(const mod_int& rhs) const { return mod_int(*this) /= rhs; } bool operator<(const mod_int& rhs) const { return x < rhs.x; } mod_int inv() const { assert(x != 0); if (x <= static_cast<signed>(TABLE_SIZE)) { if (_inv[1].x == 0) prepare(); return _inv[x]; } else { signed a = x, b = MODULO, u = 1, v = 0, t; while (b) { t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); } return mod_int(u); } } mod_int pow(long long t) const { assert(!(x == 0 && t == 0)); mod_int e = *this, res = mod_int(1); for (; t; e *= e, t >>= 1) if (t & 1) res *= e; return res; } mod_int fact() { if (_fact[0].x == 0) prepare(); return _fact[x]; } mod_int inv_fact() { if (_fact[0].x == 0) prepare(); return _inv_fact[x]; } mod_int choose(mod_int y) { assert(y.x <= x); return this->fact() * y.inv_fact() * mod_int(x - y.x).inv_fact(); } static mod_int _inv[TABLE_SIZE + 1]; static mod_int _fact[TABLE_SIZE + 1]; static mod_int _inv_fact[TABLE_SIZE + 1]; static void prepare() { _inv[1] = 1; for (int i = 2; i <= (int)TABLE_SIZE; ++i) { _inv[i] = 1LL * _inv[MODULO % i].x * (MODULO - MODULO / i) % MODULO; } _fact[0] = 1; for (unsigned i = 1; i <= TABLE_SIZE; ++i) { _fact[i] = _fact[i - 1] * signed(i); } _inv_fact[TABLE_SIZE] = _fact[TABLE_SIZE].inv(); for (int i = (int)TABLE_SIZE - 1; i >= 0; --i) { _inv_fact[i] = _inv_fact[i + 1] * (i + 1); } } }; template <signed M, unsigned F> std::ostream& operator<<(std::ostream& os, const mod_int<M, F>& rhs) { return os << rhs.x; } template <signed M, unsigned F> std::istream& operator >> (std::istream& is, mod_int<M, F>& rhs) { long long s; is >> s; rhs = mod_int<M, F>(s); return is; } template <signed M, unsigned F> mod_int<M, F> mod_int<M, F>::_inv[TABLE_SIZE + 1]; template <signed M, unsigned F> mod_int<M, F> mod_int<M, F>::_fact[TABLE_SIZE + 1]; template <signed M, unsigned F> mod_int<M, F> mod_int<M, F>::_inv_fact[TABLE_SIZE + 1]; template <signed M, unsigned F> bool operator==(const mod_int<M, F>& lhs, const mod_int<M, F>& rhs) { return lhs.x == rhs.x; } template <int M, unsigned F> bool operator!=(const mod_int<M, F>& lhs, const mod_int<M, F>& rhs) { return !(lhs == rhs); } const signed MF = 1000010; const signed MOD = 1000000007; using mint = mod_int<MOD, MF>; mint binom(int n, int r) { return (r < 0 || r > n || n < 0) ? 0 : mint(n).choose(r); } mint fact(int n) { return mint(n).fact(); } mint inv_fact(int n) { return mint(n).inv_fact(); } //出典 http://beet-aizu.hatenablog.com/entry/2017/12/01/225955 /* コンストラクタ引数説明 int n_ 要素数。 f 2つの要素Tをマージするための関数。 区間MAX区間更新の時: max 区間Sum区間Addの時: + g 1つの要素Tに作用素Eを適用するための関数。 区間MAX区間更新の時: = 区間Sum区間Addの時: + h 2つの作用素Eをマージするための関数。 区間MAX区間更新の時: = 区間Sum区間Addの時: + T d1 演算fの単位元。 区間MAX区間更新の時: -INF  区間Sum区間Addの時: 0 E d0, g, hの単位元。 区間MAX区間更新の時: 定義域外のどこか 区間Sum区間Addの時: 0 vector<T> v = vector<T>() セグ木を構成するときのvector P p = [](E a, int b) {return a; } 区間の長さbを引数に取り、区間の長さによって変化する作用素E'を返す関数。 例えば、区間MAX区間Addの時なんかは区間長によって足すべき数が変化するので必要 区間Sum区間Addの時: * //具体例 //区間chmin, 区間min auto myMin = [](int a, int b) {return min(a, b); }; SegmentTree<int, int> seg(n, myMin, myMin, myMin, LL_HALFMAX, LL_HALFMAX); //区間update、区間min SegmentTree<int, int> seg(n, myMin, myMin, myMin, LL_HALFMAX, LL_HALFMAX); //区間Add、区間Sum vector<int> v(0, N + 1); SegmentTree<int, int> segtree(N + 1, plus<int>(), plus<int>(), plus<int>(), 0, 0, v, [](int a, int b) {return a * b; }); //区間Add、区間Min vector<int> v(0, N + 1); SegmentTree<int, int> segtree(N + 1, myMin, plus<int>(), plus<int>(), LL_HALFMAX, 0, v, [](int a, int b) {return a; }); */ template <typename T, typename E> struct SegmentTree { typedef function<T(T, T)> F; typedef function<T(T, E)> G; typedef function<E(E, E)> H; typedef function<E(E, int)> P; int n; F f; G g; H h; P p; T d1; E d0; vector<T> dat; vector<E> laz; SegmentTree(int n_, F f, G g, H h, T d1, E d0, vector<T> v = vector<T>(), P p = [](E a, int b) {return a; }) : f(f), g(g), h(h), d1(d1), d0(d0), p(p) { init(n_); if (n_ == (int)v.size()) build(n_, v); } //初期化。要素配列と遅延配列を2*n-1個にする void init(int n_) { n = 1; while (n < n_) n *= 2; dat.clear(); dat.resize(2 * n - 1, d1); laz.clear(); laz.resize(2 * n - 1, d0); } //既存のvectorからセグ木を構築 void build(int n_, vector<T> v) { for (int i = 0; i < n_; i++) dat[i + n - 1] = v[i]; for (int i = n - 2; i >= 0; i--) dat[i] = f(dat[i * 2 + 1], dat[i * 2 + 2]); } //ノードを評価する。 inline void eval(int len, int k) { //遅延配列に単位元が入ってたら評価済みなのでおしまい if (laz[k] == d0) return; //葉ノードでないなら遅延伝播する if (k * 2 + 1 < n * 2 - 1) { //h: 2つの作用素を引数に取り合成した作用素を返す関数 laz[k * 2 + 1] = h(laz[k * 2 + 1], laz[k]); laz[k * 2 + 2] = h(laz[k * 2 + 2], laz[k]); } //p: このノードに対応する区間長と作用素を引数に取り、区間長に対応する作用素を返す関数 //dat[k] にlaz に溜めていた作用素を適用(g: 要素型と作用素型を引数に取り、要素に作用素を作用させた結果を返す関数、ここでの作用素とは区間Sum区間Addなら (+ 3) とか) dat[k] = g(dat[k], p(laz[k], len)); //適用し終わったので遅延配列をクリア laz[k] = d0; } //[l,r)の区間を再帰的に見ながら0-indexedの[a, b)を更新する T update(int a, int b, E x, int k, int l, int r) { //先に評価 eval(r - l, k); //範囲外ならなにもしないでそのノードが持つ値を返す if (r <= a || b <= l) return dat[k]; //完全被覆なら既に遅延配列に入っている作用素と追加したい作用素をマージした後にそれを要素に作用させた結果を返す、pは区間長に対応する作用素を得るための(ry if (a <= l && r <= b) { laz[k] = h(laz[k], x); return g(dat[k], p(laz[k], r - l)); } //完全被覆でも範囲外でもないなら(中途半端にかぶっているなら)完全被覆と範囲外の境界が見えるまで木を潜って変化後の値を得る return dat[k] = f(update(a, b, x, k * 2 + 1, l, (l + r) / 2), update(a, b, x, k * 2 + 2, (l + r) / 2, r)); } T update(int a, int b, E x) { return update(a, b, x, 0, 0, n); } T update(int a, E x) { return update(a, a + 1, x); } T query(int a, int b, int k, int l, int r) { eval(r - l, k); //範囲外なら単位元を返す if (r <= a || b <= l) return d1; //完全被覆ならそのまま返す if (a <= l && r <= b) return dat[k]; //一部被覆なら完全被覆と範囲外に分かれるまで木を潜る T vl = query(a, b, k * 2 + 1, l, (l + r) / 2); T vr = query(a, b, k * 2 + 2, (l + r) / 2, r); return f(vl, vr); } //0-indexedで[a, b)の区間*を求める T query(int a, int b) { return query(a, b, 0, 0, n); } T query(int a) { return query(a, a + 1, 0, 0, n); } void debug_print(int num) { vector<T> v; rep(i, num) { v.push_back(query(i)); } cout << "{" << v << "}\n"; } }; //座標圧縮 class compress { public: map<int, int> zip; vector<int> unzip; compress(vector<int> x) { sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end()); for (int i = 0; i < x.size(); i++) { zip[x[i]] = i; unzip.push_back(i); } } }; unsigned euclidean_gcd(unsigned a, unsigned b) { while (1) { if (a < b) swap(a, b); if (!b) break; a %= b; } return a; } //https://ei1333.github.io/luzhiled/snippets/dp/cumulative-sum-2d.html template< class T > struct CumulativeSum2D { vector< vector< T > > data; CumulativeSum2D(int W, int H) : data(W + 1, vector< int >(H + 1, 0)) {} void add(int x, int y, T z) { ++x, ++y; if (x >= data.size() || y >= data[0].size()) return; data[x][y] += z; } void build() { for (int i = 1; i < data.size(); i++) { for (int j = 1; j < data[i].size(); j++) { data[i][j] += data[i][j - 1] + data[i - 1][j] - data[i - 1][j - 1]; } } } T query(int sx, int sy, int gx, int gy) { return (data[gx][gy] - data[sx][gy] - data[gx][sy] + data[sx][sy]); } }; //lib int nC2(int n) { return n * (n - 1) / 2; } class node { public: int depth; int num; node(int d, int n) { depth = d; num = n; } }; template< class T > struct CumulativeSum { vector< T > data; CumulativeSum(int sz) : data(sz, 0) {}; void add(int k, T x) { data[k] += x; } void build() { for (int i = 1; i < data.size(); i++) { data[i] += data[i - 1]; } } T query(int k) { if (k < 0) return (0); return (data[min(k, (int)data.size() - 1)]); } //[left, right]の和 T query(int left, int right) { return query(right) - query(left - 1); } }; std::vector<int> eratosthenes_sieve(int n) { std::vector<int> ps(n + 1); std::iota(ps.begin() + 2, ps.end(), 2); for (int i = 2; i * i <= n; ++i) if (ps[i]) for (int j = i * i; j <= n; j += i) ps[j] = 0; return ps; } std::vector<int> make_primes(int n) { std::vector<int> ps = eratosthenes_sieve(n); ps.erase(std::remove(ps.begin(), ps.end(), 0), ps.end()); return ps; } // 区間[a, b)の素数判定をする、is_prime[i]: a + i が素数 or not つまり is_prime[i-a] が true: iが素数 std::vector<bool> segment_eratosthenes_sieve(int a, int b) { vector<bool> is_prime(b - a, true); vector<bool> is_prime_small; for (int i = 0; i*i < b; i++)is_prime_small.push_back(true); for (int i = 2; i*i < b; i++) { if (is_prime_small[i]) { for (int j = 2 * i; j*j < b; j += i) { is_prime_small[j] = false; // [2, sqrt(b))のふるい } // (a + i - 1LL) / i * i a以上の最小のiの倍数 for (int j = max(2LL, (a + i - 1LL) / i) * i; j < b; j += i) { is_prime[j - a] = false; // [a, b)のふるい } } } return is_prime; } vector< int64_t > divisor(int64_t n) { vector< int64_t > ret; for (int64_t i = 1; i * i <= n; i++) { if (n % i == 0) { ret.push_back(i); if (i * i != n) ret.push_back(n / i); } } sort(begin(ret), end(ret)); return (ret); } // 汎用的な二分探索のテンプレ(めぐる式) int binary_search(function<bool(int)> isOk, int ng, int ok) { /* ok と ng のどちらが大きいかわからないことを考慮 */ while (abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (isOk(mid)) ok = mid; else ng = mid; } return ok; } std::pair<std::vector<Weight>, bool> bellmanFord(const Graph& g, int s) { int n = g.size(); const Weight inf = std::numeric_limits<Weight>::max() / 8; Edges es; for (int i = 0; i < n; i++) for (auto& e : g[i]) es.emplace_back(e); //初期化、スタート地点以外の距離は無限大 std::vector<Weight> dist(n, inf); dist[s] = 0; bool negCycle = false; for (int i = 0;; i++) { bool update = false; //すべての辺について、その辺をとおった場合に最短経路が更新できる場合は更新する for (auto& e : es) { if (dist[e.src] != inf && dist[e.dst] > dist[e.src] + e.weight) { dist[e.dst] = dist[e.src] + e.weight; update = true; } } //更新がなくなったらおはり if (!update) break; //n回以上更新されてたら負閉路がある if (i > n) { negCycle = true; break; } } return std::make_pair(dist, !negCycle); } //ゴールを指定して、それまでのパスに負閉路がなかったらOK(嘘修正済) std::pair<std::vector<Weight>, bool> bellmanFord(const Graph& g, int s, int d) { int n = g.size(); const Weight inf = std::numeric_limits<Weight>::max() / 8; Edges es; for (int i = 0; i < n; i++) for (auto& e : g[i]) es.emplace_back(e); //初期化、スタート地点以外の距離は無限大 std::vector<Weight> dist(n, inf); dist[s] = 0; bool negCycle = false; for (int i = 0; i < n * 2; i++) { bool update = false; //すべての辺について、その辺をとおった場合に最短経路が更新できる場合は更新する for (auto& e : es) { if (dist[e.src] != inf && dist[e.dst] > dist[e.src] + e.weight) { // n回目の更新で d が更新されてたら問答無用で負閉路ありとしてNG if (i >= n - 1 && e.dst == d) { negCycle = true; } // 終点以外に負閉路がある場合はそこの距離を十分小さい値に置き換える else if (i >= n - 1) { dist[e.dst] = -inf; update = true; } else { dist[e.dst] = dist[e.src] + e.weight; update = true; } } } //更新がなくなったらおはり if (!update) break; } return std::make_pair(dist, !negCycle); } //R[i] == S[i] を中心とした極大回文長 なるvector Rを返す vector<int> Manachar(string S) { int len = S.length(); vector<int> R(len); int i = 0, j = 0; while (i < S.size()) { while (i - j >= 0 && i + j < S.size() && S[i - j] == S[i + j]) ++j; R[i] = j; int k = 1; while (i - k >= 0 && i + k < S.size() && k + R[i - k] < j) R[i + k] = R[i - k], ++k; i += k; j -= k; } return R; } std::vector<int> tsort(const Graph &g) { int n = g.size(), k = 0; std::vector<int> ord(n), in(n); for (auto &es : g) for (auto &e : es) in[e.dst]++; std::queue<int> q; //入次数0の点をキューに追加 for (int i = 0; i < n; ++i) if (in[i] == 0) q.push(i); while (q.size()) { int v = q.front(); //Sから node n を削除する q.pop(); //L に n を追加する ord[k++] = v; for (auto &e : g[v]) { //選択した点から出てる辺を削除、0になったらキューに追加 if (--in[e.dst] == 0) { q.push(e.dst); } } } return *std::max_element(in.begin(), in.end()) == 0 ? ord : std::vector<int>(); } std::vector<Weight> dijkstra(const Graph &g, int s) { const Weight INF = std::numeric_limits<Weight>::max() / 8; using state = std::tuple<Weight, int>; std::priority_queue<state> q; std::vector<Weight> dist(g.size(), INF); dist[s] = 0; q.emplace(0, s); while (q.size()) { Weight d; int v; std::tie(d, v) = q.top(); q.pop(); d *= -1; /* if(v == t) return d; */ if (dist[v] < d) continue; for (auto &e : g[v]) { if (dist[e.dst] > dist[v] + e.weight) { dist[e.dst] = dist[v] + e.weight; q.emplace(-dist[e.dst], e.dst); } } } return dist; } Matrix WarshallFloyd(const Graph &g) { auto const INF = std::numeric_limits<Weight>::max() / 8; int n = g.size(); Matrix d(n, Array(n, INF)); rep(i, n) d[i][i] = 0; rep(i, n) for (auto &e : g[i]) d[e.src][e.dst] = std::min(d[e.src][e.dst], e.weight); rep(k, n) rep(i, n) rep(j, n) { if (d[i][k] != INF && d[k][j] != INF) d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]); } return d; } std::pair<std::vector<int>, std::vector<int>> prime_factor_decomp(int n) { std::vector<int> p, e; int m = n; for (int i = 2; i * i <= n; i++) { if (m % i != 0) continue; int c = 0; while (m % i == 0) c++, m /= i; p.push_back(i); e.push_back(c); } if (m > 1) { p.push_back(m); e.push_back(1); } return std::make_pair(p, e); } int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; } // 不定方程式 ax + by = c の一般整数解(pt + q, rt + s)を求める /* * exist: 解が存在するか否か * p, q, r, s: 存在するならば不定方程式の一般解(pt + q, rt + s) * ここで、式変形から、p > 0、 q < 0 となることに注意する。(解の条件を絞るときなどに必要になる) */ void IndeterminateEq(int a, int b, int c, bool& exist, int& p, int& q, int& r, int& s) { int X, Y; int g = euclidean_gcd(a, b); // c が最大公約数の整数倍でないならNG if (c % g != 0) { exist = false; return; } exist = true; // 拡張ユークリッドの互除法で ax + by = gcd(a, b) なる (X, Y) を求める extgcd(a, b, X, Y); int m = c / g; // ax + by = c の解にする X *= m; Y *= m; int a2 = a / g; int b2 = b / g; p = b2; q = X; r = -a2; s = Y; } // x^n mod modulo を繰り返し二乗法で計算する // n を 2^k の和で表す -> n を二進表記したとき、kbit目(0-indexed)が立っているときだけx^kをかける int mod_pow(int x, int n, int modulo) { int res = 1; while (n > 0) { if (n & 1) { res = res * x % modulo; } x = x * x % modulo; n >>= 1; } return res; } int64_t popcnt(int64_t n) { int64_t c = 0; c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555); c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333); c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f); c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff); c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff); c = (c & 0x00000000ffffffff) + ((c >> 32) & 0x00000000ffffffff); return(c); } /* 行列積と行列累乗 行列積 vector<vector<T>> matrixMultiplies(vector<vector<T>> l, vector<vector<T>> r, F plus = plus<T>(), G multiple = multiplies<T>(), T eplus = 0LL) 行列累乗 vector<vector<T>> matrixPower(vector<vector<T>> m, int n, F plus = std::plus<T>(), G multiple = multiplies<T>(), T eplus = 0LL, T emultiple = 1LL) T: 考える集合(競プロにおいてはたぶんほぼ整数) l: 左からかける行列 r: 右からかける行列 plus: 加法演算 multiple: 乗法演算 eplus: 加法の単位元 emultiple: 乗法の単位元 */ template<typename T = long long, typename F = decltype(std::plus<T>()), typename G = decltype(multiplies<T>())> vector<vector<T>> matrixMultiplies(vector<vector<T>> l, vector<vector<T>> r, F plus = plus<T>(), G multiple = multiplies<T>(), T eplus = 0LL) { int rx = r[0].size(); int ry = r.size(); vector<vector<T> > ret; for (int y = 0; y < ry; y++) { vector<T> add; for (int x = 0; x < rx; x++) { T cell = eplus; for (int i = 0; i < ry; i++) { T mul = multiple(l[y][i], r[i][x]); cell = plus(cell, mul); } add.push_back(cell); } ret.push_back(add); } return ret; } template<typename T = long long, typename F = decltype(std::plus<T>()), typename G = decltype(multiplies<T>())> vector<vector<T>> matrixPower(vector<vector<T>> m, int n, F plus = std::plus<T>(), G multiple = multiplies<T>(), T eplus = 0LL, T emultiple = 1LL) { int k = m.size(); if (n == 0) { vector<vector<T> > E; for (int i = 0; i < k; i++) { // 単位行列は対角成分を乗法単位元、非対角成分をゼロ元で埋める vector<T> v(k, eplus); v[i] = emultiple; E.push_back(v); } return E; } vector<vector<T>> ret = matrixPower(matrixMultiplies(m, m, plus, multiple, eplus), n / 2, plus, multiple, eplus, emultiple); if (n % 2 == 1) { ret = matrixMultiplies(m, ret, plus, multiple); } return ret; } // フロー系のアルゴリズム // 最大流 /* Ford-Fulkerson法(蟻本) O(F|E|) F: 最大流量 E: 辺数 コンストラクタ引数でノード数nを受け取り初期化し、add_edge で辺と逆辺を追加していく */ class Ford_Fulkerson { private: struct Edge { int src, dst; // libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持 int rev; int cap; Edge(int s, int d, int c, int r) : src(s), dst(d), cap(c), rev(r) {} }; vector<vector<Edge> > G; vector<bool> used; public: Ford_Fulkerson(int n) : G(n), used(n, false) {} void add_edge(int s, int d, int cap) { G[s].emplace_back(s, d, cap, G[d].size()); G[d].emplace_back(d, s, 0, G[s].size() - 1); } int dfs(int v, int t, int f) { if (v == t) { return f; } used[v] = true; for (Edge& e : G[v]) { if (!used[e.dst] && e.cap > 0) { // 流せる辺があったら流す int d = dfs(e.dst, t, min(f, e.cap)); if (d > 0) { // 辺の残り容量を減らす e.cap -= d; // 逆辺の容量を増やす G[e.dst][e.rev].cap += d; return d; } } } // t にたどり着けなかったら0 return 0; } int max_flow(int s, int t) { int flow = 0; while (1) { for (int i = 0; i < used.size(); i++) { used[i] = false; } int f = dfs(s, t, LL_HALFMAX); if (f == 0) { return flow; } flow += f; } } }; /* Dinic法 From libalgo O(V^2 * E) dinic::solve(s, t) : s -> t の最大流を求める dinic;;flow[u][v] : 辺(u, v)の流量 */ struct dinic { int n, s, t; std::vector<int> level, prog, que; std::vector<std::vector<Flow>> cap, flow; std::vector<std::vector<int>> g; Flow inf; dinic(const Graph &graph) : n(graph.size()), cap(n, std::vector<Flow>(n)), flow(n, std::vector<Flow>(n)), g(n, std::vector<int>()), inf(std::numeric_limits<Flow>::max() / 8) { for (int i = 0; i < n; i++) { for (auto &e : graph[i]) { int u = e.src, v = e.dst; Flow c = e.cap; cap[u][v] += c; cap[v][u] += c; flow[v][u] += c; g[u].push_back(v); g[v].push_back(u); } } } // 残りを求める inline Flow residue(int u, int v) { return cap[u][v] - flow[u][v]; } // 実際に最大流問題を解く Flow solve(int s_, int t_) { this->t = t_, this->s = s_; que.resize(n + 1); Flow res = 0; // levelize() == false: bfs で s から t に到達できなかった while (levelize()) { prog.assign(n, 0); res += augment(s, inf); } return res; } // bfs でレベルグラフをつくる bool levelize() { int l = 0, r = 0; level.assign(n, -1); level[s] = 0; que[r++] = s; while (l != r) { int v = que[l++]; if (v == t) break; for (const int &d : g[v]) { // まだレベルが決まっておらず、v -> dの辺に流せるならlevel[d] = level[v] + 1 if (level[d] == -1 && residue(v, d) != 0) { level[d] = level[v] + 1; que[r++] = d; } } } // t に到達できるなら true を返す return level[t] != -1; } // dfs で実際に流してみる Flow augment(int v, Flow lim) { Flow res = 0; if (v == t) return lim; // prog[v]: dfs において、vを展開する際、vの子の何番目まで展開したかを覚えておく for (int &i = prog[v]; i < (int)g[v].size(); i++) { const int &d = g[v][i]; // v -> d に流せない or v(流す側) の方がレベルが大きい(=深い)場合NG if (residue(v, d) == 0 || level[v] >= level[d]) continue; // 流せるなら、流せるだけ流す const Flow aug = augment(d, std::min(lim, residue(v, d))); flow[v][d] += aug; flow[d][v] -= aug; res += aug; lim -= aug; // ノードvに来ている流量を使い切ったら終わり if (lim == 0) break; } return res; } }; /* Primal-Dual法(蟻本版 / ベルマンフォード) */ class Primal_Dual_BellmanFord { using Cost = int; struct Edge { int src, dst; // libalgo のものに追加、メンバを追加するだけなので互換性は崩さないはず、逆辺のG[e.dstの]インデックスを保持 int rev; Cost cost; Flow cap; Edge(int s, int d, int aRev, Cost aCost, Flow aCap) : src(s), dst(d), rev(aRev), cost(aCost), cap(aCap) {} }; int V; //頂点数 vector<vector<Edge>> G; // 隣接リスト vector<int> dist; // 最短距離 vector<int> prevv; // 直前の頂点 vector<int> preve; // 直前の辺 const int INF; public: // 頂点数 n を引数にとって初期化 Primal_Dual_BellmanFord(int n) : V(n), G(n), dist(n, 0), prevv(n, 0), preve(n, 0), INF(std::numeric_limits<int>::max() / 8) {} void add_edge(int src, int dst, int cap, int cost) { // cost は weight に入れる G[src].emplace_back(src, dst, G[dst].size(), cost, cap); G[dst].emplace_back(dst, src, G[src].size() - 1, -cost, 0); } int min_cost_flow(int s, int t, int f) { int res = 0; while (f > 0) { // ベルマンフォードによりs-t最短路をもとめる dist.assign(V, INF); dist[s] = 0; bool update = true; while (update) { update = false; for (int v = 0; v < V; v++) { if (dist[v] == INF) continue; for (int i = 0; i < G[v].size(); i++) { Edge& e = G[v][i]; if (e.cap > 0 && dist[e.dst] > dist[v] + e.cost) { dist[e.dst] = dist[v] + e.cost; prevv[e.dst] = v; preve[e.dst] = i; update = true; } } } } // これ以上流せない if (dist[t] == INF) { return -1; } // 復元したs-t最短路に沿って流せるだけ流す int d = f; // 尻からprevvを辿っていき、流せる量を求める for (int v = t; v != s; v = prevv[v]) { // 一つ手前に戻るための辺 Edge &e = G[prevv[v]][preve[v]]; chmin(d, e.cap); } f -= d; // ここでの dist はコスト和なので、それに流す量をかけると今回見つけた最短パスに流すコストとなる。 res += d * dist[t]; for (int v = t; v != s; v = prevv[v]) { Edge &e = G[prevv[v]][preve[v]]; e.cap -= d; G[v][e.rev].cap += d; } } return res; } }; /* ダイクストラ版 Primal-Dual 出典: https://ei1333.github.io/luzhiled/snippets/graph/primal-dual.html */ template< typename flow_t, typename cost_t > struct PrimalDual { const cost_t INF; struct edge { int to; flow_t cap; cost_t cost; int rev; bool isrev; edge(int aTo, flow_t aCap, cost_t aCost, int aRev, bool aIsRev) : to(aTo), cap(aCap), cost(aCost), rev(aRev), isrev(aIsRev) {} }; vector< vector< edge > > graph; vector< cost_t > potential, min_cost; vector< int > prevv, preve; PrimalDual(int V) : graph(V), INF(numeric_limits< cost_t >::max()) {} void add_edge(int from, int to, flow_t cap, cost_t cost) { graph[from].emplace_back(to, cap, cost, (int)graph[to].size(), false); graph[to].emplace_back(from, 0, -cost, (int)graph[from].size() - 1, true); } cost_t min_cost_flow(int s, int t, flow_t f) { int V = (int)graph.size(); cost_t ret = 0; using Pi = pair< cost_t, int >; priority_queue< Pi, vector< Pi >, greater< Pi > > que; potential.assign(V, 0); preve.assign(V, -1); prevv.assign(V, -1); while (f > 0) { min_cost.assign(V, INF); que.emplace(0, s); min_cost[s] = 0; while (!que.empty()) { Pi p = que.top(); que.pop(); if (min_cost[p.second] < p.first) continue; for (int i = 0; i < graph[p.second].size(); i++) { edge &e = graph[p.second][i]; cost_t nextCost = min_cost[p.second] + e.cost + potential[p.second] - potential[e.to]; if (e.cap > 0 && min_cost[e.to] > nextCost) { min_cost[e.to] = nextCost; prevv[e.to] = p.second, preve[e.to] = i; que.emplace(min_cost[e.to], e.to); } } } if (min_cost[t] == INF) return -1; for (int v = 0; v < V; v++) potential[v] += min_cost[v]; flow_t addflow = f; for (int v = t; v != s; v = prevv[v]) { addflow = min(addflow, graph[prevv[v]][preve[v]].cap); } f -= addflow; ret += addflow * potential[t]; for (int v = t; v != s; v = prevv[v]) { edge &e = graph[prevv[v]][preve[v]]; e.cap -= addflow; graph[v][e.rev].cap += addflow; } } return ret; } void output() { for (int i = 0; i < graph.size(); i++) { for (auto &e : graph[i]) { if (e.isrev) continue; auto &rev_e = graph[e.to][e.rev]; cout << i << "->" << e.to << " (flow: " << rev_e.cap << "/" << rev_e.cap + e.cap << ")" << endl; } } } }; class lca { public: int n, segn; vector<int> path; // 蟻本の vs、オイラーツアーを保持 vector<int> depth; // 蟻本の depth、path[i] であるノードの深さを保持 vector<int> in_order; // 蟻本の id、ノードiがオイラーツアーで最初に出てくるインデックスを保持 vector<pair<int, int>> dat; const std::pair<int, int> INF = std::make_pair(1000000000, 1000000000); lca(const Graph& g, int root) : n(g.size()), path(n * 2 - 1), depth(n * 2 - 1), in_order(n) { int k = 0; dfs(g, root, -1, 0, k); // セグ木を構築、持つのはpair(depth, index) => depth が最小となる index がわかる for (segn = 1; segn < n * 2 - 1; segn <<= 1); dat.assign(segn * 2, INF); for (int i = 0; i < (int)depth.size(); ++i) dat[segn + i] = std::make_pair(depth[i], i); for (int i = segn - 1; i >= 1; --i) dat[i] = min(dat[i * 2], dat[i * 2 + 1]); } int get(int u, int v) const { int l = std::min(in_order[u], in_order[v]); int r = std::max(in_order[u], in_order[v]) + 1; return path[range_min(1, segn, l, r).second]; } void dfs(const Graph& g, int v, int p, int d, int& k) { // k: オイラーツアーの何番目かを保持する変数 in_order[v] = k; path[k] = v; depth[k++] = d; for (auto &e : g[v]) { if (e.dst != p) { dfs(g, e.dst, v, d + 1, k); // ここに来た時はノードvの子であるe.dstを展開し終わってvに戻ってきたときなので、再度 path と depth に記録する path[k] = v; depth[k++] = d; } } } // v : いまみてるノード、w: 今見てるノードに対応する区間長 l: ? r: ? pair<int, int> range_min(int v, int w, int l, int r) const { if (r <= l || w == 0) return INF; if (r - l == w) return dat[v]; int m = w / 2; auto rmin = range_min(v * 2, m, l, std::min(r, m)); auto lmin = range_min(v * 2 + 1, m, std::max(0LL, l - m), r - m); return min(rmin, lmin); } }; // int における ceil と floor、負数対応(a / b の ceil, floor) int64_t intceil(int64_t a, int64_t b) { int sign_a = (a > 0) - (a < 0); int sign_b = (b > 0) - (b < 0); if (sign_a == sign_b) { return (a + b - sign_b) / b; } else { return a / b; } } int64_t intfloor(int64_t a, int64_t b) { int sign_a = (a > 0) - (a < 0); int sign_b = (b > 0) - (b < 0); if (sign_a == sign_b) { return a / b; } else { return (a - b + sign_b) / b; } } const string YES = "Yes"; void solve(ostringstream& aout, long long N, long long M, std::vector<long long> A, std::vector<long long> B); void solve_TLE(ostringstream& aout, long long N, long long M, std::vector<long long> A, std::vector<long long> B); class StressTest { private: mt19937 m_RandEngine; bool judge_case(long long N, long long M, std::vector<long long> A, std::vector<long long> B) { ostringstream fast, tle; solve(fast, N, M, std::move(A), std::move(B)); solve_TLE(tle, N, M, std::move(A), std::move(B)); if (fast.str() == tle.str()) { return true; } else { return false; } } // [l, l+1, ... r] の数列を生成し、シャッフルする vector<int> create_range_permutation(int l, int r) { vector<int> ret; for (int i = l; i <= r; i++) { ret.push_back(i); } shuffle(ret.begin(), ret.end(), m_RandEngine); return ret; } // [1, n] の順列を生成する vector<int> create_permutation(int n) { create_range_permutation(1, n); } // 範囲が[l, r] でサイズが n の数列を生成する vector<int> create_random_sequence(int l, int r, int n) { uniform_int_distribution<> randLR(l, r); vector<int> ret; for (int i = 0; i < n; i++) { ret.push_back(randLR(m_RandEngine)); } return ret; } /* * 頂点数 n, 辺数 m で自己ループと多重辺のない無向グラフを生成 * 慣習的に頂点番号が1-indexed な AtCoder で 1-n の頂点が使えるようにするため n+1 頂点のグラフを生成し、0番を無視することとする * weighted を true にすると重み付き、maxWeight で最大重みを指定 * 連結でないグラフが出力される可能性があることに注意する */ Graph create_undirected_graph(int n, int m, bool weighted = false, int maxWeight = 10) { Graph ret(n + 1); set<pair<int, int>> used; uniform_int_distribution<> randNode(1, n); uniform_int_distribution<> randWeight(1, maxWeight); while (used.size() < m * 2) { int src = randNode(m_RandEngine); int dst = randNode(m_RandEngine); // 自己ループ、多重辺判定 if (used.count(make_pair(src, dst)) == 0 && used.count(make_pair(dst, src)) == 0 && src != dst) { used.insert(make_pair(src, dst)); used.insert(make_pair(dst, src)); add_edge(ret, src, dst, weighted ? randWeight(m_RandEngine) : 1); } } return ret; } /* * 頂点数 n, 辺数 m で自己ループと多重辺のない有向グラフを生成 * 慣習的に頂点番号が1-indexed な AtCoder で 1-n の頂点が使えるようにするため n+1 頂点のグラフを生成し、0番を無視することとする * weighted を true にすると重み付き、maxWeight で最大重みを指定 * 連結でないグラフが出力される可能性があることに注意する */ Graph create_directed_graph(int n, int m, bool weighted = false, int maxWeight = 10) { Graph ret(n + 1); set<pair<int, int>> used; uniform_int_distribution<> randNode(1, n); uniform_int_distribution<> randWeight(1, maxWeight); while (used.size() < m) { int src = randNode(m_RandEngine); int dst = randNode(m_RandEngine); // 自己ループ、多重辺判定 if (used.count(make_pair(src, dst)) == 0 && src != dst) { used.insert(make_pair(src, dst)); add_arc(ret, src, dst, weighted ? randWeight(m_RandEngine) : 1); } } return ret; } /* * 頂点数nの木(無向)を生成します。 */ Graph create_tree(int n, bool weighted = false, int maxWeight = 10) { Graph ret(n + 1); uf_tree uf(n + 1); int cnt = 0; uniform_int_distribution<> randNode(1, n); uniform_int_distribution<> randWeight(1, maxWeight); while (cnt < n - 1) { int n1 = randNode(m_RandEngine); int n2 = randNode(m_RandEngine); if (n1 != n2 && !uf.is_same(n1, n2)) { cnt++; add_edge(ret, n1, n2, weighted ? randWeight(m_RandEngine) : 1); } } } public: StressTest(int seed) : m_RandEngine(seed) {} void test() { while (1) { // TODO: generate random case //if (!judge_case(N, M, std::move(A), std::move(B))) { // TODO: output case //break; //} } } }; void solve(ostringstream& aout, long long N, long long M, std::vector<long long> A, std::vector<long long> B){ } void solve_TLE(ostringstream& aout, long long N, long long M, std::vector<long long> A, std::vector<long long> B) { } int cum[255][100010]; signed main() { string s; cin >> s; int len = s.length(); rep(i, len - 1) { if (s[i] == s[i + 1]) { cout << i + 1 << " " << i + 2 << "\n"; return; } } rep(i, len - 2) { if (s[i] == s[i + 2]) { cout << i + 1 << " " << i + 3 << "\n"; return; } } cout << -1 << " " << -1 << "\n"; return 0; }
a.cc: In member function 'std::vector<long long int> StressTest::create_permutation(long long int)': a.cc:1377:9: warning: no return statement in function returning non-void [-Wreturn-type] 1377 | } | ^ a.cc: In member function 'Graph StressTest::create_tree(long long int, bool, long long int)': a.cc:1456:9: warning: no return statement in function returning non-void [-Wreturn-type] 1456 | } | ^ a.cc: In function 'int main()': a.cc:1491:25: error: return-statement with no value, in function returning 'int' [-fpermissive] 1491 | return; | ^~~~~~ a.cc:1497:25: error: return-statement with no value, in function returning 'int' [-fpermissive] 1497 | return; | ^~~~~~
s356847209
p04026
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; const ll MOD=1000000007; const ll MOD2=998244353; const double PI=acos(-1); const ll INF=1e15; typedef pair<ll,ll> P; typedef vector<ll> vl; typedef vector<vl> vvl; #define FOR(i,a,b) for(ll i=a;i<b;i++) #define rep(i,n) FOR(i,0,n) string abc="abcdefghijklmnopqrstuvwxyz"; string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; struct edge{ll to,cost;}; int main() { string s; cin >> s; ll k=s.size(); ll l=-1,r=-1; rep(i,n-1){ if(s[i]==s[i+1]){ l=i+1;r=i+2; } } rep(i,n-2){ if(s[i]==s[i+2]){ l=i+1; r=i+3; } } cout << l << " " << r << endl; }
a.cc: In function 'int main()': a.cc:22:9: error: 'n' was not declared in this scope 22 | rep(i,n-1){ | ^ a.cc:11:33: note: in definition of macro 'FOR' 11 | #define FOR(i,a,b) for(ll i=a;i<b;i++) | ^ a.cc:22:3: note: in expansion of macro 'rep' 22 | rep(i,n-1){ | ^~~ a.cc:27:9: error: 'n' was not declared in this scope 27 | rep(i,n-2){ | ^ a.cc:11:33: note: in definition of macro 'FOR' 11 | #define FOR(i,a,b) for(ll i=a;i<b;i++) | ^ a.cc:27:3: note: in expansion of macro 'rep' 27 | rep(i,n-2){ | ^~~
s547720159
p04026
Java
import java.io.*; import java.util.*; public class B { public static final long mod = (long)1e9+7; public static final long INF = Long.MAX_VALUE/2; public static final int inf = Integer.MAX_VALUE/2; static void solve(InputReader in, PrintWriter out){ char[] s = in.ns().toCharArray(); boolean flag = false; for (int i = 0; i < s.length-1; i++) { if(i<s.length-2){ if(s[i]==s[i+1]||s[i]==s[i+2]){ out.printf("%d %d\n",i+1, i+3); flag = true; } }else{ if(s[i]==s[i+1]){ out.printf("%d %d\n",i+1, i+2); flag = true; } } if(flag) break; } if(!flag) out.println("-1 -1"); } public static void main(String[] args){ InputReader in = new InputReader(System.in); PrintWriter out = new PrintWriter(System.out); solve(in, out); out.close(); } public static class InputReader{ private BufferedReader br; private StringTokenizer st; public InputReader(InputStream is){ br = new BufferedReader(new InputStreamReader(is)); st = null; } public String ns(){ if(st == null || !st.hasMoreTokens()){ try{ st = new StringTokenizer(br.readLine()); }catch (Exception e){ throw new RuntimeException(e); } } return st.nextToken(); } public int ni(){ return Integer.parseInt(ns()); } public long nl(){ return Long.parseLong(ns()); } public double nd(){ return Double.parseDouble(ns()); } public char nc(){ return ns().toCharArray()[0]; } public int[] ni(int n){ int[] a = new int[n]; for (int i = 0; i < n; i++) { a[i] = ni(); } return a; } public long[] nl(int n){ long[] a = new long[n]; for (int i = 0; i < n; i++) { a[i] = nl(); } return a; } public double[] nd(int n){ double[] a = new double[n]; for (int i = 0; i < n; i++) { a[i] = nd(); } return a; } } }
Main.java:4: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s129596339
p04026
C++
#include <bits/stdc++.h> #define fi first #define se second #define rep(i, n) for (int i = 0; i < (n); ++i) #define rrep(i, n) for (int i = 1; i <= (n); ++i) #define drep(i, n) for (int i = (n)-1; i >= 0; --i) #define srep(i, s, t) for (int i = s; i < t; ++i) #define rng(a) a.begin(), a.end() #define rrng(a) a.rbegin(), a.rend() #define maxs(x, y) (x = max(x, y)) #define mins(x, y) (x = min(x, y)) #define limit(x, l, r) max(l, min(x, r)) #define lims(x, l, r) (x = max(l, min(x, r))) #define isin(x, l, r) ((l) <= (x) && (x) < (r)) #define pb push_back #define eb emplace_back #define sz(x) (int)(x).size() #define pcnt __builtin_popcountll #define uni(x) x.erase(unique(rng(x)), x.end()) #define show(x) cout << #x << " = " << x << endl; #define PQ(T) priority_queue<T, v(T), greater<T>> #define bn(x) ((1 << x) - 1) #define dup(x, y) (((x) + (y)-1) / (y)) #define newline puts("") #define v(T) vector<T> #define vv(T) v(v(T)) using namespace std; typedef long long int ll; typedef unsigned uint; typedef unsigned long long ull; typedef pair<int, int> P; typedef tuple<int, int, int> T; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<P> vp; typedef vector<T> vt; int main() { string s; cin >> s; int n = sz(s); if(n==2){ if(s[i] == s[i+1]){ cout<<1<<" "<<2<<endl; return 0; } } rep(i,n-2){ 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:44:10: error: 'i' was not declared in this scope 44 | if(s[i] == s[i+1]){ | ^
s406122035
p04026
C++
#include<iostream> using namespace std; int main() { char arr[100000]; scanf("%s",arr); int n=strlen(arr); int p=0,a,b; for(int i=0;i<n-2;i++) { if(arr[i]==arr[i+1]) { p=1; a=i; b=i+1; break; } else if(arr[i]==arr[i+2]) { p=1; a=i; b=i+2; break; } } if(arr[n-2]==arr[n-1]) { p=1; a=n-2; b=n-1; } if(p) { cout<<a+1<<' '<<b+1; } else { cout<<"-1 -1"; } }
a.cc: In function 'int main()': a.cc:7:11: error: 'strlen' was not declared in this scope 7 | int n=strlen(arr); | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | using namespace std;
s685178600
p04026
C++
#include<iostream> using namespace std; int main() { char arr[100000]; scanf("%s",&arr); int n=strlen(arr); int p=0,a,b; for(int i=0;i<n-2;i++) { if(arr[i]==arr[i+1]) { p=1; a=i; b=i+1; break; } else if(arr[i]==arr[i+2]) { p=1; a=i; b=i+2; break; } } if(arr[n-2]==arr[n-1]) { p=1; a=n-2; b=n-1; } if(p) { cout<<a+1<<' '<<b+1; } else { cout<<"-1 -1"; } }
a.cc: In function 'int main()': a.cc:7:11: error: 'strlen' was not declared in this scope 7 | int n=strlen(arr); | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | using namespace std;
s047220015
p04026
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; | ^~
s997530228
p04026
C++
#include <iostream> #include <vector> using namespace std; int main(){ string s; cin >> s; int a[30]={0}; for(int i=0;i<s.size();i++){ a[s[i]-'a']++; for(int j=0;j<26;j++){ if(a[j]> i/2 && a[j] != 1){ cout << "1" << " " << i << endl; return 0; } } cout << "-1" << " " << "-1" << endl; }
a.cc: In function 'int main()': a.cc:31:4: error: expected '}' at end of input 31 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s768218202
p04026
C++
#include<bits/stdc++.h> using namespace std; main(){ string S;cin>>S; int n=S.size(); if(n==2){ if(S[0]==S[1])cout<<"0 1"<<endl; else cout<<"-1 -1"endl; return 0; } for(int i=0;i<n-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:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:8:16: error: unable to find string literal operator 'operator""endl' with 'const char [6]', 'long unsigned int' arguments 8 | else cout<<"-1 -1"endl; | ^~~~~~~~~~~
s171271175
p04026
C++
#include<bits/stdc++.h> using namespace std; const int N=1e5+10; char s[N]; int main() { //freopen("H:\\c++1\\in.txt","r",stdin); //freopen("H:\\c++1\\out.txt","w",stdout); scanf("%s",s+1); int len=strlen(s+1); int l=-1,r=-1; for(int i=1;i<len;i++){ if(s[i]==s[i+1]){ flag=1; l=i,r=i+1; break; } } printf("%d %d\n",l,r); return 0; }
a.cc: In function 'int main()': a.cc:14:25: error: 'flag' was not declared in this scope 14 | flag=1; | ^~~~
s646503731
p04026
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<long long,long long> pll; #define pb push_back #define mp make_pair #define rep(i,n) for(int i=0;i<(n);++i) constexpr int mod=1000000007; constexpr int mod1=998244353; vector<int> dx={0,1,0,-1},dy={-1,0,1,0}; bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; } int main(){ cin.tie(0); ios::sync_with_stdio(false); string s;cin >> s; int a = 0, b = 0; rep(i,s.size() - 2){ if(s.at(i) == s.at(i + 1) && s.at(i) != s.at(i + 2)){ a = i; b = i + 2; break; } else if(s.at(i) == s.at(i + 2) && s.at(i) != s.at(i + 1)){ a = i; b = i + 2; break; } else if(s.at(i) != s.at(i + 1) && s.at(i + 1) == s.at(i + 2)){ a = i; b = i + 2; break; } } rep(i,s.size() - 1){ if(s.at(i) == s.at(i + 1)){ a = i; b = i + 1; } if(b == 0) cout << "-1 -1" << endl; else cout << a + 1 << " " << b + 1 << endl; }
a.cc: In function 'int main()': a.cc:50:2: error: expected '}' at end of input 50 | } | ^ a.cc:21:11: note: to match this '{' 21 | int main(){ | ^
s726168947
p04026
Java
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) { new Main(); } FS in = new FS(); PrintWriter out = new PrintWriter(System.out); int len; char[] str; boolean found = false; Main() { len = (str = in.next().toCharArray()).length; for (int i = 0; i < len - 1; i++) { if (str[i] == str[i + 1]) { out.printf("%d %d%n", i + 1, i + 2); found = true; break; } if (i < len - 2 && str[i] == str[i + 2]) { out.printf("%d %d%n", i + 1, i + 3); found = true; break; } } if (!found) out.printf("%d %d%n", -1, -1); out.close(); } class FS { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenzier(""); String next() { while (!st.hasMoreTokens()) { try { st = new StringTokenizer(br.readLine()); } catch (Exception e) {} } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } long nextLong() { return Long.parseLong(next()); } double nextDouble() { return Double.parseDouble(next()); } } }
Main.java:37: error: cannot find symbol StringTokenizer st = new StringTokenzier(""); ^ symbol: class StringTokenzier location: class Main.FS 1 error
s240924835
p04026
C++
include<bits/stdc++.h> using namespace std; string a,b; int main() { cin>>a; for(int s=1;s<a.size();s++) { if(a[s]==a[s-1]) { cout<<s<<" "<<s+1<<endl; return 0; } } for(int s=2;s<a.size();s++) { if(a[s]==a[s-2]) { cout<<s-1<<" "<<s+1<<endl; return 0; } } cout<<-1<<" "<<-1<<endl; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc:3:1: error: 'string' does not name a type 3 | string a,b; | ^~~~~~ a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | cin>>a; | ^~~ a.cc:6:10: error: 'a' was not declared in this scope 6 | cin>>a; | ^ a.cc:11:13: error: 'cout' was not declared in this scope 11 | cout<<s<<" "<<s+1<<endl; | ^~~~ a.cc:11:32: error: 'endl' was not declared in this scope 11 | cout<<s<<" "<<s+1<<endl; | ^~~~ a.cc:19:13: error: 'cout' was not declared in this scope 19 | cout<<s-1<<" "<<s+1<<endl; | ^~~~ a.cc:19:34: error: 'endl' was not declared in this scope 19 | cout<<s-1<<" "<<s+1<<endl; | ^~~~ a.cc:23:5: error: 'cout' was not declared in this scope 23 | cout<<-1<<" "<<-1<<endl; | ^~~~ a.cc:23:24: error: 'endl' was not declared in this scope 23 | cout<<-1<<" "<<-1<<endl; | ^~~~
s324944286
p04026
C++
#include<bits/stdc++.h> using namespace std; #define ll long long typedef pair<ll,ll> P; #define M 1000000007 #define all(a) (a).begin(),(a).end() #define rep(i,n) reps(i,0,n) #define reps(i,m,n) for(int i=(m);i<(n);i++) int main(){ string s;cin>>s; if(s.size()==2){ if(s[0]==s[1])cout<<"1 2"; else cout<<"-1 -1"; }else{ rep(i,2,s.size()){ if(s[i-2]==s[i-1]||s[i-2]==s[i]||s[i-1]==s[i]){ cout<<i-1<<" "<<i+1; return 0; } } cout<<"-1 -1"; } }
a.cc:15:21: error: macro "rep" passed 3 arguments, but takes just 2 15 | rep(i,2,s.size()){ | ^ a.cc:7:9: note: macro "rep" defined here 7 | #define rep(i,n) reps(i,0,n) | ^~~ a.cc: In function 'int main()': a.cc:15:5: error: 'rep' was not declared in this scope 15 | rep(i,2,s.size()){ | ^~~
s440344805
p04026
C++
#include<bits/stdc++.h> using namespace std; int main(){ string a; gets(a); for(int i = 1; i < a.size(); i++){ if(a[i] == a[i-1]){ cout << i << " " << i+1 <<endl; sum++; } } if(sum == 0){ for(int i = 2; i < a.size(); i++){ if(a[i] == a[i-2]){ cout << i-1 << " " << i+1 << endl; sum++; } } } if(sum == 0){ cout << -1 << " " << -1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:4:19: error: 'gets' was not declared in this scope; did you mean 'getw'? 4 | string a; gets(a); | ^~~~ | getw a.cc:8:13: error: 'sum' was not declared in this scope 8 | sum++; | ^~~ a.cc:11:8: error: 'sum' was not declared in this scope 11 | if(sum == 0){ | ^~~ a.cc:19:8: error: 'sum' was not declared in this scope 19 | if(sum == 0){ | ^~~
s194693203
p04026
C++
#include <iostream> int a=-1,i; main(){ string s; std::cin>>s; for(i=0,i<s.length();i++;)if(s[i]==s[i+1]){if(i>0)a=i-1;else a=i;} if(a!=-1)std::cout<<a<<" "<<a+2; else std::cout<<-1<<" "<<-1; }
a.cc:2:13: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | int a=-1,i; main(){ | ^~~~ a.cc: In function 'int main()': a.cc:3:1: error: 'string' was not declared in this scope 3 | string s; | ^~~~~~ a.cc:3:1: 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:4:11: error: 's' was not declared in this scope 4 | std::cin>>s; | ^
s227372006
p04026
C++
s = input() is_unbalanced = False for i in range(len(s)-1): if s[i] == s[i+1]: print(i+1, i+2) is_unbalanced = True break if is_unbalanced == False: for i in range(len(s)-2): if s[i] == s[i+2]: print(i+1, i+2) is_unbalanced = True break if is_unbalanced == False: print(-1, -1)
a.cc:1:1: error: 's' does not name a type 1 | s = input() | ^
s526230271
p04026
C++
Unbalanced #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<cmath> #include<queue> #include<stack> #include<vector> using namespace std; typedef long long ll; const int maxn = 1000005; const int maxm = maxn*2; const int inf = 0x3f3f3f3f; char s[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin>>(s+1); int n = strlen(s+1); for(int i = 2;i<=n;i++) { if(s[i]==s[i-1]) { cout<<i-1<<' '<<i<<'\n'; return 0; } if(i>=3 && s[i]==s[i-2]) { cout<<i-2<<' '<<i<<'\n'; return 0; } } cout<<-1<<' '<<-1<<'\n'; return 0; }
a.cc:1:1: error: 'Unbalanced' does not name a type 1 | Unbalanced | ^~~~~~~~~~ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, 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/exception_ptr.h:38, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ 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/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /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/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive] 134 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared 140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared 142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT | ^~~ /usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:145:52: error: expected primary-expression before 'const' 145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~~ /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/new:147:54: error: expected primary-expression before 'const' 147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT | ^~~~~ /usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^~~~~~ /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/new:154:68: error: expected primary-expression before ')' token 154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive] 155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:156:68: error: expected primary-expression before ',' token 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:156:70: error: expected primary-expression before 'const' 156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~~~ /usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^~~~~~ /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/new:162:70: error: expected primary-expression before ')' token 162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t) | ^ /usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive] 163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__)); | ^ /usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~~~ /usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~~ /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/new:164:70: error: expected primary-expression before ',' token 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^ /usr/include/c++/14/new:164:72: error: expected primary-expression before 'const' 164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) | ^~~~~ /usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared 171 | void operator delete(void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared 173 | void operator delete[](void*, std::size_t, std::align_val_t) | ^~~ /usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function 179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 179 | _GLIBCXX_N
s262771739
p04026
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, j, n) for (ll i = j; i < n; i++) #define all(x) (x).begin(),(x).end() #define INF (1000000000) #define MOD (1000000007) #define MAX (500000) #define pii pair<int, int> ///////////////////////////////////////////////////////// class XY{ public: ll x, y; XY() {x = y = 0;} XY(ll u, ll v) {x = u; y = v;} }; class e{ public: ll a, b; e() {a = b = -1;} e(ll u, ll v) {a = u; b = v;} }; template<typename T1, typename T2> void chmin(T1 &a, T2 b) {if(a > b) a = b;} template<typename T1, typename T2> void chmax(T1 &a, T2 b) {if(a < b) a = b;} template<typename T1, typename T2> ll mypow(T1 a, T2 n){ if(n == 0) return 1; if(n == 1) return a; if(n % 2) return a * mypow(a, n - 1); ll tmp = mypow(a, n / 2); return tmp * tmp; } template<typename T> int BS(vector<T> &V, int left, int right, T key){ int mid = (left + right) / 2; if(V[mid] <= key) left = mid; else right = mid; if(right - mid == 1) return left; else return BS(V, left, right, key); } ll comb(ll n, ll r){ ll res = 1; rep(i, 0, r){ res *= n - i; res /= i + 1; } return res; } template<typename T> T euclid(T a, T b){ if(b == 0) return a; else return euclid(b, a % b); } vector<ll> fact(MAX, 0), fact_inv(MAX, 0); ll pow_mod(ll a, ll b){ ll res = 1; while(b > 0){ if(b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; } void prepare_comb_mod(ll n){ fact[0] = 1LL; for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD; fact_inv[n] = pow_mod(fact[n], MOD - 2); for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD; } ll comb_mod(ll n, ll r){ return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD; } ///////////////////////////////////////////////////////// void Main() { string S; cin >> S; rep(i, 0, S.size() - 1){ if(S[i] == S[i + 1]){ if(i == 0){ cout << i + 1 << " " << i + 3 << endl; return; }else{ cout << i << " " << i + 2 << endl; return; } } if(i == N - 1) continue; if(S[i] == S[i + 2]){ cout << i + 1 << " " << i + 3 << endl; } } cout << -1 << " " << -1 << endl; } ///////////////////////////////////////////////////////// int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); cout << std::fixed << std::setprecision(15); Main(); }
a.cc: In function 'void Main()': a.cc:102:13: error: 'N' was not declared in this scope 102 | if(i == N - 1) continue; | ^
s799161090
p04026
C++
#include <iostream> #include <cstdio> #include <map> #include <set> #include <vector> #include <algorithm> #include <queue> #include <stack> using namespace std; typedef long long ll; const int mo = 1e9 + 7; #define rep(i, n) for (int i = 0; i < n; i++) char str[210000]; void solve() { scanf("%s",str); int n=strlen(str); rep(i,n-1)if(str[i]==str[i+1]){printf("%d %d\n",i+1,i+2);return 0;} rep(i,n-2)if(str[i]==str[i+1]){printf("%d %d\n",i+1,i+3);return 0;} } main() { cin.tie(0); ios::sync_with_stdio(0); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:17:11: error: 'strlen' was not declared in this scope 17 | int n=strlen(str); | ^~~~~~ a.cc:9:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include <stack> +++ |+#include <cstring> 9 | using namespace std; a.cc:18:69: error: return-statement with a value, in function returning 'void' [-fpermissive] 18 | rep(i,n-1)if(str[i]==str[i+1]){printf("%d %d\n",i+1,i+2);return 0;} | ^ a.cc:19:69: error: return-statement with a value, in function returning 'void' [-fpermissive] 19 | rep(i,n-2)if(str[i]==str[i+1]){printf("%d %d\n",i+1,i+3);return 0;} | ^ a.cc: At global scope: a.cc:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 21 | main() | ^~~~
s451498774
p04026
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; typedef pair<int,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define mod 1000000007 #define fi first #define sc second #define rep(i,x) for(long long i=0;i<x;i++) #define repn(i,x) for(long long i=1;i<=x;i++) #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) vector<pair<string,P> >vec; void solve(string s){ rep(i, s.length()-1) { if (s[i] == s[i+1]) { cout << i+1 << " " << i+2 << endl; return 0; } if (s[i] == s[i+2]) { cout << i+1 << " " << i+3 << endl; return 0; } } cout << "-1 -1" << endl; } int main(){ string s; cin >> s; solve(s); return 0; }
a.cc: In function 'void solve(std::string)': a.cc:27:32: error: return-statement with a value, in function returning 'void' [-fpermissive] 27 | return 0; | ^ a.cc:31:32: error: return-statement with a value, in function returning 'void' [-fpermissive] 31 | return 0; | ^
s708725333
p04026
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long n,i,j,d=1,b[100000],k; char s[1000000]; gets(s); cout<<"-1 -1"; }
a.cc: In function 'int main()': a.cc:6:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 6 | gets(s); | ^~~~ | getw
s250013267
p04026
C++
#include<bits/stdc++.h> using namespace std; int main(){ char a[100000]; gets(a); int c[100000]; for(int i = 97; i <= 122; i++){ c[0] = 0; for(int j = 0; j < strlen(a) ; j++){ if(a[j] == i){ c[j + 1] = c[j] + 1; } else { c[j + 1] = c[j]; } } for(int j = 1; j < strlen(a); j++){ for(int k = j + 1; k < strlen(a); k++){ if(2 * (c[k] - c[j - 1]) > k - j + 1){ cout << j << " " << k; return 0; } } } } cout << -1 << " " << -1; }
a.cc: In function 'int main()': a.cc:6:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 6 | gets(a); | ^~~~ | getw
s628454619
p04026
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.io.PrintWriter; import java.util.ArrayList; public class ARC059B { static class Scanner { BufferedReader br; StringTokenizer tk=new StringTokenizer(""); public Scanner(InputStream is) { br=new BufferedReader(new InputStreamReader(is)); } public int nextInt() throws IOException { if(tk.hasMoreTokens()) return Integer.parseInt(tk.nextToken()); tk=new StringTokenizer(br.readLine()); return nextInt(); } public long nextLong() throws IOException { if(tk.hasMoreTokens()) return Long.parseLong(tk.nextToken()); tk=new StringTokenizer(br.readLine()); return nextLong(); } public String next() throws IOException { if(tk.hasMoreTokens()) return (tk.nextToken()); tk=new StringTokenizer(br.readLine()); return next(); } public String nextLine() throws IOException { tk=new StringTokenizer(""); return br.readLine(); } public double nextDouble() throws IOException { if(tk.hasMoreTokens()) return Double.parseDouble(tk.nextToken()); tk=new StringTokenizer(br.readLine()); return nextDouble(); } public char nextChar() throws IOException { if(tk.hasMoreTokens()) return (tk.nextToken().charAt(0)); tk=new StringTokenizer(br.readLine()); return nextChar(); } public int[] nextIntArray(int n) throws IOException { int a[]=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n) throws IOException { long a[]=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public int[] nextIntArrayOneBased(int n) throws IOException { int a[]=new int[n+1]; for(int i=1;i<=n;i++) a[i]=nextInt(); return a; } public long[] nextLongArrayOneBased(int n) throws IOException { long a[]=new long[n+1]; for(int i=1;i<=n;i++) a[i]=nextLong(); return a; } } public static void main(String args[]) throws IOException { new Thread(null, new Runnable() { public void run() { try { solve(); } catch(Exception e) { e.printStackTrace(); } } }, "1", 1 << 26).start(); } static void solve() throws IOException { Scanner in=new Scanner(System.in); PrintWriter out=new PrintWriter(System.out); char c[]=in.next().toCharArray(); int st=-1, en=-1; for(char i='a';i<='z';i++){ ArrayList<Integer> a=new ArrayList<>(); int cnt=0; int max=0; int min=0; int minRem=0; for(int j=0;j<c.length;j++){ if(i==c[j]){ cnt++; int nv=2*cnt-j-min-1; if(nv>0&&j!=0){ //find answer here en=j; st=j; cnt=1; do{ st--; if(c[st]==i) cnt++; }while(2*cnt<=en-st+1); en++; st++; break; } min=Math.min(min, minRem); minRem=nv; } else{ min=Math.min(min, minRem); } if(st!=-1) break; } if(st!=-1) break; } out.println(st+" "+en); out.close(); } }
Main.java:8: error: class ARC059B is public, should be declared in a file named ARC059B.java public class ARC059B ^ 1 error
s570740946
p04026
C++
#include <iostream> #include <string> #include <utility> #include <stack> #include <vector> #include <queue> #include <algorithm> #include <map> #include <climits> #include <set> #include <cmath> #include <numeric> using namespace std; int main(){ string s; cin >> s; if(s.size() == 2){ if(s[0] == [1]){ cout << 1 << " " << 2 << endl; } else { cout << -1 << " " << -1 << endl; } return 0; } for(int i = 0; i < s.size() - 3; i++){ map <char, int> char_counts; for(int j = 0; j < 3; j++){ if(char_counts.find(s[i + j]) != char_counts.end()){ char_counts[s[i + j]] += 1; } else { char_counts[s[i + j]] = 1; } } for(auto it = char_counts.begin(); it != char_counts.end(); it++){ if(it->second > 1){ cout << i + 1 << " " << i + 3 << endl; return 0; } } } cout << -1 << " " << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:21: error: expected identifier before numeric constant 20 | if(s[0] == [1]){ | ^ a.cc: In lambda function: a.cc:20:23: error: expected '{' before ')' token 20 | if(s[0] == [1]){ | ^ a.cc: In function 'int main()': a.cc:20:17: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} and 'main()::<lambda()>') 20 | if(s[0] == [1]){ In file included from /usr/include/c++/14/iosfwd:42, 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/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::fpos<_StateT>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::allocator<_CharT>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::reverse_iterator<_Iterator>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::reverse_iterator<_Iterator>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::move_iterator<_IteratorL>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::move_iterator<_IteratorL>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::pair<_T1, _T2>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char' 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char' 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:20:23: note: 'main()::<lambda()>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const _CharT*' and 'char' 20 | if(s[0] == [1]){ | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2558 | operator==(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed: a.cc:20:23: note: mismatched types 'const std::tuple<_UTypes ...>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} 20 | if(s[0] == [1]){ | ^ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)' 234 | operator==(const istreambuf_iterator<_CharT, _Traits>& __a, |
s262416831
p04026
C++
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define reps(i,n) for(int i=1;i<=(n);++i) #define repr(i,n) for(int i=(n);i>=0;--i) #define cinv(n,v) VL v(n);rep(i,n)cin>>v[i] #define int long long #define itn int #define pb push_back #define eb emplace_back #define m_p make_pair #define m_t make_tuple #define p_p(a,b) pb(m_p(a,b)) #define all(a) a.begin(),a.end() #define SORT(a) sort(all(a)) #define RSORT(a) sort(all(a),greater<>()) #define UNIQUE(a) a.erase(unique(all(a)),a.end()) #define SZ(a) (signed)(a.size()) #define debg(a) cout<<#a<<" "<<a<<endl; #define debgp(a) cout<<#a<<" "<<a.fi<<" : "<<a.se<<endl #define call(a) for(auto i:a)cout<<i<<" ";cout<<endl #define callp(a) for(auto [k,v]:a)cout<<k<<":"<<v<<endl #define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;} #define out(a) cout<<(a)<<endl #define ENDL cout<<endl #define YES cout<<"YES"<<endl #define NO cout<<"NO"<<endl #define Yes cout<<"Yes"<<endl #define No cout<<"No"<<endl #define LINE puts("------------------") #define fi first #define se second #define V vector #define P pair #define T tuple #define PQ priority_queue #define cont const auto #define VV(type,name,y,x,a) vector<vector<type>> name = vector<vector<type>>(y,vector<type>(x,a)) typedef long long ll; typedef double D; typedef long double LD; typedef string str; typedef vector<ll> VL; typedef pair<ll,ll> PL; typedef vector<pair<ll,ll>> VP; typedef tuple<ll,ll,ll> T3; typedef tuple<ll,ll,ll,ll> T4; typedef struct{ll to;ll cost;} Graphs; typedef V<V<Graphs>> AdjList; const signed INF = (1LL<<30); const long long MOD = (1e9+7); const long long LINF = (1LL<<60); const long long LMAX = LLONG_MAX; void YN(bool b){cout<<(b?"Yes":"No")<<endl;} template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));} template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;} template<class T>inline bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;} template<class T>inline bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;} template<class T>T center(T a,T b,T c){ if( (a<=b&&b<=c)||(a>=b&&b>=c) )return b; if( (b>=a&&a>=c)||(b<=a&&a<=c) )return a; return c; } void print(){} template<class Head,class... Tail> void print(Head&& head, Tail&&... tail){ cout<<head<<endl; print(forward<Tail>(tail)...); } void input(){} template<class Head,class... Tail> void input(Head&& head, Tail&&... tail){ cin>>head; input(forward<Tail>(tail)...); } template<typename T> ostream &operator<<(ostream&out,const vector<T>&v){ if(!v.empty()){ copy(v.begin(),v.end(),ostream_iterator<T>(out,", ")); out<<"\b\b"; } return out; } template<typename T1, typename T2> ostream &operator<<(ostream&out,const pair<T1,T2>&p){ out<<p.first<<", "<<p.second; return out; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<<fixed<<setprecision(10); str s; cin>>s; rep(i,SZ(s)-1){ if(s[i]==s[i+1]){ cout<<i+1<<" "<<i+2<<endl; return 0; } if(i+2<n && s[i]==s[i+2]){ cout<<i+1<<" "<<i+3<<endl; return 0; } } out("-1 -1"); return 0; }
a.cc: In function 'int main()': a.cc:105:12: error: 'n' was not declared in this scope 105 | if(i+2<n && s[i]==s[i+2]){ | ^
s639561668
p04026
C++
#include<iostream> using namespace std; int main(){ int a = -1,b = -1; char s[100000]; scanf("%s",s); for(int i = 0; i < n; i++){ if(s[i] == s[i+1] ){ a = i; b = i +1; break; } if(s[i] == s[i+2]){ a = i; b = i+2; break } } cout << a << " " << b << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:9:29: error: 'n' was not declared in this scope 9 | for(int i = 0; i < n; i++){ | ^ a.cc:18:30: error: expected ';' before '}' token 18 | break | ^ | ; 19 | } | ~
s014953922
p04026
C++
// /*==========================================================*/ /* Template ver 2017-0720 | Created by JollyBee */ /* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */ /*==========================================================*/ #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<pii> vii; const double EPS=(double)1e-9; const double PI=(double)acos(-1.0); #define fi first #define se second #define mp make_pair #define pb push_back #define pob pop_back #define pf push_front #define pof pop_front #define FOR(i,n) for(int i=0;i<n;i++) #define REPP(i,l,r,c) for(int i=l;i<=r;i+=c) #define REP(i,l,r) REPP(i,l,r,1) #define FORD(i,n) for(int i=n-1;i>=0;i--) #define REVV(i,l,r,c) for(int i=l;i>=r;i-=c) #define REV(i,l,r) REVV(i,l,r,1) //random int irand(int lo, int hi){ return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo; } //ll to string string toString(ll x) { stringstream ss; ss << x; return ss.str(); } //string to ll ll toNumber(string S) { ll ret; sscanf(S.c_str(),"%lld",&ret); return ret; } // std::fill(start, end, value); // for(auto it: DS){} const int INF=(int)2e9; const ll MOD=(ll)1e9+7; /*==========================================================*/ /* END OF TEMPLATE */ /* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */ /*==========================================================*/ int s[100005]; pii solve(){ int n = strlen(s+1); REP(pos,1,n-2) REP(i,pos,pos+2) REP(j,i+1,pos+2){ if(s[i] == s[j]) return mp(pos,pos+2); } return mp(-1,-1); } int main(){ scanf("%s", s+1); pii res = solve(); printf("%d %d\n", res.fi, res.se); return 0; }
a.cc: In function 'pii solve()': a.cc:58:21: error: cannot convert 'int*' to 'const char*' 58 | int n = strlen(s+1); | ~^~ | | | int* In file included from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:6: /usr/include/string.h:407:35: note: initializing argument 1 of 'size_t strlen(const char*)' 407 | extern size_t strlen (const char *__s) | ~~~~~~~~~~~~^~~
s243694556
p04026
C++
#include <cstdio> const int N=100005; char a[N]; int main (){ scanf ("%s",a+1); int n=strlen(a+1); if (n==2) { if (a[1]==a[2]) puts("1 2"); else puts("-1 -1"); return 0; } for (int i=1;i<=n-2;i++) if ((a[i]==a[i+1])||(a[i]==a[i+2])||(a[i+1]==a[i+2])){ printf ("%d %d",i,i+2);return 0; } puts("-1 -1"); return 0; }
a.cc: In function 'int main()': a.cc:6:9: error: 'strlen' was not declared in this scope 6 | int n=strlen(a+1); | ^~~~~~ a.cc:2:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <cstdio> +++ |+#include <cstring> 2 | const int N=100005;
s814054319
p04026
C++
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10 #define ll long long #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define all(a) (a).begin(), (a).end() #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define sz size #define f first #define s second #define pb push_back #define er erase #define in insert #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define mod 1000000007 #define PI 3.14159265359 #define CODE_START ios_base::sync_with_stdio();cin.tie();cout.tie(); using namespace std; ll n,cnt[27]; string s; int32_t main(){ CODE_START; cin >> s; n=s.size(); if(n==2){ cout << "-1" << ' ' << "-1"; return 0; } for(ll i=0;i<n-1;i++) if(s[i]==s[i+1]){ if(i!=n-2){ cout << i+1 << ' ' << i+3; return 0; }else if(i==n-2){ cout<< i << ' ' <<i+2; return 0; } cout << "-1" << ' ' <<"-1"; return 0;}
a.cc: In function 'int32_t main()': a.cc:40:11: error: expected '}' at end of input 40 | return 0;} | ^ a.cc:22:15: note: to match this '{' 22 | int32_t main(){ | ^
s805966525
p04026
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; for(int i=0;i<n-2;i++) { if(s[i]==s[i+1]||s[i+1]==s[i+2]||s[i]==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:6:17: error: 'n' was not declared in this scope 6 | for(int i=0;i<n-2;i++) { | ^
s011110682
p04026
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String t = sc.next(); sc.close(); int n = t.length(); if(n <= 2) { System.out.println("-1 -1"); System.exit(0); } for(int i = 0; i < n - 2; i++) { char c0 = t.charAt(i); char c1 = t.charAt(i + 1); char c2 = t.charAt(i + 2); int[] k = new int[26]; k[(int)(c0 - 'a')]++; k[(int)(c1 - 'a')]++; k[(int)(c2 - 'a')]++; Arrays.sort(k); if(k[25] == 2) { System.out.printf("%d %d\n", i + 1, i + 3); System.exit(0); } } System.out.println("-1 -1"); } }
Main.java:21: error: cannot find symbol Arrays.sort(k); ^ symbol: variable Arrays location: class Main 1 error
s062705515
p04026
C++
#include <iostream> #include <malloc.h> #include<stack> #include<map> #include<stdio.h> #include<bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; struct Node { int a; char c; }w[1000000]; int n; bool cmp(Node a,Node b) { return a.c<b.c; } int main() { set<char>s; int i; string ss; cin>>ss; int len=ss.length(); for(int i=0;i<len;i++) { s.insert(ss[i]); w[i].c=ss[i]; w[i].a=i+1; } sort(w,w+len,cmp); if(len==s.size()) printf("-1 -1\n"); else { for(i=1;i<len;i++) { if(w[i].c==w[i-1].c) { int t=abs(w[i].a-w[i-1].a); if(t<=3) if(w[i].a<w[i-1].a) { printf("%d %d",w[i].a,w[i].a); break; } else { printf("%d %d",w[i].a,w[i].a); break } } } } return 0; }
a.cc: In function 'int main()': a.cc:52:31: error: expected ';' before '}' token 52 | break | ^ | ; 53 | } | ~
s606459264
p04026
C++
#include <iostream> #include <malloc.h> #include<stack> #include<map> #include<stdio.h> #include<bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; struct Node { int a; char c; }w[1000000]; int n; bool cmp(Node a,Node b) { return a.c<b.c; } int main() { set<char>s; int i; string ss; cin>>ss; int len=ss.length(); for(int i=0;i<len;i++) { s.insert(ss[i]); w[i].c=ss[i]; w[i].a=i+1; } sort(w,w+len,cmp); if(len==s.size()) printf("-1 -1\n"); else { for(i=1;i<len;i++) { if(w[i].c==w[i-1].c) { int t=abs(w[i].a-w[i-1].a); if(t<=3) if(w[i].a<w[i-1].a) { printf("%d %d",w[i].a,w[i].a); break; } else { printf("%d %d",w[i].a,w[i].a); break } } } } return 0; }
a.cc: In function 'int main()': a.cc:52:31: error: expected ';' before '}' token 52 | break | ^ | ; 53 | } | ~
s794724601
p04026
C++
#include<cstdio> using namespace std; #include<cstring> int main(){ char s[100010]; int n; scanf("%s",s); n=strlen(s); for(int i=0;i<n-2;i++){ if(s[i]==s[i+1]){ printf("%d %d\n",i,i+1); return 0; } else if(s[i]==s[i+2]){ printf("%d %d\n",i,i+2); return 0; } } if(s[n-2]==s[n-1]){ peinrf("%d %d\n",n-2,n-1); return 0; } printf("-1 -1\n"); }
a.cc: In function 'int main()': a.cc:21:5: error: 'peinrf' was not declared in this scope; did you mean 'printf'? 21 | peinrf("%d %d\n",n-2,n-1); | ^~~~~~ | printf
s447553703
p04026
C++
#include<stdio.h> int main(){ char s[111111]; int i,a=-1,b=-1; for(i=0;i<111111;i++) s[i]='\0'; scanf("%s",s); if(s[0]==s[1]){ a=1; b=2; for(i=2;s[i]!='\0';i++){ if(s[i]==s[i-1]){ a=i; b=i+1; } if(s[i]==s[i-2]){ a=i-1; b=i+1; } } printf("%d %d\n",a,b); return 0; }
a.cc: In function 'int main()': a.cc:23:2: error: expected '}' at end of input 23 | } | ^ a.cc:2:11: note: to match this '{' 2 | int main(){ | ^
s644031508
p04026
C++
#include <iostream> #include <algorithm> #include <cmath> #include <limits> #include <vector> #include <cstdio> #include <bits/stdc++.h> #include <set> #include <map> #include <stdio.h> #include <stack> #include <queue> #include <deque> #include <numeric> #include<bits/stdc++.h> #define ALL(obj) (obj).begin(), (obj).end() #define FOR(i,a,b) for(int i = (a); i < (b); i++) #define RFOR(i,a,b) for(int i = (a); (b) <= i; i--) #define REP(i,n) for(int i = 0; i < (n); i++) #define RREP(i,n) for(int i = n; n <= i; i--) #define ABS(a) ((a < 0) ? ((-1)*(a)) : (a)) #define elif else if #define MOD 1000000007 #define INF (1<<29) using namespace std; using ll = long long; map <int ,int> mpa,mpb; typedef pair<ll, ll> P; priority_queue<P, vector<P>, greater<P>> pque; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); string s; cin >> s; n=s.size(); REP(i,n){ if(s[i]==s[i+1]){ cout << i << " " << i+1 << endl; }elif(s[i]==s[i+2]){ cout << i << " " << i+2 << endl; } } cout << -1 << " " << -1 << endl; }
a.cc: In function 'int main()': a.cc:38:3: error: 'n' was not declared in this scope 38 | n=s.size(); | ^
s565682068
p04026
C++
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author kishore */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskD solver = new TaskD(); solver.solve(1, in, out); out.close(); } static class TaskD { public void solve(int testNumber, InputReader in, PrintWriter out) { String s = in.nextLine(); if (s.length() > 2) { int arr[][] = new int[s.length()][26]; for (int i = 0; i < s.length(); i++) { arr[i] = findArr(s.substring(i)); } for (int i = 0; i < s.length() - 1; i++) { if (max(arr[i]) > (s.length() - i) / 2) { out.println((i + 1) + " " + s.length()); return; } } for (int i = 0; i < s.length(); i++) { for (int j = i + 2; j < s.length(); j++) if (diff(arr[i], arr[j]) > (j - i) / 2) { out.println((i + 1) + " " + j); return; } } } out.println("-1 -1"); } private int diff(int[] a, int[] b) { int max = a[0] - b[0]; for (int i = 1; i < 26; i++) { if (a[i] - b[i] > max) max = a[i] - b[i]; } return max; } private int max(int[] arr) { int max = arr[0]; for (int i = 1; i < 26; i++) if (max < arr[i]) max = arr[i]; return max; } private int[] findArr(String s) { int[] sol = new int[26]; for (int i = 0; i < s.length(); i++) { sol[(int) (s.charAt(i) - 'a')]++; } return sol; } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String nextLine() { try { return reader.readLine(); } catch (Exception e) { throw new RuntimeException(e); } } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.OutputStream; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.IOException; | ^~~~~~ 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.InputStream; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.PrintWriter; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.StringTokenizer; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.io.BufferedReader; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:7:1: error: 'import' does not name a type 7 | import java.io.InputStreamReader; | ^~~~~~ a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: 'import' does not name a type 8 | import java.io.InputStream; | ^~~~~~ a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:16:1: error: expected unqualified-id before 'public' 16 | public class Main { | ^~~~~~
s819269804
p04026
C++
#include <bits/stdc++.h> using ll = long long; using namespace std; void die(int x, int y) { cout << x << " " << y; die(0); } int main() { cin.tie(0); cin.sync_with_stdio(0); string s; cin >> s; int n = s.size(); for (int i = 1; i < n; ++i) if (s[i] == s[i - 1]) die(i, i + 1); else if (i - 2 >= 0 && s[i - 2] == s[i]) die(i - 1, i + 1); cout << "-1 1"; }
a.cc: In function 'void die(int, int)': a.cc:7:6: error: too few arguments to function 'void die(int, int)' 7 | die(0); | ~~~^~~ a.cc:5:6: note: declared here 5 | void die(int x, int y) { | ^~~
s158467547
p04026
C++
#include <iostream> using namespace std; int main() { string S; cin >> S; for (int i = 0; i < S.length() - 1; i++) { if (S[i] == S[i + 1]) { cout << i << ' ' << i + 1 << endl; return 0; } if (i > 0) { if (S[i - 1:] == S[i + 1]) { cout << i - 1 << ' ' << i + 1 << endl; return 0; } } } cout << -1 << ' ' << -1 << endl; }
a.cc: In function 'int main()': a.cc:13:24: error: expected ']' before ':' token 13 | if (S[i - 1:] == S[i + 1]) { | ^ | ] a.cc:13:24: error: expected ')' before ':' token 13 | if (S[i - 1:] == S[i + 1]) { | ~ ^ | ) a.cc:13:25: error: expected primary-expression before ']' token 13 | if (S[i - 1:] == S[i + 1]) { | ^
s976442744
p04026
C++
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> int descending_compare(const void *a, const void *b){ if (*(int*)a > *(int*)b){ return -1; }else if (*(int*)a == *(int*)b){ return 0; }else{ return 1; } } int ascending_compare(const void *a, const void *b){ if (*(int*)a < *(int*)b){ return -1; }else if (*(int*)a == *(int*)b){ return 0; }else{ return 1; } } // array pointer = *a, num of element = n, key key int lower_bound(int *a, int n, int key){ int ng, mid, ok; ng = -1, ok = n-1; while (abs(ok - ng) > 1){ mid = (ok + ng) / 2; if (key <= a[mid]){ ok = mid; }else{ ng = mid; } } if (a[ok] >= key)return ok; return n; } //greatest common divisor unsigned long gcd(unsigned long x, unsigned long y){ if (y == 0){ return x; }else if (x > y){ return gcd(y, x % y); }else{ return gcd(x, y % x); } } unsigned long lcm(unsigned long x, unsigned long y){ unsigned long g = gcd(x, y); return x*y/g; } long long factorial(int x){ long long rtn = 1; int i; for (i = x; i > 1; i--){ rtn = (rtn*i); } return rtn; } /* int struct_ascending_compare(const void *p, const void *q) { return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name; }*/ /*unsigned long long pascal[100][100] = {0}; void make_pascal(void){ for (int i = 0; i < 100; i++){ pascal[i][0] = 1; } pascal[1][1] = 1; for (int i = 2; i < 100; i++){ for (int j = 1; j < 100; j++){ pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod; } } }*/ long long mod = 1000000007; //x ^ n long long mod_pow(long long x, long long n){ long long res = 1; for(int i = 0;i < 60; i++){ if(n >> i & 1) res = res * x % mod; x = x * x % mod; } return res; } char s[100005]; int main(void){ scanf("%s", s); int len = strlen(s); for (int i = 1; i < len-1; i++){ for (int j = i-1; j <= i+1; j++){ if ((i != j && s[i] == s[j]) || s[i-1] == s[i+1])) { printf("%d %d\n", i, i+2); return 0; } } } printf("-1 -1\n"); return 0; }
a.cc: In function 'int main()': a.cc:106:62: error: expected primary-expression before ')' token 106 | if ((i != j && s[i] == s[j]) || s[i-1] == s[i+1])) { | ^
s172399247
p04026
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; //typedef long long ll; #define INF (1LL << 31 - 1) #define INFLL ((1LL << 62) - 1) #define MOD int(1e9+7) #define repi(i,j,n) for(int i = (j); i < (n); ++i) #define rep(i,n) repi(i,0,n) #define rrep(i,n) for (int i = n; i >= 0; --i) #define fi first #define se second #define all(v) (v).begin(), (v).end() int vx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, vy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; inline bool check(int ux, int uy, int x, int y) { return (0 <= x and x < ux and 0 <= y and y < uy); } inline void init() { cin.tie(0); ios::sync_with_stdio(false); } string s; int main() { cin >> s; int n = s.size(), l, r; l = 0, r = 1; // [l, r] map<char, int> mp; mp[s[0]]++, mp[s[1]]++; d while(true) { if (l == r and r == n - 1) break; if (l == r) { r++; mp[r]++; } else { int len = r - l + 1; if (len >= 2) { for (char c = 'a'; c <= 'z'; ++c) { if (mp[c] > (len / 2)) { cout << l + 1 << " " << r + 1 << endl; return 0; } } } if (r < n - 1 and mp[s[r + 1]] > 0) { r++; mp[s[r]]++; } else { mp[s[l]]--; l++; } } } cout << -1 << " " << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:38:1: error: 'd' was not declared in this scope 38 | d | ^