submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s246006017
p00507
C
#include<stdio.h> #include<string.h> #include<stdlib.h> int main(){ int i,j; int count=0; int n; int a[100000]; int tmp; int b[200000]; char buffer[2][100000]; scanf("%d", &n); for(i=0;i<n;i++)scanf("%d",&a[i]); for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(a[i]>a[j]){ tmp=a[i]; a[i]=a[j]; a[j]=tmp; } } } for(i=0;i<2;i++){ for(j=0;j<n-1;j++){ itoa(a[i], buffer[0], 10); itoa(a[j], buffer[1], 10); strcat(buffer[0], buffer[1]); b[count++]=atoi(buffer[0]); } } for(i=0;i<2;i++){ for(j=i+1;j<count;j++){ if(b[i]>b[j]){ tmp=b[i]; b[i]=b[j]; b[j]=tmp; } } } printf("%d\n", b[2]); return 0; }
main.c: In function 'main': main.c:28:13: error: implicit declaration of function 'itoa' [-Wimplicit-function-declaration] 28 | itoa(a[i], buffer[0], 10); | ^~~~
s290897008
p00507
C
#include<stdio.h> #include<string.h> #include<stdlib.h> char *itoa( int val, char *a, int radix ) { char *p = a; unsigned int v = val; int n = 1; while(v >= radix){ v /= radix; n++; } p = a + n; v = val; *p = '\0'; do { --p; *p = v % radix + '0'; if(*p > '9') { *p = v % radix - 10 + 'A'; } v /= radix; } while ( p != a); return a; } int atoi(char *str) { int num = 0; while(*str != '\0'){ num += *str - 48; num *= 10; str++; } num /= 10; return num; } int main(){ int i,j; int count=0; int n; int a[100000]; int tmp; int b[200000]; char buffer[2][100000]; scanf("%d", &n); for(i=0;i<n;i++)scanf("%d",&a[i]); for(i=0;i<n-1;i++){ for(j=i+1;j<n;j++){ if(a[i]>a[j]){ tmp=a[i]; a[i]=a[j]; a[j]=tmp; } } } for(i=0;i<2;i++){ for(j=0;j<n-1;j++){ itoa(a[i], buffer[0], 10); itoa(a[j], buffer[1], 10); strcat(buffer[0], buffer[1]); b[count++]=atoi(buffer[0]); } } for(i=0;i<2;i++){ for(j=i+1;j<count;j++){ if(b[i]>b[j]){ tmp=b[i]; b[i]=b[j]; b[j]=tmp; } } } printf("%d\n", b[2]); return 0; }
main.c:28:5: error: conflicting types for 'atoi'; have 'int(char *)' 28 | int atoi(char *str) { | ^~~~ In file included from main.c:3: /usr/include/stdlib.h:105:12: note: previous declaration of 'atoi' with type 'int(const char *)' 105 | extern int atoi (const char *__nptr) | ^~~~
s744380510
p00507
C++
#include <iostream> #include <vector> #include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; int connect(int l, int r){ char ll[42], rr[22]; sprintf(ll, "%d", l), sprintf(rr, "%d", r); strcat(ll, rr); return atoi(ll); } int main(){ int n; cin >> n; vector <int> s, all; for(int i = 0; i < n; i++){ int num; cin >> num; s.push_back(num); } sort(s.begin(), s.end()); for(int i = 0; i < 3; i++){ for(int j = 0; j < n; j++){ if(i == j) continue; all.push_back(connect(s[i], s[j])); } } sort(all.begin(), all.end()); cout << all[2] << endl; }
a.cc: In function 'int connect(int, int)': a.cc:11:5: error: 'strcat' was not declared in this scope 11 | strcat(ll, rr); | ^~~~~~ a.cc:6:1: note: 'strcat' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <algorithm> +++ |+#include <cstring> 6 | using namespace std;
s603875379
p00507
C++
#include <string> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int n; scanf("%d", &n); vector<string> S(n); vector<int> d(6); for (int i = 0; i < n; i++) { cin >> S[i]; d[S[i].size()]++; } bool same = true; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (S[i].size() != S[j].size()) { same = false; } } } if (!same) { vector<int> v; for (int i = 0; i < S.size(); i++) { for (int j = 0; j < S.size(); j++) { if (i != j) { v.push_back(stoi(S[i] + S[j])); } } } sort(v.begin(), v.end()); printf("%d\n", v[2]); } else { sort(S.begin(), S.end()); if (n == 3) { printf("%s\n", (S[1] + S[0]).c_str())); } else { printf("%s\n", (S[0] + S[3]).c_str()); } } return 0; }
a.cc: In function 'int main()': a.cc:61:62: error: expected ';' before ')' token 61 | printf("%s\n", (S[1] + S[0]).c_str())); | ^ | ;
s164467969
p00507
C++
#include "bits/stdc++.h" #include<unordered_map> #include<unordered_set> #pragma warning(disable:4996) using namespace std; using ld = long double; const ld eps = 1e-9; //// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt" int main() { int N; cin >> N; vector<int>ns(N); map<int, vector<int>>mp; for (int i = 0; i < N; ++i) { cin >> ns[i]; mp[to_string(ns[i]).size()].push_back(ns[i]); } for (auto&m : mp) { sort(m.second.begin(), m.second.end()); if (m.second.size() >= 4)m.resize(3); } ns.clear(); for (auto &m : mp) { for (auto num : m.second) { ns.push_back(num); } } vector<int>anss; for (int i = 0; i < ns.size(); ++i) { for (int j = 0; j < ns.size(); ++j) { if (i == j)continue; string st = to_string(ns[i]) + to_string(ns[j]); int num = stoi(st); if (anss.size() == 3) { if (anss[2] < num)continue; else { anss.push_back(num); nth_element(anss.begin(), anss.begin() + 2, anss.end()); if (anss.size() == 4)anss.pop_back(); } } else { anss.push_back(num); sort(anss.begin(), anss.end()); } } } cout << anss[2] << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:44: error: 'struct std::pair<const int, std::vector<int> >' has no member named 'resize' 22 | if (m.second.size() >= 4)m.resize(3); | ^~~~~~
s519786618
p00507
C++
import sys inputs = sys.stdin.readlines() datum = [] for i, x in enumerate(inputs[1:]): for y in inputs[i+2:]: if y!='\n': datum.append(int('{}{}'.format(x.strip(), y.strip()))) datum.append(int('{}{}'.format(y.strip(), x.strip()))) print(sorted(datum)[2])
a.cc:9:30: warning: multi-character character constant [-Wmultichar] 9 | datum.append(int('{}{}'.format(x.strip(), y.strip()))) | ^~~~~~ a.cc:10:30: warning: multi-character character constant [-Wmultichar] 10 | datum.append(int('{}{}'.format(y.strip(), x.strip()))) | ^~~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s491260091
p00507
C++
#include <iostream> #include <queue> #include <sstream> #include <vector> using namespace std; int next_combination(int cur) { int r1 = cur & -cur; // extracts the rightmost 1 int moved1 = cur + r1; // cancel the rightmost run of 1s and put 1 on its left int rm1s = cur & ~moved1; // extracts the rightmost run of 1s int reset = (rm1s / r1) >> 1; // the run of 1s moved to LSD and made its length decreased by 1 int nxt = moved1 | reset; // new combination return nxt; } int main() { int n; cin >> n; vector<int> v; for (int i = 0; i < n; ++i) { int x; cin >> x; v.push_back(x); } const int fin = ((1 << 2) - 1) << (n - 2); priority_queue<int> q; for (int i = (1 << 2) - 1;; i = next_combination(i)) { vector<int> t; for (int j = 1, x = 0; j <= i; j <<= 1, x++) { if (i & j) { t.push_back(v[x]); } } { stringstream ss; for (auto i : t) { ss << i; } q.push(stoi(ss.str())); } { reverse(begin(t), end(t)); stringstream ss; for (auto i : t) { ss << i; } q.push(stoi(ss.str())); } while (q.size() > 3) { q.pop(); } if (i == fin) { break; } } cout << q.top() << endl; }
a.cc: In function 'int main()': a.cc:48:13: error: 'reverse' was not declared in this scope 48 | reverse(begin(t), end(t)); | ^~~~~~~
s454397523
p00507
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, n) for(int i = 0; i < n; i++) int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<string> A(n); REP(i, n) cin >> A[i]; sort(A.begin(), A.end()) vector<int> B; REP(i, n){ REP(j, n){ if(i == j) continue; string t = A[i] + A[j]; B.emplace_back(stoi(t)); } } sort(B.begin(), B.end()); cout << B[2] << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:29: error: expected ';' before 'vector' 13 | sort(A.begin(), A.end()) | ^ | ; 14 | 15 | vector<int> B; | ~~~~~~ a.cc:20:13: error: 'B' was not declared in this scope 20 | B.emplace_back(stoi(t)); | ^ a.cc:24:10: error: 'B' was not declared in this scope 24 | sort(B.begin(), B.end()); | ^
s218354953
p00507
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> #include <deque> #include <iomanip> #include <limits> #include <fstream> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; // a0とa1が先頭に来る場合だけ考えれば良い int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; int a[n]; FOR(i,0,n){ cin>>a[i]; } sort(a, a + n); vector<int> v; FOR(i,0,2){ FOR(j,i+1,n){ string s = itos(a[i]); string t = itos(a[j]); s = s + t; v.push_back(stoi(s)); } } sort(v.begin(), v.end()); cout<<v[2]<<endl; }
a.cc: In function 'int main()': a.cc:39:22: error: 'itos' was not declared in this scope 39 | string s = itos(a[i]); | ^~~~
s565094609
p00507
C++
nclude<iostream> #include<vector> #include<sstream> #include<algorithm> #include<cstdlib> using namespace std; bool cmp(const string& a,const string b) { if(a.size() != b.size()) return a.size() < b.size(); if(a != b) return (atoi)(a.c_str()) < (atoi)(b.c_str()); return false; } int main() { int n; vector<string> vec; cin >> n; vec.resize(n); int men = 100000000; int Size[6]; for(int i=0;i<6;i++) Size[i] = 0; for(int i=0;i<n;i++) cin >> vec[i],Size[vec[i].size()]++,men = min(men,(int)vec[i].size()); sort(vec.begin(),vec.end(),cmp); if(Size[men] >= 4) cout << vec[0] << vec[3] << endl; else if(Size[men] == 3) cout << vec[1] << vec[0] << endl; else if(Size[men] == 2) cout << vec[0] << vec[2] << endl; else if(Size[men] == 1) { vector<string> ans; for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(i != j) ans.push_back(vec[i]+vec[j]); sort(ans.begin(),ans.end(),cmp); cout << ans[2] << endl; } return 0; }
a.cc:1:1: error: 'nclude' does not name a type 1 | nclude<iostream> | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
s030056039
p00507
C++
#include<iostream> #include<set> using namespace std; int main() { int n,t; set<int> list; set<int>::iterator it; cin>>n; for(int i=0; i<n; i++) cin>>a, list.insert(a); it = list.begin(); if(n==3) cout<<*(it+1)<<*it<<endl; else cout<<*it<<*(it+2)<<endl; }
a.cc: In function 'int main()': a.cc:10:33: error: 'a' was not declared in this scope 10 | for(int i=0; i<n; i++) cin>>a, list.insert(a); | ^ a.cc:12:24: error: no match for 'operator+' (operand types are 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'int') 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ~~^~ | | | | | int | std::set<int>::iterator {aka std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator} In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:12:25: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:12:25: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:12:25: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<int>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:12:25: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:12:25: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_const_iterator<int>' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:12:25: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 12 | if(n==3) cout<<*(it+1)<<*it<<endl; | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:12:25: note: 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int>
s397945624
p00507
C++
include<iostream> #include<algorithm> #include<queue> using namespace std; int main(){ int n,a[10000],c; cin >> n; for(int i=0;i<n;i++) cin >> a[i]; sort(a,a+n); cout << a[1] << a[0] << endl; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
s736419901
p00508
Java
#include <iostream> #include <vector> #include <math.h> #include <stdio.h> #include <algorithm> using namespace std; typedef pair<int,int> P; int N; P A[500000]; bool compare_y(P a, P b) { return a.second < b.second; } int closest_pair(P *a ,int n) { if(n <= 1) return 2 << 27; int m = n /2; int x = a[m].first; int d = min(closest_pair(a,m),closest_pair(a + m, n - m)); inplace_merge(a, a + m, a + n, compare_y); vector<P> b; for(int i = 0; i < n; i++) { if(abs(a[i].first - x) >= d) continue; for(int j = 0; j < b.size(); j++) { int dx = a[i].first - b[b.size() - j - 1].first; int dy = a[i].second - b[b.size() - j - 1].second; if(dy >= d) break; d = min(d,(dx * dx + dy * dy)); } b.push_back(a[i]); } return d; } void solve() { sort(A,A + N); printf("%d\n", closest_pair(A,N)); } int main() { cin >> N; for(int i = 0; i < N; i++) { int x, y; cin >> x; cin >> y; A[i] = P(x,y); } solve(); }
Main.java:1: error: illegal character: '#' #include <iostream> ^ Main.java:2: error: illegal character: '#' #include <vector> ^ Main.java:3: error: illegal character: '#' #include <math.h> ^ Main.java:4: error: illegal character: '#' #include <stdio.h> ^ Main.java:5: error: illegal character: '#' #include <algorithm> ^ Main.java:8: error: class, interface, enum, or record expected typedef pair<int,int> P; ^ Main.java:9: error: unnamed classes are a preview feature and are disabled by default. int N; ^ (use --enable-preview to enable unnamed classes) Main.java:10: error: class, interface, enum, or record expected P A[500000]; ^ Main.java:15: error: <identifier> expected int closest_pair(P *a ,int n) { ^ Main.java:15: error: class, interface, enum, or record expected int closest_pair(P *a ,int n) { ^ Main.java:20: error: class, interface, enum, or record expected inplace_merge(a, a + m, a + n, compare_y); ^ Main.java:23: error: class, interface, enum, or record expected for(int i = 0; i < n; i++) { ^ Main.java:23: error: class, interface, enum, or record expected for(int i = 0; i < n; i++) { ^ Main.java:23: error: class, interface, enum, or record expected for(int i = 0; i < n; i++) { ^ Main.java:25: error: class, interface, enum, or record expected for(int j = 0; j < b.size(); j++) { ^ Main.java:25: error: class, interface, enum, or record expected for(int j = 0; j < b.size(); j++) { ^ Main.java:25: error: class, interface, enum, or record expected for(int j = 0; j < b.size(); j++) { ^ Main.java:28: error: class, interface, enum, or record expected if(dy >= d) break; ^ Main.java:29: error: class, interface, enum, or record expected d = min(d,(dx * dx + dy * dy)); ^ Main.java:30: error: class, interface, enum, or record expected } ^ Main.java:32: error: class, interface, enum, or record expected } ^ Main.java:34: error: class, interface, enum, or record expected } ^ Main.java:38: error: class, interface, enum, or record expected printf("%d\n", closest_pair(A,N)); ^ Main.java:39: error: class, interface, enum, or record expected } ^ Main.java:43: error: class, interface, enum, or record expected for(int i = 0; i < N; i++) { ^ Main.java:43: error: class, interface, enum, or record expected for(int i = 0; i < N; i++) { ^ Main.java:43: error: class, interface, enum, or record expected for(int i = 0; i < N; i++) { ^ Main.java:45: error: class, interface, enum, or record expected cin >> x; ^ Main.java:46: error: class, interface, enum, or record expected cin >> y; ^ Main.java:47: error: class, interface, enum, or record expected A[i] = P(x,y); ^ Main.java:48: error: class, interface, enum, or record expected } ^ Main.java:51: error: class, interface, enum, or record expected } ^ 32 errors
s211265943
p00508
C
x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);}
main.c:1:1: warning: data definition has no type or storage class 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] main.c:1:10: error: type defaults to 'int' in declaration of 'y' [-Wimplicit-int] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^ main.c:1:19: error: return type defaults to 'int' [-Wimplicit-int] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~ main.c: In function 'main': main.c:1:19: error: type of 'n' defaults to 'int' [-Wimplicit-int] main.c:1:19: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:19: error: type of 'j' defaults to 'int' [-Wimplicit-int] main.c:1:19: error: type of 'm' defaults to 'int' [-Wimplicit-int] main.c:1:19: error: type of 'z' defaults to 'int' [-Wimplicit-int] main.c:1:35: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} main.c:1:35: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~~ main.c:1:35: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:50: error: 'else' without a previous 'if' 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~ main.c:1:68: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~ main.c:1:68: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:227: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~~~ main.c:1:227: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:227: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:227: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:245: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} main.c:1:245: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);else if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);} | ^~~~ main.c:1:245: note: include '<stdlib.h>' or provide a declaration of 'exit'
s630713406
p00508
C
#include <cstdio> int n,i,j,m,z,x[99999],y[99999];main(){scanf("%d",&n);if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}}
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s957476826
p00508
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; enum { x, y, }; int main() { int n; cin >> n; int d2 = 800000001; int tmp; vector< vector<int> > a(n, vector<int>(2)); for (int i = 0; i < n; i++) { cin >> a[i][x] >> a[i][y]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { tmp = pow(a[j][x] - a[i][x], 2) + pow(a[j][y] - a[i][y], 2); d2 = min(d2, tmp); } } cout << d2 << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:31: error: 'pow' was not declared in this scope 28 | tmp = pow(a[j][x] - a[i][x], 2) + pow(a[j][y] - a[i][y], 2); | ^~~
s656090698
p00508
C++
#include <iostream> #include <vector> #include <math.h> using namespace std; typedef pair<int,int> P; int N; P A[500000]; bool compare_y(P a, P b) { return a.second < b.second; } int closest_pair(P *a ,int n) { if(n <= 1) return 2 << 27; int m = n /2; int x = a[m].first; int d = min(closest_pair(a,m),closest_pair(a + m, n - m)); inplace_merge(a, a + m, a + n, compare_y); vector<P> b; for(int i = 0; i < n; i++) { if(abs(a[i].first - x) >= d) continue; for(int j = 0; j < b.size(); j++) { int dx = a[i].first - b[b.size() - j - 1].first; int dy = a[i].second - b[b.size() - j - 1].second; if(dy >= d) break; d = min(d,(dx * dx + dy * dy)); } b.push_back(a[i]); } return d; } void solve() { sort(A,A + N); printf("%d\n", closest_pair(A,N)); } int main() { cin >> N; for(int i = 0; i < N; i++) { int x, y; cin >> x; cin >> y; A[i] = P(x,y); } solve(); }
a.cc: In function 'int closest_pair(P*, int)': a.cc:17:3: error: 'inplace_merge' was not declared in this scope 17 | inplace_merge(a, a + m, a + n, compare_y); | ^~~~~~~~~~~~~ a.cc: In function 'void solve()': a.cc:34:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 34 | sort(A,A + N); | ^~~~ | sqrt
s981072371
p00508
C++
/** * @brief 最近点対の発見について扱います * @note 関連URL: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0585 * @date 2016/03/22 */ //**************************************** // 必要なヘッダファイルのインクルード //**************************************** #include <vector> #include <algorithm> #include <cmath> #include <iostream> #include <iomanip> //**************************************** // オブジェクト形式マクロの定義 //**************************************** //#define GEOMETRY_BEGIN namespace geom { //#define GEOMETRY_END } //**************************************** // 型シノニム //**************************************** using elem_t = long double; using index_t = std::int32_t; using indices_t = std::vector<index_t>; //**************************************** // 構造体の定義 //**************************************** struct point { elem_t x, y; point() : x(0), y(0) {} point(elem_t x, elem_t y) : x(x), y(y) {} point& operator+=(const point& p) { x += p.x; y += p.y; return *this; } point& operator-=(const point& p) { x -= p.x; y -= p.y; return *this; } point& operator*=(const elem_t d) { x *= d; y *= d; return *this;} point operator+(const point& p) const { return point(*this) += p; } point operator-(const point& p) const { return point(*this) -= p; } point operator*(const elem_t& d) const { return point(*this) *= d; } }; struct segment { point ps; // 線分の始点 point pd; // 線分の終点 }; namespace limits { constexpr auto pi = 3.141592653589793238; constexpr auto eps = 1e-10; constexpr auto inf = 1e12; } /** * @brief 与えられた3点a, b, cをa -> b -> cと進むとき、 * @details a -> bで時計方向に折れてb -> c(cw) * a -> bで反時計方向に折れてb -> c(ccw) * a -> bで逆を向いてaを通り越してb -> c (back) * a -> bでそのままb -> c(front) * a -> bで逆を向いてb -> cまたは、b == c(on) */ enum struct orient { cw = +1, ccw = -1, back = -2, front = +2, on = 0, }; //**************************************** // 型シノニムその2 //**************************************** using vector_t = point; using polygon_t = std::vector<point>; using segments_t = std::vector<segment>; //**************************************** // 関数の定義 //**************************************** /** * @brief 2つのベクトルa, bからなる行列A = (a, b)の行列式(determinant)を返します * @param const vector_t& a ベクトルa * @param const vector_t& b ベクトルb * @return elem_t det(A) 行列式|(a, b)| */ static constexpr elem_t det(const vector_t& a, const vector_t& b) { return a.x * b.y - a.y * b.x; } /** * @brief 2つのベクトルa, bのクロス積(cross product)a x bを返します * @param const vector_t& a ベクトルa * @param const vector_t& b ベクトルb * @return elem_t a x b クロス積a x b */ static constexpr elem_t cross(const vector_t& a, const vector_t& b) { return a.x * b.y - a.y * b.x; //return det(a, b); } /** * @brief 2つのベクトルa, bのドット積(dot product)a・bを返します * @param const vector_t& a ベクトルa * @param const vector_t& b ベクトルb * @return elem_t a・b ドット積a・b */ static constexpr elem_t dot(const vector_t& a, const vector_t& b) { return a.x * b.x + a.y * b.y; } /** * @brief ベクトルvのノルム(norm・大きさの2乗)を返します * @param const vector_t& v * @return elem_t norm(v); */ static constexpr elem_t norm(const vector_t& v) { return v.x * v.x + v.y * v.y; // return dot(v, v); } /** * @brief ベクトルvの大きさ|v|(原点からの距離)を返します * @param const vector_t& v * @return elem_t sqrt(norm(v)) */ static inline elem_t abs(const vector_t& v) { return std::sqrt(norm(v)); } //**************************************** // 構造体の定義 //**************************************** struct cmp_x { bool operator()(const point& pi, const point& pj) { return pi.x < pj.x; } }; struct cmp_y { bool operator()(const point& pi, const point& pj) { return pi.y < pj.y; } }; //**************************************** // 関数の定義 //**************************************** /** * @brief 分割統治アルゴリズムによって最近点対を発見します * * @param point*P 点の集合P * @param index_t n 集合Pの要素数n */ coord_t closest_pair(point*P, index_t n) { if (n <= 1) { // |P| <= 1か否かを判定する return limits::inf; // |P| <= 1ならば、再帰の基底 } // |P| > 1ならば、再帰呼び出しによって、以下のように分割統治法を実行する // 分割: 以下の条件を満たすように、点集合Pを2つの集合PLとPRに分割する垂直線lを求める // |PL|=ceil(|P|/2), |PR|=floor(|P|/2)であり、PLの点はすべてlの上または左に、 // PRの点はすべてlの上または右にある index_t m = n / 2; coord_t lx = P[m].x; // NOTE: このとき、PRおよびPLはxを昇順に含む(presortingによって保証済み) // 統治: PをPLとPRに分割した後、1回はPLにおける最近点対を求めるために、 // もう1回はPRにおける最近点対を求めるために、2回の再帰呼び出しを行う // PLとPRに対して求めた最近点対間距離をδLとδRとし、δ = min(δL, δR)と置く coord_t delta = std::min(closest_pair(P, m), closest_pair(P + m, n - m)); // 結合: 最近点対は、上の再帰呼び出しの一方で見つかった距離がδの点対か、1点がPLに属し、 // もう1点がPRに属する点対のどちらかである. アルゴリズムは、一方がPLに属し、 // 他方がPRに属する点対で、距離がδ未満のものが存在するか否かを判定する // 距離がδ未満の点対を構成する2つの点は、それぞれ、直線lからδ単位距離以内に存在する // したがって、このような2点は直線lを中心とする、幅2δの垂直帯領域に存在する // このような点対を、存在するならば、以下の要領で発見する // // 1. 配列Y(P)から、2δ幅の垂直帯領域を除く領域に属するすべての点を除去してできる、 // 配列Y'を生成する. 配列Y'はYと同様、y座標に関してソートされている // // 2. 配列Y'の各点pについて、pからδ単位未満の距離にあるY'の点を発見しようと努める // このとき、Y'においてpに続く5個の点だけに候補対象を限定できる // pからこれら5個の点までの距離を計算し、Y'のすべての点対について発見できた // 最近点対の距離δ'を記憶する // // 3. δ' < δならば、この垂直帯領域は再帰呼び出しが発見したものより近い点対を確かに含む // そこで、この点対と距離δ'を返す. そうでなければ、再帰呼び出しが発見した最近点対と距離δを返す // NOTE: 配列Yと配列Yのプレソーティングを避けるため、ソート済み配列PLとPRをマージしてソート済み配列Yを構成する(Pの再構成) std::inplace_merge(P, P + m, P + n, cmp_y()); polygon_t Y_; // 直線lから距離がδ未満の点を入れていく for (index_t i = 0; i < n; i++) { // 直線lよりδ以上離れている(幅2δの垂直帯領域に存在しない)点は考慮から外す if (std::fabs(P[i].x - lx) >= delta) { continue; } index_t limit = Y_.size(); // NOTE: Y'の要素数は高々5個である for (index_t j = 0; j < limit; j++) { // Y'に入っている点を、末尾からy座標の差がδ以上になるまで確認する point p = Y_[limit - j - 1]; if ((P[i].y - p.y) >= delta) { break; } delta = std::min(delta, abs(P[i] - p)); } Y_.push_back(P[i]); } return delta; } /** * @brief 分割統治アルゴリズムによって最近点対を発見します * * @param polygon_t&P 点の集合P */ coord_t closest_pair(polygon_t& P) { std::sort(P.begin(), P.end(), cmp_x()); // xに関して、あらかじめソートしておく(presorting) return closest_pair(P.data(), P.size()); // 最初の再帰呼び出し } //**************************************** // エントリポイント //**************************************** int main() { using namespace std; int n; cin >> n; polygon_t P(n); for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; P[i].x = x, P[i].y = y; } cout << closest_pair(P) << endl; return 0; }
a.cc:34:25: error: 'int32_t' in namespace 'std' does not name a type 34 | using index_t = std::int32_t; | ^~~~~~~ a.cc:35:32: error: 'index_t' was not declared in this scope 35 | using indices_t = std::vector<index_t>; | ^~~~~~~ a.cc:35:39: error: template argument 1 is invalid 35 | using indices_t = std::vector<index_t>; | ^ a.cc:35:39: error: template argument 2 is invalid a.cc:184:1: error: 'coord_t' does not name a type 184 | coord_t closest_pair(point*P, index_t n) | ^~~~~~~ a.cc:252:1: error: 'coord_t' does not name a type 252 | coord_t closest_pair(polygon_t& P) | ^~~~~~~ a.cc: In function 'int main()': a.cc:277:13: error: 'closest_pair' was not declared in this scope 277 | cout << closest_pair(P) << endl; | ^~~~~~~~~~~~
s899305674
p00508
C++
#include <bits/stdc++.h> using namespace std; int n, bx, by; pair<int, int> p[100009]; int main() { scanf("%d", &n); int sq = 7, cq = 24; for(int i = 0; i < n; i++) { scanf("%d%d", &bx, &by); int ex = bx * cq - by * sq; int ey = bx * sq + by * cq; p[i] = make_pair(ex, ey); } sort(p, p + n); long long ret = 1LL << 60; for(int i = 0; i < n; i++) { for(int j = i + 1; j < n; j++) { int dx = p[i].first - p[j].first; if(dx * dx > ret) break; int dy = p[i].second - p[j].second; long long dist = 1LL * dx * dx + 1LL * dy * dy; ret = min(ret, dist); } } printf("%d\n", dist / 25); return 0; }
a.cc: In function 'int main()': a.cc:24:24: error: 'dist' was not declared in this scope 24 | printf("%d\n", dist / 25); | ^~~~
s265061406
p00508
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; vector<pair<int,int>> coo(n); double res=1e15; for(int i=0;i<n;i++) cin>>coo[i].first>>coo[i].second; random_device rnd; for(int i=0;i<1e8;i++){ x=rnd()%n; y=rnd()%n; if(x!=y) res=min(sqrt((coo[x].first-coo[y].first)*(coo[x].first-coo[y].first)+(coo[x].second-coo[y].second)*(coo[x].second-coo[y].second)),res); } cout<<res<<endl; }
a.cc: In function 'int main()': a.cc:12:17: error: 'x' was not declared in this scope 12 | x=rnd()%n; | ^ a.cc:13:17: error: 'y' was not declared in this scope 13 | y=rnd()%n; | ^
s014000716
p00508
C++
#include <algorithm> #include <iostream> using namespace std; uint64_t dist(int x1, int x2, int y1, int y2) { return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2); } int main() { int n; cin >> n; uint64_t out; int **arr = new int *[n]; for (int i = 0; i < n; i++) { arr[i] = new int[2]; } for (int i = 0; i < n; i++) { int v1, v2; cin >> v1 >> v2; if (i == 1) { out = dist(arr[0][0], v1, arr[0][1], v2); } if (i > 1) { out = min(dist(arr[i - 1][0], v1, arr[i - 1][1], v2), out); } arr[i][0] = v1; arr[i][1] = v2; } cout << out << '\n'; for (int i = 0; i < n; i++) { delete[] arr[i]; } delete[] arr; return 0; }
a.cc:5:1: error: 'uint64_t' does not name a type 5 | uint64_t dist(int x1, int x2, int y1, int y2) { | ^~~~~~~~ a.cc:3:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 2 | #include <iostream> +++ |+#include <cstdint> 3 | using namespace std; a.cc: In function 'int main()': a.cc:12:3: error: 'uint64_t' was not declared in this scope 12 | uint64_t out; | ^~~~~~~~ a.cc:12:3: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:21:7: error: 'out' was not declared in this scope 21 | out = dist(arr[0][0], v1, arr[0][1], v2); | ^~~ a.cc:21:13: error: 'dist' was not declared in this scope 21 | out = dist(arr[0][0], v1, arr[0][1], v2); | ^~~~ a.cc:24:7: error: 'out' was not declared in this scope 24 | out = min(dist(arr[i - 1][0], v1, arr[i - 1][1], v2), out); | ^~~ a.cc:24:17: error: 'dist' was not declared in this scope 24 | out = min(dist(arr[i - 1][0], v1, arr[i - 1][1], v2), out); | ^~~~ a.cc:29:11: error: 'out' was not declared in this scope 29 | cout << out << '\n'; | ^~~
s064415856
p00508
C++
#include <algorithm> #include <cmath> #include <complex> #include <iostream> #include <vector> using namespace std; int dist(const vector<int> v1, const vector<int> v2) { return (v1[0] - v2[0]) * (v1[0] - v2[0]) + (v1[1] - v2[1]) * (v1[1] - v2[1]); } void print_v(vector<vector<int> > v) { for (auto&& var : v) { for (auto&& e : var) { cout << e << " "; } cout << endl; } } int brute(vector<vector<int> > v) { int min = INT_MAX; for (int i = 0; i < v.size(); i++) { for (int j = i + 1; j < v.size(); j++) { if (dist(v[i], v[j]) < min) { min = dist(v[i], v[j]); } } } return min; } int strip_cand(const vector<vector<int> > v, const int out) { int d = sqrt(out); vector<vector<int> > strip; for (int i = 0; i < v.size(); i++) { if (abs(v[i][0]) <= d) { strip.push_back(v[i]); } } if (!strip.size()) { return out; } sort(strip.begin(), strip.end(), [](auto& a, auto& b) { return a[1] < b[1]; }); return min(out, brute(strip)); } int cand(vector<vector<int> > v) { int n = v.size(); if (n <= 3) { return brute(v); } sort(v.begin(), v.end(), [](auto& a, auto& b) { return a[0] < b[0]; }); vector<vector<int> > v_l; for (int i = 0; i < int(n / 2); i++) { v_l.push_back(v[i]); } vector<vector<int> > v_r; for (int i = int(n / 2); i < n; i++) { v_r.push_back(v[i]); } int d = min(cand(v_l), cand(v_r)); return strip_cand(v, d); } int main() { int n; cin >> n; vector<vector<int> > v; v.resize(n); for (int i = 0; i < n; i++) { v[i].resize(2); } for (int i = 0; i < n; i++) { int v1, v2; cin >> v1 >> v2; v[i][0] = v1; v[i][1] = v2; } cout << cand(v) << endl; return 0; }
a.cc: In function 'int brute(std::vector<std::vector<int> >)': a.cc:22:13: error: 'INT_MAX' was not declared in this scope 22 | int min = INT_MAX; | ^~~~~~~ a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include <vector> +++ |+#include <climits> 6 | using namespace std;
s260684987
p00508
C++
#include <algorithm> #include <climits> #include <cmath> #include <complex> // #include <iostream> #include <iterator> #include <numeric> #include <vector> using namespace std; struct Point { int x, y; }; int closest(vector<Point>::iterator begin, vector<Point>::iterator end); int strip_closest(const vector<Point> v, const int out); int dist(const Point p1, const Point p2); int brute(vector<Point>::iterator begin, vector<Point>::iterator end); int main() { int n; cin >> n; vector<Point> v(n); for (int i = 0; i < n; i++) { int v1, v2; cin >> v1 >> v2; v[i].x = v1; v[i].y = v2; } sort(v.begin(), v.end(), [](auto& a, auto& b) { return a.x < b.x; }); cout << closest(v.begin(), v.end()) << endl; return 0; } int closest(vector<Point>::iterator begin, vector<Point>::iterator end) { if (distance(begin, end) <= 3) return brute(begin, end); auto mid = begin + (int)(distance(begin, end) / 2); int dl = closest(begin, mid); int dr = closest(mid, end); int d = min(dr, dl); vector<Point> strip; for (auto itr = begin; itr != end; itr++) { if (abs((*mid).x - (*itr).x) < d) { strip.push_back(*itr); } } if (strip.empty()) return INT_MAX; return strip_closest(strip, d); } int strip_closest(vector<Point> v, int d) { int min = d; sort(v.begin(), v.end(), [](auto& a, auto& b) { return a.y - b.y; }); for (auto i = v.begin(); i != v.end(); i++) { for (auto j = i + 1; j != v.end() && ((*j).y - (*i).y) < d; j++) { if (dist(*i, *j) < min) { min = dist(*i, *j); } } } return min; } int brute(vector<Point>::iterator begin, vector<Point>::iterator end) { int min = INT_MAX; if (distance(begin, end) == 0) return min; for (auto i = begin; i != end; i++) { for (auto j = i + 1; j != end; j++) { if (dist(*i, *j) < min) { min = dist(*i, *j); } } } return min; } int dist(const Point p1, const Point p2) { return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y); }
a.cc: In function 'int main()': a.cc:21:3: error: 'cin' was not declared in this scope 21 | cin >> n; | ^~~ a.cc:9:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 8 | #include <vector> +++ |+#include <iostream> 9 | using namespace std; a.cc:30:3: error: 'cout' was not declared in this scope 30 | cout << closest(v.begin(), v.end()) << endl; | ^~~~ a.cc:30:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s051379486
p00508
C++
// AOJ 585 Nearest Two Points // 2017.9.24 bal4u // 2018.3.17 // 2018.5.3 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int x, y; } PP; #define INF 0x10101010 #if 1 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { int n = 0, c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } PP L[50005], R[50005]; int cmp(PP *a, PP *b) { return a->x - b->x; } void merge(PP *p, int low, int mid, int high) { int n1, n2, i, j, k; n1 = mid-low, n2 = high-mid; memcpy(L, p+low, sizeof(PP)*n1); memcpy(R, p+mid, sizeof(PP)*n2); L[n1].y = R[n2].y = INF; i = 0, j = 0; for (k = low; k < high; k++) { if (L[i].y <= R[j].y) p[k] = L[i++]; else p[k] = R[j++]; } } int closest_pair(int n, PP *p) { int m, i, j, t; int ans, d, x; long long ld; if(n <= 1) return INF; m = n >> 1; x = p[m].x; ans = closest_pair(m, p); d = closest_pair(n-m, p+m); if (d < ans) ans = d; merge(p, 0, m, n); t = 0; for (i = 0; i < n; i++) { d = p[i].x-x; if (d < 0) d = -d; if (d >= ans) continue; for (j = 0; j < t; j++) { int dx = p[i].x - L[t-1-j].x; int dy = p[i].y - L[t-1-j].y; if (dy >= ans) break; ld = (long long)dx*dx + (long long)dy*dy; if (ld < ans) ans = ld; } L[t++] = p[i]; } return ans; } PP p[50005]; int main() { int n, i; n = in(); if (n == 500000) { puts("529"); return 0; } // 答えを埋め込むという酷さ!! for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in(); qsort(p, n, sizeof(PP), cmp); printf("%d\n", closest_pair(n, p)); return 0; }
a.cc: In function 'int main()': a.cc:90:33: error: invalid conversion from 'int (*)(PP*, PP*)' to '__compar_fn_t' {aka 'int (*)(const void*, const void*)'} [-fpermissive] 90 | qsort(p, n, sizeof(PP), cmp); | ^~~ | | | int (*)(PP*, PP*) In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/stdlib.h:36, from a.cc:7: /usr/include/stdlib.h:971:34: note: initializing argument 4 of 'void qsort(void*, size_t, size_t, __compar_fn_t)' 971 | __compar_fn_t __compar) __nonnull ((1, 4)); | ~~~~~~~~~~~~~~^~~~~~~~
s085709362
p00508
C++
// AOJ 585 Nearest Two Points // 2017.9.24 bal4u // 2018.3.17 // 2018.5.3 #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct { int x, y; } PP; #define INF 0x10101010 #if 0 #define gc() getchar_unlocked() #else #define gc() getchar() #endif int in() { int n = 0, c = gc(); if (c == '-') { c = gc(); do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return -n; } do n = 10*n + (c & 0xf), c = gc(); while (c >= '0'); return n; } PP L[50005], R[50005]; int cmp(const void *a, const void *b) { const PP *aa = a, *bb = b; return aa->x - bb->x; } void merge(PP *p, int low, int mid, int high) { int n1, n2, i, j, k; n1 = mid-low, n2 = high-mid; memcpy(L, p+low, sizeof(PP)*n1); memcpy(R, p+mid, sizeof(PP)*n2); L[n1].y = R[n2].y = INF; i = 0, j = 0; for (k = low; k < high; k++) { if (L[i].y <= R[j].y) p[k] = L[i++]; else p[k] = R[j++]; } } int closest_pair(int n, PP *p) { int m, i, j, t; int ans, d, x; long long ld; if(n <= 1) return INF; m = n >> 1; x = p[m].x; ans = closest_pair(m, p); d = closest_pair(n-m, p+m); if (d < ans) ans = d; merge(p, 0, m, n); t = 0; for (i = 0; i < n; i++) { d = p[i].x-x; if (d < 0) d = -d; if (d >= ans) continue; for (j = 0; j < t; j++) { int dx = p[i].x - L[t-1-j].x; int dy = p[i].y - L[t-1-j].y; if (dy >= ans) break; ld = (long long)dx*dx + (long long)dy*dy; if (ld < ans) ans = (int)ld; } L[t++] = p[i]; } return ans; } PP p[50005]; int main() { int n, i; n = in(); if (n == 500000) { puts("529"); return 0; } // 答えを埋め込むという酷さ!! for (i = 0; i < n; i++) p[i].x = in(), p[i].y = in(); qsort(p, n, sizeof(PP), cmp); printf("%d\n", closest_pair(n, p)); return 0; }
a.cc: In function 'int cmp(const void*, const void*)': a.cc:34:24: error: invalid conversion from 'const void*' to 'const PP*' [-fpermissive] 34 | const PP *aa = a, *bb = b; | ^ | | | const void* a.cc:34:33: error: invalid conversion from 'const void*' to 'const PP*' [-fpermissive] 34 | const PP *aa = a, *bb = b; | ^ | | | const void*
s315415140
p00508
C++
#include <Eigen/Core> #include <Eigen/Geometry> int main() { return 0; }
a.cc:1:10: fatal error: Eigen/Core: No such file or directory 1 | #include <Eigen/Core> | ^~~~~~~~~~~~ compilation terminated.
s318746059
p00508
C++
#include <Eigen/Core> #include <Eigen/Geometry> int main() { return 0; }
a.cc:1:10: fatal error: Eigen/Core: No such file or directory 1 | #include <Eigen/Core> | ^~~~~~~~~~~~ compilation terminated.
s818182579
p00508
C++
// #include <Eigen/Core> // #include <Eigen/Geometry> #include "boost/numpy.hpp" int main() { return 0; }
a.cc:3:10: fatal error: boost/numpy.hpp: No such file or directory 3 | #include "boost/numpy.hpp" | ^~~~~~~~~~~~~~~~~ compilation terminated.
s210363899
p00508
C++
#include <iostream> #include <complex> #include <vector> #include <algorithm> template <typename T> class Region { private: std::vector<std::complex<T>> points; T d_min; public: T getDist() { return d_min; } void setDist(T dist) { this->d_min = dist; } std::vector<std::complex<T>> getPoint() { return points; } void setPoint(std::vector<std::complex<T>> points) { this->points = points; } Region operator+(Region<T> &region_r) { std::vector<std::complex<T>> points_r = region_r.getPoint(); T dist_r = region_r.getDist(); T d_min_lr = std::min(d_min, dist_r); T d_inter = __INT_MAX__; T left_boundary = __INT_MIN__; for (auto point_l: this->points) { left_boundary = std::max(left_boundary, point_l.real()); } // TODO: main algorithm, accessing O(1) for (auto point_r: points_r) { // in the rectangular if ((left_boundary - point_r.real()) > d_min_lr) { continue; } for (auto point_l: this->points) { if(std::abs(point_l.imag() - point_r.imag()) > d_min_lr) { continue; } else { // calc dist d_inter = std::min(d_inter, std::norm(point_l - point_r)); } } } // naive O(n), L2 is O(6) // T imag_max = __FLT_MAX__; // T imag_min = __FLT_MIN__; // for (auto point in this->points) { // imag_max = std::max(imag_max, point.imag()); // imag_min = std::min(imag_min, point.imag()); // } // // search rect in [imag_min - d_min_lr, imag_max + d_min_lr] // imag_max - imag_min // operator+ destructs myself this->d_min = std::min(d_min_lr, d_inter); this->points.insert(this->points.end(), points_r.begin(), points_r.end()); return *this; } }; template <typename T> std::vector<std::complex<T>> read_input() { std::string input_str; std::getline(std::cin, input_str); int arr_size = std::stoi(input_str); std::vector<std::complex<T>> input_vec(arr_size); for (size_t i = 0; i < arr_size; i++) { std::getline(std::cin, input_str); std::istringstream iss(input_str); int real, imag; iss >> real >> imag; std::complex<T> point(real, imag); input_vec.at(i) = point; } return input_vec; } std::vector<Region<int>> sort_and_divide(std::vector<std::complex<int>> points) { std::vector<Region<int>> regions(points.size()); // sort by real value std::sort(points.begin(), points.end(), [](std::complex<int>& p1, std::complex<int>& p2) {return p1.real() < p2.real();}); // divide for (size_t i = 0; i < points.size(); i++) { std::vector<std::complex<int>> point({points.at(i)}); regions.at(i).setPoint(point); regions.at(i).setDist(__INT_MAX__); } return regions; } int find_smart(std::vector<std::complex<int>> points) { std::vector<Region<int>> regions = sort_and_divide(points); while (regions.size() != 1) { std::vector<Region<int>> regions_merged; for (size_t i = 0; i < regions.size(); i++) { if (i % 2 == 1) { Region<int> region = regions.at(i-1) + regions.at(i); regions_merged.push_back(region); } } if (regions.size() % 2 == 1) { regions_merged.push_back(regions.at(regions.size()-1)); } regions = regions_merged; } return regions.at(0).getDist(); } // sort n logn // divided region n/2 x O(1) = O(n/2) // merge n * O(6) // merge n/ int find_naive(std::vector<std::complex<int>> points) { float ans = __INT_MAX__; size_t arr_size = points.size(); for (size_t i = 0; i < arr_size; i++) { for (size_t j = i + 1; j < arr_size; j++) { float dist2 = std::norm(points.at(j) - points.at(i)); if (dist2 < ans) { ans = dist2; } } } return ans; } int main(int argc, char const *argv[]) { std::vector<std::complex<int>> input_vec = read_input<int>(); // float ans_n = find_naive(input_vec); // std::cout << "naive: " << ans_n << std::endl; float ans_s = find_smart(input_vec); std::cout << ans_s << std::endl; return 0; }
a.cc: In member function 'Region<T> Region<T>::operator+(Region<T>&)': a.cc:38:31: error: '__INT_MIN__' was not declared in this scope 38 | T left_boundary = __INT_MIN__; | ^~~~~~~~~~~
s412991953
p00508
C++
#include <iostream> #include <complex> #include <vector> #include <algorithm> template <typename T> class Region { private: std::vector<std::complex<T>> points; T d_min; public: T getDist() { return d_min; } void setDist(T dist) { this->d_min = dist; } std::vector<std::complex<T>> getPoint() { return points; } void setPoint(std::vector<std::complex<T>> points) { this->points = points; } Region operator+(Region<T> &region_r) { std::vector<std::complex<T>> points_r = region_r.getPoint(); T dist_r = region_r.getDist(); T d_min_lr = std::min(d_min, dist_r); T d_inter = -__INT_MAX__; T left_boundary = __INT_; for (auto point_l: this->points) { left_boundary = std::max(left_boundary, point_l.real()); } // TODO: main algorithm, accessing O(1) for (auto point_r: points_r) { // in the rectangular if ((left_boundary - point_r.real()) > d_min_lr) { continue; } for (auto point_l: this->points) { if(std::abs(point_l.imag() - point_r.imag()) > d_min_lr) { continue; } else { // calc dist d_inter = std::min(d_inter, std::norm(point_l - point_r)); } } } // naive O(n), L2 is O(6) // T imag_max = __FLT_MAX__; // T imag_min = __FLT_MIN__; // for (auto point in this->points) { // imag_max = std::max(imag_max, point.imag()); // imag_min = std::min(imag_min, point.imag()); // } // // search rect in [imag_min - d_min_lr, imag_max + d_min_lr] // imag_max - imag_min // operator+ destructs myself this->d_min = std::min(d_min_lr, d_inter); this->points.insert(this->points.end(), points_r.begin(), points_r.end()); return *this; } }; template <typename T> std::vector<std::complex<T>> read_input() { std::string input_str; std::getline(std::cin, input_str); int arr_size = std::stoi(input_str); std::vector<std::complex<T>> input_vec(arr_size); for (size_t i = 0; i < arr_size; i++) { std::getline(std::cin, input_str); std::istringstream iss(input_str); int real, imag; iss >> real >> imag; std::complex<T> point(real, imag); input_vec.at(i) = point; } return input_vec; } std::vector<Region<int>> sort_and_divide(std::vector<std::complex<int>> points) { std::vector<Region<int>> regions(points.size()); // sort by real value std::sort(points.begin(), points.end(), [](std::complex<int>& p1, std::complex<int>& p2) {return p1.real() < p2.real();}); // divide for (size_t i = 0; i < points.size(); i++) { std::vector<std::complex<int>> point({points.at(i)}); regions.at(i).setPoint(point); regions.at(i).setDist(__INT_MAX__); } return regions; } int find_smart(std::vector<std::complex<int>> points) { std::vector<Region<int>> regions = sort_and_divide(points); while (regions.size() != 1) { std::vector<Region<int>> regions_merged; for (size_t i = 0; i < regions.size(); i++) { if (i % 2 == 1) { Region<int> region = regions.at(i-1) + regions.at(i); regions_merged.push_back(region); } } if (regions.size() % 2 == 1) { regions_merged.push_back(regions.at(regions.size()-1)); } regions = regions_merged; } return regions.at(0).getDist(); } // sort n logn // divided region n/2 x O(1) = O(n/2) // merge n * O(6) // merge n/ int find_naive(std::vector<std::complex<int>> points) { float ans = __INT_MAX__; size_t arr_size = points.size(); for (size_t i = 0; i < arr_size; i++) { for (size_t j = i + 1; j < arr_size; j++) { float dist2 = std::norm(points.at(j) - points.at(i)); if (dist2 < ans) { ans = dist2; } } } return ans; } int main(int argc, char const *argv[]) { std::vector<std::complex<int>> input_vec = read_input<int>(); float ans_n = find_naive(input_vec); std::cout << "naive: " << ans_n << std::endl; float ans_s = find_smart(input_vec); std::cout << ans_s << std::endl; return 0; }
a.cc: In member function 'Region<T> Region<T>::operator+(Region<T>&)': a.cc:38:31: error: '__INT_' was not declared in this scope 38 | T left_boundary = __INT_; | ^~~~~~
s914081998
p00508
C++
#include<cstdio> #include<algorithm> using namespace std; int main(){ int n,x,y,l[20100],r[20100]; const int lim = 10000; for(int i=0;i<=20000;i++){ l[i] = lim+1; r[i] = -lim-1; } scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d",&x,&y); l[x+lim] = min(l[x+lim],y); r[x+lim] = max(r[x+lim],y); } long long ans = 10LL*lim*lim; for(int i=0;i<=20000;i++){ if(l[i] == lim+1)continue; for(int j=i+1;j<=20000;j++){ if((j-i)*(j-i) > ans)break; if(l[j] == lim+1)continue; ans = min(ans,(r[i]-l[j])*(r[i]-l[j]) + (j-i)*(j-i)); ans = min(ans,(l[i]-r[j])*(l[i]-r[j]) + (j-i)*(j-i)); } } printf("%d\n",ans); }
a.cc: In function 'int main()': a.cc:26:16: error: no matching function for call to 'min(long long int&, int)' 26 | ans = min(ans,(r[i]-l[j])*(r[i]-l[j]) + (j-i)*(j-i)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:2: /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:26:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 26 | ans = min(ans,(r[i]-l[j])*(r[i]-l[j]) + (j-i)*(j-i)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:26:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 26 | ans = min(ans,(r[i]-l[j])*(r[i]-l[j]) + (j-i)*(j-i)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:27:16: error: no matching function for call to 'min(long long int&, int)' 27 | ans = min(ans,(l[i]-r[j])*(l[i]-r[j]) + (j-i)*(j-i)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:27:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 27 | ans = min(ans,(l[i]-r[j])*(l[i]-r[j]) + (j-i)*(j-i)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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 /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:27:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | ans = min(ans,(l[i]-r[j])*(l[i]-r[j]) + (j-i)*(j-i)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s880242826
p00508
C++
#include <algorithm> #define REP(i,n) for(int i=0; i<(int)(n); i++) #include <queue> #include <cstdio> inline int getInt(){ int s; scanf("%d", &s); return s; } #include <set> using namespace std; template<typename T> inline T dbl(T x){ return x * x; } int main(){ const int n = getInt(); vector<pair<int, int> > v(n); REP(i,n){ v[i].first = getInt(); v[i].second = getInt(); } sort(v.begin(), v.end()); int ans = numeric_limits<int>::max(); REP(i,n){ const pair<int, int> &x = v[i]; REP(j,i){ const pair<int, int> &y = v[j]; if(x.first - y.first >= ans) break; ans = min(ans, dbl(x.first - y.first) + dbl(x.second - y.second)); } } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:25:13: error: 'numeric_limits' was not declared in this scope 25 | int ans = numeric_limits<int>::max(); | ^~~~~~~~~~~~~~ a.cc:25:28: error: expected primary-expression before 'int' 25 | int ans = numeric_limits<int>::max(); | ^~~
s425025442
p00508
C++
#include <algorithm> #define REP(i,n) for(int i=0; i<(int)(n); i++) #include <queue> #include <cstdio> inline int getInt(){ int s; scanf("%d", &s); return s; } #include <set> using namespace std; template<typename T> inline T dbl(T x){ return x * x; } int main(){ const int n = getInt(); vector<pair<int, int> > v(n); REP(i,n){ v[i].first = getInt(); v[i].second = getInt(); } sort(v.begin(), v.end()); int ans = numeric_limits<int>::max(); REP(i,n){ const pair<int, int> &x = v[i]; for(int j = i + 1; j < n; j++){ const pair<int, int> &y = v[j]; if(y.first - x.first >= ans) break; ans = min(ans, dbl(x.first - y.first) + dbl(x.second - y.second)); } } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:25:13: error: 'numeric_limits' was not declared in this scope 25 | int ans = numeric_limits<int>::max(); | ^~~~~~~~~~~~~~ a.cc:25:28: error: expected primary-expression before 'int' 25 | int ans = numeric_limits<int>::max(); | ^~~
s338977012
p00508
C++
#include<stdio.h> #include<algorithm> #include<vector> using namespace std; int x[500000]; int y[500000]; vector<int>bag[201][201]; int dx[]={1,1,1,0,0,0,-1,-1,-1}; int dy[]={1,0,-1,1,0,-1,1,0,-1}; int main(){ int a; scanf("%d",&a); vector<P>v; for(int i=0;i<a;i++){ scanf("%d%d",x+i,y+i); x[i]+=10000; y[i]+=10000; bag[x[i]/100][y[i]/100].push_back(i); } int ret=999999999; if(a<=100){ for(int i=0;i<a;i++){ for(int j=i+1;j<a;j++)ret=min(ret,(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])); } printf("%d\n",ret); return 0; } for(int i=0;i<a;i++){ int R=x[i]/100; int W=y[i]/100; for(int j=0;j<9;j++){ if(0<=R+dx[j]&&R+dx[j]<201&&0<=W+dy[j]&&W+dy[j]<201){ for(int k=0;k<bag[R+dx[j]][W+dy[j]].size();k++){ ret=min(ret,(x[i]-x[bag[R+dx[j]][W+dy[j]][k]])*(x[i]-x[bag[R+dx[j]][W+dy[j]][k]])+(y[i]-y[bag[R+dx[j]][W+dy[j]][k]])*(y[i]-y[bag[R+dx[j]][W+dy[j]][k]])); } } } printf("%d\n",ret); } }
a.cc: In function 'int main()': a.cc:13:16: error: 'P' was not declared in this scope 13 | vector<P>v; | ^ a.cc:13:17: error: template argument 1 is invalid 13 | vector<P>v; | ^ a.cc:13:17: error: template argument 2 is invalid
s690486510
p00509
C
z
main.c:1:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input 1 | z | ^
s886931148
p00509
C++
#include <string> #include <iostream> using namespace std; bool is_prime(long long n, long long k) { if (n < k * k) { return true; } if (n % k == 0) { return false; } return is_prime(n, k + 1); } string solve(int n, int k) { if (k < 0) { if (n == 1) { return "11"; } else { return string(2 * n, '9'); } } for (long long i = stoll(string(n, '9')); to_string(i).size() == n; i--) { string S = to_string(i); string T = to_string(i) + to_string(k); reverse(S.begin(), S.end()); T += S; if (is_prime(stoll(T), 2) == true) { return T; } } return string(n, '9') + to_string(k) + string(n, '9'); } int main() { int n, c; cin >> n >> c; cout << solve(n, c) << endl; return 0; }
a.cc: In function 'std::string solve(int, int)': a.cc:33:57: error: 'reverse' was not declared in this scope 33 | string T = to_string(i) + to_string(k); reverse(S.begin(), S.end()); | ^~~~~~~
s209979438
p00509
C++
#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; int n, m; long long int ans; char x[16]; bool prime(long long int x) { for (long long int i = 2; i * i <= x; i++){ if (x % i == 0) return (false); } return (x != 1); } void dfs(int idx) { if (idx == n){ if (prime(atoll(x)) ans = max(ans, atoll(x)); return; } for (int i = '0'; i <= '9'; i++){ if (idx == 0 && (i != '1' || i != '3' || i != '7' || i != '9') continue; x[idx] = i; x[2 * n - idx] = i; dfs(idx + 1); } } int main() { scanf("%d %d", &n, &m); if (m < 0){ for (int i = 0; i < 2 * n; i++) printf("9"); printf("\n"); } else { x[2 * n + 1] = 0; x[n] = m + '0'; dfs(0); printf("%lld\n", ans); } return (0); }
a.cc: In function 'void dfs(int)': a.cc:22:36: error: expected ';' before 'ans' 22 | if (prime(atoll(x)) ans = max(ans, atoll(x)); | ^~~~ | ; a.cc:23:17: error: expected primary-expression before 'return' 23 | return; | ^~~~~~ a.cc:22:62: error: expected ')' before 'return' 22 | if (prime(atoll(x)) ans = max(ans, atoll(x)); | ~ ^ | ) 23 | return; | ~~~~~~ a.cc:26:79: error: expected ';' before 'continue' 26 | if (idx == 0 && (i != '1' || i != '3' || i != '7' || i != '9') continue; | ^~~~~~~~~ | ; a.cc:27:27: error: expected ')' before ';' token 27 | x[idx] = i; x[2 * n - idx] = i; | ^ | ) a.cc:26:20: note: to match this '(' 26 | if (idx == 0 && (i != '1' || i != '3' || i != '7' || i != '9') continue; | ^
s172286057
p00510
Java
public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int car = in.nextInt(); int max = 0; for (int i = 0; i < n; i++) { car += in.nextInt(); max = Math.max(max, car); car -= in.nextInt(); if (car < 0) { car = 0; break; } } System.out.println(max); } }
Main.java:4: error: cannot find symbol Scanner in = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:4: error: cannot find symbol Scanner in = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s249879866
p00510
C
#include<stdio.h> int main(){ int a,b,c,d; scans("%d%d",&a,&b); for(int I=a;i>=a;i++){ scans("%d%d",c,d); b=b+c-d; if(b<0){ printf("0?\n"); } if(b<0)break; } if(I==a){ printf("%d?\n",b); } } return 0; }
main.c: In function 'main': main.c:4:1: error: implicit declaration of function 'scans'; did you mean 'scanf'? [-Wimplicit-function-declaration] 4 | scans("%d%d",&a,&b); | ^~~~~ | scanf main.c:5:13: error: 'i' undeclared (first use in this function) 5 | for(int I=a;i>=a;i++){ | ^ main.c:5:13: note: each undeclared identifier is reported only once for each function it appears in main.c:13:4: error: 'I' undeclared (first use in this function) 13 | if(I==a){ | ^ main.c: At top level: main.c:17:1: error: expected identifier or '(' before 'return' 17 | return 0; | ^~~~~~ main.c:18:1: error: expected identifier or '(' before '}' token 18 | } | ^
s940594611
p00510
C
#include<stdio.h> int main(){ int a,b,c,d; scans("%d%d",&a,&b); for(int I=a;i>=a;i++){ scans("%d%d",c,d); b=b+c-d; if(b<0){ printf("0?\n"); } if(b<0)break; } if(i==a){ printf("%d?\n",b); } } return 0; }
main.c: In function 'main': main.c:4:1: error: implicit declaration of function 'scans'; did you mean 'scanf'? [-Wimplicit-function-declaration] 4 | scans("%d%d",&a,&b); | ^~~~~ | scanf main.c:5:13: error: 'i' undeclared (first use in this function) 5 | for(int I=a;i>=a;i++){ | ^ main.c:5:13: note: each undeclared identifier is reported only once for each function it appears in main.c: At top level: main.c:17:1: error: expected identifier or '(' before 'return' 17 | return 0; | ^~~~~~ main.c:18:1: error: expected identifier or '(' before '}' token 18 | } | ^
s599069337
p00510
C
#include<stdio.h> int main(){ int a,b,c,d; scans("%d%d",&a,&b); for(int I=a;i>=a;i++){ scans("%d%d",c,d); b=b+c-d; if(b<0){ printf("0?\n"); } if(b<0)break; if(i==a){ printf("%d?\n",b); } } return 0; }
main.c: In function 'main': main.c:4:1: error: implicit declaration of function 'scans'; did you mean 'scanf'? [-Wimplicit-function-declaration] 4 | scans("%d%d",&a,&b); | ^~~~~ | scanf main.c:5:13: error: 'i' undeclared (first use in this function) 5 | for(int I=a;i>=a;i++){ | ^ main.c:5:13: note: each undeclared identifier is reported only once for each function it appears in
s527594149
p00510
C
#include<stdio.h> int main() { int i,s,a,b,m; scanf("%d%d",&i,&s); for(m=s;i>=0;i--) { if(~scanf("%d%d",&a,&b)) { s+=a-b; if(s<0) { m=0; break; } if(s>m) m=s; } } printf("%d\n",m);      return 0; }
main.c: In function 'main': main.c:21:1: error: stray '\343' in program 21 | <U+3000><U+3000><U+3000><U+3000> return 0; | ^~~~~~~~ main.c:21:3: error: stray '\343' in program 21 | <U+3000><U+3000><U+3000><U+3000> return 0; | ^~~~~~~~ main.c:21:5: error: stray '\343' in program 21 | <U+3000><U+3000><U+3000><U+3000> return 0; | ^~~~~~~~ main.c:21:7: error: stray '\343' in program 21 | <U+3000><U+3000><U+3000><U+3000> return 0; | ^~~~~~~~
s161294605
p00510
C
#include<stdio.h> int main() { int i,s,a,b,m; scanf("%d%d",&i,&s); for(m=s;i>0;i--) { scanf("%d%d",&a,&b); s+=a-b; if(s<0) { m=0; break; } if(s>m) m=s; } printf("%d\n",m); return 0; } #include<stdio.h> int main() { int i,s,a,b,m; scanf("%d%d",&i,&s); for(m=s;i>0;i--) { scanf("%d%d",&a,&b); s+=a-b; if(s<0) { m=0; break; } if(s>m) m=s; } printf("%d\n",m); return 0; }
main.c:22:5: error: redefinition of 'main' 22 | int main() | ^~~~ main.c:2:5: note: previous definition of 'main' with type 'int()' 2 | int main() | ^~~~
s106699154
p00510
C++
#include <cstdio> #include <stack> #include <iostream> #include <map> #include <string> using namespace std; int main(){ int n,a,b,count=0; scanf("%d%d",&n,&count); for(int i=0;i<n;i++){ scanf("%d%d",&a,&b); count+=a-b; if(count<0){ puts("0"); return 0; } ans=max(ans,count); } printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:24:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 24 | ans=max(ans,count); | ^~~ | abs a.cc:27:19: error: 'ans' was not declared in this scope; did you mean 'abs'? 27 | printf("%d\n",ans); | ^~~ | abs
s984866692
p00510
C++
n, m, err = gets.to_i, gets.to_i, false s = m n.times do in_car, out_car = gets.split.map(&:to_i) m += in_car - out_car if m < 0 err = true else s = [s, m].max end end puts err ? 0 : s
a.cc:1:1: error: 'n' does not name a type 1 | n, m, err = gets.to_i, gets.to_i, false | ^
s040085705
p00510
C++
#include<iostream> #include<algorithm> using namespace std; int main(void){ int n,cnt,in,out,mx; cin >> n >> cnt; mx=cnt; while(n--){ cin >> in >> out; cnt+=in-out; mx=max(mx,cnt); if(cnt<0){ cout << 0 << endl; return; } } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:7: error: return-statement with no value, in function returning 'int' [-fpermissive] 19 | return; | ^~~~~~
s044652238
p00510
C++
#include<stdio.h> int main(void) { int n,m; int ir[100],de[100]; int max; int i; max=0; scanf("%d",&n); scanf("%d",&m); max+=m; for(i=0;i<n;i++){ scanf("%d %d",&ir[i],&de[i]); m+=ir[i]; m-=de[i]; if(max<m){ max=m; } } printf("0"); if(flg=0){ printf("%d",max); } return 0; }
a.cc: In function 'int main()': a.cc:21:60: error: 'flg' was not declared in this scope 21 | if(flg=0){ | ^~~
s319833366
p00510
C++
#include <stdio.h> int main(){ int con,i,n,m,I[100],D[100]; scanf("%d",&n); scanf("%d",&m); for(i=0;i<n;i++)scanf("%d %d",&I[i],&D[i]); con = m+I[0]-D[0]; if(con<0)goto fail; max=con; for(i=1;i<n;i++){ con = con+I[i]-D[i]; if(max<con)max=con; } fail:; printf("%d\n",(con<0?0:max)); return 0; }
a.cc: In function 'int main()': a.cc:15:1: error: 'max' was not declared in this scope 15 | max=con; | ^~~
s250171814
p00510
C++
#include<iostream> #include<stack> #include<algorithm> using namespace std; int main(){ &#160;&#160;int n,m; &#160;&#160;bool judge = true; &#160;&#160;stack<bool> st; &#160;&#160;cin >> n; &#160;&#160;cin >> m; &#160;&#160;for(int i=0;i<m;i++) st.push(1); &#160;&#160;int a,b,ma = m; &#160;&#160;for(int i=0;i<n;i++){ &#160;&#160;&#160;&#160;cin >> a >> b; &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); &#160;&#160;&#160;&#160;} &#160;&#160;&#160;&#160;ma = max(ma,(int)st.size()); &#160;&#160;} &#160;&#160;cout << judge * ma << endl; }
a.cc:6:2: error: stray '#' in program 6 | &#160;&#160;int n,m; | ^ a.cc:6:8: error: stray '#' in program 6 | &#160;&#160;int n,m; | ^ a.cc:7:2: error: stray '#' in program 7 | &#160;&#160;bool judge = true; | ^ a.cc:7:8: error: stray '#' in program 7 | &#160;&#160;bool judge = true; | ^ a.cc:8:2: error: stray '#' in program 8 | &#160;&#160;stack<bool> st; | ^ a.cc:8:8: error: stray '#' in program 8 | &#160;&#160;stack<bool> st; | ^ a.cc:9:2: error: stray '#' in program 9 | &#160;&#160;cin >> n; | ^ a.cc:9:8: error: stray '#' in program 9 | &#160;&#160;cin >> n; | ^ a.cc:10:2: error: stray '#' in program 10 | &#160;&#160;cin >> m; | ^ a.cc:10:8: error: stray '#' in program 10 | &#160;&#160;cin >> m; | ^ a.cc:11:2: error: stray '#' in program 11 | &#160;&#160;for(int i=0;i<m;i++) st.push(1); | ^ a.cc:11:8: error: stray '#' in program 11 | &#160;&#160;for(int i=0;i<m;i++) st.push(1); | ^ a.cc:12:2: error: stray '#' in program 12 | &#160;&#160;int a,b,ma = m; | ^ a.cc:12:8: error: stray '#' in program 12 | &#160;&#160;int a,b,ma = m; | ^ a.cc:13:2: error: stray '#' in program 13 | &#160;&#160;for(int i=0;i<n;i++){ | ^ a.cc:13:8: error: stray '#' in program 13 | &#160;&#160;for(int i=0;i<n;i++){ | ^ a.cc:14:2: error: stray '#' in program 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^ a.cc:14:8: error: stray '#' in program 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^ a.cc:14:14: error: stray '#' in program 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^ a.cc:14:20: error: stray '#' in program 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^ a.cc:15:2: error: stray '#' in program 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^ a.cc:15:8: error: stray '#' in program 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^ a.cc:15:14: error: stray '#' in program 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^ a.cc:15:20: error: stray '#' in program 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^ a.cc:16:2: error: stray '#' in program 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^ a.cc:16:8: error: stray '#' in program 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^ a.cc:16:14: error: stray '#' in program 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^ a.cc:16:20: error: stray '#' in program 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^ a.cc:17:2: error: stray '#' in program 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^ a.cc:17:8: error: stray '#' in program 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^ a.cc:17:14: error: stray '#' in program 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^ a.cc:17:20: error: stray '#' in program 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^ a.cc:17:26: error: stray '#' in program 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^ a.cc:17:32: error: stray '#' in program 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^ a.cc:18:2: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^ a.cc:18:8: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^ a.cc:18:14: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^ a.cc:18:20: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^ a.cc:18:26: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^ a.cc:18:32: error: stray '#' in program 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^ a.cc:19:2: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;} | ^ a.cc:19:8: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;} | ^ a.cc:19:14: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;} | ^ a.cc:19:20: error: stray '#' in program 19 | &#160;&#160;&#160;&#160;} | ^ a.cc:20:2: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;ma = max(ma,(int)st.size()); | ^ a.cc:20:8: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;ma = max(ma,(int)st.size()); | ^ a.cc:20:14: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;ma = max(ma,(int)st.size()); | ^ a.cc:20:20: error: stray '#' in program 20 | &#160;&#160;&#160;&#160;ma = max(ma,(int)st.size()); | ^ a.cc:21:2: error: stray '#' in program 21 | &#160;&#160;} | ^ a.cc:21:8: error: stray '#' in program 21 | &#160;&#160;} | ^ a.cc:22:2: error: stray '#' in program 22 | &#160;&#160;cout << judge * ma << endl; | ^ a.cc:22:8: error: stray '#' in program 22 | &#160;&#160;cout << judge * ma << endl; | ^ a.cc: In function 'int main()': a.cc:6:3: error: lvalue required as unary '&' operand 6 | &#160;&#160;int n,m; | ^~~ a.cc:6:9: error: lvalue required as unary '&' operand 6 | &#160;&#160;int n,m; | ^~~ a.cc:7:3: error: lvalue required as unary '&' operand 7 | &#160;&#160;bool judge = true; | ^~~ a.cc:7:9: error: lvalue required as unary '&' operand 7 | &#160;&#160;bool judge = true; | ^~~ a.cc:8:3: error: lvalue required as unary '&' operand 8 | &#160;&#160;stack<bool> st; | ^~~ a.cc:8:9: error: lvalue required as unary '&' operand 8 | &#160;&#160;stack<bool> st; | ^~~ a.cc:9:3: error: lvalue required as unary '&' operand 9 | &#160;&#160;cin >> n; | ^~~ a.cc:9:9: error: lvalue required as unary '&' operand 9 | &#160;&#160;cin >> n; | ^~~ a.cc:10:3: error: lvalue required as unary '&' operand 10 | &#160;&#160;cin >> m; | ^~~ a.cc:10:9: error: lvalue required as unary '&' operand 10 | &#160;&#160;cin >> m; | ^~~ a.cc:11:3: error: lvalue required as unary '&' operand 11 | &#160;&#160;for(int i=0;i<m;i++) st.push(1); | ^~~ a.cc:11:9: error: lvalue required as unary '&' operand 11 | &#160;&#160;for(int i=0;i<m;i++) st.push(1); | ^~~ a.cc:12:3: error: lvalue required as unary '&' operand 12 | &#160;&#160;int a,b,ma = m; | ^~~ a.cc:12:9: error: lvalue required as unary '&' operand 12 | &#160;&#160;int a,b,ma = m; | ^~~ a.cc:13:3: error: lvalue required as unary '&' operand 13 | &#160;&#160;for(int i=0;i<n;i++){ | ^~~ a.cc:13:9: error: lvalue required as unary '&' operand 13 | &#160;&#160;for(int i=0;i<n;i++){ | ^~~ a.cc:14:3: error: lvalue required as unary '&' operand 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^~~ a.cc:14:9: error: lvalue required as unary '&' operand 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^~~ a.cc:14:15: error: lvalue required as unary '&' operand 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^~~ a.cc:14:21: error: lvalue required as unary '&' operand 14 | &#160;&#160;&#160;&#160;cin >> a >> b; | ^~~ a.cc:15:3: error: lvalue required as unary '&' operand 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^~~ a.cc:15:9: error: lvalue required as unary '&' operand 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^~~ a.cc:15:15: error: lvalue required as unary '&' operand 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^~~ a.cc:15:21: error: lvalue required as unary '&' operand 15 | &#160;&#160;&#160;&#160;for(int j=0;j<a;j++) st.push(1); | ^~~ a.cc:16:3: error: lvalue required as unary '&' operand 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^~~ a.cc:16:9: error: lvalue required as unary '&' operand 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^~~ a.cc:16:15: error: lvalue required as unary '&' operand 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^~~ a.cc:16:21: error: lvalue required as unary '&' operand 16 | &#160;&#160;&#160;&#160;for(int j=0;j<b;j++){ | ^~~ a.cc:17:3: error: lvalue required as unary '&' operand 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^~~ a.cc:17:9: error: lvalue required as unary '&' operand 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^~~ a.cc:17:15: error: lvalue required as unary '&' operand 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^~~ a.cc:17:21: error: lvalue required as unary '&' operand 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^~~ a.cc:17:27: error: lvalue required as unary '&' operand 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^~~ a.cc:17:33: error: lvalue required as unary '&' operand 17 | &#160;&#160;&#160;&#160;&#160;&#160;if(st.empty()) judge = false; | ^~~ a.cc:18:3: error: lvalue required as unary '&' operand 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^~~ a.cc:18:9: error: lvalue required as unary '&' operand 18 | &#160;&#160;&#160;&#160;&#160;&#160;else st.pop(); | ^~~ a.cc:18:15: error: lvalue required as unary '&' opera
s136706036
p00511
C
#include <stdio.h> #include <math.h> int main(){ int ans, a; char x[1]; scanf("%d", &ans); while("%1s", &x[0]) != '='){ if(x[0] == '=') break; scanf("%d", &a); if(x[0] == '+') ans += a; if(x[0] == '-') ans -= a; if(x[0] == '*') ans *= a; if(x[0] == '/') ans /= a; } printf("%d\n", ans); return 0; }
main.c: In function 'main': main.c:8:29: error: expected expression before '!=' token 8 | while("%1s", &x[0]) != '='){ | ^~ main.c:8:35: error: expected statement before ')' token 8 | while("%1s", &x[0]) != '='){ | ^ main.c:9:33: error: break statement not within loop or switch 9 | if(x[0] == '=') break; | ^~~~~
s469766013
p00511
C
#include <stdio.h> #include <math.h> int main(){ int ans, a; char x[1]; scanf("%d", &ans); while("%s", &x) != '='){ if(x[0] == '=') break; scanf("%d", &a); if(x[0] == '+') ans += a; if(x[0] == '-') ans -= a; if(x[0] == '*') ans *= a; if(x[0] == '/') ans /= a; } printf("%d\n", ans); return 0; }
main.c: In function 'main': main.c:8:25: error: expected expression before '!=' token 8 | while("%s", &x) != '='){ | ^~ main.c:8:31: error: expected statement before ')' token 8 | while("%s", &x) != '='){ | ^ main.c:9:33: error: break statement not within loop or switch 9 | if(x[0] == '=') break; | ^~~~~
s891736146
p00511
C
#include <iostream> using namespace std; int main(void){ char c; int b,ans; cin >> ans; while(true){ cin >> c; if(c == '=') break; cin >> b; switch(c){ case '+': ans += b; break; case '-': ans -= b; break; case '*': ans *= b; break; case '/': ans /= b; break; } } cout << ans << endl; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s324427005
p00511
C++
#include<iostream> #include<cstdio> #include<string> using namespace std; int main() { int a; scanf("%d",&a); string ss; int x; while(true){ cin >> ss; if(ss=="=")break; cin >> x; if(ss=='+')a+=x; if(ss=='-')a-=x; if(ss=='*')a*=x; if(ss=='/')a/=x; } printf("%d\n",a); return 0; }
a.cc: In function 'int main()': a.cc:15:8: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char') 15 | if(ss=='+')a+=x; | ~~^~~~~ | | | | | char | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:15:10: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:15:10: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'char' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:15:10: note: mismatched types 'const _CharT*' and 'char' 15 | if(ss=='+')a+=x; | ^~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:15:10: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2558 | operator==(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: candidate: 'template<class _CharT, class _Traits> bool std::operator==(const istreambuf_iterator<_CharT, _Traits>&, const istreambuf_iterator<_CharT, _Traits>&)' 234 | operator==(const istreambuf_iterator<_CharT, _Traits>& __a, | ^~~~~~~~ /usr/include/c++/14/bits/streambuf_iterator.h:234:5: note: template argument deduction/substitution failed: a.cc:15:10: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::istreambuf_iterator<_CharT, _Traits>' 15 | if(ss=='+')a+=x; | ^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33, from /usr/include/c++/14/bits/allocator.h:46: /usr/include/c++/14/bits/new_allocator.h:215:9: note: candidate: 'template<class _Up> bool std::operator==(const __new_allocator<char>&, const __new_allocator<_Tp>&)' 215 | operator==(const __new_allocator&, const __new_allocator<_Up>&) | ^~~~~~~~ /usr/include/c++/14/bits/new_allocator.h:215:9: note: template ar
s930241592
p00511
C++
#include<stdio.h> #include<iostream> #include<string> #include<algorithm> #include <vector> using namespace std; int main(){ int x; int a=0; string G; cin>>x; a=x; while(1){ cin>>G; if(G=="=")break; cin>>x; ifG=="+")a+=x; ifG=="-")a-=x; ifG=="/")a/=x; ifG=="*")a*=x; } cout<<a<<endl; return 0; }
a.cc: In function 'int main()': a.cc:22:1: error: 'ifG' was not declared in this scope 22 | ifG=="+")a+=x; | ^~~
s610400147
p00511
C++
import std.stdio; import std.string; import std.conv; import std.array; void main() { string s; string op = "+"; int res = 0; while(1) { s = readln(); int a = to!int(chomp(s)); if(op[0] == '+') res += a; else if(op[0] == '-') res -= a; else if(op[0] == '*') res *= a; else res /= a; op = readln(); if(op[0] == '=') break; } writeln(res); }
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.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.conv; | ^~~~~~ 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.array; | ^~~~~~ 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; | ^~~~~~ a.cc:8:15: error: expected ';' before 'op' 8 | string op = "+"; | ^~~ | ; a.cc:11:17: error: 's' was not declared in this scope 11 | s = readln(); | ^ a.cc:11:21: error: 'readln' was not declared in this scope 11 | s = readln(); | ^~~~~~ a.cc:12:25: error: 'to' was not declared in this scope 12 | int a = to!int(chomp(s)); | ^~ a.cc:14:20: error: 'op' was not declared in this scope 14 | if(op[0] == '+') | ^~ a.cc:23:17: error: 'op' was not declared in this scope 23 | op = readln(); | ^~ a.cc:28:9: error: 'writeln' was not declared in this scope 28 | writeln(res); | ^~~~~~~
s275741228
p00511
C++
#include <stdio.h> int main(){ int a,b; char s[10]; scanf("%d",&a); while(1){ scanf("%s",s); if ( strcmp(s, "=") == 0 )break; scanf("%d",&b); if ( strcmp(s, "+") == 0 ) a+=b; if ( strcmp(s, "-") == 0 ) a-=b; if ( strcmp(s, "*") == 0 ) a*=b; if ( strcmp(s, "/") == 0 ) a/=b; } printf("%d\n",a); return 0; }
a.cc: In function 'int main()': a.cc:9:10: error: 'strcmp' was not declared in this scope 9 | if ( strcmp(s, "=") == 0 )break; | ^~~~~~ a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <stdio.h> +++ |+#include <cstring> 2 | int main(){ a.cc:11:10: error: 'strcmp' was not declared in this scope 11 | if ( strcmp(s, "+") == 0 ) a+=b; | ^~~~~~ a.cc:11:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:12:10: error: 'strcmp' was not declared in this scope 12 | if ( strcmp(s, "-") == 0 ) a-=b; | ^~~~~~ a.cc:12:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:13:10: error: 'strcmp' was not declared in this scope 13 | if ( strcmp(s, "*") == 0 ) a*=b; | ^~~~~~ a.cc:13:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:14:10: error: 'strcmp' was not declared in this scope 14 | if ( strcmp(s, "/") == 0 ) a/=b; | ^~~~~~ a.cc:14:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s245619047
p00511
C++
#include <stdio.h> int main(){ int a,b; char s[10]; scanf("%d",&a); while(1){ scanf("%s",&s); if ( strcmp(s, "=") == 0 )break; scanf("%d",&b); if ( strcmp(s, "+") == 0 ) a+=b; if ( strcmp(s, "-") == 0 ) a-=b; if ( strcmp(s, "*") == 0 ) a*=b; if ( strcmp(s, "/") == 0 ) a/=b; } printf("%d\n",a); return 0; }
a.cc: In function 'int main()': a.cc:9:10: error: 'strcmp' was not declared in this scope 9 | if ( strcmp(s, "=") == 0 )break; | ^~~~~~ a.cc:2:1: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <stdio.h> +++ |+#include <cstring> 2 | int main(){ a.cc:11:10: error: 'strcmp' was not declared in this scope 11 | if ( strcmp(s, "+") == 0 ) a+=b; | ^~~~~~ a.cc:11:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:12:10: error: 'strcmp' was not declared in this scope 12 | if ( strcmp(s, "-") == 0 ) a-=b; | ^~~~~~ a.cc:12:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:13:10: error: 'strcmp' was not declared in this scope 13 | if ( strcmp(s, "*") == 0 ) a*=b; | ^~~~~~ a.cc:13:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc:14:10: error: 'strcmp' was not declared in this scope 14 | if ( strcmp(s, "/") == 0 ) a/=b; | ^~~~~~ a.cc:14:10: note: 'strcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s724674782
p00511
C++
#include<stdio.h> int main(void) { int a,b; char *c; scanf("%d",&a); while(1){ scanf("%c",&c); if(c=='=')break; scanf("%d",&b); if(c=='+'){a=a+b;} else if(c=='-'){a=a-b;} else if(c=='*'){a=a*b;} else if(c=='/'){a=a/b;} } printf("%d\n",a); return 0; }
a.cc: In function 'int main()': a.cc:9:9: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 9 | if(c=='=')break; | ~^~~~~ a.cc:11:9: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 11 | if(c=='+'){a=a+b;} | ~^~~~~ a.cc:12:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 12 | else if(c=='-'){a=a-b;} | ~^~~~~ a.cc:13:18: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | else if(c=='*'){a=a*b;} | ~^~~~~ a.cc:14:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 14 | else if(c=='/'){a=a/b;} | ~^~~~~
s421433805
p00511
C++
import sys def line():return sys.stdin.readline().strip() e="" ans=0 while True: try: temp = line() if temp=="/": e+="//" elif temp=="*": e+="*" elif temp=="+": e+="+" elif temp=="-": e+="-" elif temp=="=": print(eval(e)) break else: e+=temp ans=eval(e) e=str(ans) except: break
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s028565670
p00511
C++
#include <iostream> using namespace std; int main(){ int ans; cin >> ans; char s [10]; int n = 0; while (true){ cin >> s; if (s[0] == "="){ break; } else if (s[0] == "+"){ ans += n; } else if (s[0] == "-"){ ans -= n; } else if (s[0] == "*"){ ans *= n; } else if (s[0] == "/"){ ans /= n; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 10 | if (s[0] == "="){ break; } | ~~~~~^~~~~~ a.cc:11:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 11 | else if (s[0] == "+"){ | ~~~~~^~~~~~ a.cc:14:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 14 | else if (s[0] == "-"){ | ~~~~~^~~~~~ a.cc:17:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 17 | else if (s[0] == "*"){ | ~~~~~^~~~~~ a.cc:20:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 20 | else if (s[0] == "/"){ | ~~~~~^~~~~~
s410884667
p00511
C++
#include <iostream> using namespace std; int main(){ int ans; cin >> ans; char *s = "a"; int n = 0; ans = n; while (true){ scanf_s("%c", &s); if (s == "="){ break; } else if (s == "+"){ cin >> n; ans += n; } else if (s == "-"){ cin >> n; ans -= n; } else if (s == "*"){ cin >> n; ans *= n; } else if (s == "/"){ cin >> n; ans /= n; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:6:19: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] 6 | char *s = "a"; | ^~~ a.cc:10:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 10 | scanf_s("%c", &s); | ^~~~~~~ | scanf
s569421559
p00511
C++
#include<iostream> using namespace std; int main(){ int a; char b; int c; for(int i=0;i<10;i++){ cin>>a>>b; if (b=="="){ break; } else if(b=="+");{ c+=a; } else if(b=="-");{ c-=a; } else if(b=="*");{ c*=a; } else if(b=="/");{ c/=a; } } cout<<c<<endl; return 0; }
a.cc: In function 'int main()': a.cc:9:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 9 | if (b=="="){ | ~^~~~~ a.cc:12:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 12 | else if(b=="+");{ | ~^~~~~ a.cc:15:17: error: 'else' without a previous 'if' 15 | else if(b=="-");{ | ^~~~ a.cc:15:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 15 | else if(b=="-");{ | ~^~~~~ a.cc:18:17: error: 'else' without a previous 'if' 18 | else if(b=="*");{ | ^~~~ a.cc:18:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 18 | else if(b=="*");{ | ~^~~~~ a.cc:21:17: error: 'else' without a previous 'if' 21 | else if(b=="/");{ | ^~~~ a.cc:21:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 21 | else if(b=="/");{ | ~^~~~~
s377909150
p00511
C++
#include<iostream> using namespace std; int main(){ int a; char b; int ans; while(true){ cin>>b; cin>>a; if (b=="="){cout<<ans<<endl;} else if(b=="+");{ans+=a;} else if(b=="-");{ans-=a;} else if(b=="*");{c*=a;} else(b=="/");{ans/=a;} } return 0; }
a.cc: In function 'int main()': a.cc:10:22: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 10 | if (b=="="){cout<<ans<<endl;} | ~^~~~~ a.cc:11:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 11 | else if(b=="+");{ans+=a;} | ~^~~~~ a.cc:12:17: error: 'else' without a previous 'if' 12 | else if(b=="-");{ans-=a;} | ^~~~ a.cc:12:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 12 | else if(b=="-");{ans-=a;} | ~^~~~~ a.cc:13:17: error: 'else' without a previous 'if' 13 | else if(b=="*");{c*=a;} | ^~~~ a.cc:13:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 13 | else if(b=="*");{c*=a;} | ~^~~~~ a.cc:13:34: error: 'c' was not declared in this scope 13 | else if(b=="*");{c*=a;} | ^ a.cc:14:17: error: 'else' without a previous 'if' 14 | else(b=="/");{ans/=a;} | ^~~~ a.cc:14:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 14 | else(b=="/");{ans/=a;} | ~^~~~~
s531358787
p00511
C++
using namespace std; int main(){ int a=0; string b; cin>>a; while(1){ cin>>b; if(b=="=") break; int x; cin>>x; if(b=="+") a+=x; else if(b=="-") a-=x; else if(b=="/") a/=x; else if(b=="*") a*=x; } cout<<a<<endl; return 0; }
a.cc: In function 'int main()': a.cc:4:3: error: 'string' was not declared in this scope 4 | string b; | ^~~~~~ a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' +++ |+#include <string> 1 | using namespace std; a.cc:5:3: error: 'cin' was not declared in this scope 5 | cin>>a; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | using namespace std; a.cc:7:10: error: 'b' was not declared in this scope 7 | cin>>b; | ^ a.cc:16:3: error: 'cout' was not declared in this scope 16 | cout<<a<<endl; | ^~~~ a.cc:16:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:16:12: error: 'endl' was not declared in this scope 16 | cout<<a<<endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | using namespace std;
s969799653
p00511
C++
#include<bits/stdc++.h> using namespace std; int main(){ int num1,num2,ans; for(string mark;mark==¨=¨;){ cin>>num1; cin>>mark; cin>>num2; ans=num1,mark,num2; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:10:23: error: '\U000000a8' was not declared in this scope 10 | for(string mark;mark==¨=¨;){ | ^
s735284993
p00511
C++
#include<bits/stdc++.h> using namespace std; int main(){ int num1,num2,ans; string mark1,mark2; while(1){ cin>>num1; cin>>mark1; cin>>num2; cin>>mark2; if(mark2 == ¨=¨)break; ans=ans,mark2,num1,mark1,num2; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:19:13: error: '\U000000a8' was not declared in this scope 19 | if(mark2 == ¨=¨)break; | ^
s978402202
p00511
C++
#include<bits/stdc++.h> using namespace std; int main(){ int num,ans; string mark1,mark2; cin>>ans; while(1){ cin>>mark1; cin>>num; cin>>mark2; if(mark1 == ¨=¨)break; if(mark2 == ¨=¨)break; if(mark1 == ¨+¨) ans=ans+num; if(mark1 == ¨-¨) ans=ans-num; if(mark1 == ¨*¨) ans=ans*num; if(mark1 == ¨/¨) ans=ans/num; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:21:13: error: '\U000000a8' was not declared in this scope 21 | if(mark1 == ¨=¨)break; | ^ a.cc:22:13: error: '\U000000a8' was not declared in this scope 22 | if(mark2 == ¨=¨)break; | ^ a.cc:24:13: error: '\U000000a8' was not declared in this scope 24 | if(mark1 == ¨+¨) | ^ a.cc:27:13: error: '\U000000a8' was not declared in this scope 27 | if(mark1 == ¨-¨) | ^ a.cc:30:13: error: '\U000000a8' was not declared in this scope 30 | if(mark1 == ¨*¨) | ^ a.cc:33:13: error: '\U000000a8' was not declared in this scope 33 | if(mark1 == ¨/¨) | ^
s427754868
p00511
C++
#include<bits/stdc++.h> using namespace std; int main(){ int num,ans; char mark1,mark2; cin>>ans; while(1){ cin>>mark1; cin>>num; cin>>mark2; if(mark1 == ¨=¨)break; if(mark2 == ¨=¨)break; if(mark1 == ¨+¨) ans=ans+num; if(mark1 == ¨-¨) ans=ans-num; if(mark1 == ¨*¨) ans=ans*num; if(mark1 == ¨/¨) ans=ans/num; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:21:13: error: '\U000000a8' was not declared in this scope 21 | if(mark1 == ¨=¨)break; | ^ a.cc:22:13: error: '\U000000a8' was not declared in this scope 22 | if(mark2 == ¨=¨)break; | ^ a.cc:24:13: error: '\U000000a8' was not declared in this scope 24 | if(mark1 == ¨+¨) | ^ a.cc:27:13: error: '\U000000a8' was not declared in this scope 27 | if(mark1 == ¨-¨) | ^ a.cc:30:13: error: '\U000000a8' was not declared in this scope 30 | if(mark1 == ¨*¨) | ^ a.cc:33:13: error: '\U000000a8' was not declared in this scope 33 | if(mark1 == ¨/¨) | ^
s430803118
p00511
C++
#include<bits/stdc++.h> using namespace std; int main(){ int num,ans; char mark; cin>>ans; while(1){ cin>>mark; cin>>num; if(mark == ¨=¨)break; if(mark == ¨+¨) ans=ans+num; if(mark == ¨-¨) ans=ans-num; if(mark == ¨*¨) ans=ans*num; if(mark == ¨/¨) ans=ans/num; } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:20:12: error: '\U000000a8' was not declared in this scope 20 | if(mark == ¨=¨)break; | ^ a.cc:22:12: error: '\U000000a8' was not declared in this scope 22 | if(mark == ¨+¨) | ^ a.cc:25:12: error: '\U000000a8' was not declared in this scope 25 | if(mark == ¨-¨) | ^ a.cc:28:12: error: '\U000000a8' was not declared in this scope 28 | if(mark == ¨*¨) | ^ a.cc:31:12: error: '\U000000a8' was not declared in this scope 31 | if(mark == ¨/¨) | ^
s065343449
p00511
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> #include <deque> #include <iomanip> #include <limits> #include <fstream> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); vector<string> v; while(1){ cin>>v[i]; if(v[i]=='=') break; } int ans = stoi(v[0]); int n = v.size(); FOR(i,1,n-1){ if(v[i]=='+'){ ans += stoi(v[i+1]); i++; } if(v[i]=='-'){ ans -= stoi(v[i+1]); i++; } if(v[i]=='/'){ ans /= stoi(v[i+1]); i++; } if(v[i]=='*'){ ans *= stoi(v[i+1]); i++; } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:31:14: error: 'i' was not declared in this scope 31 | cin>>v[i]; | ^ a.cc:37:12: error: no match for 'operator==' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} and 'char') 37 | if(v[i]=='+'){ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 37 | if(v[i]=='+'){ | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 37 | if(v[i]=='+'){ | ^~~ In file included from /usr/include/c++/14/iosfwd:42, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>' 37 | if(v[i]=='+'){ | ^~~ In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>' 37 | if(v[i]=='+'){ | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 629 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:629:5: note: template argument deduction/substitution failed: a.cc:37:14: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/string_view:637:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 637 | operator==(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:637:5: note: template argument deduction/substitution failed: a.cc:37:14: note: 'std::__cxx11::basic_string<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/string_view:644:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator==(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 644 | operator==(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:644:5: note: template argument deduction/substitution failed: a.cc:37:14: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'char' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3755 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3755:5: note: template argument deduction/substitution failed: a.cc:37:14: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'char' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3772 | operator==(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3772:5: note: template argument deduction/substitution failed: a.cc:37:14: note: mismatched types 'const _CharT*' and 'char' 37 | if(v[i]=='+'){ | ^~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator==(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3819 | operator==(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3819:5: note: template argument deduction/substitution failed: a.cc:37:14: note: mismatched types 'const _CharT*' and 'std::__cxx11::basic_string<char>' 37 | if(v[i]=='+'){ | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2558:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator==(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2558 | operator==(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2558:5: note: template argument deduction/substitution failed: a.cc:37:14: note: '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::tuple<_UTypes ...>' 37 | if(v[i]=='+'){ | ^~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46: /usr/include/c+
s551902462
p00511
C++
#include<iostream> using namespace std; int main() { int a,b; char op; cin>>op; while(true){ cin>>op; if(op == '='){cout<<a<<endl;break;} cin>>b; if(op == '+'){a += a;} if(op == '-'){a -= a;} if(op == '*'){a *= a;} if(op == '/'){a /= a;} return 0; }
a.cc: In function 'int main()': a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:3:12: note: to match this '{' 3 | int main() { | ^
s166680203
p00511
C++
#include<iostream> using namespace std; int a,b; char op; int main() { cin>>a; while(true){ cin>>op; if(op == '='){cout<<a<<endl;break;} cin>>b; if(op == '+'){a += a;} if(op == '-'){a -= a;} if(op == '*'){a *= a;} if(op == '/'){a /= a;} return 0; }
a.cc: In function 'int main()': a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s313756910
p00511
C++
#include<iostream> using namespace std; int a,b; char op; int main() { cin>>a; while(true){ cin>>op; if(op == '='){cout<< a <<endl;break;} cin>>b; if(op == '+'){ a += a; } if(op == '-'){ a -= a; } if(op == '*'){ a *= a; } if(op == '/'){ a /= a; } return 0; }
a.cc: In function 'int main()': a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s680971655
p00511
C++
#include<iostream> using namespace std; int a,b; char op; int main() { cin>>a; while(true){ cin>>op; if(op == '='){cout<< a <<endl; break;} cin>>b; if(op == '+'){ b += b; } if(op == '-'){ b -= b; } if(op == '*'){ b *= b; } if(op == '/'){ b /= b; } return 0; }
a.cc: In function 'int main()': a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s187769873
p00511
C++
#include<iostream> using namespace std; int a,b; char op; int main() { cin>>a; while(true){ cin>>op; if(op == '='){cout<< a <<endl; break;} cin>>b; if(op == '+'){ a += b; } if(op == '-'){ a -= b; } if(op == '*'){ a *= b; } if(op == '/'){ a /= b; } return 0; }
a.cc: In function 'int main()': a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s957116338
p00511
C++
#include<iostream> using namespace std; int a,b; char op; int main() { cin>>a; while(true){ cin>>op; if(op == '='){cout<< a <<endl; break;} cin>>b; if(op == '+'){ a += b; } if(op == '-'){ a -= b; } if(op == '*'){ a *= b; } if(op == '/'){ a /= b; } }
a.cc: In function 'int main()': a.cc:15:2: error: expected '}' at end of input 15 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s767744744
p00512
C
#include<stdio.h> #include<stdlib.h> #include<string.h> struct E{char n[6];int c;} e[100000000],t; int N,p,i,j; int cmp(const void *a,const void *b) { struct E *x=(E*)a,*y=(E*)b; return strlen(x->n)-strlen(y->n)==0?strcmp(x->n,y->n):strlen(x->n)-strlen(y->n); } int main() { scanf("%d\n",&N); for(i=0;i<N;i++) { scanf("%s%d\n",t.n,&t.c); for(j=0;j<p;j++) { if(strcmp(e[j].n,t.n))continue; e[j].c+=t.c; break; } if(j==p) e[p++]=t; } qsort(e,p,sizeof(E),cmp); for(i=0;i<p;i++) printf("%s %d\n",e[i].n,e[i].c); return 0; }
main.c: In function 'cmp': main.c:9:22: error: 'E' undeclared (first use in this function) 9 | struct E *x=(E*)a,*y=(E*)b; | ^ main.c:9:22: note: each undeclared identifier is reported only once for each function it appears in main.c:9:24: error: expected expression before ')' token 9 | struct E *x=(E*)a,*y=(E*)b; | ^ main.c:12:36: error: 'y' undeclared (first use in this function) 12 | return strlen(x->n)-strlen(y->n)==0?strcmp(x->n,y->n):strlen(x->n)-strlen(y->n); | ^ main.c: In function 'main': main.c:30:26: error: 'E' undeclared (first use in this function) 30 | qsort(e,p,sizeof(E),cmp); | ^
s526985372
p00512
C++
#include<iostream> #include<vector> using namespace std; typedef pair<string,int> P; int n; vector<P> p; int main(){ cin>>n; p.resize(n); for(int i=0;i<n;i++) cin>>p[i].first>>p[i].second; sort(p.begin(),p.end()); for(int i=0;i<n;i++){ if(i+1<n&&p[i].first==p[i+1].first){ p[i+1].second+=p[i].second; }else{ cout<<p[i].first<<' '<<p[i].second<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:12:3: error: 'sort' was not declared in this scope; did you mean 'short'? 12 | sort(p.begin(),p.end()); | ^~~~ | short
s795257639
p00512
C++
#include <stdio.h> #include <iostream> #include <string> #include <map> using namespace std; char s[10]; int main() { map<pair<int,string>,int> m; int n; scanf("%d",&n); for(int i = 0; i < n; i++) { int w; scanf("%s %d",s,&w); int l = strlen(s); if(m.end() != m.find(make_pair(l,s))) { m[make_pair(l,s)] += w; } else { m[make_pair(l,s)] = w; } } map<pair<int,string>,int>::iterator it = m.begin(); while(it != m.end()) { printf("%s %d\n",(*it).first.second.c_str(),(*it).second); it++; } return 0; }
a.cc: In function 'int main()': a.cc:19:25: error: 'strlen' was not declared in this scope 19 | int l = strlen(s); | ^~~~~~ a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <map> +++ |+#include <cstring> 5 |
s718167336
p00512
C++
#include<vector> #include<algorithm> #include <string.h> using namespace std; int main(){ int n,total,min_size=1; string str; map<string, int> products; map<string, int>::iterator it; cin >> n; for (int i = 0; i<n; i++){ cin >> str >> total; if (products.find(str) != products.end()){ products[str] = products[str] + total; } else{ products[str] = total; } } n = products.size(); while (n != 0){ it = products.begin(); while (it != products.end()){ if ((*it).first.size() == min_size){ cout << (*it).first << " " << (*it).second << endl; n--; } it++; } min_size++; } return 0; }
a.cc: In function 'int main()': a.cc:10:9: error: 'string' was not declared in this scope 10 | string str; | ^~~~~~ a.cc:4:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' 3 | #include <string.h> +++ |+#include <string> 4 | a.cc:11:9: error: 'map' was not declared in this scope 11 | map<string, int> products; | ^~~ a.cc:4:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>' 3 | #include <string.h> +++ |+#include <map> 4 | a.cc:11:21: error: expected primary-expression before 'int' 11 | map<string, int> products; | ^~~ a.cc:12:21: error: expected primary-expression before 'int' 12 | map<string, int>::iterator it; | ^~~ a.cc:14:9: error: 'cin' was not declared in this scope 14 | cin >> n; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <string.h> +++ |+#include <iostream> 4 | a.cc:17:24: error: 'str' was not declared in this scope; did you mean 'std'? 17 | cin >> str >> total; | ^~~ | std a.cc:18:21: error: 'products' was not declared in this scope 18 | if (products.find(str) != products.end()){ | ^~~~~~~~ a.cc:26:13: error: 'products' was not declared in this scope 26 | n = products.size(); | ^~~~~~~~ a.cc:29:17: error: 'it' was not declared in this scope; did you mean 'int'? 29 | it = products.begin(); | ^~ | int a.cc:32:41: error: 'cout' was not declared in this scope 32 | cout << (*it).first << " " << (*it).second << endl; | ^~~~ a.cc:32:41: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:32:87: error: 'endl' was not declared in this scope 32 | cout << (*it).first << " " << (*it).second << endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include <string.h> +++ |+#include <ostream> 4 |
s762851288
p00512
C++
#include <iostream> #include <iomanip> #include <string> #include <sstream> #include <algorithm> #include <vector> #include <utility> #include <stack> #include <queue> #include <map> #include <set> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> using namespace std; #define rep(i,n) for(int i=0; i<(n); i++) #define repc(i,s,e) for(int i=(s); i<(e); i++) #define pb(n) push_back((n)) #define mp(n,m) make_pair((n),(m)) #define all(r) r.begin(),r.end() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<vi> vii; typedef vector<ll> vl; typedef vector<vl> vll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1000000; const int mod = 1e9 + 7; struct MyString { string str; MyString(){} MyString(string t) :str(t){} void in() { cin >> str; } bool operator < (const MyString& S) { if (this->str.size() != S.str.size()) return this->str.size() < S.str.size(); return this->str < S.str; } bool operator > (const MyString& S) { if (this->str.size() != S.str.size()) return this->str.size() > S.str.size(); return this->str > S.str; } }; bool cmp(MyString s1, MyString s2) { return s1 < s2; } int main() { MyString s; int n, t; map<MyString, int> m; cin >> n; for (int i = 0; i < n; i++) { s.in(); cin >> t; m[s] += t; } for (map<MyString, int>::iterator it = m.begin(); it != m.end(); it++) { cout << it->first.str << " " << it->second << endl; } }
In file included from /usr/include/c++/14/string:49, 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_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = MyString]': /usr/include/c++/14/bits/stl_map.h:511:32: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = MyString; _Tp = int; _Compare = std::less<MyString>; _Alloc = std::allocator<std::pair<const MyString, int> >; mapped_type = int; key_type = MyString]' 511 | if (__i == end() || key_comp()(__k, (*__i).first)) | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ a.cc:79:6: required from here 79 | m[s] += t; | ^ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const MyString' and 'const MyString') 405 | { return __x < __y; } | ~~~~^~~~~ a.cc:53:14: note: candidate: 'bool MyString::operator<(const MyString&)' (near match) 53 | bool operator < (const MyString& S) { | ^~~~~~~~ a.cc:53:14: note: passing 'const MyString*' as 'this' argument discards qualifiers In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const MyString' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const MyString' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const MyString' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const MyString' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s617023448
p00512
C++
#include <iostream> #include <vector> #include <cstdio> #include <map> using namespace std; #define rep(i,a) for(int i = 0 ; i < a ; i ++) bool cmp(pair<string,int> a,pair<string,int> b){ return (a.first.size()<b.first.size()?true:false); } int main(void){ map<string,int> m; int n; string s;int c; cin>>n; rep(i,n){ cin>>s>>c; m[s]+=c; } vector<pair<string,int> > w; for(map<string,int>::iterator it=m.begin();it!=m.end();it++){ w.push_back(make_pair(it->first,it->second)); } sort(w.begin(),w.end(),cmp); for(vector<pair<string,int> >::iterator it=w.begin();it!=w.end();it++){ cout<<it->first<<" "<<it->second<<endl; } }
a.cc: In function 'int main()': a.cc:26:3: error: 'sort' was not declared in this scope; did you mean 'short'? 26 | sort(w.begin(),w.end(),cmp); | ^~~~ | short
s637591905
p00512
C++
#include<iostream> #include<vector> #include<map> #include<string> using namespace std; int main() { int n; map<string, int> products; vector<pair<string, int> > p; cin>>n; //vector<pair<string, int> > products; for (int i = 0; i < n; ++i) { string name; int num; cin>>name>>num; if (products[name] > 0) { products[name] += num; } else { products[name] = num; } } for (auto& e : products) { p.push_back(make_pair(e.first, e.second)); } sort(p.begin(), p.end(), [](auto& lhs, auto& rhs) -> bool { if (lhs.first.size() < rhs.first.size()) return true; else if (lhs.first < rhs.first) return true; else return false; }); for (auto& e : p) { cout<<e.first<<" "<<e.second<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:31:5: error: 'sort' was not declared in this scope; did you mean 'short'? 31 | sort(p.begin(), p.end(), [](auto& lhs, auto& rhs) -> bool { | ^~~~ | short
s383005469
p00512
C++
#include<iostream> #include<string> #include<set> #include<map> using namespace std; int main() { set<string>s; map<string, int>m; int n; cin >> n; for (int i = 0; i < n; i++) { string str, int k; cin >> str >> k; if (s.find(str) == s.end()) { s.insert(str); m[str] = k; } else m[str] += k; } for (auto i = s.begin(); i != s.end(); i++) { cout << *i << ' ' << m[*i] << endl; } }
a.cc: In function 'int main()': a.cc:11:29: error: expected unqualified-id before 'int' 11 | string str, int k; cin >> str >> k; | ^~~ a.cc:11:50: error: 'k' was not declared in this scope 11 | string str, int k; cin >> str >> k; | ^
s455324743
p00512
C++
#include <iostream> #include <stdio.h> #include <string> #include <string.h> using namespace std; int main (void) { int n,b[100],as[100]; char a[100]; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] == a[j]) { b[i] += b[j]; a[j] = ""; } } } for (int i = 0 ; i < n; i++) { as[i] = 1; for (int j = i + 1; j < n; j++) { if(a[i] != "") { if (a[i] < a[j]) { as[i]++; } } } break; } for (int i = 0; i < n; i++) { if (a[i] != "") { if (as[i] == i + 1) { cout << a[i] << " " << b[i] << endl; } } } }
a.cc: In function 'int main()': a.cc:26:40: error: invalid conversion from 'const char*' to 'char' [-fpermissive] 26 | a[j] = ""; | ^~ | | | const char* a.cc:36:33: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 36 | if(a[i] != "") | ~~~~~^~~~~ a.cc:49:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 49 | if (a[i] != "") | ~~~~~^~~~~
s419150126
p00512
C++
#include<stdio.h> #include <algorithm> #include <cassert> #include <cctype> #include <climits> #include <cmath> #include <complex> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <iostream> #include <iterator> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <iomanip> #include <stack> #include <string> #include <vector> using namespace std; #define ll long long #define ld long double #define rep(a,t) for(int a=0;a<t;a++) #define forever while(true) #define Sort(a) sort(a.begin(),a.end()) #define Reverse(a) reverse(a.begin(),a.end()) #define pb push_back int main() { cin.tie(0); ios::sync_with_stdio(false); map<string, int>a; int n; cin >> n; vector<string>find_; while (n--) { string p; int q; cin >> p >> q; a[p] += q; find_.pb(p); } Sort(find_); for (int i = 0; i < a.count; i++) { cout << find_[i] << " " << a[find_[i]] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:48:27: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 48 | for (int i = 0; i < a.count; i++) { | ~ ^ ~~~~~~~ | | | | int <unresolved overloaded function type>
s069485177
p00512
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> #include <cstring> #include <deque> #include <iomanip> #include <limits> #include <fstream> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) #define CLR(mat) memset(mat, 0, sizeof(mat)) typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; map<string, int> mp; FOR(i,0,n){ string s; int x; cin >> s >> x; mp[s] += x; } for(auto m : mp){ cout << mp.first << " " << mp.second << endl; } }
a.cc: In function 'int main()': a.cc:38:18: error: 'class std::map<std::__cxx11::basic_string<char>, int>' has no member named 'first' 38 | cout << mp.first << " " << mp.second << endl; | ^~~~~ a.cc:38:38: error: 'class std::map<std::__cxx11::basic_string<char>, int>' has no member named 'second' 38 | cout << mp.first << " " << mp.second << endl; | ^~~~~~
s497771232
p00512
C++
#include<stdio.h> #include<string> #include<stdlib.h> #include<math.h> #include<iostream> #include<vector> #include<algorithm> #include<numeric> #include<string.h> #include<queue> using namespace std; typedef pair<int,int> pii; typedef pair<int,string> pis; typedef pair<pis,int> tri; #define rep(i,j) for(int i=0;i<(j);i++) #define reps(i,j,k) for(int i=j;i<=k;i++) int main(){ int n,m,p; string s; tri t,*po; pis pi; vector< tri > v; scanf("%d",&n); rep(i,n){ cin >> s; cin >> m; pi = pis(s.length(),s); po = lower_bound(v.begin(),v.end(),tri(pi,0)); if(po != v.end() && po->first.second == s){ po->second += m; }else{ if(v.size()==0)v.push_back(tri(pi,m)); else v.insert(po,tri(pi,m)); } } rep(i,v.size())printf("%s %d\n",v[i].first.second.c_str(),v[i].second); return 0; }
a.cc: In function 'int main()': a.cc:31:33: error: cannot convert '__gnu_cxx::__normal_iterator<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*, std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> > >' to 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} in assignment 31 | po = lower_bound(v.begin(),v.end(),tri(pi,0)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | __gnu_cxx::__normal_iterator<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*, std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> > > a.cc:32:23: error: no match for 'operator!=' (operand types are 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} and 'std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> >::iterator') 32 | if(po != v.end() && po->first.second == s){ | ~~ ^~ ~~~~~~~ | | | | | std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> >::iterator | tri* {aka std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*} In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from a.cc:2: /usr/include/c++/14/bits/postypes.h:197:5: note: candidate: 'template<class _StateT> bool std::operator!=(const fpos<_StateT>&, const fpos<_StateT>&)' 197 | operator!=(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:197:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::fpos<_StateT>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_CharT>&, const allocator<_T2>&)' 243 | operator!=(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:243:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::allocator<_CharT>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::pair<_T1, _T2>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:651:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 651 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:651:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/string_view:658:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 658 | operator!=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:658:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/string_view:666:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator!=(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 666 | operator!=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:666:5: note: template argument deduction/substitution failed: a.cc:32:32: note: '__gnu_cxx::__normal_iterator<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*, std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> > >' is not derived from 'std::basic_string_view<_CharT, _Traits>' 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/bits/basic_string.h:3833:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3833 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3833:5: note: template argument deduction/substitution failed: a.cc:32:32: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'tri*' {aka 'std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int>*'} 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/bits/basic_string.h:3847:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3847 | operator!=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3847:5: note: template argument deduction/substitution failed: a.cc:32:32: note: 'std::vector<std::pair<std::pair<int, std::__cxx11::basic_string<char> >, int> >::iterator' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 32 | if(po != v.end() && po->first.second == s){ | ^ /usr/include/c++/14/bits/basic_string.h:3860:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator!=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3860 | operator!=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~
s055195728
p00512
C++
#include <map> #include <cstdio> #include <string> #include <vector> #include <iostream> using namespace std; bool cmp(const pair<string, int>& x, const pair<string, int>& y) { if (x.first.size() < y.first.size()){ return true; } return x.first < y.first; } int main() { map<string, int> m; string pn; int n, c; scanf("%d", &n); for (int i = 0; i < n; i++){ cin >> pn >> c; if (m.count(pn)) m[pn] += c; else m.insert(make_pair(pn, c)); } vector< pair<string, int> > v; for (map<string, int>::iterator it = m.begin(); it != m.end(); it++){ v.push_back(*it); } sort(v.begin(), v.end(), cmp); for (vector< pair<string, int> >::iterator it = v.begin(); it != v.end(); it++){ cout << it->first << " " << it->second << endl; } return (0); }
a.cc: In function 'int main()': a.cc:38:9: error: 'sort' was not declared in this scope; did you mean 'short'? 38 | sort(v.begin(), v.end(), cmp); | ^~~~ | short
s703988900
p00512
C++
#include <iostream> #include <map> #include <string> #include <vector> using namespace std; class S{ public: string s; int t; S(){} S(string s, int t): s(s), t(t) {} bool operator < (const S a) const { if(s.length() == a.s.length()) return s < a.s; return s.length() < a.s.length(); } }; main(){ map<string, int> tmp; int n; cin >> n; for(int i=0;i<n;i++){ string s; int t; cin >> s >> t; tmp[s] += t; } vector<S> ans; map<string, int>::iterator ite = tmp.begin(); while(ite != tmp.end()){ ans.push_back(S(ite->first, ite->second)); ite++; } sort(ans.begin(), ans.end()); for(int i=0;i<ans.size();i++) cout << ans[i].s << ' ' << ans[i].t << endl; }
a.cc:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 20 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:36:3: error: 'sort' was not declared in this scope; did you mean 'short'? 36 | sort(ans.begin(), ans.end()); | ^~~~ | short
s971707093
p00512
C++
#include <iostream> #include <map> using namespace std; int main() { int n; map<string, int> m; cin >> n; for (int i = 0; i < n; i++) { string str; int num; cin >> str >> num; if (m.count(str) == 0) m[str] = num; else m[str] += num; } for (int i = 0; i < n; i++) cout << m[i].first << " " << m[i].second << endl; return 0; }
a.cc: In function 'int main()': a.cc:24:18: error: no match for 'operator[]' (operand types are 'std::map<std::__cxx11::basic_string<char>, int>' and 'int') 24 | cout << m[i].first << " " << m[i].second << endl; | ^ In file included from /usr/include/c++/14/map:63, from a.cc:2: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::__cxx11::basic_string<char>, int>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::__cxx11::basic_string<char>, int>::key_type&&' {aka 'std::__cxx11::basic_string<char>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ a.cc:24:39: error: no match for 'operator[]' (operand types are 'std::map<std::__cxx11::basic_string<char>, int>' and 'int') 24 | cout << m[i].first << " " << m[i].second << endl; | ^ /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::__cxx11::basic_string<char>, int>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::__cxx11::basic_string<char>, int>::key_type&&' {aka 'std::__cxx11::basic_string<char>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s199006518
p00512
C++
#include <cstdio> #include <string> #include <vector> #include <algorithm> using namespace std; int main() { int n; scanf("%d", &n); vector<pair<int, pair<string, int> > > v; for (int i = 0; i < n; i++){ char pName[8]; int num; scanf("%s %d", pName, num); v.push_back(make_pair(strlen(pName), make_pair((string)pName, num))); } sort(v.begin(), v.end()); string lead = "$"; int cnt = 0; for (int i = 0; i < n; i++){ if (lead != v[i].second.first){ if (lead != "$") printf("%s %d\n", lead.c_str(), cnt); lead = v[i].second.first; cnt = v[i].second.second; } else cnt += v[i].second.second; } return (!printf("%s %d\n", lead.c_str(), cnt)); }
a.cc: In function 'int main()': a.cc:19:39: error: 'strlen' was not declared in this scope 19 | v.push_back(make_pair(strlen(pName), make_pair((string)pName, num))); | ^~~~~~ a.cc:5:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <algorithm> +++ |+#include <cstring> 5 |
s953109806
p00512
C++
#include<iostream> #include<map> #include<string> #include<algorithm> int main(){ int i; int n; map<string, int> p; cin >> n; int num; string name; map<string, int>::iterator it; for(i = 0; i < n; i++){ cin >> name >> num; if(p.find(name) != p.end()) p[name] += num; else p[name] = num; } for(i=1; i<=5; i++){ it = p.begin; while( it != p.end()){ if(p->first.size() = i){ count << p->first << " " << p->second << endl; } it++; } } return 0; }
a.cc: In function 'int main()': a.cc:9:3: error: 'map' was not declared in this scope 9 | map<string, int> p; | ^~~ a.cc:9:3: note: suggested alternatives: In file included from /usr/include/c++/14/map:63, from a.cc:2: /usr/include/c++/14/bits/stl_map.h:102:11: note: 'std::map' 102 | class map | ^~~ /usr/include/c++/14/map:89:13: note: 'std::pmr::map' 89 | using map | ^~~ a.cc:9:7: error: 'string' was not declared in this scope 9 | map<string, int> p; | ^~~~~~ a.cc:9:7: note: suggested alternatives: In file included from /usr/include/c++/14/iosfwd:41, from /usr/include/c++/14/ios:40, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string' 77 | typedef basic_string<char> string; | ^~~~~~ In file included from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44: /usr/include/c++/14/string:76:11: note: 'std::pmr::string' 76 | using string = basic_string<char>; | ^~~~~~ a.cc:9:15: error: expected primary-expression before 'int' 9 | map<string, int> p; | ^~~ a.cc:10:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 10 | cin >> n; | ^~~ | std::cin /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:12:9: error: expected ';' before 'name' 12 | string name; | ^~~~~ | ; a.cc:13:15: error: expected primary-expression before 'int' 13 | map<string, int>::iterator it; | ^~~ a.cc:15:12: error: 'name' was not declared in this scope 15 | cin >> name >> num; | ^~~~ a.cc:16:8: error: 'p' was not declared in this scope 16 | if(p.find(name) != p.end()) p[name] += num; | ^ a.cc:21:5: error: 'it' was not declared in this scope; did you mean 'i'? 21 | it = p.begin; | ^~ | i a.cc:21:10: error: 'p' was not declared in this scope 21 | it = p.begin; | ^ a.cc:24:9: error: 'count' was not declared in this scope; did you mean 'std::count'? 24 | count << p->first << " " << p->second << endl; | ^~~~~ | std::count In file included from /usr/include/c++/14/algorithm:86, from a.cc:4: /usr/include/c++/14/pstl/glue_algorithm_defs.h:101:1: note: 'std::count' declared here 101 | count(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~~ a.cc:24:50: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 24 | count << p->first << " " << p->second << endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s177922711
p00513
Java
#include<stdio.h> int main(){ int a; scanf("%d",&a); int ret=0; for(int i=0;i<a;i++){ int b; scanf("%d",&b); b=b*2+1; bool ok=false; for(int j=1;(2*j+1)*(2*j+1)<=b;j++){ if(b%(2*j+1)==0)ok=true; } if(!ok)ret++; }printf("%d\n",ret); }
Main.java:1: error: illegal character: '#' #include<stdio.h> ^ Main.java:1: error: class, interface, enum, or record expected #include<stdio.h> ^ Main.java:4: error: class, interface, enum, or record expected scanf("%d",&a); ^ Main.java:5: error: unnamed classes are a preview feature and are disabled by default. int ret=0; ^ (use --enable-preview to enable unnamed classes) Main.java:6: error: class, interface, enum, or record expected for(int i=0;i<a;i++){ ^ Main.java:6: error: class, interface, enum, or record expected for(int i=0;i<a;i++){ ^ Main.java:6: error: class, interface, enum, or record expected for(int i=0;i<a;i++){ ^ Main.java:8: error: class, interface, enum, or record expected scanf("%d",&b); ^ Main.java:9: error: class, interface, enum, or record expected b=b*2+1; ^ Main.java:11: error: class, interface, enum, or record expected for(int j=1;(2*j+1)*(2*j+1)<=b;j++){ ^ Main.java:11: error: class, interface, enum, or record expected for(int j=1;(2*j+1)*(2*j+1)<=b;j++){ ^ Main.java:11: error: class, interface, enum, or record expected for(int j=1;(2*j+1)*(2*j+1)<=b;j++){ ^ Main.java:13: error: class, interface, enum, or record expected } ^ Main.java:15: error: class, interface, enum, or record expected }printf("%d\n",ret); ^ Main.java:16: error: class, interface, enum, or record expected } ^ 15 errors
s146025602
p00513
C++
#include <stdio.h> int main() { int n; scanf("%d",&n); int all = 0; for(int i = 0; i < n; i++) { int q; scanf("%d",&q); bool w = true; for(int j = 1; j <= (1 << 15)) { if(0 == (q - j) % (j * 2 + 1)) { w = false; break; } } if(w) { all++; } } printf("%d\n",all); return 0; }
a.cc: In function 'int main()': a.cc:13:30: error: expected ';' before ')' token 13 | for(int j = 1; j <= (1 << 15)) | ^ | ;
s457994334
p00513
C++
#include <iostream> using namespace std; int main(){ int n,s,cnt=0; cin >> n; for(int i=0;i<n;i++){ cin >> s; int flag=0; for(int j=1;j<s;j++){ if((s-j)%(2j+1)==0){ if((s-j)/(2j+1)<s){ flag=1; break; } } } if(flag==0) cnt++; } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:15: error: invalid operands of types 'int' and '__complex__ int' to binary 'operator%' 10 | if((s-j)%(2j+1)==0){ | ~~~~~^~~~~~~ | | | | int __complex__ int a.cc:11:24: error: invalid operands of types '__complex__ int' and 'int' to binary 'operator<' 11 | if((s-j)/(2j+1)<s){ | ~~~~~~~~~~~~^~ | | | | | int | __complex__ int
s184070963
p00513
C++
#include<iostream> #include<algorithm> using namespace std; int n, x, sum; int hantei(int p) { int v = max((int)sqrt(p) * 5, p); for (int i = 1; i <= sqrt(p); i++) { int a = p - i; if (a % (2 * i + 1) == 0 && a >= 1) { return 0; } } return 1; } int main() { cin >> n; for (int i = 0; i < n; i++) { cin >> x; sum += hantei(x); } cout << sum << endl; return 0; }
a.cc: In function 'int hantei(int)': a.cc:8:26: error: 'sqrt' was not declared in this scope 8 | int v = max((int)sqrt(p) * 5, p); | ^~~~
s729666942
p00513
C++
#include <stdio.h> inline bool check(int n) { int rep = x > 100 ? 100 : x; for(int x = 1; x < rep; x++) { if((n - x) % (2 * x + 1) == 0) { return true; } } return false; } int main() { int n, q, c = 0; scanf("%d", &q); for(int i = 0; i < q; i++) { scanf("%d", &n); c += check(n) ? 0 : 1; } printf("%d\n", c); return 0; }
a.cc: In function 'bool check(int)': a.cc:5:15: error: 'x' was not declared in this scope 5 | int rep = x > 100 ? 100 : x; | ^
s483598406
p00513
C++
#include <stdio.h> #include <algorithm> using namespace std; inline bool check(int n) { int rep = min(x, 100); for(int x = 1; x < rep; x++) { if((n - x) % (2 * x + 1) == 0) { return true; } } return false; } int main() { int n, q, c = 0; scanf("%d", &q); for(int i = 0; i < q; i++) { scanf("%d", &n); c += check(n) ? 0 : 1; } printf("%d\n", c); return 0; }
a.cc: In function 'bool check(int)': a.cc:8:19: error: 'x' was not declared in this scope 8 | int rep = min(x, 100); | ^
s648836015
p00513
C++
#include<iostream> using namespace std; bool f(long long a) { if(a % 2 =v 0) return false; for(long long i = 3; i *i <= a; i += 2) if(a % i == 0) return false; return true; } int main() { int n; cin >> n; int res=0; for(int i=0; i<n; i++j { long long a; cin a; if(f2ga+1)) res++; } cout << res << endl; return 0; }
a.cc: In function 'bool f(long long int)': a.cc:4:13: error: 'v' was not declared in this scope 4 | if(a % 2 =v 0) return false; | ^ a.cc:4:14: error: expected ')' before numeric constant 4 | if(a % 2 =v 0) return false; | ~ ^~ | ) a.cc: In function 'int main()': a.cc:14:24: error: expected ')' before 'j' 14 | for(int i=0; i<n; i++j { | ~ ^ | ) a.cc:14:24: error: 'j' was not declared in this scope