submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s687472007
p03946
C
#include<stdio.h> int main() { int n,t; int i,j; int c=0; int g=0; int min; if(scanf("%d %d",&n,&t) < 2) { fprintf(stderr, "error: ill-formed fraction.\n"); exit(1); } int a[n]; for(i=0;i<n;i++){ if(scanf("%d",&a[i]) < 1) { fprintf(stderr, "error: ill-formed fraction.\n"); exit(1); } } min = a[0]; for(i=1;i<n;i++){ if(min>a[i]){ min=a[i]; }else if(a[i]-min>g){ c=1; g=a[i]-mig; }else if(a[i]-min==g){ c++; } } printf("%d\n",c); return 0; }
main.c: In function 'main': main.c:13:5: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 13 | exit(1); | ^~~~ main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'exit' 1 | #include<stdio.h> +++ |+#include <stdlib.h> 2 | main.c:13:5: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 13 | exit(1); | ^~~~ main.c:13:5: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c:21:5: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 21 | exit(1); | ^~~~ main.c:21:5: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c:31:32: error: 'mig' undeclared (first use in this function); did you mean 'min'? 31 | g=a[i]-mig; | ^~~ | min main.c:31:32: note: each undeclared identifier is reported only once for each function it appears in
s119185625
p03946
C++
#include <stdlib.h> #include <stdio.h> #include <iostream> #include <vector> #include <string> #include <math.h> #include <map> #include <algorithm> using namespace std; int main(){ int n,t; cin >> n >> t; vector<int> a(n); int alocal=1e9+1; ai[0]=0; int ans=0; int local =0; for (int i = 0; i < n; i++) { cin >> a[i]; if(alocal>a[i]){ alocal=a[i]; } if(a[i]-alocal>local){ local=a[i]-alocal; ans=1; }else if(a[i]-alocal == 0){ ans++; } } cout <<ans <<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:3: error: 'ai' was not declared in this scope; did you mean 'a'? 16 | ai[0]=0; | ^~ | a
s049395084
p03946
C++
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i = 0; i < n; i++) #define FOR(i,a,b) for(int i = a; i < b; i++) #define FORR(i,a,b) for (int i = a; i > b; i--) #define pi acos(-1.0) typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VI> VVI; typedef pair<int,int> P; typedef pair<ll,ll> PL; VI a; int main(){ int n, t; int a_min = INT_MAX; int b_max = INT_MIN; int ans = 1; cin >> n >> t; REP(i,n){ int temp; cin >> temp; a.push_back(temp); } REP(i,n-1){ if(a[i] < a_min) a_min = a[i]; if(b_max < a[i+1] - a_min){ b_max = a[i+1] - a_min; }else if(b_max == a[i+1] - a_min){ ans++; } } if(ans > t/2) ans = t/2; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:17: error: 'INT_MAX' was not declared in this scope 31 | int a_min = INT_MAX; | ^~~~~~~ a.cc:13:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 12 | #include <algorithm> +++ |+#include <climits> 13 | using namespace std; a.cc:32:17: error: 'INT_MIN' was not declared in this scope 32 | int b_max = INT_MIN; | ^~~~~~~ a.cc:32:17: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s527182590
p03946
C++
#include <bits/stdc++.h> using namespace std; #define LOG(...) fprintf(stderr, __VA_ARGS__) // #define LOG(...) #define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i) #define REP(i, n) for(int i = 0; i < (int)(n); ++i) #define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i) #define RFOR(i, a, b) for(int i = (int)(b - 1); i >= (int)(a); --i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define EXIST(s, e) ((s).find(e) != (s).end()) #define SORT(c) sort(ALL(c)) #define RSORT(c) sort(RALL(c)) #define SQ(n) (n) * (n) #define BIT(x, i) (((x) >> (i)) & 1) typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<bool> vb; typedef vector<int> vi; typedef vector<char> vc; typedef vector<pii> vpi; typedef vector<pll> vpl; typedef vector<ll> vll; typedef vector<vb> vvb; typedef vector<vi> vvi; typedef vector<vc> vvc; typedef vector<vll> vvll; int main() { int N, T; cin >> N >> T; T /= 2; vll apples(N); REP(i, N) { cin >> apples[i]; } vll maxd(N, -1); ll maxv = 0; RREP(i, N) { maxv = max(maxv, apples[i]); maxd[i] = maxv - apples[i]; } gain gain = 0; int cnt = 0; REP(i, N) { ll d = maxd[i]; if (gain == d) { cnt++; } else if(gain < d) { gain = d; cnt = 1; } } // REP(i, N - 1) FOR(j, i + 1, N) { // int d = apples[j] - apples[i]; // if (gain == d) { // cnt++; // } else if(gain < d) { // gain = d; // cnt = 1; // } // } cout << min(cnt, T) << endl; // LOG("gain %d, n %d\n", gain, cnt); }
a.cc: In function 'int main()': a.cc:51:3: error: 'gain' was not declared in this scope; did you mean 'main'? 51 | gain gain = 0; | ^~~~ | main
s529356184
p03946
C++
#include <iostream> int main(){ long long int N, T; long long int A[100000], B[100000], C[100000]; long long int min, max, cnt; std::cin >> N >> T; for(int i=0; i<N; i++){ std::cin >> A[i]; } for(int i=0; i<N; i++){ for(int int j=i; j<N; j++){ if(max < A[i]-A[j]) max = A[j]-A[i]; } B[i]=max; C[i]=j; } std::sort(B, B+100000); for(int i=N-2; i>=0; i--){ if(B[N-1] == B[i] && C[N-1] == C[i]) cnt++; } std::cout << cnt << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: two or more data types in declaration of 'j' 15 | for(int int j=i; j<N; j++){ | ^~~ a.cc:15:22: error: 'j' was not declared in this scope 15 | for(int int j=i; j<N; j++){ | ^ a.cc:19:10: error: 'j' was not declared in this scope 19 | C[i]=j; | ^ a.cc:22:8: error: 'sort' is not a member of 'std'; did you mean 'qsort'? 22 | std::sort(B, B+100000); | ^~~~ | qsort
s740853962
p03946
C++
#include <iostream> using namespace std; int main(){ int n, t; cin >> n >> t; int maxi = 0, diff = 1e9, count = 0; while(n--){ int a; cin >> a; maxi = max(maxi, a); if(diff == maxi - a) count++; if(diff < maxi - a){ count = 1; diff = maxi - a; } } cout << count << end; }
a.cc: In function 'int main()': a.cc:18:23: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 18 | cout << count << end; | ~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | operator<<(nullptr_t) | ^~~~~~~~ /usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::nullptr_t' 306 | operator<<(nullptr_t)
s957516094
p03946
C++
#include <cstdio> using namespace std; int n, t; int a[100000]; int p[100000][100000]; int m; int ans; int main(){ scanf("%d %d", &n, &t); for(int i=0; i<n; i++) scanf("%d", &a[i]); int s = t / 2; for(int i=0; i<n-1; i++){ for(int j=1; i+j<=n-1; j++){ p[i][i+j] = s * (a[i+j] - a[i]); if(m == p[i][i+j]){ ans++; }else if(m < p[i][i+j]){ m = p[i][i+j]; ans = 1; } } } printf("%d\n", ans); return 0; }
/tmp/ccXAbMqj.o: in function `main': a.cc:(.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccXAbMqj.o a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXAbMqj.o a.cc:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXAbMqj.o a.cc:(.text+0x17d): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccXAbMqj.o a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccXAbMqj.o a.cc:(.text+0x1b9): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXAbMqj.o a.cc:(.text+0x1f3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccXAbMqj.o collect2: error: ld returned 1 exit status
s673588871
p03946
C
#include <stdio.h> #include <stdlib.h> int main(){ int N,T; scanf("%d %d",&N,&T); if(T < 2){ printf("0\n"); return 0; } int * cost = malloc(N*sizeof(int)); int i; for(i = 0; i < N; i++){ scanf("%d",&cost[i]); } //find max profit int j; int max = 0; for(i = 0; i < N-1; i++){ for(j = i+1; j<N; j++){ int diff = cost[j]-cost[i]; if(diff>max){ max = (cost[j]-cost[i]); count = 0; }else if(diff == max){ count++; } } } printf("%d\n",count); return EXIT_SUCCESS; }
main.c: In function 'main': main.c:25:17: error: 'count' undeclared (first use in this function) 25 | count = 0; | ^~~~~ main.c:25:17: note: each undeclared identifier is reported only once for each function it appears in
s234017214
p03946
C++
#include <cstdio> #include <algorithm> #include <set> #include <vector> using namespace std; int n, t; int a[100000]; int p[100000][100000]; int m; int ans; int main(){ scanf("%d %d", &n, &t); for(int i=0; i<n; i++) scanf("%d", &a[i]); int s = t / 2; for(int i=0; i<n-1; i++){ for(int j=1; i+j<=n-1; j++){ p[i][i+j] = s * (a[i+j] - a[i]); // printf("%d %d %d\n", i, i+j, p[i][i+j]); if(m == p[i][i+j]){ ans++; }else if(m < p[i][i+j]){ m = p[i][i+j]; ans = 1; } } } printf("%d\n", ans); return 0; }
/tmp/ccKGdGmU.o: in function `main': a.cc:(.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccKGdGmU.o a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccKGdGmU.o a.cc:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccKGdGmU.o a.cc:(.text+0x17d): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccKGdGmU.o a.cc:(.text+0x1b3): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccKGdGmU.o a.cc:(.text+0x1b9): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccKGdGmU.o a.cc:(.text+0x1f3): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccKGdGmU.o collect2: error: ld returned 1 exit status
s755697858
p03946
C++
#include <iostream> #define int long long int main() { int n, t; std::cin >> n >> t; int maxDiff = 0, maxCount = 0; int nowMin = 0; std::cin >> nowMin; int prev = nowMin; for (int i = 1; i <= n; ++i) { int a; if (i != n) std::cin >> a; else a = prev - 1; if (a < prev) { if (maxDiff < prev - nowMin) maxDiff = prev - nowMin, maxCount = 1; else if (maxDiff == prev - nowMin) ++maxCount; nowMin = a; } prev = a; } std::cout << maxCount << std::endl; }
cc1plus: error: '::main' must return 'int'
s466251247
p03946
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 整数の入力 int n = sc.nextInt(); int t = sc.nextInt(); int a[] = new a[n]; for(int i=0; i<n; i++){ a[i] = sc.nextInt(); } int maxsa = 0; int maxa = 0; int sa = 0; int counter = 0; for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ if(maxa < a[j]){ maxa = a[j]; } } sa = maxa - a[i]; if(maxsa < sa){ maxsa = sa; counter = 1; } if(maxsa == sa){ counter = counter + 1; } maxa = 0; } System.out.println(counter); } }
Main.java:8: error: cannot find symbol int a[] = new a[n]; ^ symbol: class a location: class Main 1 error
s127632489
p03946
C++
#include <iostream> #include <vector> typedef signed long long int slli; int main() { unsigned N; slli T; std::cin >> N >> T; std::vector<slli> A(N); for(unsigned n=0; n<N; ++n) { std::cin >> A[n]; } if(N == 1) { std::cout << 0 << std::endl; return 0; } std::vector<char> C(N-1); for(unsigned n=0; n<N-1; ++n) { C[n] = (A[n] < A[n+1]) ? 'U' : 'D'; } /* for(unsigned n=0; n<N-1; ++n) { std::cerr << C[n]; if(n + 1 < N - 1) std::cerr << ' '; } std::cerr << std::endl; */ unsigned i = 0; while(C[i] != 'D') ++i; unsigned c = 0; char x = C[i]; for(unsigned n=i; n<N-1; ++n) { if(C[n] != x) { if(x == 'D') ++c; x = C[n]; } } std::cout << std::min(c, T) << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:51:24: error: no matching function for call to 'min(unsigned int&, slli&)' 51 | std::cout << std::min(c, T) << std::endl; | ~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:51:24: note: deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'slli' {aka 'long long int'}) 51 | std::cout << std::min(c, T) << std::endl; | ~~~~~~~~^~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
s835626416
p03946
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> VI; typedef vector<VI> VVI; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const int INF = numeric_limits<int>::max() / 2; const int NEG_INF = numeric_limits<int>::min() / 2; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n,t; cin >> n >> t; ll dif=0,res=0,a[n]; for(int i=0;i<n;i++) cin >> a[i]; for(int i=0;i<n;i++){ for(int j=i+1;j<n;j++){ if(dif<a[j]-a[i]){ dif=a[j]-a[i]; res=1;   i=j; break; } else if(dif==a[j]-a[i]) res++; else continue; } } cout << res << endl; }
a.cc:27:1: error: extended character   is not valid in an identifier 27 |   i=j; | ^ a.cc:27:1: error: extended character   is not valid in an identifier a.cc: In function 'int main()': a.cc:27:1: error: '\U00003000\U00003000i' was not declared in this scope 27 |   i=j; | ^~~~~
s500386743
p03947
C++
#include <cstdio> #include <string> using namespace std; int main() { char s[100005]; int len; char c; int b, w; int i; fgets(s, 100005, stdin); len = strlen(s) - 1; #if 0 printf("string is %s\n", s); printf("len %d\n", len); #endif b = w = 0; c = s[0]; if (c == 'B') b++; else if (c == 'W') w++; for (i=1; i<len; i++) { if (s[i] != c) { if (s[i] == 'B') { b++; } else { w++; } c = s[i]; } } #if 0 printf("b=%d w=%d\n", b, w); #endif if (b == 0 || w == 0) { printf("0\n"); return 0; } if (b == 1 || w == 1) { printf("1\n"); return 0; } if (w > b) { printf("%d\n", 2*b -1 ); } else { printf("%d\n", 2*w -1 ); } return 0; }
a.cc: In function 'int main()': a.cc:15:9: error: 'strlen' was not declared in this scope 15 | len = strlen(s) - 1; | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <string> +++ |+#include <cstring> 3 |
s281310269
p03947
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using Graph = vector<vector<int>>; const ll mod=1000000007; const int MAX_N = 1000; // n の最大値 int main() { string s; cin>>s; ll f=0; ll counter=0; ll n=s.size(); if(s.at(0)=='W'){ f++;} for(ll i=1; i<n; i++){ if((f==1&&s.at(i)=='W')||(f==0&&s.at(i)=='B') continue; else{ counter++; if(s.at(i)=='W'){ f=1;} else f=0;}} cout<<counter<<endl;}
a.cc: In function 'int main()': a.cc:17:46: error: expected ';' before 'continue' 17 | if((f==1&&s.at(i)=='W')||(f==0&&s.at(i)=='B') continue; | ^~~~~~~~~ | ; a.cc:18:1: error: expected primary-expression before 'else' 18 | else{ | ^~~~ a.cc:17:56: error: expected ')' before 'else' 17 | if((f==1&&s.at(i)=='W')||(f==0&&s.at(i)=='B') continue; | ~ ^ | ) 18 | else{ | ~~~~ a.cc:23:6: error: expected primary-expression before '}' token 23 | f=0;}} | ^
s992564564
p03947
C++
#include <cstdio> #include <cstring> #include <cmath> #include <utility> #include <iostream> #include <functional> #include <bitset> #include <algorithm> #include <vector> #include <forward_list> #include <set> #include <map> #include <queue> #include <deque> #include <stack> #include <numeric> #define ll long long int #define pb push_back #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; int mx4[] = {0,1,0,-1}; int my4[] = {1,0,-1,0}; int INF = 2e6; ll MOD = 1e9 + 7; int main(){ string s; cin >> s; int n = s.size(); a int ans = 0; for(int i = 0; i < n - 1; i++){ if(s[i+1] != s[i]) ans++; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:29:1: error: 'a' was not declared in this scope 29 | a | ^ a.cc:32:28: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | if(s[i+1] != s[i]) ans++; | ^~~ | abs a.cc:34:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 34 | cout << ans << endl; | ^~~ | abs
s339927906
p03947
C++
#include<bits/stdc++.h> using namespace std; int main(void) { string s;cin >> s; int cnt=0; for(i=0;i<s.size()-1;i++){ cnt+=(s[i]!=s[i+1])?1:0; } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:7:7: error: 'i' was not declared in this scope 7 | for(i=0;i<s.size()-1;i++){ | ^
s698252852
p03947
C++
#include <iostream> using namespace std; int main() { string s; cin>>s; int ans=0; for(int i=1;i<s.size();i++) if(s[i]!=s[i-1]) ans++; cout<<ans<<endl; return 0; }
a.cc:1:21: warning: extra tokens at end of #include directive 1 | #include <iostream> using namespace std; int main() { string s; cin>>s; int ans=0; for(int i=1;i<s.size();i++) if(s[i]!=s[i-1]) ans++; cout<<ans<<endl; return 0; } | ^~~~~ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s055554757
p03947
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back void solve(){ string s ; cin>>S; int n = s.size(); int ans =0; for(int i=1;i<n;i++){ if(s[i]!=s[i-1])ans++; } cout<<ans<<endl; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t=1; // cin>> t; while(t--)solve(); return 0; }
a.cc: In function 'void solve()': a.cc:7:10: error: 'S' was not declared in this scope 7 | cin>>S; | ^
s539077720
p03947
C++
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const long long INF= 1e+18+1; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll> >vvl; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> T; const ll MOD=1000000007LL; string abc="abcdefghijklmnopqrstuvwxyz"; string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; int main(){ string s;cin>>s; ll ans=0; rep(i,s.size()-1){ if(s[i+1]!=a[i])ans++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:19:16: error: 'a' was not declared in this scope 19 | if(s[i+1]!=a[i])ans++; | ^
s383435294
p03947
C++
#include<iostream> #include<cstring> #include<queue> #include<algorithm> #include<cstdio> using namespace std; int check(int x,int y){ if(s[x]=='W'){ if(s[y]=='B') return 1; else return 0; } if(s[x]=='B'){ if(s[y]=='W') return 1; else return 0; } } int main(){ char s[100005]; scanf("%s",s); int n=strlen(s),ans=0; for(int i=0;i<n;i++){ if(check(i,i+1)){ ans++; } } printf("%d",ans); return 0; }
a.cc: In function 'int check(int, int)': a.cc:8:12: error: 's' was not declared in this scope 8 | if(s[x]=='W'){ | ^ a.cc:12:12: error: 's' was not declared in this scope 12 | if(s[x]=='B'){ | ^ a.cc:16:1: warning: control reaches end of non-void function [-Wreturn-type] 16 | } | ^
s176527544
p03947
C++
#include <iostream> #include <vector> #include <algorithm> #include <set> #include <map> #include <utility> #include <tuple> #include <string> #include <cctype> #include <cstdio> #include <math.h> using i8 = int8_t; using u8 = uint8_t; using i16 = int16_t; using u16 = uint16_t; using i32 = int32_t; using u32 = uint32_t; using i64 = int64_t; using u64 = uint64_t; using f32 = float; using f64 = double; constexpr i64 INF = 1'010'000'000'000'000'017LL; constexpr i64 MOD = 1'000'000'007LL; constexpr f64 EPS = 1e-12; constexpr f64 PI = 3.14159265358979323846; const int AMAX = 100000; using namespace std; #define rep(i, n) for (i64 i = 0; i < (int)(n); i++) #define FOR(i, m, n) for (i64 i = m; i < n; i++) #define SORT(x) sort(x.begin(), x.end()) #define REVE(x) reverse(x.begin(), x.end()) #define all(x) (x).begin(), (x).end() #define fst first #define mp make_pair #define pb push_back #define eb emplace_back #define pob pop_back #define sw swap #define UP(x) transform(x.begin(), x.end(), x.begin(), ::toupper); #define down(x) transform(x.begin(), x.end(), x.begin(), ::tolower); using LL = long long; using ULL = unsigned long long; template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return 1; } return 0; } template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(void) { string a; cin >> a; LL ans; rep(i, a.size()-1){    if(a[i]!=a[i+1])ans++ } return 0; }
a.cc:69:1: error: extended character   is not valid in an identifier 69 |    if(a[i]!=a[i+1])ans++ | ^ a.cc:69:1: error: extended character   is not valid in an identifier a.cc:13:12: error: 'uint8_t' does not name a type 13 | using u8 = uint8_t; | ^~~~~~~ a.cc:12:1: note: 'uint8_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 11 | #include <math.h> +++ |+#include <cstdint> 12 | using i8 = int8_t; a.cc:15:13: error: 'uint16_t' does not name a type 15 | using u16 = uint16_t; | ^~~~~~~~ a.cc:15:13: note: 'uint16_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:17:13: error: 'uint32_t' does not name a type 17 | using u32 = uint32_t; | ^~~~~~~~ a.cc:17:13: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:19:13: error: 'uint64_t' does not name a type 19 | using u64 = uint64_t; | ^~~~~~~~ a.cc:19:13: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc: In function 'int main()': a.cc:69:1: error: '\U00003000\U00003000' was not declared in this scope 69 |    if(a[i]!=a[i+1])ans++ | ^~~~
s439291387
p03947
C++
wwbww#include <iostream> using namespace std; int main(){ string s; cin >> s; char latest = s[0]; int acc = 0; for (int i=1;i<s.size();i++){ if (s[i] != latest){ acc += 1; } latest = s[i]; } cout << acc << endl; return 0; }
a.cc:1:6: error: stray '#' in program 1 | wwbww#include <iostream> | ^ a.cc:1:1: error: 'wwbww' does not name a type 1 | wwbww#include <iostream> | ^~~~~ a.cc: In function 'int main()': a.cc:5:5: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:6:5: error: 'cin' was not declared in this scope 6 | cin >> s; | ^~~ a.cc:6:12: error: 's' was not declared in this scope 6 | cin >> s; | ^ a.cc:15:5: error: 'cout' was not declared in this scope 15 | cout << acc << endl; | ^~~~ a.cc:15:20: error: 'endl' was not declared in this scope 15 | cout << acc << endl; | ^~~~
s915851393
p03947
C++
#include <bits/stdc++.h> using namespace std; char ch[1000005]; int main() { long int s=0,l=0,i,j; gets(ch); l=strlen(ch); for(i=1; i<l; i++){ if (ch[i]!=ch[i-1]){ ++s; } } printf("%ld\n",s); return 0; }
a.cc: In function 'int main()': a.cc:11:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 11 | gets(ch); | ^~~~ | getw
s554525836
p03947
C++
#include<bits/stdc++.h> using namespace std; int main(){ string a; cin>>a; char b=a.at(0); int c=0; for(int i=0;i<a.aize();i++){ if(a.at(i)!=b){ b=a.at(i); c++; } } cout<<c<<endl; }
a.cc: In function 'int main()': a.cc:9:19: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'aize'; did you mean 'size'? 9 | for(int i=0;i<a.aize();i++){ | ^~~~ | size
s352018564
p03947
C++
#include<string.h> int main() { int n,i,k; char s[100005]; scanf("%s",&s); k=strlen(s); n=1; for(i=0;i<k-1;i++) { if(s[i]!=s[i+1])  n++; } printf("%d\n",n-1); return 0; }
a.cc:12:1: error: extended character   is not valid in an identifier 12 |  n++; | ^ a.cc: In function 'int main()': a.cc:6:1: error: 'scanf' was not declared in this scope 6 | scanf("%s",&s); | ^~~~~ a.cc:12:1: error: '\U000000a0n' was not declared in this scope 12 |  n++; | ^~ a.cc:14:1: error: 'printf' was not declared in this scope 14 | printf("%d\n",n-1); | ^~~~~~ a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 1 | #include<string.h> +++ |+#include <cstdio> 2 | int main()
s689746386
p03947
C++
#include <iostream> using namespace std; int a; string a; int main() { cin >> a; for (int i =1; i < a.size(); i++) { if (a[i] != a[i - 1]) s++; } cout << a; return 0; }
a.cc:6:9: error: conflicting declaration 'std::string a' 6 | string a; | ^ a.cc:5:6: note: previous declaration as 'int a' 5 | int a; | ^ a.cc: In function 'int main()': a.cc:10:27: error: request for member 'size' in 'a', which is of non-class type 'int' 10 | for (int i =1; i < a.size(); i++) { | ^~~~ a.cc:11:16: error: invalid types 'int[int]' for array subscript 11 | if (a[i] != a[i - 1]) s++; | ^ a.cc:11:24: error: invalid types 'int[int]' for array subscript 11 | if (a[i] != a[i - 1]) s++; | ^ a.cc:11:33: error: 's' was not declared in this scope 11 | if (a[i] != a[i - 1]) s++; | ^
s186136528
p03947
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { char s[100000]={'\0'}; gets(s); int len=strlen(s); int count=0; for(int i=1;i<len;i++){ if(s[i]!=s[i-1]){ count++; } } cout<<count<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 7 | gets(s); | ^~~~ | getw
s061416156
p03947
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; int main() { char s[100000]={'\0'}; gets(s); int len=strlen(s); int count=0; for(int i=1;i<len;i++){ if(s[i]!=s[i-1]){ count++; } } cout<<count<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 7 | gets(s); | ^~~~ | getw
s892637432
p03947
C++
/*g++ file.cpp -o file.out*/ /*./file.out*/ #include <cmath> #include <cstdio> #include <string> #include <cstring> #include <iostream> #include <algorithm> using namespace std; #define LL long long #define Mod 1000000007 #define L_Mod 17100000013 char str[100001]; int main() { int mn=0; cin>>str; for(int i=0; i<strlen(str)-1; i++) if(str[i]!=str{i+1}) mn++; cout<<mn; return 0; }
a.cc: In function 'int main()': a.cc:23:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 23 | if(str[i]!=str{i+1}) | ~~~~~~^~~~~ a.cc:23:23: error: expected ')' before '{' token 23 | if(str[i]!=str{i+1}) | ~ ^ | )
s782767195
p03947
C++
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() #define Decimal fixed<<setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000LL #define MOD 1000000007 typedef long long ll; typedef pair<pair<ll,ll>,ll> P; ll w,h,n; bool isup[333333]; ll nyan(vector<pair<ll,pair<ll,ll>>> nowA, vector<pair<ll,pair<ll,ll>>> nowB){ ll ret = 0; ll lineA = -1,lineB = -1; deque<pair<ll,ll>> deq; for(ll i = 0;i < nowA.size();i++){ ll nowU = nowA[i].SE.FI; ll nowD = nowA[i].SE.SE; ll nowL = nowA[i].FI; while((ll)lineA < (ll)nowB.size() - 1 && nowB[lineA+1].SE.FI >= nowU && nowB[lineA+1].SE.SE <= nowD)lineA++; if(lineA != -1){ ret = max(ret,nowU - nowD + nowB[lineA].FI - nowL); } lineB = max(lineA,lineB); while((ll)lineB < (ll)nowB.size() - 1 && nowB[lineB+1].SE.SE <= nowD){ while(!deq.empty() && deq.rbegin()->FI < nowB[lineB+1].SE.FI + nowB[lineB+1].FI){ deq.pop_back(); } deq.push_back(MP(nowB[lineB+1].SE.FI + nowB[lineB+1].FI,lineB+1)); lineB++; } while(!deq.empty() && deq[0].SE <= lineA)deq.pop_front(); if(deq.size())ret = max(ret,deq[0].FI - nowL - nowD); //cout << "NYAN " << lineA << " " << lineB << endl; } //cout << "RET " << ret << endl; return ret; } ll seica(vector<P> v1, vector<P> v2, ll U, ll D, ll L, ll R){ ll ret = 0; //cout << v1.size() << " " << v2.size() << " " << U << ' ' << D << " " << L << " " << R << endl; vector<P> vv1; vector<P> vv2; vector<P> vv3; vector<P> vv4; ll mid; REP(i,v2.size()){ if(i < v2.size() / 2){ isup[v2[i].SE] = 0; vv2.PB(v2[i]); } else { isup[v2[i].SE] = 1; vv4.PB(v2[i]); } if(i == v2.size()/2)mid = v2[i].FI.FI; } REP(i,v1.size()){ if(isup[v1[i].SE])vv3.PB(v1[i]); else vv1.PB(v1[i]); } if(vv1.size() > 1)ret = max(ret,seica(vv1, vv2, mid, D, L, R)); if(vv3.size() > 1)ret = max(ret,seica(vv3, vv4, U, mid, L, R)); vv1.clear(); vv3.clear(); REP(i,v1.size()){ if(v[i].FI < (L + R) / 2)vv1.PB(v1[i]); else vv3.PB(v1[i]); } vector<pair<ll,pair<ll,ll>>> nowA; vector<pair<ll,pair<ll,ll>>> nowB; ll uu = U,dd = D; for(int i = vv1.size() - 1;i >= 0;i--){ nowA.PB(MP(vv1[i].FI.FI,MP(uu,dd))); if(vv1[i].FI.SE > mid)uu = min(uu,vv1[i].FI.SE); else if(vv1[i].FI.SE == mid){ if(uu - vv1[i].FI.SE > vv1[i].FI.SE - dd)dd = max(dd,vv1[i].FI.SE); else uu = min(uu,vv1[i].FI.SE); } else dd = max(dd,vv1[i].FI.SE); } nowA.PB(MP(L,MP(uu,dd))); uu = U,dd = D; for(ll i = 0;i < vv3.size();i++){ nowB.PB(MP(vv3[i].FI.FI,MP(uu,dd))); if(vv3[i].FI.SE > mid)uu = min(uu,vv3[i].FI.SE); else if(vv3[i].FI.SE == mid){ if(uu - vv3[i].FI.SE > vv3[i].FI.SE - dd)dd = max(dd,vv3[i].FI.SE); else uu = min(uu,vv3[i].FI.SE); } else dd = max(dd,vv3[i].FI.SE); } nowB.PB(MP(R,MP(uu,dd))); //cout << " IN SEICA " << nowA.size() << " " << nowB.size() << endl; ret = max(ret,nyan(nowA,nowB)); REP(i,nowA.size())nowA[i].FI = R - nowA[i].FI; REP(i,nowB.size())nowB[i].FI = R - nowB[i].FI; ret = max(ret,nyan(nowB,nowA)); return ret; } int main(){ cin >> w >> h >> n; vector<P> v1; vector<P> v2; REP(i, n){ ll a,b;cin >> a >> b; v1.PB(MP(MP(a,b),i)); v2.PB(MP(MP(b,a),i)); } sort(ALL(v1)); sort(ALL(v2)); cout << 2*max(seica(v1,v2,h,0,0,w),seica(v2,v1,w,0,0,h)) << endl; return 0; }
a.cc: In function 'll seica(std::vector<std::pair<std::pair<long long int, long long int>, long long int> >, std::vector<std::pair<std::pair<long long int, long long int>, long long int> >, ll, ll, ll, ll)': a.cc:87:20: error: 'v' was not declared in this scope 87 | if(v[i].FI < (L + R) / 2)vv1.PB(v1[i]); | ^
s361055685
p03947
C
#include<stdio.h> #include<string.h> int main(){ char s[100010]; int n; scanf("%s",s); n=strlen(s); for(int i=1;i<n;i++) if(s[i]!=s[i-1]) cnt++; printf("%d\n",cnt); }
main.c: In function 'main': main.c:11:7: error: 'cnt' undeclared (first use in this function); did you mean 'int'? 11 | cnt++; | ^~~ | int main.c:11:7: note: each undeclared identifier is reported only once for each function it appears in
s631544351
p03947
C++
#include <iostream> #include <string> using namespace std; int main(){ string s; cin >> s; int ans=0; char x = s[0]; for(auto i=s.begin();i<s.end();i++){ if((*s)==x){ continue; }else{ x=(*s); ans++; } } cout << ans; return 0;}
a.cc: In function 'int main()': a.cc:12:5: error: no match for 'operator*' (operand type is 'std::string' {aka 'std::__cxx11::basic_string<char>'}) 12 | if((*s)==x){ | ^~ a.cc:15:4: error: no match for 'operator*' (operand type is 'std::string' {aka 'std::__cxx11::basic_string<char>'}) 15 | x=(*s); | ^~
s302187479
p03947
C++
#include<bits/stdc++.h> using namespace std; #define fi first #define se second const int N = 1e5 + 1; const int inf = 1e9 + 7; typedef pair<int,int> ii; vector<int> g[N]; int n, k; ii L[N]; int h[N]; int ans[N]; void dfs(int u,int p) { for(int v : g[u]) if(v != p) { h[v] = h[u] + 1; dfs(v); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1 ; i <= n ; ++i) L[i] = ii(-inf,inf); for(int i = 1 ; i < n ; ++i) { int x, y; cin >> x >> y; g[x].push_back(y); g[y].push_back(x); } dfs(1,0); queue<int> q; cin >> k; int m = -1; while(k--) { int u, p; cin >> u >> p; L[u] = ii(p,p); q.push(u); int c = (p - h[u] + 1000000000) % 2; if(m = -1) m = c; if(m != c) { cout << "No"; exit(0); } } while(q.size()) { int u = q.front(); q.pop(); for(int v : g[u]) { ii tmp = L[v]; tmp.fi = max(tmp.fi,L[u].fi - 1); tmp.se = min(tmp.se,L[u].se + 1); if(tmp.fi > tmp.se) { cout << "No"; exit(0); } if(tmp != L[v]) { L[v] = tmp; q.push(v); } } } cout << "Yes\n"; for(int i = 1 ; i <= n ; ++i) { cout << L[i].fi << "\n"; for(int u : g[i]) L[u] = ii(max(L[u].fi,L[i].fi - 1),min(L[u].se,L[i].fi + 1)); } }
a.cc: In function 'void dfs(int, int)': a.cc:23:28: error: too few arguments to function 'void dfs(int, int)' 23 | dfs(v); | ~~~^~~ a.cc:19:6: note: declared here 19 | void dfs(int u,int p) { | ^~~
s372473512
p03947
C++
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; string s; int a[10000005]={0}; int main() { cin>>s; n=s.length(); for(int i=0;i<n;i++)if(s[i]=='W')a[i]=1; int ans=0; for(int i=0;i+1<n;i++)if(a[i]!=a[i+1])ans++; cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:11:9: error: 'n' was not declared in this scope 11 | n=s.length(); | ^
s577045674
p03947
C++
#include<iostream> #include<iomanip> #include<map> #include<set> #include<string> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<stack> #include<cstring> #include<sstream> using namespace std; #define P(p) cout<<(p)<<endl #define rep(i,m,n) for(int i = (m); i < (int)(n); i++) #define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--) #define vsort(v) sort(v.begin(), v.end()); #define rvsort(v) sort(v.begin(), v.end(),greater<int>()); #define YES cout<<"YES"<< endl #define NO cout<<"NO"<<endl #define Yes cout<<"Yes"<<endl #define No cout<<"No"<<endl #define yes cout<<"yes"<<endl #define no cout<<"no"<<endl #define ret return #define C(i) cin>>i #define C2(i,j) cin>>i>>j #define C3(i,j,k) cin>>i>>j>>k #define C4(i,j,k,m) cin>>i>>j>>k>>m //////////////////////////////////////////////////////////// int main(){ string s; cin >> s; bool f[s.size()]={}; rep(i,0,s.size()) if(s[i]=='W') f[i] = 1; int cnt = 0; int F = f[0]; rep(i,1,s.size(){ if( F != f[i] ){ cnt++; F = f[i]; } } P(cnt); ret 0; }
a.cc:52:2: error: unterminated argument list invoking macro "rep" 52 | } | ^ a.cc: In function 'int main()': a.cc:43:9: error: 'rep' was not declared in this scope 43 | rep(i,1,s.size(){ | ^~~ a.cc:43:12: error: expected '}' at end of input 43 | rep(i,1,s.size(){ | ^ a.cc:33:11: note: to match this '{' 33 | int main(){ | ^
s503012419
p03947
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)n;i++) #define all(c) (c).begin(),(c).end() #define pb push_back #define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0); using namespace std; namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};} template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";} template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";} void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);} typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9; int main(){ cin.tie(0); cin.sync_with_stdio(0); string s; cin >> s; int a = 0; rep(i, s.size() - 1){ a += a[i] != a[i + 1]; } cout << a << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:23: error: invalid types 'int[int]' for array subscript 20 | a += a[i] != a[i + 1]; | ^ a.cc:20:31: error: invalid types 'int[int]' for array subscript 20 | a += a[i] != a[i + 1]; | ^
s652441255
p03947
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin>>s; cout<<s.count("BW")+s.count("WB")<<endl; }
a.cc: In function 'int main()': a.cc:6:13: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'count' 6 | cout<<s.count("BW")+s.count("WB")<<endl; | ^~~~~ a.cc:6:27: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'count' 6 | cout<<s.count("BW")+s.count("WB")<<endl; | ^~~~~
s719969243
p03947
C++
#include <assert.h> #include <ctype.h> #include <errno.h> #include <float.h> #include <fstream> #include <iomanip> #include <iostream> #include <limits> #include <locale> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <wchar.h> #include <wctype.h> #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <exception> #include <functional> #include <map> #include <ios> #include <iosfwd> #include <istream> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <utility> #include <vector> #include <cwchar> #include <cwctype> #include <complex.h> #include <fenv.h> #include <inttypes.h> #include <stdbool.h> #include <stdint.h> #include <tgmath.h> #include <conio.h> #include <numeric> #include <list> #include <windows.h> #include <cfloat> #include <climits> #include <unordered_map> #include <unordered_set> using namespace std; string s; int pos,ans; int main() { cin>>s; pos=s.size()-1; while(pos>=0) { int cur=pos; while(s[cur]==s[pos]&&pos>=0) pos--; ans++; } cout<<ans-1; return 0; }
a.cc:53:10: fatal error: conio.h: No such file or directory 53 | #include <conio.h> | ^~~~~~~~~ compilation terminated.
s631774242
p03947
C++
s = gets.chomp.split("") ans = 0 s.each_cons(2) do |c, d| next if c == d ans += 1 end puts ans
a.cc:1:1: error: 's' does not name a type 1 | s = gets.chomp.split("") | ^
s991252850
p03947
C++
#include <bits/stdc++.h> using namespace std; int main(){ string s; cin >> s; char c = s[0]; int cnt = 0: for (int i = 0; i < s.size(); i++){ if(c != s[i]){ c = s[i]; cnt++; } cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:7:14: error: expected ',' or ';' before ':' token 7 | int cnt = 0: | ^ a.cc:8:19: error: 'i' was not declared in this scope 8 | for (int i = 0; i < s.size(); i++){ | ^
s876116904
p03947
C++
#include <bits/stdc++.h> using namespace std; int main{ string s; cin >> s; char c = s[0]; int cnt = 0: for (int i = 0; i < s.size(); i++){ if(c != s[i]){ c = s[i]; cnt++; } cout << cnt << endl; } }
a.cc:3:5: error: cannot declare '::main' to be a global variable 3 | int main{ | ^~~~ a.cc:4:9: error: expected primary-expression before 's' 4 | string s; | ^ a.cc:4:9: error: expected '}' before 's' a.cc:3:9: note: to match this '{' 3 | int main{ | ^ a.cc:5:2: error: 'cin' does not name a type 5 | cin >> s; | ^~~ a.cc:6:12: error: 's' was not declared in this scope 6 | char c = s[0]; | ^ a.cc:7:14: error: expected ',' or ';' before ':' token 7 | int cnt = 0: | ^ a.cc:8:19: error: 'i' does not name a type 8 | for (int i = 0; i < s.size(); i++){ | ^ a.cc:8:33: error: 'i' does not name a type 8 | for (int i = 0; i < s.size(); i++){ | ^ a.cc:15:1: error: expected declaration before '}' token 15 | } | ^
s678946418
p03947
C++
#include <bits/stdc++.h> using namespace std; int main{ string s; cin >> s; char c = s[0]; int cnt = 0: for (int i = 0; i < s.size(); i++){ if(c != s[i]){ c = s[i]; cnt++; } cout << cnt << endl; }
a.cc:3:5: error: cannot declare '::main' to be a global variable 3 | int main{ | ^~~~ a.cc:4:9: error: expected primary-expression before 's' 4 | string s; | ^ a.cc:4:9: error: expected '}' before 's' a.cc:3:9: note: to match this '{' 3 | int main{ | ^ a.cc:5:2: error: 'cin' does not name a type 5 | cin >> s; | ^~~ a.cc:6:12: error: 's' was not declared in this scope 6 | char c = s[0]; | ^ a.cc:7:14: error: expected ',' or ';' before ':' token 7 | int cnt = 0: | ^ a.cc:8:19: error: 'i' does not name a type 8 | for (int i = 0; i < s.size(); i++){ | ^ a.cc:8:33: error: 'i' does not name a type 8 | for (int i = 0; i < s.size(); i++){ | ^
s612700809
p03947
C++
#include <iostream> using namespace std; int main{ string s; cin >> s; char c = s[0]; int cnt = 0: for (int i = 0; i < s.size(); i++){ if(c != s[i]){ c = s[i]; cnt++; } cout << cnt << endl; }
a.cc:3:5: error: cannot declare '::main' to be a global variable 3 | int main{ | ^~~~ a.cc:4:9: error: expected primary-expression before 's' 4 | string s; | ^ a.cc:4:9: error: expected '}' before 's' a.cc:3:9: note: to match this '{' 3 | int main{ | ^ a.cc:5:2: error: 'cin' does not name a type 5 | cin >> s; | ^~~ a.cc:6:12: error: 's' was not declared in this scope 6 | char c = s[0]; | ^ a.cc:7:14: error: expected ',' or ';' before ':' token 7 | int cnt = 0: | ^ a.cc:8:19: error: 'i' does not name a type 8 | for (int i = 0; i < s.size(); i++){ | ^ a.cc:8:33: error: 'i' does not name a type 8 | for (int i = 0; i < s.size(); i++){ | ^
s007709481
p03947
C++
#include <bits/stdc++.h> using namespace std; //#define FILE_IO int N; char s[100005]; int main() { #ifdef FILE_IO freopen("1.in", "r", stdin); freopen("1.out", "w", stdout); #endif gets(s + 1); N = strlen(s + 1); int ans = 0; for(int i = 1; i < N; i++) if(s[i] != s[i + 1]) ans++; printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:17:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 17 | gets(s + 1); | ^~~~ | getw
s453703322
p03947
C++
#include<<bits/stdc++.h> using namespace std; char a[100010]; int cnt, i, n; int main() { scanf("%s",a); n=strlen(a); for(i=1;i<=n;i++) if(a[i]!=a[i-1]) cnt++; printf("%d",cnt-1); }
a.cc:1:9: fatal error: <bits/stdc++.h: No such file or directory 1 | #include<<bits/stdc++.h> | ^~~~~~~~~~~~~~~~ compilation terminated.
s322371356
p03947
C++
#include<stdio.h> #include<algorithm> using namespace std; char a[100010]; int cnt; int main() { scanf("%s",a); int i,n; n=strlen(a); for(i=1;i<=n;i++) if(a[i]!=a[i-1]) cnt++; printf("%d",cnt-1); }
a.cc: In function 'int main()': a.cc:10:7: error: 'strlen' was not declared in this scope 10 | n=strlen(a); | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s517455900
p03947
C++
#include<stdio.h> #include<algorithm> using namespace std; char a[100010]; int cnt; int main() { scanf("%s",&a[1]); int i,n=strlen(&a[1]); for(i=1;i<=n;i++) if(a[i]!=a[i-1]) cnt++; printf("%d",cnt-1); }
a.cc: In function 'int main()': a.cc:9:13: error: 'strlen' was not declared in this scope 9 | int i,n=strlen(&a[1]); | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s147055668
p03947
C++
omething came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it mea
a.cc:1:230: error: extended character ≦ is not valid in an identifier 1 | omething came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it mea | ^ a.cc:1:234: error: extended character ≦ is not valid in an identifier 1 | omething came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it mea | ^ a.cc:1:1: error: 'omething' does not name a type 1 | omething came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S represents the color of the i-th (1 ≦ i ≦ |S|) stone from the left. If the i-th character in S is B, it means that the color of the corresponding stone on the board is black. Similarly, if the i-th character in S is W, it mea | ^~~~~~~~
s621769446
p03947
C++
he row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. In the middle of a game, something came up and Saburo has to leave the game. The state of the board at this point is described by a string S. There are |S| (the length of S) stones on the board, and each character in S rep
a.cc:1:1: error: 'he' does not name a type 1 | he row. Similarly to the original game of Reversi, when a white stone is placed, all black stones between the new white stone and another white stone, turn into white stones, and vice versa. | ^~
s243820408
p03947
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class plactice63C { private static Integer ct; private static Integer len; public static void main(String[] args) throws IOException { proconScan proScan = new proconScan(); proScan.scan(); ct = 0; len = proScan.backLine().length(); Character flag=' '; for(Character buf:proScan.backLine().toCharArray()){ if(flag==' ') flag=buf; else if(flag!=buf){ ct++; flag=buf; } } System.out.println(ct); proScan.proconEnd(); } } class proconScan { private BufferedReader br; private String inLine; private String[] inString; private Integer idx; private String splitChar; public proconScan() { br = new BufferedReader(new InputStreamReader(System.in)); idx = 0; splitChar = " "; } public proconScan(String split) { br = new BufferedReader(new InputStreamReader(System.in)); idx = 0; splitChar = split; } public void proconEnd() throws IOException { // TODO 自動生成されたメソッド・スタブ br.close(); } public String scan() throws IOException { idx = 0; inLine = br.readLine(); inString = inLine.split(splitChar, 0); return inLine; } public Integer scanInteger1() throws IOException { scan(); return Integer.parseInt(inString[0]); } public String backLine() { return inLine; } public String nextString() { return inString[idx++]; } public String[] getString() { return inString; } public Integer nextInteger() { Integer num; try { num = Integer.parseInt(inString[idx++]); } catch (NumberFormatException e) { num = null;// TODO: handle exception } return num; } public Integer[] getInteger() { Integer[] num = new Integer[this.getLen()]; for (int i = 0; i < this.getLen(); i++) { num[i] = Integer.parseInt(inString[i]); } return num; } public Float nextFloat() { Float num; try { num = Float.parseFloat(inString[idx++]); } catch (NumberFormatException e) { num = null;// TODO: handle exception } return num; } public Float[] getFloat() { Float[] num = new Float[this.getLen()]; for (int i = 0; i < this.getLen(); i++) { num[i] = Float.parseFloat(inString[i]); } return num; } public Integer getLen() { return inString.length; } public int[] getInt() { int[] num = new int[this.getLen()]; for (int i = 0; i < this.getLen(); i++) { num[i] = Integer.parseInt(inString[i]); } return num; } }
Main.java:5: error: class plactice63C is public, should be declared in a file named plactice63C.java public class plactice63C { ^ 1 error
s065106070
p03947
Java
import static org.hamcrest.CoreMatchers.nullValue; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { private static Integer ct; private static Integer len; public static void main(String[] args) throws IOException { proconScan proScan = new proconScan(); proScan.scan(); ct = 0; len = proScan.backLine().length(); changeOthello(new StringBuilder(proScan.backLine())); System.out.println(ct); proScan.proconEnd(); } public static StringBuilder changeOthello(StringBuilder board){ Character buf = null; Character buf2 = null; StringBuilder buf3 = new StringBuilder(); int i; for(i=0; i<len; i++){ if( i==0 ) buf=board.charAt(i); else if(board.charAt(i)!=buf){ ct++; buf2=board.charAt(i); for(int j=0;j<i;j++){ buf3.append(buf2); } board.replace(0, i, buf3.toString()); break; } } if(i<len){ changeOthello(board); } return board; } } class proconScan { private BufferedReader br; private String inLine; private String[] inString; private Integer idx; private String splitChar; public proconScan() { br = new BufferedReader(new InputStreamReader(System.in)); idx = 0; splitChar = " "; } public proconScan(String split) { br = new BufferedReader(new InputStreamReader(System.in)); idx = 0; splitChar = split; } public void proconEnd() throws IOException { // TODO 自動生成されたメソッド・スタブ br.close(); } public String scan() throws IOException { idx = 0; inLine = br.readLine(); inString = inLine.split(splitChar, 0); return inLine; } public Integer scanInteger1() throws IOException { scan(); return Integer.parseInt(inString[0]); } public String backLine() { return inLine; } public String nextString() { return inString[idx++]; } public String[] getString() { return inString; } public Integer nextInteger() { Integer num; try { num = Integer.parseInt(inString[idx++]); } catch (NumberFormatException e) { num = null;// TODO: handle exception } return num; } public Integer[] getInteger() { Integer[] num = new Integer[this.getLen()]; for (int i = 0; i < this.getLen(); i++) { num[i] = Integer.parseInt(inString[i]); } return num; } public Float nextFloat() { Float num; try { num = Float.parseFloat(inString[idx++]); } catch (NumberFormatException e) { num = null;// TODO: handle exception } return num; } public Float[] getFloat() { Float[] num = new Float[this.getLen()]; for (int i = 0; i < this.getLen(); i++) { num[i] = Float.parseFloat(inString[i]); } return num; } public Integer getLen() { return inString.length; } public int[] getInt() { int[] num = new int[this.getLen()]; for (int i = 0; i < this.getLen(); i++) { num[i] = Integer.parseInt(inString[i]); } return num; } }
Main.java:1: error: package org.hamcrest does not exist import static org.hamcrest.CoreMatchers.nullValue; ^ Main.java:1: error: static import only from classes and interfaces import static org.hamcrest.CoreMatchers.nullValue; ^ 2 errors
s509151627
p03947
C++
input = gets.chomp ans = 0 (input.length - 1).times {|i| ans += 1 if(input[i] != input[i+1]) } puts ans
a.cc:1:1: error: 'input' does not name a type; did you mean 'int'? 1 | input = gets.chomp | ^~~~~ | int a.cc:6:1: error: 'puts' does not name a type 6 | puts ans | ^~~~
s239064889
p03947
C++
#include <iostream> #include <cstring> using namespace std; int main(void){ char s[1000000]; int count=0; cin >> s; for(i=0;i<strlen(s);i++){ if(s[i]!=s[i+1])count++; } cout << count << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:5: error: 'i' was not declared in this scope 9 | for(i=0;i<strlen(s);i++){ | ^
s923848498
p03947
C++
#include <iostream> #include <string> using namespace std; int main(void){ char s[1000000]; int count=0; cin >> s; for(i=0;i<strlen(s);i++){ if(s[i]!=s[i+1])count++; } cout << count << endl; return 0; }
a.cc: In function 'int main()': a.cc:9:5: error: 'i' was not declared in this scope 9 | for(i=0;i<strlen(s);i++){ | ^ a.cc:9:11: error: 'strlen' was not declared in this scope 9 | for(i=0;i<strlen(s);i++){ | ^~~~~~ 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 | #include <string>
s832024459
p03947
C++
#include <iostream> #include <string> int main(void){ char s[1000000]; int count=0; cin >> s; for(i=0;i<strlen(s);i++){ if(s[i]!=s[i+1])count++; } cout << count << endl; return 0; }
a.cc: In function 'int main()': a.cc:6:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 6 | cin >> s; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:8:5: error: 'i' was not declared in this scope 8 | for(i=0;i<strlen(s);i++){ | ^ a.cc:8:11: error: 'strlen' was not declared in this scope 8 | for(i=0;i<strlen(s);i++){ | ^~~~~~ 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 | #include <string> a.cc:11:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 11 | cout << count << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:11:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 11 | cout << count << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s868567683
p03947
Java
public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); char[] input_char = input.toCharArray(); char current_char = input_char[0]; int count = 0; for (int i=1;i<input_char.length;i++) { if (input_char[i]!=current_char) { count++; current_char = input_char[i]; } } System.out.println(count); }
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
s491760518
p03947
Java
import java.util.Scanner; public class Reversi { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String input = scan.nextLine(); char[] input_char = input.toCharArray(); char current_char = input_char[0]; int count = 0; for (int i=1;i<input_char.length;i++) { if (input_char[i]!=current_char) { count++; current_char = input_char[i]; } } System.out.println(count); } }
Main.java:3: error: class Reversi is public, should be declared in a file named Reversi.java public class Reversi { ^ 1 error
s740418673
p03947
C
#include <stdio.h> #include <string.h> int main(){ long count; long s_number; int i; char S[100000]; int color,lastcolor; scanf(%c,&S); s_number = strlen(S); if(S[0]=="B")lastcolor=0; else if(S[0]=="W")lastcolor=1; for (i=1;i<s_number;i++){ if(S[i] == "B"){ color=0; } else if(S[i]=="W"){ color=1; } if(lastcolor==color){ count++; } else{ } lastcolor = color; } printf(%d,count); }
main.c: In function 'main': main.c:13:15: error: expected expression before '%' token 13 | scanf(%c,&S); | ^ main.c:16:16: warning: comparison between pointer and integer 16 | if(S[0]=="B")lastcolor=0; | ^~ main.c:17:21: warning: comparison between pointer and integer 17 | else if(S[0]=="W")lastcolor=1; | ^~ main.c:20:25: warning: comparison between pointer and integer 20 | if(S[i] == "B"){ | ^~ main.c:23:29: warning: comparison between pointer and integer 23 | else if(S[i]=="W"){ | ^~ main.c:36:16: error: expected expression before '%' token 36 | printf(%d,count); | ^
s205470714
p03947
C
#include <stdio.h> int main(){ long count; long s_number; int i,; char S[]; scanf(%c,&S); s_number = strlen(S); if(S[0]=="B")lastcolor=0; else if(S[0]=="W")lastcolor=1; for (i=1;i<s_number;i++){ if(S[i] == "B"){ color=0; } else if(S[i]=="W"){ color=1; } if(lastcolor==color){ count++; } else{ } lastcolor = color; } printf(%d,count); }
main.c: In function 'main': main.c:8:15: error: expected identifier or '(' before ';' token 8 | int i,; | ^ main.c:9:14: error: array size missing in 'S' 9 | char S[]; | ^ main.c:11:15: error: expected expression before '%' token 11 | scanf(%c,&S); | ^ main.c:12:20: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 12 | s_number = strlen(S); | ^~~~~~ main.c:3:1: note: include '<string.h>' or provide a declaration of 'strlen' 2 | #include <stdio.h> +++ |+#include <string.h> 3 | main.c:12:20: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 12 | s_number = strlen(S); | ^~~~~~ main.c:12:20: note: include '<string.h>' or provide a declaration of 'strlen' main.c:14:16: warning: comparison between pointer and integer 14 | if(S[0]=="B")lastcolor=0; | ^~ main.c:14:22: error: 'lastcolor' undeclared (first use in this function) 14 | if(S[0]=="B")lastcolor=0; | ^~~~~~~~~ main.c:14:22: note: each undeclared identifier is reported only once for each function it appears in main.c:15:21: warning: comparison between pointer and integer 15 | else if(S[0]=="W")lastcolor=1; | ^~ main.c:18:25: warning: comparison between pointer and integer 18 | if(S[i] == "B"){ | ^~ main.c:19:25: error: 'color' undeclared (first use in this function) 19 | color=0; | ^~~~~ main.c:21:29: warning: comparison between pointer and integer 21 | else if(S[i]=="W"){ | ^~ main.c:34:16: error: expected expression before '%' token 34 | printf(%d,count); | ^
s150102749
p03947
C++
int main(){ string s; int ans=0; cin>>s; char prev= s.at(0); for(int i=1; i<s.size(); i++){ // cout<< prev<<endl; // cout<< s.at(i)<<endl; if(prev!= s.at(i)) ans++; prev= s.at(i); } cout<< ans<< endl; return 0; }
a.cc: In function 'int main()': a.cc:2:9: error: 'string' was not declared in this scope 2 | string s; | ^~~~~~ a.cc:5:9: error: 'cin' was not declared in this scope 5 | cin>>s; | ^~~ a.cc:5:14: error: 's' was not declared in this scope 5 | cin>>s; | ^ a.cc:18:9: error: 'cout' was not declared in this scope 18 | cout<< ans<< endl; | ^~~~ a.cc:18:22: error: 'endl' was not declared in this scope 18 | cout<< ans<< endl; | ^~~~
s043462831
p03947
C
#include <stdio.h> int main(void){ char S[100001]; int i, j, n, Ans; scanf("%s",S); j = S[0]; n = strlen(S); Ans = 0; for(i=1; i<n; i++){ if(S[i] != j){ ++Ans; j = S[i]; } } printf(%d\n", Ans); return 0; }
main.c: In function 'main': main.c:7:9: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 7 | n = strlen(S); | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'strlen' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | int main(void){ main.c:7:9: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 7 | n = strlen(S); | ^~~~~~ main.c:7:9: note: include '<string.h>' or provide a declaration of 'strlen' main.c:15:12: error: expected expression before '%' token 15 | printf(%d\n", Ans); | ^ main.c:15:14: error: stray '\' in program 15 | printf(%d\n", Ans); | ^ main.c:15:16: warning: missing terminating " character 15 | printf(%d\n", Ans); | ^ main.c:15:16: error: missing terminating " character 15 | printf(%d\n", Ans); | ^~~~~~~~ main.c:16:14: error: expected ';' before '}' token 16 | return 0; | ^ | ; 17 | } | ~
s203201595
p03947
C
#include <stdio.h> int main(void){ char S[100001]; int i, j, n, Ans; scanf("%s",S); j = S[0]; n = strlen(S)-1; Ans = 0; for(i=1; i<n; i++){ if(S[i] != j){ ++Ans; j = S[i]; } } printf(%d\n", Ans); return0; }
main.c: In function 'main': main.c:7:9: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 7 | n = strlen(S)-1; | ^~~~~~ main.c:2:1: note: include '<string.h>' or provide a declaration of 'strlen' 1 | #include <stdio.h> +++ |+#include <string.h> 2 | int main(void){ main.c:7:9: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 7 | n = strlen(S)-1; | ^~~~~~ main.c:7:9: note: include '<string.h>' or provide a declaration of 'strlen' main.c:15:12: error: expected expression before '%' token 15 | printf(%d\n", Ans); | ^ main.c:15:14: error: stray '\' in program 15 | printf(%d\n", Ans); | ^ main.c:15:16: warning: missing terminating " character 15 | printf(%d\n", Ans); | ^ main.c:15:16: error: missing terminating " character 15 | printf(%d\n", Ans); | ^~~~~~~~ main.c:16:13: error: expected ';' before '}' token 16 | return0; | ^ | ; 17 | } | ~
s125731963
p03947
C++
324
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 324 | ^~~
s240990377
p03947
C++
#include<bits/stdc++.h> #define INF 987654321 #define N 100005 using namespace std; struct A{ int num,lef,rig; /// lef,rig는 가능한 구간이라고 하자 } s[N]; vector<int> V[N]; int n,m,ai[N],bi[N],visit[N],visit2[N]; void dfs(int from) { int to,i,st,ed; st=-INF; ed=INF; visit[from]=1; for(i=0;i<V[from].size();i++){ to=V[from][i]; if(visit[to]==1) continue; dfs(to); //printf("%d %d %d\n",from,to,s[to].num); if(s[to].rig!=INF){ if(ed!=INF && (st-s[to].rig)%2==0){ ///홀짝성에 어긋 난다면 printf("No"); exit(1); } if((ed<s[to].lef-1 || s[to].rig+1<st)){ ///겹치지 않는 다면 printf("No"); exit(1); } /// 범위의 교집합 구한다. st=max(st,s[to].lef-1); ed=min(ed,s[to].rig+1); } } if(s[from].num!=INF){ if(st<=s[from].num && s[from].num<=ed){ s[from].lef=s[from].num; s[from].rig=s[from].num; } else{ printf("No"); exit(1); } } else{ s[from].lef=st; s[from].rig=ed; } // printf("%d %d //%d %d//st:%d,ed:%d\n",from,s[from].num,s[from].lef,s[from].rig,st,ed); } void dfs2(int from,int num) { int i,to; visit2[from]=1; // printf("%d %d %d\n",from,s[from].num,num); if(s[from].lef<=num-1 && num-1<=s[from].rig){ s[from].num=num-1; } else s[from].num=num+1; for(i=0;i<V[from].size();i++){ to=V[from][i]; // printf("->%d %d\n",from,to); if(visit2[to]==0){ dfs2(to,s[from].num); } } } int main() { // freopen("input.txt","r",stdin); scanf("%d",&n); int i,v,p; for(i=1;i<n;i++){ scanf("%d%d",&ai[i],&bi[i]); s[i].lef=-INF; s[i].rig=s[i].num=INF; V[ai[i]].push_back(bi[i]); V[bi[i]].push_back(ai[i]); } s[n].lef=-INF; s[n].rig=s[n].num=INF; scanf("%d",&m); for(i=1;i<=m;i++){ scanf("%d%d",&v,&p); s[v].lef=p; s[v].rig=p; s[v].num=p; } dfs(1); // dfs2(1,s[1].rig==INF ? 0: s[1].rig+1); printf("Yes\n"); for(i=1;i<=n;i++) printf("%d\n",s[i].num);
a.cc: In function 'void dfs(int)': a.cc:17:5: error: reference to 'visit' is ambiguous 17 | visit[from]=1; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80, from a.cc:1: /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:10:21: note: 'int visit [100005]' 10 | int n,m,ai[N],bi[N],visit[N],visit2[N]; | ^~~~~ a.cc:20:12: error: reference to 'visit' is ambiguous 20 | if(visit[to]==1) | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:10:21: note: 'int visit [100005]' 10 | int n,m,ai[N],bi[N],visit[N],visit2[N]; | ^~~~~ a.cc: In function 'int main()': a.cc:99:33: error: expected '}' at end of input 99 | printf("%d\n",s[i].num); | ^ a.cc:75:1: note: to match this '{' 75 | { | ^
s425364376
p03947
Java
import java.io.*; import java.util.*; import java.lang.*; public class Main { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); String s = r.readLine(); System.out.println(solve(s)); } public int solve(String s) { int result = 0; for (int j = 1; j < s.length(); j++) if (s.charAt(j) != s.charAt(j - 1)) result++; return result; } }
Main.java:11: error: non-static method solve(String) cannot be referenced from a static context System.out.println(solve(s)); ^ 1 error
s634846448
p03947
C++
// -*- coding: utf-8 -*- //import java.awt.*; import java.io.*; import java.math.*; import java.text.*; import java.util.*; public class Main { public static void main(String[] args) { InputStream inputStream; if (args.length > 0 && args[0].equals("devTesting")) { try { inputStream = new FileInputStream(args[1]); } catch(FileNotFoundException e) { throw new RuntimeException(e); } } else { inputStream = System.in; } OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); TaskC solver = new TaskC(); solver.solve(1, in, out); out.close(); } static class TaskC { String s; void solve(int testNumber, InputReader in, PrintWriter out) { s = in.next(); int ans = Integer.MAX_VALUE, cnt = 0, n = s.length(); char color = s.charAt(0); for (int i = 1; i < n; ++i) if (s.charAt(i) != color) { color = s.charAt(i); ++cnt; } ans = cnt; cnt = 0; color = s.charAt(n - 1); for (int i = n - 2; i >= 0; --i) if (s.charAt(i) != color) { color = s.charAt(i); ++cnt; } ans = Math.min(ans, cnt); out.println(ans); } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream)); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public String nextLine() { try { return reader.readLine(); } catch(IOException e) { throw new RuntimeException(e); } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public boolean hasInput() { try { if (tokenizer != null && tokenizer.hasMoreTokens()) { return true; } reader.mark(1); int ch = reader.read(); if (ch != -1) { reader.reset(); return true; } return false; } catch(IOException e) { throw new RuntimeException(e); } } } }
a.cc:3:1: error: 'import' does not name a type 3 | import java.io.*; | ^~~~~~ 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.math.*; | ^~~~~~ 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.text.*; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.*; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: expected unqualified-id before 'public' 8 | public class Main { | ^~~~~~
s059657071
p03947
C++
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<map> #include<sstream> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<cmath> #include<utility> #include<set> #include <queue> #define ull unsigned long long #define ll long long #define pii pair<int,int> #define pb(x) push_back(x) #define S(x) scanf("%d",&x) #define Sl(x) scanf("%lld",&x) #define M(x,i) memset(x,i,sizeof(x)) #define F(i,a,n) for(i=(a);i<(n);++i) #define FD(i,a,n) for(i=(a);i>=(n);--i) using namespace std; int main() { int i,cnt; cnt = 0; string s; cin>>s; int len = s.length(); if(len == 1){ cout<<0<<endl; return 0; } F(i,1,len){ if(s[i] != s[i-1]){ cnt++; } } cout<<
a.cc: In function 'int main()': a.cc:43:11: error: expected primary-expression at end of input 43 | cout<< | ^ a.cc:43:11: error: expected '}' at end of input a.cc:26:1: note: to match this '{' 26 | { | ^
s412941164
p03947
C++
#include<cstdio> #include<iostream> #include<vector> #include<string> #include<algorithm> #include<queue> #include<stack> #include<map> #include <iomanip> #define rep0(i,N) for(int i=0;i<N;i++) #define rep1(i,a,N) for(int i=0+a;i<N;i++) #define lint long long int #define SIZE 100005 using namespace std; int main(){ string str; cin>>str; lint ans=0; int cc; if(str[0]=='B')cc=0; else cc=1; rep1(i,1,str.size()){ if(str[i]=='B'){ if(cc==1) ans++; cc=0; } else{ if(cc==0) ans++; cc=1; } } cout<<ans; return 0;
a.cc: In function 'int main()': a.cc:37:10: error: expected '}' at end of input 37 | return 0; | ^ a.cc:18:11: note: to match this '{' 18 | int main(){ | ^
s611523962
p03947
C++
import std.stdio; import std.conv, std.array, std.algorithm, std.string; import std.math, std.random, std.range, std.datetime; import std.bigint; void main(){ string s = readln.chomp; int ans; char x = 'a'; foreach(c; s){ if(x != 'a') if(x != c) ans += 1; x = c; } ans.writeln; }
a.cc:1:1: error: 'import' does not name a type 1 | import std.stdio; | ^~~~~~ 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 std.conv, std.array, std.algorithm, std.string; | ^~~~~~ 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 std.math, std.random, std.range, std.datetime; | ^~~~~~ 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 std.bigint; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: '::main' must return 'int' 6 | void main(){ | ^~~~ a.cc: In function 'int main()': a.cc:7:9: error: 'string' was not declared in this scope 7 | string s = readln.chomp; | ^~~~~~ a.cc:11:17: error: 'c' was not declared in this scope 11 | foreach(c; s){ | ^ a.cc:11:20: error: 's' was not declared in this scope 11 | foreach(c; s){ | ^ a.cc:16:13: error: request for member 'writeln' in 'ans', which is of non-class type 'int' 16 | ans.writeln; | ^~~~~~~
s360018475
p03947
C++
#include<bits/stdc++.h> using namesapce std; int main() { string s; cin>>s; int num=0; char c=s[0]; for(int i=1;s[i]!=0;i++){ if(c!=s[i]){ num++; c=s[i]; } } printf("%d\n",num); }
a.cc:2:7: error: expected nested-name-specifier before 'namesapce' 2 | using namesapce std; | ^~~~~~~~~ a.cc: In function 'int main()': a.cc:5:9: error: 'string' was not declared in this scope 5 | string s; | ^~~~~~ a.cc:5:9: note: suggested alternatives: In file included from /usr/include/c++/14/string:41, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:6:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 6 | cin>>s; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:6:14: error: 's' was not declared in this scope 6 | cin>>s; | ^
s257151792
p03947
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; char str[123456]; int main(void) { scanf("%s", str); int ans = 0; for (int i = 1; i < strlen(str); ++i) { if (str[i - 1] != str[i])++ans; } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:28:29: error: 'strlen' was not declared in this scope 28 | for (int i = 1; i < strlen(str); ++i) | ^~~~~~ a.cc:20:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 19 | #include <queue> +++ |+#include <cstring> 20 | using namespace std;
s365363147
p03948
C++
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; #define int long long int n, A[N], T; map < int, int > Map; main() { cin >> n >> T; for(int i = 1; i <= n; ++ i) scanf("%lld", &A[i]); int Mi = 1e9, ans = 0; for(int i = 1; i <= n; ++ i) { Mi = min(Mi, A[i]); ans = max(ans, A[i] - Mi); } Mi = 1e9; int cnt1 = 0, cnt2 = 0; for(int i = 1; i <= n; ++ i) { ++ Map[A[i]]; Mi = min(Mi, A[i]); if(A[i] - Mi == ans) { cnt1 += Map[Mi]; ++ cnt2; Map[Mi] = 0; } } cout << min(min(cnt1, cnt2), 1000000000); }
a.cc:12:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 12 | main() { | ^~~~ a.cc: In function 'int main()': a.cc:32:20: error: no matching function for call to 'min(const long long int&, int)' 32 | cout << min(min(cnt1, cnt2), 1000000000); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:32:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 32 | cout << min(min(cnt1, cnt2), 1000000000); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:32:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | cout << min(min(cnt1, cnt2), 1000000000); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s649548880
p03948
C++
#include <cstdio> using i32 = int; using i64 = long long; constexpr i32 maxn = 100000; inline i32 in() { static i32 n; scanf("%d", &n); return n; } i32 a[maxn + 1]; i32 main() { const i32 n = in(), T = in(); for (i32 i = 1; i <= n; ++i) a[i] = in(); a[n + 1] = -1; std::pair<i32, i32> ans = std::make_pair(0, 0); for (i32 l = 1, r = 1; r <= n; ++r) if (a[r + 1] < a[r]) { const i32 val = a[r] - a[l]; if (val > ans.first) ans = std::make_pair(val, 1); else if (val == ans.first) ++ans.second; l = r + 1; } printf("%d\n", ans.second); return 0; }
a.cc: In function 'i32 main()': a.cc:21:14: error: 'pair' is not a member of 'std' 21 | std::pair<i32, i32> ans = std::make_pair(0, 0); | ^~~~ a.cc:2:1: note: 'std::pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' 1 | #include <cstdio> +++ |+#include <utility> 2 | a.cc:21:22: error: expected primary-expression before ',' token 21 | std::pair<i32, i32> ans = std::make_pair(0, 0); | ^ a.cc:21:27: error: expected primary-expression before '>' token 21 | std::pair<i32, i32> ans = std::make_pair(0, 0); | ^ a.cc:21:29: error: 'ans' was not declared in this scope 21 | std::pair<i32, i32> ans = std::make_pair(0, 0); | ^~~ a.cc:21:40: error: 'make_pair' is not a member of 'std' 21 | std::pair<i32, i32> ans = std::make_pair(0, 0); | ^~~~~~~~~ a.cc:21:40: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>' a.cc:25:57: error: 'make_pair' is not a member of 'std' 25 | if (val > ans.first) ans = std::make_pair(val, 1); | ^~~~~~~~~ a.cc:25:57: note: 'std::make_pair' is defined in header '<utility>'; this is probably fixable by adding '#include <utility>'
s044173769
p03948
C++
#include<iostream> #include<algorithm> #define MAX 100005 using namespace std; ll a[MAX],ans=0; typedef long long ll; int main() { //最多买卖T int N, T; cin >> N >> T; ll tmp = 0,pro=0; cin >> a[1]; tmp = a[1]; for (int i = 2; i <= N; i++){ cin >> a[i]; if (a[i] > tmp) { if (a[i] - tmp >= pro) { pro = a[i] - tmp; ans++; } tmp = a[i]; } else { tmp = a[i]; } } cout << ans << endl; return 0; }
a.cc:5:1: error: 'll' does not name a type 5 | ll a[MAX],ans=0; | ^~ a.cc: In function 'int main()': a.cc:12:16: error: 'a' was not declared in this scope 12 | cin >> a[1]; | ^ a.cc:19:33: error: 'ans' was not declared in this scope; did you mean 'abs'? 19 | ans++; | ^~~ | abs a.cc:27:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 27 | cout << ans << endl; | ^~~ | abs
s790012450
p03948
C++
#include<stdio.h> #include<string.h> #include<algorithm> #include<iostream> #include<map> #include<vector> using namespace std; typedef long long ll; #define maxn 100500 #define inf 0x3f3f3f3f int a[maxn]; int main() { int ans = 0; int n, t; scanf_s("%d%d", &n, &t); for (int i = 1; i <= n; i++) { scanf_s("%d", &a[i]); } int temp, maxx; temp = inf; maxx = -inf; for (int i = 1; i <= n; i++) { temp = min(temp, a[i]); maxx = max(maxx, a[i]-temp); } temp = inf; for (int i = 1; i <= n; i++) { temp = min(temp, a[i]); if (maxx == a[i]-temp)ans++; } printf("%d\n", ans); }
a.cc: In function 'int main()': a.cc:16:9: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 16 | scanf_s("%d%d", &n, &t); | ^~~~~~~ | scanf
s395516592
p03948
C++
#include <iostream> #include <bits/stdc++>h> using namespace std; int main(){ long long int a, b , c[100010], x[100010]; cin >> a >> b; for(int i=0;i<a;i++) cin >> c[i]; x[0] = 1e15; for(int i=0;i<a;i++){ x[i+1] = min(c[i+1] , x[i]); } int p = -1e9; int ans = 0; for(int i=0;i<a;i++){ if(x[i]-c[i] > p){ p = x[i] - c[i]; ans = 1; } else if(x[i] - c[i] == p){ ans ++; } } cout << ans << endl; }
a.cc:2:24: warning: extra tokens at end of #include directive 2 | #include <bits/stdc++>h> | ^ a.cc:2:10: fatal error: bits/stdc++>: No such file or directory 2 | #include <bits/stdc++>h> | ^~~~~~~~~~~~~~ compilation terminated.
s899964454
p03948
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) int main(){ int n,t;cin>>n>>t; int a[n];rep(i,n)cin>>a[i]; int cur=a[0]; multiset<int> ms; rep(i,n-1){ if(a[i]>a[i-1])continue; ms.insert(a[i-1]-cur); if(cur>a[i])cur=a[i]; } ms.insert(a[n-1]-cur); int ans=1; auto it=ms.end(); --it; int mval=(*it); while(it!=ms.begin()){ if(*(--it)!=mval)break; else ++ans; } cout<<ans<<endl; }
a.cc:20:24: error: redefinition of 'template<class T> bool chmax(T&, const T&)' 20 | template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } | ^~~~~ a.cc:6:24: note: 'template<class T> bool chmax(T&, const T&)' previously declared here 6 | template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } | ^~~~~ a.cc:21:24: error: redefinition of 'template<class T> bool chmin(T&, const T&)' 21 | template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } | ^~~~~ a.cc:7:24: note: 'template<class T> bool chmin(T&, const T&)' previously declared here 7 | template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } | ^~~~~
s938238999
p03948
C++
#include<iostream> #include<sstream> #include<fstream> #include<string> #include<vector> #include<stack> #include<map> #include<set> #include<queue> #include<deque> #include<bitset> #include<utility> #include<algorithm> #include<functional> #include<ctime> #include<cmath> #include<cstdlib> #include<cstdio> using namespace std; int A[100100]; map<int,int> mp; int main() { int N,T,lst; cin>>N>>T; for(int i=0;i<N;i++) { cin>>A[i]; if(!i) int x=A[i]; else int x=min(lst,A[i-1]); mp[A[i]-x]++; lst=x; } map<int,int>::iterator it=mp.end(); it--; cout<<it->second<<endl; return 0; }
a.cc: In function 'int main()': a.cc:32:25: error: 'x' was not declared in this scope 32 | mp[A[i]-x]++; | ^
s083867204
p03948
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; int main(){ int n; long long t; cin>>n>>t; if(n==1){ cout<<0<<endl; return 0; } long long a[n]; REP(i,n){ cin>>a[i]; } long long opt[n]={};//町iでりんごを買って最適に売った時の利益 vector<int> p[n];//町iで買ったりんごをどの町で売るのが最適か? long long M=0; for(int i=n-2;i>=0;i--){ if(M<a[i+1]){ M = a[i+1]; p[i].push_back(i+1); }else if(M==a[i+1]){ p[i].push_back(i+1); REP(j,(int)p[i+1].size()){ p[i].push_back(p[i+1][j]); } }else{ REP(j,(int)p[i+1].size()){ p[i].push_back(p[i+1][j]); } } opt[i]=(M-a[i])*(t/2); } long long maxp=0; REP(i,n){ maxp = max(maxp,opt[i]); } bool used[n]={}; int ans=0; REP(i,n){ if(opt[i]==maxp){ REP(j,(int)p[i].size()){ if(!used(p[i][j])){ ans++; used(p[i][j]) = true; } } } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:129:17: error: 'used' cannot be used as a function 129 | if(!used(p[i][j])){ | ~~~~^~~~~~~~~ a.cc:131:15: error: 'used' cannot be used as a function 131 | used(p[i][j]) = true; | ~~~~^~~~~~~~~
s997260969
p03948
C
#include<stdio.h> int main(){ int a[100000],i,j,n,N=0,num=0; int max=0; scanf("%d%d",&n,&N); for(i=0;i<n;i++){ scanf("%d",&a[i]); if(i>0&&a[i-1]-a[i]>max) max=a[i-1]-a[i]; } for(i=0;i<n-1;i++){ if(max==a[i]-a[i+1]) num++; } if(N<num) num=N; printf("%d",num); return 0; }
main.c: In function 'main': main.c:8:9: error: 'if\U0000ff08i' undeclared (first use in this function) 8 | if(i>0&&a[i-1]-a[i]>max) | ^~~~~ main.c:8:9: note: each undeclared identifier is reported only once for each function it appears in main.c:8:33: error: expected ';' before ')' token 8 | if(i>0&&a[i-1]-a[i]>max) | ^ | ; main.c:8:33: error: expected statement before ')' token
s267207541
p03948
C++
#include <bits/stdc++.h> typedef long long ll; using namespace std; int main() { ll N, T; cin >> N >> T; ll A[N + 5]; map<ll, ll> mp; for (int i = 0; i < N; i++) { cin >> A[i]; } ll max_v = -2000000000000; ll min_v = R[0]; for (int i = 0; i < N; i++) { max_v = max(max_v, A[i] - min_v); min_v = min(min_v, A[i]); } ll dis = max_v; ll cnt = 0; for (int i = 0; i < N; i++) { mp[A[i]]++; if (mp[A[i] - dis]) { cnt++; } } cout<<min(T/2,cnt)<<endl; }
a.cc: In function 'int main()': a.cc:15:16: error: 'R' was not declared in this scope 15 | ll min_v = R[0]; | ^
s221288580
p03948
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <queue> #include <cmath> typedef long long ll; typedef unsigned int uint; using namespace std; int main() { cin.sync_with_stdio(false); cin.tie(0); int n, t; cin >> n >> t; int A[n]; int mn = INT_MAX; int mx = 0; for (int i = 0; i < n; i++) { cin >> A[i]; mn = min(mn, A[i]); mx = max(mx, A[i] - mn); } int count = 0; int mn2 = INT_MAX; for (int i = 0; i < n; i++) { mn2 = min(mn2, A[i]); if (A[i] - mn2 == mx) { count++; } } cout << count << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:18:14: error: 'INT_MAX' was not declared in this scope 18 | int mn = INT_MAX; | ^~~~~~~ a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 6 | #include <cmath> +++ |+#include <climits> 7 | typedef long long ll;
s733409207
p03948
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <string> #include <cstring> #include <cctype> #include <cmath> #include <stack> #include <queue> #include <vector> #include <set> #include <map> #include <list> #include <stdio.h> #include <string.h> #include <cstdlib> #include <math.h> #include <bitset> #include <iterator> #include <iomanip> #include <sstream> #include <numeric> #define INF INT_MAX using namespace std; int dx[5]={1,0,-1,0,0},dy[5]={0,1,0,-1,0}; long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);} long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;} #define MOD 1000000007 #define sym cout<<"---------"<<endl; #define ll long long #define PL pair<long long, long long> #define mk make_pair #define en endl #define WHITE 1 #define BLACK 2 #define GRAY 1 #define RE return 0 #define int ll #define P pair<int,int> #define MAX 100005 int a[MAX]; // 利益の最大値 first 配列の場所 second vector<P> max_dif; signed main(){ int n,t; cin>>n>>t; for(int i=0; i<n; i++) cin>>a[i]; max_dif.push_back(mk(-1,-1)); int minl=INF; for(int i=0; i<n; i++){ minl=min(minl,a[i]); int d=a[i]-minl; if(d==max_dif[0].first) max_dif.push_back(mk(d,i)); else if(d>max_dif[0].first){ max_dif.clear(); max_dif.push_back(mk(d,i)); } } cout<<max_dif.size()<<en; }
a.cc: In function 'int main()': a.cc:23:13: error: 'INT_MAX' was not declared in this scope 23 | #define INF INT_MAX | ^~~~~~~ a.cc:52:12: note: in expansion of macro 'INF' 52 | int minl=INF; | ^~~ a.cc:23:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 22 | #include <numeric> +++ |+#include <climits> 23 | #define INF INT_MAX
s530233379
p03948
C++
#include<iostream> #include<algorithm> using namespace std; int N, T; int in[100001]; int main() { cin >> N >> T; for (int i = 0; i < N; i++)ifs >> in[i]; int ct = 1, biggest = -1, small = in[0]; int ans = 0; int beforesmall = 0; for (int i = 1; i <= N; i++) { beforesmall = small; small = min(small, in[i]); if (i != N && in[i] > in[i - 1])ct++; else { if (ct != 0) { if (biggest == in[i - 1] - beforesmall) { ans++; } else if (biggest < in[i - 1] - beforesmall) { biggest = in[i - 1] - beforesmall; ans = 1; } ct = 0; } } //cout << i << " " << biggest << " " << small << endl; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:36: error: 'ifs' was not declared in this scope 12 | for (int i = 0; i < N; i++)ifs >> in[i]; | ^~~
s856145497
p03948
C++
#include <cstdio> #include <algorithm> #include <iostream> #include <vector> #include <cmath> #include <cstring> #include <map> #include <queue> #include <string> #define pb push_back #define mod 1000000007 #define all(x) x.begin(),x.end() #define inf (int)(1e9) using namespace std; typedef long long int ll; typedef pair<int,int> pii; int max_a[111111]; int min_a[111111]; //bool use[111111]; map<int,int> mp; int main(void){ int n,t; cin>>n>>t; int x; vector<int> a; for(int i=0;i<n;i++){ cin>>x; a.pb(x); } min_a[0]=a[0]; max_a[n-1]=a[n-1]; for(int i=1;i<n;i++){ min_a[i]=min(min_a[i-1],a[i]); max_a[n-i-1]=max(max_a[n-i],a[n-i-1]); } int r=0; for(int i=0;i<n;i++){ r=max(r,max_a[i]-min_a[i]); } int res=0; for(int i=0;i<n;i++){ if(max_a[i]-min_a[i]==r){ if(mp[max_a[i]]!=1) res++; map[max_a[i]]=1; } } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:45:16: error: expected ']' before '[' token 45 | map[max_a[i]]=1; | ^ | ] a.cc:45:21: error: class template argument deduction failed: 45 | map[max_a[i]]=1; | ^ a.cc:45:21: error: no matching function for call to 'map(int)' In file included from /usr/include/c++/14/map:63, from a.cc:7: /usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate: 'template<class _InputIterator, class _Compare, class _Allocator, class, class, class> std::map(_InputIterator, _InputIterator, _Compare, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, _Compare, _Allocator>' 1473 | map(_InputIterator, _InputIterator, | ^~~ /usr/include/c++/14/bits/stl_map.h:1473:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:1482:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Allocator, class, class> std::map(initializer_list<pair<_T1, _T2> >, _Compare, _Allocator)-> map<_Key, _Tp, _Compare, _Allocator>' 1482 | map(initializer_list<pair<_Key, _Tp>>, | ^~~ /usr/include/c++/14/bits/stl_map.h:1482:5: note: template argument deduction/substitution failed: a.cc:45:21: note: mismatched types 'std::initializer_list<std::pair<_T1, _T2> >' and 'int' 45 | map[max_a[i]]=1; | ^ /usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate: 'template<class _InputIterator, class _Allocator, class, class> std::map(_InputIterator, _InputIterator, _Allocator)-> map<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type, typename iterator_traits< <template-parameter-1-1> >::value_type::second_type, less<typename remove_const<typename iterator_traits< <template-parameter-1-1> >::value_type::first_type>::type>, _Allocator>' 1489 | map(_InputIterator, _InputIterator, _Allocator) | ^~~ /usr/include/c++/14/bits/stl_map.h:1489:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate: 'template<class _Key, class _Tp, class _Allocator, class> std::map(initializer_list<pair<_T1, _T2> >, _Allocator)-> map<_Key, _Tp, less<_Key>, _Allocator>' 1495 | map(initializer_list<pair<_Key, _Tp>>, _Allocator) | ^~~ /usr/include/c++/14/bits/stl_map.h:1495:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:102:11: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Alloc>)-> std::map<_Key, _Tp, _Compare, _Alloc>' 102 | class map | ^~~ /usr/include/c++/14/bits/stl_map.h:102:11: note: template argument deduction/substitution failed: a.cc:45:21: note: mismatched types 'std::map<_Key, _Tp, _Compare, _Alloc>' and 'int' 45 | map[max_a[i]]=1; | ^ /usr/include/c++/14/bits/stl_map.h:197:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map()-> std::map<_Key, _Tp, _Compare, _Alloc>' 197 | map() = default; | ^~~ /usr/include/c++/14/bits/stl_map.h:197:7: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:219:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 219 | map(const map&) = default; | ^~~ /usr/include/c++/14/bits/stl_map.h:219:7: note: template argument deduction/substitution failed: a.cc:45:21: note: mismatched types 'const std::map<_Key, _Tp, _Compare, _Allocator>' and 'int' 45 | map[max_a[i]]=1; | ^ /usr/include/c++/14/bits/stl_map.h:227:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 227 | map(map&&) = default; | ^~~ /usr/include/c++/14/bits/stl_map.h:227:7: note: template argument deduction/substitution failed: a.cc:45:21: note: mismatched types 'std::map<_Key, _Tp, _Compare, _Allocator>' and 'int' 45 | map[max_a[i]]=1; | ^ /usr/include/c++/14/bits/stl_map.h:240:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 240 | map(initializer_list<value_type> __l, | ^~~ /usr/include/c++/14/bits/stl_map.h:240:7: note: template argument deduction/substitution failed: a.cc:45:21: note: mismatched types 'std::initializer_list<std::pair<const _Key, _Tp> >' and 'int' 45 | map[max_a[i]]=1; | ^ /usr/include/c++/14/bits/stl_map.h:252:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(const std::map<_Key, _Tp, _Compare, _Allocator>&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 252 | map(const map& __m, const __type_identity_t<allocator_type>& __a) | ^~~ /usr/include/c++/14/bits/stl_map.h:252:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:256:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::map<_Key, _Tp, _Compare, _Allocator>&&, std::__type_identity_t<_Alloc>&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 256 | map(map&& __m, const __type_identity_t<allocator_type>& __a) | ^~~ /usr/include/c++/14/bits/stl_map.h:256:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:262:7: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> map(std::initializer_list<std::pair<const _Key, _Tp> >, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 262 | map(initializer_list<value_type> __l, const allocator_type& __a) | ^~~ /usr/include/c++/14/bits/stl_map.h:262:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:268:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 268 | map(_InputIterator __first, _InputIterator __last, | ^~~ /usr/include/c++/14/bits/stl_map.h:268:9: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:285:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator)-> std::map<_Key, _Tp, _Compare, _Alloc>' 285 | map(_InputIterator __first, _InputIterator __last) | ^~~ /usr/include/c++/14/bits/stl_map.h:285:9: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_map.h:302:9: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc, class _InputIterator> map(_InputIterator, _InputIterator, const _Compare&, const _Alloc&)-> std::map<_Key, _Tp, _Compare, _Alloc>' 302 | map(_InputIterator __first, _InputIterator __last, | ^~~ /usr/include/c++/14/bits/stl_map.h:302:9: note: candidate expects 3 arguments, 1 provided a.cc:45:21: note: explicit deduction guides not considered for copy-initialization 45 | map[max_a[i]]=1; | ^
s492027265
p03948
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N, T; cin>>N>>T; vector<int> A, B; A.resize(N); B.resize(N-1); cin>>A[0]; int min=A[0]; for(int i=1; i<N; i++){ cin>>A[i]; B[i-1]=A[i]-min; if(min > A[i]){ min=A[i]; } } sort(B.begin(), B.end()); int cnt=0; for(int i=N-2; i>0; i--){ if(B[i]==B[i-1]){ cnt++; }else{ break; } } cout<<cnt+1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(B.begin(), B.end()); | ^~~~ | short
s319556198
p03948
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; int main(void) { int N, T, minprice, maxgain, cost; vector<int> A(100000), m(100000); cin >> N >> T; for (int i = 0; i < N; i++) cin >> A[i]; minprice = INT_MAX; maxgain = -INT_MAX; for (int i = 0; i < N; i++) { minprice = min(minprice, A[i]); m[i] = A[i] - minprice; if (maxgain < m[i]) maxgain = m[i]; } cost = 0; for (int i = 0; i < N; i++) if (maxgain == m[i]) cost++; cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:20: error: 'INT_MAX' was not declared in this scope 15 | minprice = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include<vector> +++ |+#include <climits> 4 |
s211109382
p03948
Java
import java.util.*; public class Main2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int T = sc.nextInt(); int A[] = new int[N]; for (int i = 0; i < N; i++) { A[i] = sc.nextInt(); } // i 以前の最小値 int min[] = new int[N]; min[0] = A[0]; for (int i = 1; i < N; i++) { if (A[i] < min[i-1]) { min[i] = A[i]; } else { min[i] = min[i-1]; } } // i 以降のAiの最大値 int max[] = new int[N]; max[N-1] = A[N-1]; for (int i = N - 2; i >=0; i--) { if(A[i] > max[i + 1]) { max[i] = A[i]; } else { max[i] = max[i + 1]; } } // 最大の価格差 int maxgap = 0; for (int i = 0; i < N; i++) { if (maxgap < max[i] - min[i]) { maxgap = max[i] - min[i]; } } // maxgapを作る場所の数を算出 // 連続したものはカウントしない int prevmax = 0; int prevmin = 0; int count = 0; for (int i = 0; i < N; i++) { if (max[i] - min[i] == maxgap && (prevmax != max[i] || prevmin != min[i])) { count++; } prevmax = max[i]; prevmin = min[i]; } System.out.println(count); } }
Main.java:3: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ 1 error
s440478780
p03948
C
#include <stdio.h> int main(void){ int N, T; scanf("%d %d\n" , &N, &T); char A[N], D[N]; scanf("%s", A); int i, j=A[1], k=0; for(i=2; i<N; i++){ if(j<A[i]){ D[k]=A[i]-j; k++; }else if(j==A[i]){ D[k]=0; k++; }else if(j>A[i]){ j=A[i]; } } int l=D[0]; for(i=0; i<k; i++){ if(l<D[i]{ l=D[i]; } } j=0; for(i=0; i<k; i++){ if(l==D[i]){ j++; } } printf("%d", j); return 0; }
main.c: In function 'main': main.c:25:18: error: expected ')' before '{' token 25 | if(l<D[i]{ | ~ ^ | ) main.c:28:5: error: expected expression before '}' token 28 | } | ^
s842472503
p03948
C++
#include <iostream> #include <cmath> using namespace std; int main(){ int N,T; cin >> N >> T; int A[N]; for(int i=0;i<N;i++) scanf("%d", &A[i]); int minA[N],profit[N]; int min_value=INT_MAX; int max_value=0; int suffer=0; for(int i=0;i<N;i++){ if(A[i]<min_value) min_value=A[i]; minA[i]=min_value; profit[i]=A[i]-minA[i]; if(max_value==profit[i]){ suffer++; }else if(max_value<profit[i]){ max_value=profit[i]; suffer=1; } } cout << suffer << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:19: error: 'INT_MAX' was not declared in this scope 13 | int min_value=INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <cmath> +++ |+#include <climits> 3 |
s095838514
p03948
C++
#include <iostream> using namespace std; int main(){ int N,T; cin >> N >> T; int A[N]; for(int i=0;i<N;i++) scanf("%d", &A[i]); int minA[N],profit[N]; int min_value=INT_MAX; int max_value=0; int suffer=0; for(int i=0;i<N;i++){ if(A[i]<min_value) min_value=A[i]; minA[i]=min_value; profit[i]=A[i]-minA[i]; if(max_value==profit[i]){ suffer++; }else if(max_value<profit[i]){ max_value=profit[i]; suffer=1; } } cout << suffer << endl; return 0; }
a.cc: In function 'int main()': a.cc:12:19: error: 'INT_MAX' was not declared in this scope 12 | int min_value=INT_MAX; | ^~~~~~~ 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 |
s602927730
p03948
C++
#include<iostream> using namespace std; int main(){ int n, t; int *a; cin>> n>> t; a= new int[n]; for(int i=0; i<n; i++) cin>> a[i]; int minA[n]; int profit[n]; minA[0]= a[0]; profit[0]= -a[0]; for(int i=1; i<n; i++) minA[i]= min(minA[i-1], a[i]); for(int i=1; i<n; i++) profit[i]= a[i]-minA[i-1]; int maxProfit= INT_MIN; int numMax=0; for(int i=0; i<n; i++) maxProfit= max(maxProfit, profit[i]); for(int i=0; i<n; i++){ if(profit[i] == maxProfit) numMax++; } cout<< numMax<< endl; return 0; }
a.cc: In function 'int main()': a.cc:22:24: error: 'INT_MIN' was not declared in this scope 22 | int maxProfit= INT_MIN; | ^~~~~~~ a.cc:2:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s858793614
p03948
C++
#include<iostream> using namespace std; int main(){ int n, t; int *a; cin>> n>> t; a= new int[n]; for(int i=0; i<n; i++) cin>> a[i]; int minA[n]; int profit[n]; minA[0]= a[0]; profit[0]= -a[0]; for(int i=1; i<n; i++) minA[i]= min(minA[i-1], a[i]); for(int i=1; i<n; i++) profit[i]= a[i]-minA[i-1]; int maxProfit= INT_MIN; int numMax=0; for(int i=0; i<n; i++) maxProfit= max(maxProfit, profit[i]); for(int i=0; i<n; i++){ if(profit[i] == maxProfit) numMax++; } cout<< numMax<< endl; return 0; }
a.cc: In function 'int main()': a.cc:22:24: error: 'INT_MIN' was not declared in this scope 22 | int maxProfit= INT_MIN; | ^~~~~~~ a.cc:2:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s383274231
p03948
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #define IOS ios::sync_with_stdio(false) using namespace std; #define inf (0x3f3f3f3f) typedef long long int LL; #include <iostream> #include <sstream> #include <vector> #include <set> #include <map> #include <queue> #include <string> const int maxn = 1e6 + 20; int dp[maxn]; void work() { int n, t; scanf("%d%d", &n, &t); if (n == 1) while(1); int mi = INT_MAX; int mx = -INT_MAX; for (int i = 1; i <= n; ++i) { int x; scanf("%d", &x); dp[i] = max(0, x - mi); mi = min(mi, x); mx = max(mx, dp[i]); } int tim = 0; for (int i = 1; i <= n; ++i) { tim += dp[i] == mx; } // for (int i = 1; i <= n; ++i) { //// cout << dp[i] << " "; // } // cout << endl; int ans = min(t / 2, tim); cout << ans << endl; } int main() { #ifdef local freopen("data.txt","r",stdin); #endif work(); return 0; }
a.cc: In function 'void work()': a.cc:24:14: error: 'INT_MAX' was not declared in this scope 24 | int mi = INT_MAX; | ^~~~~~~ a.cc:17:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 16 | #include <queue> +++ |+#include <climits> 17 | #include <string>
s521092740
p03948
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) #define repp(i, m, n) for(int i = m; i < n; i++) const int INF = 100000000; const double EPS = 1e-10; const int MOD = 1000000007; using namespace std; typedef long long ll; typedef pair<int, int> pai; typedef pair<ll,ll> pal; int n; ll t; ll m; ll sa, kazu, ll a[100010]; int main() { cin >> n >> t; cin >> a[0]; m=a[0]; kazu=0; sa=-1; repp(i, 1, n) { cin >> a[i]; if(a[i]>m) { if(a[i]-m==sa) { kazu++; } else if(a[i]-m>sa) { kazu=1; sa=a[i]-m; } } else { m=a[i]; } } cout << kazu << endl; return 0; }
a.cc:15:4: error: expected initializer before 'a' 15 | ll a[100010]; | ^ a.cc: In function 'int main()': a.cc:19:16: error: 'a' was not declared in this scope 19 | cin >> a[0]; | ^
s034388055
p03948
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < n; i++) #define repp(i, m, n) for(int i = m; i < n; i++) const int INF = 100000000; const double EPS = 1e-10; const int MOD = 1000000007; using namespace std; typedef long long ll; typedef pair<int, int> pai; typedef pair<ll,ll> pal; int n; ll t; ll m; ll sa kazu, ll a[100010]; int main() { cin >> n >> t; cin >> a[0]; m=a[0]; kazu=0; sa=-1; rep(i, 1, n) { cin >> a[i]; if(a[i]>m) { if(a[i]-m==sa) { kazu++; } else if(a[i]-m>sa) { kazu=1; sa=a[i]-m; } } else { m=a[i]; } } cout << kazu << endl; return 0; }
a.cc:23:20: error: macro "rep" passed 3 arguments, but takes just 2 23 | rep(i, 1, n) | ^ a.cc:2:9: note: macro "rep" defined here 2 | #define rep(i,n) for(int i = 0; i < n; i++) | ^~~ a.cc:14:7: error: expected initializer before 'kazu' 14 | ll sa kazu, | ^~~~ a.cc: In function 'int main()': a.cc:19:16: error: 'a' was not declared in this scope 19 | cin >> a[0]; | ^ a.cc:21:9: error: 'kazu' was not declared in this scope 21 | kazu=0; | ^~~~ a.cc:22:9: error: 'sa' was not declared in this scope 22 | sa=-1; | ^~ a.cc:23:9: error: 'rep' was not declared in this scope 23 | rep(i, 1, n) | ^~~
s747674912
p03948
C++
#include "math.h" #include <algorithm> #include <complex> #include <cstdio> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <string> #include <vector> #include <set> #define ifor(i, a, b) for (int i = (a); i < (b); i++) #define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--) #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) using namespace std; typedef long double ld; typedef long long int lli; typedef complex<double> P; const double eps = 1e-11; int vex[4] = {1, 0, -1, 0}; int vey[4] = {0, 1, 0, -1}; typedef vector<double> Vec; typedef vector<int> vec; typedef vector<Vec> MAT; typedef vector<vec> mat; lli MOD = 1000000007; int main() { lli n,t; cin >> n >> t; lli a[100005]; lli b[100005]; lli c[100005]; c[n] = 0; rep(i,n)cin >> a[i]; b[0] = a[0]; rep(i,n-1)b[i+1] = min(b[i],a[i+1]); rrep(i,n)c[i] = max(c[i+1],a[i]); rep(i,n-1){ cerr << b[i] << ' ' << c[i+1] << endl; } vector<pair<lli,pair<lli,lli>>> data; rep(i,n-1)data.push_back(make_pair(c[i+1]-b[i],make_pair(c[i+1],b[i]))); sort(data.begin(),data.end()); reverse(data.begin(),data.end()); map<lli,lli> map1,map2; rep(i,min(t/2,n-1)){ if(data[0].first == data[i].first) { map1[data[i].second.first]++; map2[data[i].second.first]++; }else{ break; } } cout << min(map1.size(),map2.size())<<endl; } Submission
a.cc:61:1: error: 'Submission' does not name a type 61 | Submission | ^~~~~~~~~~
s040390274
p03948
C++
#include<iostream> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define INF 1e10 using namespace std; long long abs(long long a){ return ((a>0)?a:-1*a); } int main(){ long long n,t,high,low; cin>>n>>t; long long a[n],tmp[n]; rep(i,n){ cin>>a[i]; } for(int i=n-1;i>=0;i--){ if(i==n-1)tmp[i]=a[i]; else{ if(tmp[i+1]<a[i])tmp[i]=a[i]; else tmp[i]=tmp[i+1]; } } long long cnt=0,diff=0; int er; rep(i,n){ if((tmp[i]-a[i])>diff){ diff=abs(tmp[i]-a[i]); cnt=1; }else if((tmp[i]-a[i])==diff){ cnt++; } } cout<<cnt<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:33: error: call of overloaded 'abs(long long int)' is ambiguous 29 | diff=abs(tmp[i]-a[i]); | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:7:11: note: candidate: 'long long int abs(long long int)' 7 | long long abs(long long a){ | ^~~ In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~
s831161438
p03948
C++
#include <iostream> #include <string.h> #include <algorithm> using namespace std; typedef long long ll; int main(void){ int n,i; ll a[100100],t,itr[100100],tmp=-1,cnt=0,dft=-1,ans; cin >> n >> t; (t+1)/=2; for(i=0; i<n; i++){ cin >> a[i]; } for(i=(n-1); i>=0; i--){ if(tmp<a[i]){ itr[i] = a[i]; tmp = a[i]; }else{ itr[i] = tmp; } itr[i] -= a[i]; } for(i=0; i<n; i++){ dft = max(dft,itr[i]); } for(i=0; i<n; i++){ if(dft==itr[i]){ cnt++; } } ans = min(t,cnt); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:11: error: lvalue required as left operand of assignment 13 | (t+1)/=2; | ~~^~~