submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s258979723
p03745
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef long double ld; typedef unsigned long long int ull; const long long int m=pow(10,9)+7; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin>>n; vector<ll>a; for(ll i=0;i<n;i++) { ll x; cin>>x; a.push_back(x); } ll res=0; for(ll i=0;i<n;i++) { while(i+1<n&&a[i+1]==a[i]) i++; if(a[i+1]>a[i]) { while(i+1<n&&aa[i+1]>=a[i]) i++; } else { while(i+1<n&&a[i+1]<=a[i]) i++; } res++; } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:28:26: error: 'aa' was not declared in this scope; did you mean 'a'? 28 | while(i+1<n&&aa[i+1]>=a[i]) | ^~ | a
s988084132
p03745
C++
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n, tmp = 0, cnt = 1; cin >> n; vector<ll> a(n); for(int i = 0; i < n; i++) { cin >> a[i]; } if (n == 1) { cout << 1 << endl; return 0; } for(int i = 0,i < n-1; i++) { if (a[i] < a[i + 1]) { if (tmp = -1) { cnt++; tmp = 0; } else { tmp = 1; } } if (a[i] > a[i + 1]) { if (tmp == 1) { cnt++; tmp = 0; } else { tmp = -1; } } } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:20: error: expected ';' before '<' token 20 | for(int i = 0,i < n-1; i++) { | ^~ | ; a.cc:20:21: error: expected primary-expression before '<' token 20 | for(int i = 0,i < n-1; i++) { | ^
s958658417
p03745
C++
#include<stdio.h> #include<iostream> #include<vector> #include<math.h> #include<queue> #include<map> #include<algorithm> #include<string.h> #include<functional> #include<limits.h> #include<stdlib.h> #include<string> #include<unordered_map> #include<set> using namespace std; #define intmax INT_MAX #define lmax LONG_MAX #define uintmax UINT_MAX #define ulmax ULONG_MAX #define llmax LLONG_MAX #define ll long long #define rep(i,a,N) for((i)=(a);(i)<(N);(i)++) #define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--) #define llfor ll i,j,k #define sc(a) cin>>a #define pr(a) cout<<a<<endl #define pY puts("YES") #define pN puts("NO") #define py puts("Yes") #define pn puts("No") #define pnn printf("\n") #define sort(a) sort(a.begin(),a.end()) #define push(a,b) (a).push_back(b) #define llvec vector<vector<ll>> #define charvec vector<vector<char>> #define sizeoof(a,b) (a,vector<ll>(b)) #define llpvec vector<pair<ll,ll>> /*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;} /*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;} /*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;} /*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;} /*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;} /*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);} /*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);} /*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;} llfor;/////////////////////////////////////////////////////////// int main(){ ll n;sc(n); ll a[n],b[n]=; ll ans=1; rep(i,0,n){ sc(a[i]); } rep(i,0,n-1){ if(a[i]<a[i+1])b[i]=0; else if(a[i]>a[i+1])b[i]=1; else b[i]=b[i-1]; if((b[i-1]==1&&b[i]==0)||(b[i-1]==0&&b[i]==1)){ ans++; // cout<<b[i-1]<<" "<<b[i]<<" "<<i<<endl; b[i]=2; } } pr(ans); return 0;}
a.cc: In function 'int main()': a.cc:50:15: error: expected primary-expression before ';' token 50 | ll a[n],b[n]=; | ^
s075232044
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; int L=0; cin>>N; vector<int>vec(N); for(int X=0;X<N;X++){ cin>>vec.at(X); if(X>1){ if(vec.at(X-2)>=vec.at(X-1) && vec.at(X-1)<=vec.at(X) && !(vec.at(X-2)=vec.at(X-1) && vec.at(X-1)=vec.at(X))){ L++; } else if(vec.at(X-2)<=vec.at(X-1) && vec.at(X-1)>=vec.at(X) && !(vec.at(X-2)=vec.at(X-1) && vec.at(X-1)=vec.at(X))){ L++; } } } cout<<L<<endl; }
a.cc: In function 'int main()': a.cc:12:90: error: lvalue required as left operand of assignment 12 | if(vec.at(X-2)>=vec.at(X-1) && vec.at(X-1)<=vec.at(X) && !(vec.at(X-2)=vec.at(X-1) && vec.at(X-1)=vec.at(X))){ | ~~~~~~~~~~~~^~~~~~~~~~~~~~ a.cc:15:95: error: lvalue required as left operand of assignment 15 | else if(vec.at(X-2)<=vec.at(X-1) && vec.at(X-1)>=vec.at(X) && !(vec.at(X-2)=vec.at(X-1) && vec.at(X-1)=vec.at(X))){ | ~~~~~~~~~~~~^~~~~~~~~~~~~~
s062099004
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; vector<int> a(N); for(int i=0;i<N;i++) { cin>>a[i]; } int count=0; for(int i=0;i<N;i++) { while(i+1<N && a[i] == a[i + 1]) ++i; if (i+1<N && [i] < a[i+1]){ while (i+1<N && a[i] <= a[i+1])++i; } else if (i+1<N && a[i]>a[i+1]){ while (i+1<N && a[i]>=a[i+1])++i; } count++; } cout << count << endl; }
a.cc: In function 'int main()': a.cc:15:24: error: 'a' is not a type 15 | if (i+1<N && [i] < a[i+1]){ | ^ a.cc:15:30: error: expected '>' before ')' token 15 | if (i+1<N && [i] < a[i+1]){ | ^ a.cc: In lambda function: a.cc:15:30: error: expected '{' before ')' token a.cc: In function 'int main()': a.cc:15:15: error: no match for 'operator&&' (operand types are 'bool' and 'main()::<lambda()>') 15 | if (i+1<N && [i] < a[i+1]){ | ~~~~~ ^~ ~~~~~~~~~~~~ | | | | bool main()::<lambda()> a.cc:15:15: note: candidate: 'operator&&(bool, bool)' (built-in) 15 | if (i+1<N && [i] < a[i+1]){ | ~~~~~~^~~~~~~~~~~~~~~ a.cc:15:15: note: no known conversion for argument 2 from 'main()::<lambda()>' to 'bool' In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166, from a.cc:1: /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:15:30: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:15:30: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:15:30: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:15:30: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'bool' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/bits/valarray_after.h:415:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__logical_and, typename _Dom1::value_type>::result_type> std::operator&&(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 415 | _DEFINE_EXPR_BINARY_OPERATOR(&&, struct std::__logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:415:5: note: template argument deduction/substitution failed: a.cc:15:30: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const valarray<_Tp>&)' 1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed: a.cc:15:30: note: mismatched types 'const std::valarray<_Tp>' and 'bool' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed: a.cc:15:30: note: mismatched types 'const std::valarray<_Tp>' and 'bool' 15 | if (i+1<N && [i] < a[i+1]){ | ^ /usr/include/c++/14/valarray:1206:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__logical_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__logical_and, _Tp>::result_type> std::operator&&(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1206 | _DEFINE_BINARY_OPERATOR(&&, __logical_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1206:1: note: template argument deduction/substitution failed: a.cc:15:30: note: 'main()::<lambda()>' is not derived from 'const std::valarray<_Tp>' 15 | if (i+1<N && [i] < a[i+1]){ | ^
s126025094
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin>>N; vector<int> a(N); for(int i=0;i<N;i++) { cin>>[i]; } int count=0; for(int i=0;i<N;i++) { while(i+1<N && a[i] == a[i + 1]) ++i; if (i+1<N && [i] < a[i+1]){ while (i+1<N && a[i] <= a[i+1])++i; } else if (i+1<N && a[i]>a[i+1]){ while (i+1<N && a[i]>=a[i+1])++i; } count++; } cout << count << endl; }
a.cc: In lambda function: a.cc:9:13: error: expected '{' before ';' token 9 | cin>>[i]; | ^ a.cc: In function 'int main()': a.cc:9:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'main()::<lambda()>') 9 | cin>>[i]; | ~~~^~~~~ | | | | | main()::<lambda()> | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from 'main()::<lambda()>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 352 | operator>>(__streambuf_type* __s
s248422527
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<int>A[N]; int ans=0; int count=0; for(int i=0;i<N;i++){ cin>>A[i]; } for(int i=0;i<N;i++){ if(i==0){ continue; } if(count==0&&A[i]<A[i-1]){ count==1; continue; } else if(count==0&&A[i]>A[i-1]){ count==2; continue; } if(count==2&&A[i]<A[i-1]){ count==0; ans++; } else if(count==1&&A[i]>A[i-1]){ count==0; ans++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:11:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>') 11 | cin>>A[i]; | ~~~^~~~~~ | | | | | std::vector<int> | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 352 | operator>>(__streambuf_type* __sb); | ~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/1
s116191446
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N; vector<int>A[N]; int ans=0; int count=0; for(int i=0;i<N;i++){ cin>>A[i]; } for(int i=0;i<N;i++){ if(i==0){ continue; } if(count==0&&A[i]<A[i-1]){ count==1; continue; } else if(count==0&&A[i]>A[i-1]){ count==2; continue; } if(count==2&&A[i]<A[i-1]){ count==0; ans++; } else if(count==1&&A[i]>A[i-1]){ count==0; ans++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:10:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<int>') 10 | cin>>A[i]; | ~~~^~~~~~ | | | | | std::vector<int> | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'std::vector<int>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'std::vector<int>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'std::vector<int>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'std::vector<int>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'std::vector<int>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'std::vector<int>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'std::vector<int>' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 352 | operator>>(__streambuf_type* __sb); | ~~~~~~~~~~~~~~~~~~^~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/1
s182368840
p03745
C++
#include<bits/stdc++.h> using namespace std; int main(){ int N vector<int>A(N); for(int i=0;i<N;i++) cin>>A.at(N); //途中まで。 return 0; }
a.cc: In function 'int main()': a.cc:6:3: error: expected initializer before 'vector' 6 | vector<int>A(N); | ^~~~~~ a.cc:8:17: error: 'N' was not declared in this scope 8 | for(int i=0;i<N;i++) cin>>A.at(N); | ^ a.cc:8:29: error: 'A' was not declared in this scope 8 | for(int i=0;i<N;i++) cin>>A.at(N); | ^
s100187293
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int x; cin >> x; vector<int> arr(x); for (int i = 0; i<x; i++){ cin >> arr[i]; } vector<vector<int>> B(1); for (int i = 0; i<x; i++){ if (B.back().size() == 0){ B.back().push_back(arr[i]); } else if (B.back().size() == 1){ B.back().push_back(arr[i]); } else if (B.back().front() == B.back().back()){ B.back().push_back(arr[i]); } else if (B.back().front() < B.back().back()){ if (B.back().back() <= arr[i]){ B.back().push_back(arr[i]); } else { B.push_back(vector<int>(1, arr[i])); } } else { assert(B.back().front()>B.back().back()); if (B.back().back() >= arr[i]){ B.back().push_back(arr[i]); } else { B.push_back(vector<int>(1, arr[i])); } } } cout << B.size() return 0; }
a.cc: In function 'int main()': a.cc:33:19: error: expected ';' before 'return' 33 | cout << B.size() | ^ | ; 34 | return 0; | ~~~~~~
s830119686
p03745
C++
# include <iostream> # include <map> using namespace std; const int NEUTRAL = 0; const int ASCENDING = -1; const int DESCENDING = 1; int main(){ int N, numbers[100005]; cin >> N; for(int i=0; i<N; i++){ cin >> numbers[i]; } int flag = NEUTRAL; int ans = 0; for(int i=0; i<N-1; i++){ if((flag == ASCENDING && numbers[i] > numbers[i+1]) || (flag == DESCENDING && numbers[i] < numbers[i+1]) { ans++; flag = NEUTRAL; } else if(numbers[i] < numbers[i+1]) flag = ASCENDING; else if(numbers[i] > numbers[i+1]) flag = DESCENDING; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:57: error: expected ';' before '{' token 20 | (flag == DESCENDING && numbers[i] < numbers[i+1]) { | ^~ | ; a.cc:24:5: error: expected primary-expression before 'else' 24 | else if(numbers[i] < numbers[i+1]) flag = ASCENDING; | ^~~~ a.cc:23:9: error: expected ')' before 'else' 23 | } | ^ | ) 24 | else if(numbers[i] < numbers[i+1]) flag = ASCENDING; | ~~~~ a.cc:19:7: note: to match this '(' 19 | if((flag == ASCENDING && numbers[i] > numbers[i+1]) || | ^
s024834713
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; pair<int,int>data=mke_pair(0,0); int y; cin >> y; data.first=y; int count=1; for(int i=1;i<N;i++){ int x; cin >> x; if(x>data.first&&data.second==2){ count++; data.second=0; } else if(x<data.first&&data.second==1){ count++; data.second=0; } else if(x>data.first&&data.second==0){ data.second=1; } else if(x<data.first&&data.second==0){ data.second=2; } data.first=x; } cout << count << endl; }
a.cc: In function 'int main()': a.cc:7:21: error: 'mke_pair' was not declared in this scope 7 | pair<int,int>data=mke_pair(0,0); | ^~~~~~~~
s096508614
p03745
C++
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define mp make_pair int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin.tie(NULL); ll int n; cin>>n; int a[n],ans=0; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n;i++) { while(i+1<n && a[i]==a[i+1]){i++;} else if(i+1<n && a[i+1]>a[i]) { while(i<n-1 && a[i+1]>=a[i]) i++; } else if(i+1<n && a[i+1]<a[i]) { while(i<n-1 && a[i+1]<=a[i] ) i++; } ans++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:21:17: error: 'else' without a previous 'if' 21 | else if(i+1<n && a[i+1]>a[i]) | ^~~~
s223784296
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int>data(N); for(int i:data){ cin >> data.at(i); } int count=1; int j=0; while(j<N){ int status=0; int i=j; while(i<N-1){ else if(data.at(i)<data.at(i+1)&&status!=2) status=1; else if(data.at(i)>data.at(i+1)&&status!=1) status=2; else if(data.at(i)==data.at(i+1)) status=status; else break; i++; j=i+1; } count++; } cout << count << endl; }
a.cc: In function 'int main()': a.cc:17:7: error: 'else' without a previous 'if' 17 | else if(data.at(i)<data.at(i+1)&&status!=2) status=1; | ^~~~
s447298608
p03745
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) int main(){ int N; cin >> N; vector<int> A(N); rep(i,N){ cin >> A[N]; } int i=0; int count=1; while(i<N-1){ if(A[i]+1 == A[i+1]){ while(A[i] == A[i+1] || A[i]+1 == A[i+1]){ i++; if(A[i] != A[i+1] && A[i]+1 != A[i+1]) count++; } } if(A[i]-1 == A[i+1]){ while(A[i] == A[i+1] || A[i]-1 == A[i+1]){ i++; if(A[i] != A[i+1] && A[i]-1 != A[i+1]) count++; } } if(A[i] != A[i+1] && A[i]+1 != A[i+1] && A[i]-1 != A[i+1]){ count++; i++ } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:32:10: error: expected ';' before '}' token 32 | i++ | ^ | ; 33 | } | ~
s384080885
p03745
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) int main(){ int N; cin >> N; vector(int) A(N); rep(i,N){ cin >> A(N); } int i=0; int count=1; while(i<N-1){ if(A[i]+1 == A[i+1]){ while(A[i] == A[i+1] || A[i]+1 == A[i+1]){ i++; if(A[i] != A[i+1] && A[i]+1 != A[i+1]) count++; } } if(A[i]-1 == A[i+1]){ while(A[i] == A[i+1] || A[i]-1 == A[i+1]){ i++; if(A[i] != A[i+1] && A[i]-1 != A[i+1]) count++; } } if(A[i] != A[i+1] && A[i]+1 != A[i+1] && A[i]-1 != A[i+1]){ count++; } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:8:9: error: missing template arguments before '(' token 8 | vector(int) A(N); | ^ a.cc:8:10: error: expected primary-expression before 'int' 8 | vector(int) A(N); | ^~~ a.cc:10:12: error: 'A' was not declared in this scope 10 | cin >> A(N); | ^ a.cc:16:8: error: 'A' was not declared in this scope 16 | if(A[i]+1 == A[i+1]){ | ^ a.cc:23:8: error: 'A' was not declared in this scope 23 | if(A[i]-1 == A[i+1]){ | ^ a.cc:30:8: error: 'A' was not declared in this scope 30 | if(A[i] != A[i+1] && A[i]+1 != A[i+1] && A[i]-1 != A[i+1]){ | ^
s728583890
p03745
C++
int main(){ int N; cin >> N; vector<ll> A(N); rep(i,N) cin >> A[i]; vector<ll> diff(N-1); rep(i,N-1){ diff[i]=A[i+1]-A[i]; } ll ans = 0; rep(i,N-2){ if(diff[i]*diff[i+1]<0){ // 増減の反転 i++; ans++; } } ans++; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:3:5: error: 'cin' was not declared in this scope 3 | cin >> N; | ^~~ a.cc:4:5: error: 'vector' was not declared in this scope 4 | vector<ll> A(N); | ^~~~~~ a.cc:4:12: error: 'll' was not declared in this scope 4 | vector<ll> A(N); | ^~ a.cc:4:16: error: 'A' was not declared in this scope 4 | vector<ll> A(N); | ^ a.cc:5:9: error: 'i' was not declared in this scope 5 | rep(i,N) cin >> A[i]; | ^ a.cc:5:5: error: 'rep' was not declared in this scope 5 | rep(i,N) cin >> A[i]; | ^~~ a.cc:6:16: error: 'diff' was not declared in this scope 6 | vector<ll> diff(N-1); | ^~~~ a.cc:10:7: error: expected ';' before 'ans' 10 | ll ans = 0; | ^~~~ | ; a.cc:18:5: error: 'ans' was not declared in this scope 18 | ans++; | ^~~ a.cc:19:5: error: 'cout' was not declared in this scope 19 | cout << ans << endl; | ^~~~ a.cc:19:20: error: 'endl' was not declared in this scope 19 | cout << ans << endl; | ^~~~
s207775369
p03745
C++
1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 | ^
s796426090
p03745
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> l_l; typedef pair<int , int> i_i; typedef vector<ll> vl; typedef vector<int> vi; typedef vector<char> vec; typedef vector<bool> veb; typedef vector<string> ves; typedef vector<vector<ll>> vvl; typedef vector<vector<int>> vvi; typedef vector<vector<char>> vvec; typedef vector<vector<bool>> vveb; typedef vector<vector<string>> vves; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<(int)(n);i++) #define rep2(i,n) for(int i=2;i<(int)(n);i++) #define repk(i,k,n) for(int i=k;i<(int)(n);i++) #define fs first #define sc second #define pb push_back #define pp pop_back #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define maxel(a) *max_element(all(a)) #define minel(a) *min_element(all(a)) #define acc accumulate #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) #define mod (1000000007) typedef long long int64; //const int64 INF = 1LL << 58; #define dame { puts("-1"); return 0;} #define YES { cout << "YES" << endl; return 0; } #define NO { cout << "NO" << endl; return 0; } #define Yes { cout << "Yes" << endl; return 0; } #define No { cout << "No" << endl; return 0; } template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int dx[] = {0, 0, -1, 1}; int dy[] = {1, -1, 0, 0}; int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vl a(n); rep(i,n){ cin >> a[i]; } int cnt = 0; rep(i,n){ while(i+1<n && a[i]==a[i+1])++i; if(i+1<n && a[i]>a[i+1]){ while(i+1<n && a[i]>=a[i+1])++i; } else if(i+1<n && a[i]>a[i+1]){ while(i+1 && a[i]>=a[i+1)++i; } } ++cnt; cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:66:37: error: expected ']' before ')' token 66 | while(i+1 && a[i]>=a[i+1)++i; | ^ | ]
s148088861
p03745
C++
#include <iostream> #include <algorithm> #include <string> #include <math.h> #include <cstdint> #include <vector> #include <sstream> #include <unordered_map> using namespace std; typedef long long ll; ll ans, mx, mn, flag, sum, cnt; int main(){ ll n; cin>>n; ans=1; ll a[n]; for(ll i=0; i<n; i++){ cin>>a[i]; } //bool increase=false; for(ll i=1; i<n-1; i++){ if(a[i]>a[i-1] && a[i]>=a[i+1]){ ans++; i++; increase=true; } else if(a[i]<a[i-1] && a[i]<=a[i+1]){ ans++; i++; } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:30:25: error: 'increase' was not declared in this scope 30 | increase=true; | ^~~~~~~~
s916941993
p03745
C++
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin>>N; vector<int>A(N); for(int i=0;i<N;i++) cin>>A.at(i); int ans=1; int a=1; for(int i=1;i<N;i++){ if(A.at(i-1)<A.at(i)){ if(a==1){ a=0; }else if(a==2){ ans++; a=1; }else a=0; } if(A.at(i)<A.at(i-1)){ if(a==1){ a=2; }else if(a==0){ ans++; a=1; }else a=2; } } }cout<<ans<<endl; return 0; }
a.cc:29:4: error: 'cout' does not name a type 29 | }cout<<ans<<endl; | ^~~~ a.cc:30:4: error: expected unqualified-id before 'return' 30 | return 0; | ^~~~~~ a.cc:31:1: error: expected declaration before '}' token 31 | } | ^
s619343019
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; vector <int> A(N); for (int i=0;i<N;i++){ cin >> A[i]; } bool j=0; int c=1 if (A[0] > A[1]){ j=1; } for (int i=1;i<N;i++){ if (j){ if (A[i] < A[i-1]){ continue; } else j=0,c++; } else { if (A[i] > A[i-1]){ continue; } else j=1,c++; } } }
a.cc: In function 'int main()': a.cc:13:3: error: expected ',' or ';' before 'if' 13 | if (A[0] > A[1]){ | ^~
s088023778
p03745
C++
#include<iostream> using namespace std; int main(){ int i,j,k; int 64_t N; int 64_t a[N]; int count=0; cin>>N>>a[N]; for(i=0;i<N-1;i=i+k+2){ k=0; if(a[i]-a[i+1]<=0){ count++; for(j=i+1;j<N;j++){ if(a[j]-a[j+1]<=0){ k++;} else if(a[j]-a[j+1]>0){ break;} }} else if(a[i]-a[i+1]>=0){ count++; for(j=i+1;j<N;j++){ if(a[j]-a[j+1]>=0){ k++;} else if(a[j]-a[j+1]<0){ break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected unqualified-id before numeric constant 6 | int 64_t N; | ^~~~ a.cc:7:7: error: expected unqualified-id before numeric constant 7 | int 64_t a[N]; | ^~~~ a.cc:9:8: error: 'N' was not declared in this scope 9 | cin>>N>>a[N]; | ^ a.cc:9:11: error: 'a' was not declared in this scope 9 | cin>>N>>a[N]; | ^
s643809265
p03745
C++
#include<iostream> using namespace std; int main(){ int i,j,k; int 64_t N; int 64_t a[N]; int count=0; cin>>N>>a[N]; for(i=0;i<N-1;i=i+k+2){ k=0; if(a[i]-a[i+1]<=0){ count++; for(j=i+1;j<N;j++){ if(a[j]-a[j+1]<=0){ k++;} else if(a[j]-a[j+1]>0){ break;} }} else if(a[i]-a[i+1]>=0){ count++; for(j=i+1;j<N;j++){ if(a[j]-a[j+1]>=0){ k++;} else if(a[j]-a[j+1]<0){ break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected unqualified-id before numeric constant 6 | int 64_t N; | ^~~~ a.cc:7:7: error: expected unqualified-id before numeric constant 7 | int 64_t a[N]; | ^~~~ a.cc:9:8: error: 'N' was not declared in this scope 9 | cin>>N>>a[N]; | ^ a.cc:9:11: error: 'a' was not declared in this scope 9 | cin>>N>>a[N]; | ^
s343391447
p03745
C++
#include<iostream> using namespace std; int main(){ int 64_t N,i,j,k; int 64_t a[N]; int count=0; cin>>N>>a[N]; for(i=0;i<N-1;i=i+k+2){ k=0; if(a[i]-a[i+1]<=0){ count++; for(j=i+1;j<N;j++){ if(a[j]-a[j+1]<=0){ k++;} else if(a[j]-a[j+1]>0){ break;} }} else if(a[i]-a[i+1]>=0){ count++; for(j=i+1;j<N;j++){ if(a[j]-a[j+1]>=0){ k++;} else if(a[j]-a[j+1]<0){ break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:5:7: error: expected unqualified-id before numeric constant 5 | int 64_t N,i,j,k; | ^~~~ a.cc:6:7: error: expected unqualified-id before numeric constant 6 | int 64_t a[N]; | ^~~~ a.cc:8:8: error: 'N' was not declared in this scope 8 | cin>>N>>a[N]; | ^ a.cc:8:11: error: 'a' was not declared in this scope 8 | cin>>N>>a[N]; | ^ a.cc:10:7: error: 'i' was not declared in this scope 10 | for(i=0;i<N-1;i=i+k+2){ | ^ a.cc:10:21: error: 'k' was not declared in this scope 10 | for(i=0;i<N-1;i=i+k+2){ | ^ a.cc:14:11: error: 'j' was not declared in this scope 14 | for(j=i+1;j<N;j++){ | ^ a.cc:22:21: error: 'j' was not declared in this scope 22 | for(j=i+1;j<N;j++){ | ^
s311023465
p03745
C++
#include<iostream> using namespace std; int main(){ int N,i,j,k; int a[N] int count=0; cin>>N>>a[N]; for(i=0;i<N-1;i+k+2){ k=0; if(a[i]-a[i+1]<=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]<=0){ k++;} else{ count++; break;} }} else if(a[i]-a[i+1]>=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]>=0){ k++;} else{ count++; break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:7:3: error: expected initializer before 'int' 7 | int count=0; | ^~~ a.cc:8:11: error: 'a' was not declared in this scope 8 | cin>>N>>a[N]; | ^ a.cc:17:11: error: 'count' was not declared in this scope 17 | count++; | ^~~~~ a.cc:25:11: error: 'count' was not declared in this scope 25 | count++; | ^~~~~ a.cc:29:6: error: 'count' was not declared in this scope 29 | if(count==0){ | ^~~~~ a.cc:31:7: error: 'count' was not declared in this scope 31 | cout<<count<<endl; | ^~~~~
s271003253
p03745
C++
#include<iostream> using namespace std; int main(){ int N,i,j,k; int a[N] int count; cin>>N>>a[]; for(i=0;i<N-1;i+k+2){ k=0; if(a[i]-a[i+1]<=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]<=0){ k++;} else{ count++; break;} }} else if(a[i]-a[i+1]>=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]>=0){ k++;} else{ count++; break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:7:3: error: expected initializer before 'int' 7 | int count; | ^~~ a.cc:8:11: error: 'a' was not declared in this scope 8 | cin>>N>>a[]; | ^ a.cc:8:13: error: expected primary-expression before ']' token 8 | cin>>N>>a[]; | ^ a.cc:17:11: error: 'count' was not declared in this scope 17 | count++; | ^~~~~ a.cc:25:11: error: 'count' was not declared in this scope 25 | count++; | ^~~~~ a.cc:29:6: error: 'count' was not declared in this scope 29 | if(count==0){ | ^~~~~ a.cc:31:7: error: 'count' was not declared in this scope 31 | cout<<count<<endl; | ^~~~~
s539303907
p03745
C++
#include<iostream> using namespace std; int main(){ int a[N],N,i,j,k; int count; cin>>N>>a[]; for(i=0;i<N-1;i+k+2){ k=0; if(a[i]-a[i+1]<=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]<=0){ k++;} else{ count++; break;} }} else if(a[i]-a[i+1]>=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]>=0){ k++;} else{ count++; break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:5:9: error: 'N' was not declared in this scope 5 | int a[N],N,i,j,k; | ^ a.cc:7:11: error: 'a' was not declared in this scope 7 | cin>>N>>a[]; | ^ a.cc:7:13: error: expected primary-expression before ']' token 7 | cin>>N>>a[]; | ^
s904354686
p03745
C++
#include<iostream> using namespace std; int main(){ int a[],N,i,j,k; int count; cin>>N>>a[]; for(i=0;i<N-1;i+k+2){ k=0; if(a[i]-a[i+1]<=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]<=0){ k++;} else{ count++; break;} }} else if(a[i]-a[i+1]>=0){ for(j=i+1;j<N-1;j++){ if(a[j]-a[j+1]>=0){ k++;} else{ count++; break;} }} } if(count==0){ count++;} cout<<count<<endl; }
a.cc: In function 'int main()': a.cc:5:7: error: storage size of 'a' isn't known 5 | int a[],N,i,j,k; | ^ a.cc:7:13: error: expected primary-expression before ']' token 7 | cin>>N>>a[]; | ^
s632649863
p03745
C++
#include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) cin>>A[i]; int res = 0; for (int i = 0; i < N; ++i) { while (i+1 < N && A[i] == A[i+1]) ++i; if (i+1 < N && A[i] < A[i+1]) { while (i+1 < N && A[i] <= A[i+1]) ++i; } else if (i+1 < N && A[i] > A[i+1]) { while (i+1 < N && A[i] >= A[i+1]) ++i; } ++res; } cout<<res<<endl; }
a.cc: In function 'int main()': a.cc:5:12: error: 'cin' was not declared in this scope 5 | int N; cin >> N; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <vector> +++ |+#include <iostream> 2 | using namespace std; a.cc:23:5: error: 'cout' was not declared in this scope 23 | cout<<res<<endl; | ^~~~ a.cc:23:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:23:16: error: 'endl' was not declared in this scope 23 | cout<<res<<endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <vector> +++ |+#include <ostream> 2 | using namespace std;
s679288858
p03745
C++
#include <vector> using namespace std; int main() { int N; cin >> N; vector<int> A(N); for (int i = 0; i < N; ++i) cin >> A[i]; int res = 0; for (int i = 0; i < N; ++i) { // same を抜ける while (i+1 < N && A[i] == A[i+1]) ++i; // up if (i+1 < N && A[i] < A[i+1]) { while (i+1 < N && A[i] <= A[i+1]) ++i; } // down else if (i+1 < N && A[i] > A[i+1]) { while (i+1 < N && A[i] >= A[i+1]) ++i; } ++res; } cout << res << endl; }
a.cc: In function 'int main()': a.cc:5:12: error: 'cin' was not declared in this scope 5 | int N; cin >> N; | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include <vector> +++ |+#include <iostream> 2 | using namespace std; a.cc:24:5: error: 'cout' was not declared in this scope 24 | cout << res << endl; | ^~~~ a.cc:24:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:24:20: error: 'endl' was not declared in this scope 24 | cout << res << endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include <vector> +++ |+#include <ostream> 2 | using namespace std;
s628953780
p03745
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++) #define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--) #define sort_asc( X ) sort(( X ).begin(), ( X ).end()) #define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>()) template <class T> bool chmax( T& a, T b ); template <class T> bool chmin( T& a, T b ); int* eratosthenes( int N ); bool bit_search( int pattern, int N ); template <class T> void cumulative_sum( T array, size_t N ); const ll INF = 1LL << 60; const int k_mod = 1e9 + 7; typedef struct { vector <int> to; int cost; } edge; typedef struct { bool a; bool b; } P; int main( void ){ int N; cin >> N; int prev_input, input, cnt = 2, ans = 1; cin >> prev_input >> input; while(input == prev_input && cnt < N){ cin >> input; cnt++; } bool is_inc = input >= prev_input; rep( i, 0, N - cnt ){ prev_input = input; cin >> input; if (input == prev_input); else if (input >= prev_input ^ is_inc){ if (i + cnt + 1 < N){ prev_input = input; cin >> input; cnt++; while(input == prev_input & i + cnt + 1 < N){ cin >> input; cnt++; } is_inc = input >= prev_input; } // is_inc = input >= prev_input; ans++; } } cout << ans << endl; } int* eratosthenes( int N ){ int* prime_array = new int[ N + 1 ]; int lim = N; prime_array[ 0 ] = 0; prime_array[ 1 ] = 0; rep( i, 2, N + 1 ){ prime_array[ i ] = 1; } rep( i, 2, lim ){ if (prime_array[ i ] == 0) continue; lim = N / i; for(int j = i * 2; j < N + 1; j += i){ prime_array[ j ] = 0; } } return prime_array; } template <class T> void cumulative_sum( T array, size_t N ) { rep( i, 1, N + 1 ){ array[ i ] += array[ i - 1 ]; } } template <class T> bool chmax( T& a, T b ) { if (a < b){ a = b; return true; } return false; } template <class T> bool chmin( T& a, T b ) { if (a > b){ a = b; return true; } return false; } bool bit_search( int pattern, int N ){ int cnt = 0; rep( bit, 0, N ){ if (pattern & ( 1 << bit )){ cnt++; } } return true; } #include <bits/stdc++.h> using namespace std; typedef long long int ll; #define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++) #define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--) #define sort_asc( X ) sort(( X ).begin(), ( X ).end()) #define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>()) template <class T> bool chmax( T& a, T b ); template <class T> bool chmin( T& a, T b ); int* eratosthenes( int N ); bool bit_search( int pattern, int N ); template <class T> void cumulative_sum( T array, size_t N ); const ll INF = 1LL << 60; const int k_mod = 1e9 + 7; typedef struct { vector <int> to; int cost; } edge; typedef struct { bool a; bool b; } P; int main( void ){ int N; cin >> N; int prev_input, input, cnt = 2, ans = 1; cin >> prev_input >> input; while(input == prev_input && cnt < N){ cin >> input; cnt++; } bool is_inc = input >= prev_input; rep( i, 0, N - cnt ){ prev_input = input; cin >> input; if (input == prev_input); else if (input >= prev_input ^ is_inc){ if (i + cnt + 1 < N){ prev_input = input; cin >> input; cnt++; while(input == prev_input & i + cnt + 1 < N){ cin >> input; cnt++; } is_inc = input >= prev_input; } // is_inc = input >= prev_input; ans++; } } cout << ans << endl; } int* eratosthenes( int N ){ int* prime_array = new int[ N + 1 ]; int lim = N; prime_array[ 0 ] = 0; prime_array[ 1 ] = 0; rep( i, 2, N + 1 ){ prime_array[ i ] = 1; } rep( i, 2, lim ){ if (prime_array[ i ] == 0) continue; lim = N / i; for(int j = i * 2; j < N + 1; j += i){ prime_array[ j ] = 0; } } return prime_array; } template <class T> void cumulative_sum( T array, size_t N ) { rep( i, 1, N + 1 ){ array[ i ] += array[ i - 1 ]; } } template <class T> bool chmax( T& a, T b ) { if (a < b){ a = b; return true; } return false; } template <class T> bool chmin( T& a, T b ) { if (a > b){ a = b; return true; } return false; } bool bit_search( int pattern, int N ){ int cnt = 0; rep( bit, 0, N ){ if (pattern & ( 1 << bit )){ cnt++; } } return true; }
a.cc:113:10: error: redefinition of 'const ll INF' 113 | const ll INF = 1LL << 60; | ^~~ a.cc:15:10: note: 'const ll INF' previously defined here 15 | const ll INF = 1LL << 60; | ^~~ a.cc:114:11: error: redefinition of 'const int k_mod' 114 | const int k_mod = 1e9 + 7; | ^~~~~ a.cc:16:11: note: 'const int k_mod' previously defined here 16 | const int k_mod = 1e9 + 7; | ^~~~~ a.cc:119:3: error: conflicting declaration 'typedef struct edge edge' 119 | } edge; | ^~~~ a.cc:21:3: note: previous declaration as 'typedef struct edge edge' 21 | } edge; | ^~~~ a.cc:123:3: error: conflicting declaration 'typedef struct P P' 123 | } P; | ^ a.cc:25:3: note: previous declaration as 'typedef struct P P' 25 | } P; | ^ a.cc:124:5: error: redefinition of 'int main()' 124 | int main( void ){ | ^~~~ a.cc:26:5: note: 'int main()' previously defined here 26 | int main( void ){ | ^~~~ a.cc:153:6: error: redefinition of 'int* eratosthenes(int)' 153 | int* eratosthenes( int N ){ | ^~~~~~~~~~~~ a.cc:55:6: note: 'int* eratosthenes(int)' previously defined here 55 | int* eratosthenes( int N ){ | ^~~~~~~~~~~~ a.cc:171:25: error: redefinition of 'template<class T> void cumulative_sum(T, size_t)' 171 | template <class T> void cumulative_sum( T array, size_t N ) { | ^~~~~~~~~~~~~~ a.cc:73:25: note: 'template<class T> void cumulative_sum(T, size_t)' previously declared here 73 | template <class T> void cumulative_sum( T array, size_t N ) { | ^~~~~~~~~~~~~~ a.cc:176:25: error: redefinition of 'template<class T> bool chmax(T&, T)' 176 | template <class T> bool chmax( T& a, T b ) { | ^~~~~ a.cc:78:25: note: 'template<class T> bool chmax(T&, T)' previously declared here 78 | template <class T> bool chmax( T& a, T b ) { | ^~~~~ a.cc:182:25: error: redefinition of 'template<class T> bool chmin(T&, T)' 182 | template <class T> bool chmin( T& a, T b ) { | ^~~~~ a.cc:84:25: note: 'template<class T> bool chmin(T&, T)' previously declared here 84 | template <class T> bool chmin( T& a, T b ) { | ^~~~~ a.cc:188:6: error: redefinition of 'bool bit_search(int, int)' 188 | bool bit_search( int pattern, int N ){ | ^~~~~~~~~~ a.cc:90:6: note: 'bool bit_search(int, int)' previously defined here 90 | bool bit_search( int pattern, int N ){ | ^~~~~~~~~~
s552594090
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; int A[N]; for (int i = 0; i < N; i++) cin >> A[i]; int ans = 0; for (int i = 0; i < N; i++){ while (i+1 <= N; && A[i] == A[i+1]) i++; if (A[i] > A[i+1]) { while (A[i] >= A[i+1]) i++; } else if (A[i] < A[i+1]) { while (A[i] <= A[i+1]) i++; } ans++; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:13:20: error: expected ')' before ';' token 13 | while (i+1 <= N; && A[i] == A[i+1]) i++; | ~ ^ | ) a.cc:13:26: error: expected ';' before '[' token 13 | while (i+1 <= N; && A[i] == A[i+1]) i++; | ^ | ; a.cc:13:25: error: label 'A' used but not defined 13 | while (i+1 <= N; && A[i] == A[i+1]) i++; | ^
s035407409
p03745
C++
#include <algorithm> #include <complex> #include <cstdlib> #include <ctime> #include <time.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <numeric> #include <limits> #include <type_traits> using namespace std; #define SAY_YES cout << "YES" << endl; #define SAY_Yes cout << "Yes" << endl; #define SAY_NO cout << "NO" << endl; #define SAY_No cout << "No" << endl; #define IFYES(TRUE_OR_FALSE) \ if (TRUE_OR_FALSE) \ { \ cout << "YES" << endl; \ } \ else \ { \ cout << "NO" << endl; \ } #define IFYes(TRUE_OR_FALSE) \ if (TRUE_OR_FALSE) \ { \ cout << "Yes" << endl; \ } \ else \ { \ cout << "No" << endl; \ } #define IFyes(TRUE_OR_FALSE) \ if (TRUE_OR_FALSE) \ { \ cout << "yes" << endl; \ } \ else \ { \ cout << "no" << endl; \ } #define DEBUG_OUTPUT_ARRAY(XXX, ONE) \ for (int i = 0; i < (ONE); i++) \ { \ cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \ } #define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO) \ for (int i = 0; i < (ONE); i++) \ { \ cout << "<<< i = " << i << " >>>" << endl; \ for (int j = 0; j < (TWO); j++) \ { \ cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \ } \ } #define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \ for (int i = 0; i < (ONE); i++) \ { \ cout << i << " "; \ for (int j = 0; j < (TWO); j++) \ { \ cout << XXX[i][j] << " "; \ } \ cout << endl; \ } typedef pair<long long int, long long int> pll; const long long int mod = 1000000007; const long long int INF = 1e18; long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; long long int dp[10005]={}; string S; vector<long long int>output; int main() { cout << fixed << setprecision(18); cin>>N; for(long long int i = 1; i <= N; i++){ cin>>A[i]; } long long int res2=0; long long int type=0; for(long long int i = 2; i <= N; i++){ if(A[i]==A[i-1]){ }else if(A[i]<A[i-1]){ if(type==1){ res++; type=0; }else{ type=2; } }else{ if(type==2){ res++; type=0; }else{ type=1; } } } cout<<res+1<<endl; } #include <algorithm> #include <complex> #include <cstdlib> #include <ctime> #include <time.h> #include <iomanip> #include <iostream> #include <map> #include <math.h> #include <queue> #include <random> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <numeric> #include <limits> #include <type_traits> using namespace std; #define SAY_YES cout << "YES" << endl; #define SAY_Yes cout << "Yes" << endl; #define SAY_NO cout << "NO" << endl; #define SAY_No cout << "No" << endl; #define IFYES(TRUE_OR_FALSE) \ if (TRUE_OR_FALSE) \ { \ cout << "YES" << endl; \ } \ else \ { \ cout << "NO" << endl; \ } #define IFYes(TRUE_OR_FALSE) \ if (TRUE_OR_FALSE) \ { \ cout << "Yes" << endl; \ } \ else \ { \ cout << "No" << endl; \ } #define IFyes(TRUE_OR_FALSE) \ if (TRUE_OR_FALSE) \ { \ cout << "yes" << endl; \ } \ else \ { \ cout << "no" << endl; \ } #define DEBUG_OUTPUT_ARRAY(XXX, ONE) \ for (int i = 0; i < (ONE); i++) \ { \ cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \ } #define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO) \ for (int i = 0; i < (ONE); i++) \ { \ cout << "<<< i = " << i << " >>>" << endl; \ for (int j = 0; j < (TWO); j++) \ { \ cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \ } \ } #define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \ for (int i = 0; i < (ONE); i++) \ { \ cout << i << " "; \ for (int j = 0; j < (TWO); j++) \ { \ cout << XXX[i][j] << " "; \ } \ cout << endl; \ } typedef pair<long long int, long long int> pll; const long long int mod = 1000000007; const long long int INF = 1e18; long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; long long int dp[10005]={}; string S; vector<long long int>output; int main() { cout << fixed << setprecision(18); cin>>N; for(long long int i = 1; i <= N; i++){ cin>>A[i]; } long long int res2=0; long long int type=0; for(long long int i = 2; i <= N; i++){ if(A[i]==A[i-1]){ }else if(A[i]<A[i-1]){ if(type==1){ res++; type=0; }else{ type=2; } }else{ if(type==2){ res++; type=0; }else{ type=1; } } } cout<<res+1<<endl; }
a.cc:201:21: error: redefinition of 'const long long int mod' 201 | const long long int mod = 1000000007; | ^~~ a.cc:81:21: note: 'const long long int mod' previously defined here 81 | const long long int mod = 1000000007; | ^~~ a.cc:202:21: error: redefinition of 'const long long int INF' 202 | const long long int INF = 1e18; | ^~~ a.cc:82:21: note: 'const long long int INF' previously defined here 82 | const long long int INF = 1e18; | ^~~ a.cc:204:15: error: redefinition of 'long long int N' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:84:15: note: 'long long int N' previously declared here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:204:17: error: redefinition of 'long long int M' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:84:17: note: 'long long int M' previously declared here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:204:19: error: redefinition of 'long long int A [300200]' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:84:19: note: 'long long int A [300200]' previously declared here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:204:29: error: redefinition of 'long long int B [201002]' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:84:29: note: 'long long int B [201002]' previously declared here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:204:39: error: redefinition of 'long long int L [200200]' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:84:39: note: 'long long int L [200200]' previously declared here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:204:49: error: redefinition of 'long long int R [202000]' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:84:49: note: 'long long int R [202000]' previously declared here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^ a.cc:204:59: error: redefinition of 'long long int sum [200200]' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^~~ a.cc:84:59: note: 'long long int sum [200200]' previously defined here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^~~ a.cc:204:74: error: redefinition of 'long long int res' 204 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^~~ a.cc:84:74: note: 'long long int res' previously defined here 84 | long long int N,M,A[300200],B[201002],L[200200],R[202000],sum[200200]={},res=0; | ^~~ a.cc:205:15: error: redefinition of 'long long int dp [10005]' 205 | long long int dp[10005]={}; | ^~ a.cc:85:15: note: 'long long int dp [10005]' previously defined here 85 | long long int dp[10005]={}; | ^~ a.cc:208:8: error: redefinition of 'std::string S' 208 | string S; | ^ a.cc:88:8: note: 'std::string S' previously declared here 88 | string S; | ^ a.cc:209:22: error: redefinition of 'std::vector<long long int> output' 209 | vector<long long int>output; | ^~~~~~ a.cc:89:22: note: 'std::vector<long long int> output' previously declared here 89 | vector<long long int>output; | ^~~~~~ a.cc:210:5: error: redefinition of 'int main()' 210 | int main() | ^~~~ a.cc:90:5: note: 'int main()' previously defined here 90 | int main() | ^~~~
s441831040
p03745
C
// 161-C Replacing Integer #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <assert.h> #include <string.h> #include <memory.h> #include <malloc.h> #include <stdlib.h> // qsortで用いる比較用関数.*a<*bならaが先になる. int compare(const void* a, const void* b) { return -1 * (*(int*)a - *(int*)b); } int main() { int n,i,cnt=1,diff; int* a; bool isReset = false; scanf("%d", &n); if (n == 1) { printf("1"); return 0; } a = (int*)malloc(sizeof(int) * n); for (i = 0; i < n - 1; i++) { scanf("%d", &a[i]); } diff = a[i] - a[i + 1]; for (i = 1; i < n - 1; i++) { if (diff == 0 && a[i] == a[i + 1]) continue; if (!(isReset)) { if (diff < 0 && a[i] > a[i + 1]) { // 一つ前のiについて,a[i] < a[i+1] cnt++; isReset = true; } if (diff > 0 && a[i] < a[i + 1]) { cnt++; isReset = true; } } else { isReset = false; } diff = a[i] - a[i + 1]; } printf("%d", cnt); return 0; }
main.c: In function 'main': main.c:21:5: error: unknown type name 'bool' 21 | bool isReset = false; | ^~~~ main.c:11:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 10 | #include <stdlib.h> +++ |+#include <stdbool.h> 11 | main.c:21:20: error: 'false' undeclared (first use in this function) 21 | bool isReset = false; | ^~~~~ main.c:21:20: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:21:20: note: each undeclared identifier is reported only once for each function it appears in main.c:43:27: error: 'true' undeclared (first use in this function) 43 | isReset = true; | ^~~~ main.c:43:27: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s566772615
p03745
C
// 161-C Replacing Integer #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <assert.h> #include <string.h> #include <memory.h> #include <malloc.h> #include <stdlib.h> // qsortで用いる比較用関数.*a<*bならaが先になる. int compare(const void* a, const void* b) { return -1 * (*(int*)a - *(int*)b); } int main() { int n,i,cnt=1,diff; int* a; bool isReset = false; scanf("%d", &n); if (n == 1) { printf("1"); return 0; } int a[n]; for (i = 0; i < n - 1; i++) { scanf("%d", &a[i]); } diff = a[i] - a[i + 1]; for (i = 1; i < n - 1; i++) { if (diff == 0 && a[i] == a[i + 1]) continue; if (!(isReset)) { if (diff < 0 && a[i] > a[i + 1]) { // 一つ前のiについて,a[i] < a[i+1] cnt++; isReset = true; } if (diff > 0 && a[i] < a[i + 1]) { cnt++; isReset = true; } } else { isReset = false; } diff = a[i] - a[i + 1]; } printf("%d", cnt); return 0; }
main.c: In function 'main': main.c:21:5: error: unknown type name 'bool' 21 | bool isReset = false; | ^~~~ main.c:11:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 10 | #include <stdlib.h> +++ |+#include <stdbool.h> 11 | main.c:21:20: error: 'false' undeclared (first use in this function) 21 | bool isReset = false; | ^~~~~ main.c:21:20: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:21:20: note: each undeclared identifier is reported only once for each function it appears in main.c:29:9: error: conflicting types for 'a'; have 'int[n]' 29 | int a[n]; | ^ main.c:20:10: note: previous declaration of 'a' with type 'int *' 20 | int* a; | ^ main.c:43:27: error: 'true' undeclared (first use in this function) 43 | isReset = true; | ^~~~ main.c:43:27: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s384205366
p03745
C
// 161-C Replacing Integer #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <assert.h> #include <string.h> #include <memory.h> #include <malloc.h> #include <stdlib.h> int main() { int n,i,cnt=1,diff; int* a; bool isReset = false; scanf("%d", &n); if (n == 1) { printf("1"); return 0; } a = (int*)malloc(sizeof(int) * n); for (i = 0; i < n - 1; i++) { scanf("%d", &a[i]); } diff = a[i] - a[i + 1]; for (i = 1; i < n - 1; i++) { if (diff == 0 && a[i] == a[i + 1]) continue; if (!(isReset)) { if (diff < 0 && a[i] > a[i + 1]) { // 一つ前のiについて,a[i] < a[i+1] cnt++; isReset = true; } if (diff > 0 && a[i] < a[i + 1]) { cnt++; isReset = true; } } else { isReset = false; } diff = a[i] - a[i + 1]; } printf("%d", cnt); return 0; }
main.c: In function 'main': main.c:15:5: error: unknown type name 'bool' 15 | bool isReset = false; | ^~~~ main.c:11:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 10 | #include <stdlib.h> +++ |+#include <stdbool.h> 11 | main.c:15:20: error: 'false' undeclared (first use in this function) 15 | bool isReset = false; | ^~~~~ main.c:15:20: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:15:20: note: each undeclared identifier is reported only once for each function it appears in main.c:37:27: error: 'true' undeclared (first use in this function) 37 | isReset = true; | ^~~~ main.c:37:27: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s012583887
p03745
C
// 161-C Replacing Integer #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <math.h> #include <assert.h> #include <string.h> #include <memory.h> #include <malloc.h> #include <stdlib.h> // qsortで用いる比較用関数.*a<*bならaが先になる. int compare(const void* a, const void* b) { return -1 * (*(int*)a - *(int*)b); } int main() { int n,i,cnt=1,step,diff; int* a; bool isReset = false; scanf("%d", &n); if (n == 1) { printf("1"); return 0; } a = (int*)malloc(sizeof(int) * n); for (i = 0; i < n - 1; i++) { scanf("%d", &a[i]); } diff = a[i] - a[i + 1]; for (i = 1; i < n - 1; i++) { if (diff == 0 && a[i] == a[i + 1]) continue; if (isReset == false) { if (diff < 0 && a[i] > a[i + 1]) { // 一つ前のiについて,a[i] < a[i+1] cnt++; isReset = true; } if (diff > 0 && a[i] < a[i + 1]) { cnt++; isReset = true; } } else { isReset = false; } diff = a[i] - a[i + 1]; } printf("%d", cnt); return 0; }
main.c: In function 'main': main.c:21:5: error: unknown type name 'bool' 21 | bool isReset = false; | ^~~~ main.c:11:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 10 | #include <stdlib.h> +++ |+#include <stdbool.h> 11 | main.c:21:20: error: 'false' undeclared (first use in this function) 21 | bool isReset = false; | ^~~~~ main.c:21:20: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:21:20: note: each undeclared identifier is reported only once for each function it appears in main.c:41:27: error: 'true' undeclared (first use in this function) 41 | isReset = true; | ^~~~ main.c:41:27: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s248223336
p03745
C++
#include <bits/stdc++.h> using namespace std; int N, L, T; float X[110000]; int W[110000]; int main () { cin >> N >> L >> T; for (int i = 1; i < N + 1; i++) cin >> X[i] >> W[i]; for (float t = 0.5; t <= T; t += 0.5) { //t秒のときの位置へ移動 for (int i = 1; i < N + 1; i++) { if (W[i] == 1) { X[i] += 0.5; } else { X[i] -= 0.5; } //円の始点終点調整 if (X[i] == L) { X[i] = 0; } else if (X[i] < 0) { X[i] = (float)L - 0.5; } } //衝突判定 for (int i = 1; i < N; i++) { if (X[i] == X[i + 1]) { W[i] = 2; W[i + 1] = 1; } } if (X[1] == X[N]) { W[1] = 1; W[N] = 2; } } //出力 for (int i = 1; i < N + 1; i++) { cout << (int)X[i] } }
a.cc: In function 'int main()': a.cc:42:22: error: expected ';' before '}' token 42 | cout << (int)X[i] | ^ | ; 43 | } | ~
s535967633
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N); vector<int> B(N-1); for (int i = 0; i < N; i++){ cin >> A.at(i); } for (int i = 0; i < N-1; i++){ B.at(i) = A.at(i+1) - A.at(i); } queue<int> q; for (int i = 0; i < N-1; i++){ if (B.at(i)!=0){ q.push(B.at(i)); } } int M = q.size(); vector<int> C(M); vector<int> D(M-1); for (int i = 0; i < M; i++){ C.at(i) = q.front(); q.pop(); } int count = 1; for (int i = 0; i < M;){ D.at(i)=C.at(i)*C.at(i+1); if (D.at(1)<0){ count++; } } cout << count << endl;
a.cc: In function 'int main()': a.cc:44:27: error: expected '}' at end of input 44 | cout << count << endl; | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s240372068
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N,S=0,i;cin>>N;int A[N]; for(i=0;i<N;i++)cin>>A[i]; i=0; while(i<N){ S++;int j=i+1,x=0; while(j<N-1&&(A[j]-[j+1])*x>=0){ if(A[j]!=A[j+1]){ if(A[j]>A[j+1])x++; else x--; } j++; } i=j+1; } cout<<S<<endl; }
a.cc: In function 'int main()': a.cc:9:26: error: expected ',' before '+' token 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ | , a.cc:9:26: error: expected identifier before '+' token a.cc: In lambda function: a.cc:9:29: error: expected '{' before ')' token 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ a.cc: In function 'int main()': a.cc:9:23: error: no match for 'operator-' (operand types are 'int' and 'main()::<lambda()>') 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ~~~~^~~~~~ | | | | | main()::<lambda()> | int In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::complex<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::complex<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::complex<_Tp>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::valarray<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::valarray<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::valarray<_Tp>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^
s344988245
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N,S=0,i;cin>>N;int A[N]; for(i=0;i<N;i++)cin>>A[i]; i=0; while(i<N){ S++;int j=i+1;int x=0; while(j<N-1&&(A[j]-[j+1])*x>=0){ if(A[j]!=A[j+1]){ if(A[j]>A[j+1])x++; else x--; } j++; } i=j+1; } cout<<S<<endl; }
a.cc: In function 'int main()': a.cc:9:26: error: expected ',' before '+' token 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ | , a.cc:9:26: error: expected identifier before '+' token a.cc: In lambda function: a.cc:9:29: error: expected '{' before ')' token 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ a.cc: In function 'int main()': a.cc:9:23: error: no match for 'operator-' (operand types are 'int' and 'main()::<lambda()>') 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ~~~~^~~~~~ | | | | | main()::<lambda()> | int In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::complex<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::complex<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::complex<_Tp>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::valarray<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:9:29: note: mismatched types 'const std::valarray<_Tp>' and 'int' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:9:29: note: 'main()::<lambda()>' is not derived from 'const std::valarray<_Tp>' 9 | while(j<N-1&&(A[j]-[j+1])*x>=0){ | ^
s091527667
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N,S=0;cin>>N;int A[N]; for(int i=0;i<N;i++)cin>>A[i]; for(int i=1;i<N;i++){ int j=i; while((T.at(i-1)-T.at(i))*(T.at(j-1)-T.at(j))>=0)j++; i=j-1; } }
a.cc: In function 'int main()': a.cc:8:12: error: 'T' was not declared in this scope 8 | while((T.at(i-1)-T.at(i))*(T.at(j-1)-T.at(j))>=0)j++; | ^
s624730751
p03745
C++
//#include <tourist> #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> p; const int INF = 1e9; const ll LINF = ll(1e18) + 1; const int MOD = 1000000007; const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0}; const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1}; #define yes cout << "Yes" << endl #define YES cout << "YES" << endl #define no cout << "No" << endl #define NO cout << "NO" << endl #define rep(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() #define debug(v) \ cout << #v << ":"; \ for (auto x : v) \ { \ cout << x << ' '; \ } \ cout << endl; template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } //cout<<fixed<<setprecision(15);有効数字15桁 //-std=c++14 ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } int n, m; vector<ll> a; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; for (int i = 0; i < n; i++) { ll temp; cin >> temp; a.push_back(temp); } if(n==1)return cout<<1<<"\n",0; ll ans=0; int i=0; while(i<=n-1){ int count=0; while(a[i]>=a[i+1]){ i++; count++; if(i>=n-1)break; } if(count){ans++;i++;}; count=0; if(i>=n-1)break; while(a[i]<=a[i+1]){ i++; count++; if(i>=n-1)break; } if(count){ans++;i++;}; //cout<<i<<" "<<ans<<"\n"; } reverse(ALL(a)); ll ans1=0; int i=0; while(i<=n-1){ int count=0; while(a[i]>=a[i+1]){ i++; count++; if(i>=n-1)break; } if(count){ans1++;i++;}; count=0; if(i>=n-1)break; while(a[i]<=a[i+1]){ i++; count++; if(i>=n-1)break; } if(count){an1s++;i++;}; //cout<<i<<" "<<ans<<"\n"; } cout<<min(ans,ans1)<<"\n"; }
a.cc: In function 'int main()': a.cc:84:9: error: redeclaration of 'int i' 84 | int i=0; | ^ a.cc:63:9: note: 'int i' previously declared here 63 | int i=0; | ^ a.cc:100:19: error: 'an1s' was not declared in this scope; did you mean 'ans1'? 100 | if(count){an1s++;i++;}; | ^~~~ | ans1
s085048985
p03745
C++
{ //ifstream in("subtask_1_02.txt"); //cin.rdbuf(in.rdbuf()); cin >> N; for (int i = 0; i < N; i++) cin >> A[i]; int counter = 0; for (int i = 0; i < N; i++){ while (i+1 < N && A[i] == A[i+1]) i++; if (i+1 < N && A[i] < A[i+1]){ while (i+1 < N && A[i] <= A[i+1]) i++; } else if (i+1 < N && A[i] > A[i+1]){ while (i+1 < N && A[i] >= A[i+1]) i++; } counter++; } cout << fixed << setprecision(10) << counter << endl; }
a.cc:1:1: error: expected unqualified-id before '{' token 1 | { | ^
s785637642
p03745
C++
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<int> a(N); for(int i = 0; i < N; i++) cin << a[i]; int ans = 1; int pm = 0; for(int i = 1; i < N; i++){ int npm = 0; if(a[i] > a[i-1]) npm = 1; else if(a[i] == a[i-1]) npm = 0; else npm = -1; if(pm == -npm && npm != 0){ pm = npm; ans += 1; } else if(npm == 0){ pm = npm; } } cout << ans; }
a.cc: In function 'int main()': a.cc:11:34: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 11 | for(int i = 0; i < N; i++) cin << a[i]; a.cc:11:34: note: candidate: 'operator<<(int, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int})' (built-in) a.cc:11:34: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)' 1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:11:30: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)' 1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ In file included from /usr/include/c++/14/bits/ios_base.h:46, from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ In file included from /usr/include/c++/14/memory:80, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56: /usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)' 70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 11 | for(int i = 0; i < N; i++) cin << a[i]; | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed: a.cc:11:40: note: 'std::istream' {aka 'std::basic_istrea
s963785962
p03745
C
(f+=NR~2||p>$1)*(t+=p<p=$1){f=t=!++s}{RS=FS}/\n/,$1=s
main.c:1:3: error: expected ')' before '+=' token 1 | (f+=NR~2||p>$1)*(t+=p<p=$1){f=t=!++s}{RS=FS}/\n/,$1=s | ^~ | ) main.c:1:38: error: expected identifier or '(' before '{' token 1 | (f+=NR~2||p>$1)*(t+=p<p=$1){f=t=!++s}{RS=FS}/\n/,$1=s | ^ main.c:1:45: error: expected identifier or '(' before '/' token 1 | (f+=NR~2||p>$1)*(t+=p<p=$1){f=t=!++s}{RS=FS}/\n/,$1=s | ^ main.c:1:46: error: stray '\' in program 1 | (f+=NR~2||p>$1)*(t+=p<p=$1){f=t=!++s}{RS=FS}/\n/,$1=s | ^
s196298309
p03745
C++
#include<bits/stdc++.h> using namespace std; int sign(long long int num) { if (num<0) { return -1; } else if(num > 0) { return 1; } else { return 0; } } int main() { long long int n; cin >> n; vector<long long int> list(n); for (long long int i=0;i<n;i++) { cin >> list.at(i); } long long int count=1; long long int len=0; for (long long int i=0;i<n-1;i++) { len++; //cout << len << endl; if (len == 1) { int judge = 0; } else { //cout << i << endl; if(judge==0) { judege = sign(list.at(i)-list.at(i-1)); } if ( judge * sign(list.at(i+1)-list.at(i)) < 0 ) { count++; len=0; } } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:33:10: error: 'judge' was not declared in this scope 33 | if(judge==0) { | ^~~~~ a.cc:34:9: error: 'judege' was not declared in this scope 34 | judege = sign(list.at(i)-list.at(i-1)); | ^~~~~~ a.cc:36:12: error: 'judge' was not declared in this scope 36 | if ( judge * sign(list.at(i+1)-list.at(i)) < 0 ) { | ^~~~~
s078881217
p03745
C++
#include<bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<long long int> list(n); for (long long int i=0;i<n;i++) { cin >> list.at(i); } long long int count=1; long long int len=0; for (long long int i=0;i<n-1;i++) { len++; //cout << len << endl; if (len != 1) { //cout << i << endl; if ( signal(list.at(i)-list.at(i-1)) * signal(list.at(i+1)-list.at(i)) < 0 ) { count++; len=0; } } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:18:18: error: too few arguments to function 'void (* signal(int, __sighandler_t))(int)' 18 | if ( signal(list.at(i)-list.at(i-1)) * signal(list.at(i+1)-list.at(i)) < 0 ) { | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/csignal:42, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116, from a.cc:1: /usr/include/signal.h:88:23: note: declared here 88 | extern __sighandler_t signal (int __sig, __sighandler_t __handler) | ^~~~~~ a.cc:18:52: error: too few arguments to function 'void (* signal(int, __sighandler_t))(int)' 18 | if ( signal(list.at(i)-list.at(i-1)) * signal(list.at(i+1)-list.at(i)) < 0 ) { | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/signal.h:88:23: note: declared here 88 | extern __sighandler_t signal (int __sig, __sighandler_t __handler) | ^~~~~~
s957288000
p03745
C++
#include<bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; vector<long long int> list(n); for (long long int i=0;i<n;i++) { cin >> list.at(i); } long long int count=1; long long int len=0; for (long long int i=0;i<n-1;i++) { len++; //cout << len << endl; if (len != 1) { //cout << i << endl; if ( sign(list.at(i)-list.at(i-1)) * sign(list.at(i+1)-list.at(i)) < 0 ) { count++; len=0; } } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:18:12: error: 'sign' was not declared in this scope; did you mean 'sin'? 18 | if ( sign(list.at(i)-list.at(i-1)) * sign(list.at(i+1)-list.at(i)) < 0 ) { | ^~~~ | sin
s387717365
p03745
C++
//code by lynmisakura.wish to be accepted! #include <iostream> #include <limits.h> #include <algorithm> #include <bitset> #include <cctype> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <numeric> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #include <queue> #include <unordered_map> #include <unordered_set> /***************************/ using namespace std; typedef long long ll; typedef vector<ll> vi; typedef vector<long long> vl; typedef pair<ll, ll> pi; typedef vector<pair<ll, ll>> vpi; //const long long INF = 1LL << 55; #define itn ll #define pb push_back #define mp make_pair #define eb emplace_back #define ss second #define ff first #define dup(x,y) ((x) + (y) - 1)/(y) #define mins(x,y) x = min(x,y) #define maxs(x,y) x = max(x,y) #define all(x) (x).begin(),(x).end() #define Rep(n) for(ll i = 0;i < n;i++) #define rep(i,n) for(ll i = 0;i < n;i++) #define flush fflush(stdout) #define rrep(i,n) for(ll i = n - 1;i >= 0;i--) #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) #define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20) ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; } #define _GLIBCXX_DEBUG #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl class ASortedArrays { public: static constexpr int kStressIterations = 0; static void generateTest(std::ostream& test) { } void solve(std::istream& cin, std::ostream& cout) { int n;cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } int inc;//増加中:1、減少中:−1、不明:0 int ans = 1; if(a[0] < a[1])inc = 1; else if(a[0] == a[1])inc = 0; else inc = -1; for(int i = 1;i < n;i++){ if(a[i] == a[i-1])continue; //前の要素と同じならそこで区切る必要は絶対にない if(inc == 0){ if(a[i] > a[i-1])inc = 1; else inc = -1; }else{ if(inc == 1 and a[i] < a[i-1])ans++,inc = 0; else if(inc == -1 and a[i] > a[i-1])ans++,inc = 0; } } cout << ans<< endl; } };
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s201982623
p03745
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long ll; int main(){ ll n; cin >> n; int flag=0; //0:なし, 1:減少, 2:増加 ll preNum, cnt=1,; cin >> preNum; for(int i=1; i<n; i++){ ll Num; cin >> Num; if(Num == preNum) break; if(flag==0){ if(preNum < Num){ flag = 2; }else{ flag = 1; } }else if(flag == 1){ if(preNum < Num){ flag = 0; cnt++; } }else{ if(preNum > Num){ flag = 0; cnt++; } } preNum = Num; } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:22: error: expected unqualified-id before ';' token 13 | ll preNum, cnt=1,; | ^
s984330396
p03745
C++
#include<bits/stdc++.h> #include<iostream> using namespace std; template <class T> using V = vector<T>; using ll = long long; using ch char; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(b);i++) void Solve(); signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<<setprecision(20)<<fixed; Solve(); } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ void Solve(){ ll n; cin>>n; vll V(n); ll past=0; vch s(0); FOR(i,0,n){ ll now; cin>>now; if(i>0){ if(past<now){ s.push_back('<'); } else if(past>now){ s.push_back('>'); } } past=now; } ll a=s.size(); ll ans=1; FOR(i,0,a-1){ if(s[i]!=s[i+1]){ ans++; i++; } } cout<<ans<<endl; }
a.cc:9:7: error: expected nested-name-specifier before 'ch' 9 | using ch char; | ^~ a.cc:10:15: error: 'ch' was not declared in this scope 10 | using vch = V<ch>; | ^~ a.cc:10:17: error: template argument 1 is invalid 10 | using vch = V<ch>; | ^ a.cc: In function 'void Solve()': a.cc:33:3: error: 'vll' was not declared in this scope; did you mean 'll'? 33 | vll V(n); | ^~~ | ll a.cc:35:3: error: 'vch' was not declared in this scope 35 | vch s(0); | ^~~ a.cc:41:9: error: 's' was not declared in this scope 41 | s.push_back('<'); | ^ a.cc:44:9: error: 's' was not declared in this scope 44 | s.push_back('>'); | ^ a.cc:50:8: error: 's' was not declared in this scope 50 | ll a=s.size(); | ^
s916503503
p03745
C++
#include<bits/stdc++.h> #include<iostream> using namespace std; template <class T> using V = vector<T>; using ll = long long; using vch = V<ch>; #define FOR(i,a,b) for(ll i=(a);i<(b);i++) void Solve(); signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout<<setprecision(20)<<fixed; Solve(); } /****************************************\ | Thank you for viewing my code:) | | Written by RedSpica a.k.a. RanseMirage | | Twitter:@asakaakasaka | \****************************************/ void Solve(){ ll n; cin>>n; vll V(n); ll past=0; vch s(0); FOR(i,0,n){ ll now; cin>>now; if(i>0){ if(past<now){ s.push_back('<'); } else if(past>now){ s.push_back('>'); } } past=now; } ll a=s.size(); ll ans=1; FOR(i,0,a-1){ if(s[i]!=s[i+1]){ ans++; i++; } } cout<<ans<<endl; }
a.cc:9:15: error: 'ch' was not declared in this scope 9 | using vch = V<ch>; | ^~ a.cc:9:17: error: template argument 1 is invalid 9 | using vch = V<ch>; | ^ a.cc: In function 'void Solve()': a.cc:32:3: error: 'vll' was not declared in this scope; did you mean 'll'? 32 | vll V(n); | ^~~ | ll a.cc:34:3: error: 'vch' was not declared in this scope 34 | vch s(0); | ^~~ a.cc:40:9: error: 's' was not declared in this scope 40 | s.push_back('<'); | ^ a.cc:43:9: error: 's' was not declared in this scope 43 | s.push_back('>'); | ^ a.cc:49:8: error: 's' was not declared in this scope 49 | ll a=s.size(); | ^
s093616654
p03745
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n, ans; cin >> n; vector<int>a(n); cin >> a.at(0) >> a.at(1); bool up=false; bool down=false; if(a.at(0)>a.at(1))up=true; if(a.at(0)<a.at(1))down=true; for(int i=2;i<n;i++){ cin >> a(i); if(up&&a.at(i-1)>a.at(i)){ ans++; up=false;down=true; } if(down&&a.at(i-1)<a.at(i)){ ans++; up=true;down=false; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:13:13: error: no match for call to '(std::vector<int>) (int&)' 13 | cin >> a(i); | ~^~~
s412903604
p03745
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n, ans; cin >> n vector<int>a(n); cin >> a.at(0) >> a.at(1); bool up=false; bool down=false; if(a.at(0)>a.at(1))up=true; if(a.at(0)<a.at(1))down=true; for(int i=2;i<n;i++){ cin >> a(i); if(up&&a.at(i-1)>a.at(i)){ ans++; up=false;down=true; } if(down&&a.at(i-1)<a.at(i)){ ans++; up=true;down=false; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:5:11: error: expected ';' before 'vector' 5 | cin >> n | ^ | ; 6 | vector<int>a(n); | ~~~~~~ a.cc:7:10: error: 'a' was not declared in this scope 7 | cin >> a.at(0) >> a.at(1); | ^
s345207075
p03745
C++
#include<bits/stdc++.h> int main(){ int n, ans; cin >> n vector<int>a(n); cin >> a.at(0) >> a.at(1); bool up=false; bool down=false; if(a.at(0)>a.at(1))up=true; if(a.at(0)<a.at(1))down=true; for(int i=2;i<n;i++){ cin >> a(i); if(up&&a.at(i-1)>a.at(i)){ ans++; up=false;down=true; } if(down&&a.at(i-1)<a.at(i)){ ans++; up=true;down=false; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:4:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 4 | cin >> n | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:6:10: error: 'a' was not declared in this scope 6 | cin >> a.at(0) >> a.at(1); | ^ a.cc:22:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 22 | cout << ans << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:22:18: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 22 | cout << ans << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s257473354
p03745
C++
include<bits/stdc++.h> typedef rep(i,n) for(int i=0;i<n;) int main(){ int N; cin>>N; vector<int> a(n); rep(i,N) cin>>a[i]; int count=0; rep(i,n-1){ if(a[i+1]>=a[i]){ while(a[i+1]>=a[i]){ i++; if(i<n || a[i+1]<a[i]){ count++; } } } else{ while(a[i+1]<=a[i]){ i++; if(i<n || a[i+1]>a[i]){ count++; } } } } cout << count << endl; return 0;
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc:2:30: error: 'i' does not name a type 2 | typedef rep(i,n) for(int i=0;i<n;) | ^ a.cc:2:34: error: expected unqualified-id before ')' token 2 | typedef rep(i,n) for(int i=0;i<n;) | ^
s189998266
p03745
C++
#include <iostream> using namespace std; //https://atcoder.jp/contests/abc001/submissions/5701454 int main(){ int n; cin >> n; int a[n]; for(int i = 0; i < n; ++i) { cin >> a[i]; } //単調 >0: 増加, <0: 減少, 0:未決定 int tan = 0; int cnt = 1; for(int i = 0; i < n-1; ++i) { if(tan == 0) { if(s[i] < s[i+1])tan = 1; if(s[i] > s[i+1])tan = -1; } else if(tan > 0) { if(s[i] > s[i+1]) { tan = 0; ++cnt; } } else if(tan < 0) { if(s[i] < s[i+1]) { tan = 0; ++cnt; } } } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:24:16: error: 's' was not declared in this scope 24 | if(s[i] < s[i+1])tan = 1; | ^ a.cc:25:16: error: 's' was not declared in this scope 25 | if(s[i] > s[i+1])tan = -1; | ^ a.cc:29:16: error: 's' was not declared in this scope 29 | if(s[i] > s[i+1]) | ^ a.cc:37:16: error: 's' was not declared in this scope 37 | if(s[i] < s[i+1]) | ^
s656772460
p03745
Java
//ABC13_C /* 8 1000 1000 1 1000 1000 1 3 2 4 */ import java.util.Scanner; public class ABC13_C{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int N = scan.nextInt(); scan.nextLine(); int arr[] = new int[N]; for (int i=0; i<N; i++) { arr[i] = scan.nextInt(); } int flag =0; int preflag = 0; int count = 1; for(int i=1; i<N; i++) { if (arr[i] > arr[i-1]) { flag = 1; } else if (arr[i] == arr[i-1]) { continue; } else { flag = -1; } if(i==1) { continue; } if (arr[i-1] > arr[i-2]) { preflag = 1; } else if (arr[i-1] == arr[i-2]) { if(preflag == 0) { continue; } } else { preflag = -1; } if(!(flag==preflag)) { ++count; preflag=0; for( int j= i-1 ; j >=0; j--) { arr[j] = arr[i]; } System.out.println("count: " + i); } } System.out.println(count); } }
Main.java:10: error: class ABC13_C is public, should be declared in a file named ABC13_C.java public class ABC13_C{ ^ 1 error
s070610638
p03745
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n, inc, ans1 = 1, ans2 = 1; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } inc = (a[0] <= a[1] ? 1 : 2); for (int i = 2; i < n; i++) { if (inc == 1) { if (a[i-1] <= a[i]) continue; else { ans1++; i++; if(i < n) inc = (a[i-1] >= a[i] ? 2 : 1); } } else { if (a[i-1] >= a[i]) continue; else { ans1++; i++; if (i < n) inc = (a[i-1] <= a[i] ? 1 : 2); } } } reverse(a.begin(), a.end()); inc = (a[0] <= a[1] ? 1 : 2); for (int i = 2; i < n; i++) { if (inc == 1) { if (a[i-1] <= a[i]) continue; else { ans2++; i++; if(i < n) inc = (a[i-1] >= a[i] ? 2 : 1); } } else { if (a[i-1] >= a[i]) continue; else { ans2++; i++; if (i < n) inc = (a[i-1] <= a[i] ? 1 : 2); } } } cout << min(ans1, ans2)@ << endl; return 0; }
a.cc:50:28: error: stray '@' in program 50 | cout << min(ans1, ans2)@ << endl; | ^
s582014656
p03745
C++
#include <bits/stdc++.h> #define rep(i,a) for(int i=0;i<int(a);++i) #define REP(i,a,b) for(int i=int(a);i<int(b);++i) #define pb push_back #define mp make_pair #define F first #define S second using ll = long long; using itn = int; using namespace std; static const long double GRATIO=(long double)(1+sqrt(5))/2; ll GCD(ll a, ll b){ return b ? GCD(b, a%b) : a; } ll LCM(ll a, ll b){ return a/GCD(a,b)*b; } int main(){ int N; cin>>N; int A[100005]; int cnt=1; rep(i,N) cin>>A[i]; for(int i=1; i<N-1; i++){ if(A[i-1]<=A[i]&&A[i]>A[i+1]){ cnt++; i++; } else if(A[i-1]=>A[i]&&A[i]<A[i+1]){ cnt++; i++; } } cout<<cnt<<endl; }
a.cc: In function 'int main()': a.cc:29:24: error: expected primary-expression before '>' token 29 | else if(A[i-1]=>A[i]&&A[i]<A[i+1]){ | ^
s911648228
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int a[n]; for(int i= 0; i < n; ++i) cin >> a[i]; int flag = 0, ans = 0; int i = 0; while(i < n){ if(a[i] == a[i+1])i++; else if(a[i] < a[i+1]){ if(flag == 0) {flag = 1; i++;} else if (flag == 1) i++; else{ans++; i++; flag =0} } else if (a[i] > a[i+1]){ if(flag == 0){flag = -1; i++;} else if (flag = -1){ i++;} else {ans++; i++; flag = 0} } } cout << ans+1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:31: error: expected ';' before '}' token 17 | else{ans++; i++; flag =0} | ^ | ; a.cc:22:33: error: expected ';' before '}' token 22 | else {ans++; i++; flag = 0} | ^ | ;
s748929452
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int a[n]; for(int i= 0; i < n; ++i) cin >> a[i]; int flag = 0, ans = 0; int i = 0; while(i < n){ if(a[i] == a[i+1])i++; else if(a[i] < a[i+1]){ if(flag == 0) {flag = 1; i++;} else if (flag == 1) i++; else{ans++; i++; flag =0} } else if (a[i] > a[i+1]){ if(flag == 0){flag = -1; i++;} else if (flag = -1){ i++;} else {ans++; i++; flag = 0} } } cout << ans+1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:31: error: expected ';' before '}' token 17 | else{ans++; i++; flag =0} | ^ | ; a.cc:22:33: error: expected ';' before '}' token 22 | else {ans++; i++; flag = 0} | ^ | ;
s255240268
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int a[n]; for(int i= 0; i < n; ++i) cin >> a[i]; int flag = 0, ans = 0; int i = 0; while(i < n){ if(a[i] == a[i+1])i++; else if(a[i] < a[i+1]){ if(flag == 0) {flag = 1; i++;} else if (flag == 1) i++; else{ans++; i++} } else if (a[i] > a[i+1]){ if(flag == 0){flag = -1; i++;} else if (flag = -1){ i++;} else {ans++; i++;} } } cout << ans+1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:22: error: expected ';' before '}' token 17 | else{ans++; i++} | ^ | ;
s474532856
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; int a[n]; for(int i= 0; i < n; ++i) cin >> a[i]; int flag = 0, ans = 0; int i = 0; while(i < n){ if(a[i] == a[i+1])i++; else if(a[i] < a[i+1]){ if(flag == 0) {flag = 1; i++} else if (flag == 1) i++; else{ans++; i++} } else if (a[i] > a[i+1]){ if(flag == 0){flag = -1; i++} else if (flag = -1){ i++} else {ans++; i++} } } cout << ans+1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:15:35: error: expected ';' before '}' token 15 | if(flag == 0) {flag = 1; i++} | ^ | ; a.cc:17:22: error: expected ';' before '}' token 17 | else{ans++; i++} | ^ | ; a.cc:20:35: error: expected ';' before '}' token 20 | if(flag == 0){flag = -1; i++} | ^ | ; a.cc:21:31: error: expected ';' before '}' token 21 | else if (flag = -1){ i++} | ^ | ; a.cc:22:23: error: expected ';' before '}' token 22 | else {ans++; i++} | ^ | ;
s942792224
p03745
C++
int main(){ int N; cin >> N; long A[N]; int cnt = 0; for (int i=0;i<N;++i){ cin >> A[i]; if (i>1){ if(A[i-2]<A[i-1]) { if(A[i-1]>A[i]) cnt++; } else if(A[i-2]>A[i-1]) { if(A[i-1]>A[i]) cnt++; } } } cout << cnt+1 << endl; }
a.cc: In function 'int main()': a.cc:3:5: error: 'cin' was not declared in this scope 3 | cin >> N; | ^~~ a.cc:16:5: error: 'cout' was not declared in this scope 16 | cout << cnt+1 << endl; | ^~~~ a.cc:16:22: error: 'endl' was not declared in this scope 16 | cout << cnt+1 << endl; | ^~~~
s152431977
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N+1,0); bool iflag = false, dflag = false; int ans = 0; for(int i = 0; i < N; i++){ if(A[i] < A[i+1]){ if(dfalg){ ans++; dflag = false; continue; } iflag = true; dflag = false; } else if(A[i] > A[i+1]){ if(ifalg){ ans++; iflag = false; continue; } dflag = true; iflag = false; } } cout << ans + 1 << endl; }
a.cc: In function 'int main()': a.cc:14:16: error: 'dfalg' was not declared in this scope; did you mean 'dflag'? 14 | if(dfalg){ | ^~~~~ | dflag a.cc:22:16: error: 'ifalg' was not declared in this scope; did you mean 'iflag'? 22 | if(ifalg){ | ^~~~~ | iflag
s675595883
p03745
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll N; cin >> N; vector<ll> A(N); for(ll i = 0; i < N; i++){ cin >> A[i];} if( N >= 3){ ll cnt = 0; for(ll i = 2w; i < N - 2; ){ if( A[i] > A[i-1] && A[i] > A[i+1]){ cnt++; i += 2;} else if( A[i] < A[i-1] && A[i] < A[i+1]){ cnt++; i+= 2;} else{ i++;} } cout << cnt+ 1 << endl; return 0;} else{ cout << 1 << endl; return 0;} }
a.cc: In function 'int main()': a.cc:16:16: error: unable to find numeric literal operator 'operator""w' 16 | for(ll i = 2w; i < N - 2; ){ | ^~
s533475123
p03745
C++
#include<iostream> #include<vector> using namespace std; int main(){ int N; cin >> N; vector<int> A(N); for(int i=0; i<N; i++) cin >> A[i]; ll ans = 1; for(int i=1; i<N-1; i++){ if((A[i-1]<A[i]&&A[i+1]<A[i]) || (A[i]<A[i-1]&&A[i]<A[i+1])) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:11:3: error: 'll' was not declared in this scope 11 | ll ans = 1; | ^~ a.cc:13:66: error: 'ans' was not declared in this scope; did you mean 'abs'? 13 | if((A[i-1]<A[i]&&A[i+1]<A[i]) || (A[i]<A[i-1]&&A[i]<A[i+1])) ans++; | ^~~ | abs a.cc:15:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 15 | cout << ans << endl; | ^~~ | abs
s901050499
p03745
C++
#include<iostream> #include<vector> using namespace std; int main() { int n;cin>>n; vector<int> A(n); for(int i=0;i<n;i++) { scanf("%d",&A[i]); } int res=0; for(int i=0;i<n;++i) { //sameを抜ける while(i+1<n && A[i]==A[i+1])++i; //単調非減少 if(i+1<N && A[i]<A[i+1]) { while(i+1<n && A[i]<=A[i+1])++i; } //単調非増加 else if(i+1<n && A[i]>A[i+1]) { while(i+1<n && A[i]>=A[i+1]) ++i; } ++res; } cout<<res<<"\n"; }
a.cc: In function 'int main()': a.cc:24:16: error: 'N' was not declared in this scope 24 | if(i+1<N && A[i]<A[i+1]) | ^
s062604629
p03745
C++
#include<iostream> #include<vector> using namespace std; int main() { int n;cin>>n; vector<int> A(n); for(int i=0;i<n;i++) { scanf("%d",&A[i]); } int res=0; for(int i=0;i<n;++i) { //sameを抜ける while(i+1<n; && A[i]==A[i+1])++i; //単調非減少 if(i+1<N && A[i]<A[i+1]) { while(i+1<n && A[i]<=A[i+1])++i; } //単調非増加 else if(i+1<n && A[i]>A[i+1]) { while(i+1<n && A[i]>=A[i+1]) ++i; } ++res; } cout<<res<<"\n"; }
a.cc: In function 'int main()': a.cc:21:20: error: expected ')' before ';' token 21 | while(i+1<n; && A[i]==A[i+1])++i; | ~ ^ | ) a.cc:21:26: error: expected ';' before '[' token 21 | while(i+1<n; && A[i]==A[i+1])++i; | ^ | ; a.cc:24:16: error: 'N' was not declared in this scope 24 | if(i+1<N && A[i]<A[i+1]) | ^ a.cc:21:25: error: label 'A' used but not defined 21 | while(i+1<n; && A[i]==A[i+1])++i; | ^
s615182473
p03745
C++
#include<iostream> #include<vector> using namespace std; int main() { int n;cin>>n; vector<int> A(n); for(int i=0;i<n;i++) { scanf("%d",&A[i]); } int res=0; for(int i=0;i<n;++i) { //sameを抜ける while(i+1<n; && A[i]==A[i+1])++i; //単調非減少 if(i+1<N && A[i]<A[i+1]) { while(i+1<n && A[i]<=[i+1])++i; } //単調非増加 else if(i+1<n && A[i]>A[i+1]) { while(i+1<n && A[i]>=A[i+1]) ++i; } ++res; } cout<<res<<"\n"; }
a.cc: In function 'int main()': a.cc:21:20: error: expected ')' before ';' token 21 | while(i+1<n; && A[i]==A[i+1])++i; | ~ ^ | ) a.cc:21:26: error: expected ';' before '[' token 21 | while(i+1<n; && A[i]==A[i+1])++i; | ^ | ; a.cc:24:16: error: 'N' was not declared in this scope 24 | if(i+1<N && A[i]<A[i+1]) | ^ a.cc:26:36: error: expected ',' before '+' token 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ | , a.cc:26:36: error: expected identifier before '+' token a.cc: In lambda function: a.cc:26:39: error: expected '{' before ')' token 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ a.cc: In function 'int main()': a.cc:26:32: error: no match for 'operator<=' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'main()::<lambda()>') 26 | while(i+1<n && A[i]<=[i+1])++i; 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:3: /usr/include/c++/14/bits/stl_iterator.h:469:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 469 | operator<=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:469:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::reverse_iterator<_Iterator>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/bits/stl_iterator.h:513:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 513 | operator<=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:513:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::reverse_iterator<_Iterator>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/bits/stl_iterator.h:1704:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1704 | operator<=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1704:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::move_iterator<_IteratorL>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/bits/stl_iterator.h:1767:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1767 | operator<=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1767:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::move_iterator<_IteratorL>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ 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:1064:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1064 | operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1064:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::pair<_T1, _T2>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++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:717:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 717 | operator<=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:717:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/string_view:724: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> >)' 724 | operator<=(basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:724:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/string_view:732: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>)' 732 | operator<=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:732:5: note: template argument deduction/substitution failed: a.cc:26:39: note: 'main()::<lambda()>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/bits/basic_string.h:3956: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>&)' 3956 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3956:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/bits/basic_string.h:3970:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3970 | operator<=(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3970:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ /usr/include/c++/14/bits/basic_string.h:3983:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<=(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3983 | operator<=(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3983:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const _CharT*' and 'int' 26 | while(i+1<n && A[i]<=[i+1])++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:2625:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2625 | operator<=(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2625:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::tuple<_UTypes ...>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:4: /usr/include/c++/14/bits/stl_vector.h:2108:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<=(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)' 2108 | operator<=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:2108:5: note: template argument deduction/substitution failed: a.cc:26:39: note: mismatched types 'const std::vector<_Tp, _Alloc>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 26 | while(i+1<n && A[i]<=[i+1])++i; | ^ a.cc:21:25: error: label 'A' used but not d
s970740548
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<int> a(n); for (int i=0; i<n; i++){ cin >> a.at(i); } int cnt = 1, flag = 0; for (int i=0; i<n-1; i++){ if (i == 0 || flag == 2){ if (a[i] < a[i+1]){ flag = 0; } else if (a[i] > a[i+1]){ flag = 1; } else{ flag = 2; } }else if (flag == 0){ if (a[i] > a[i+1]){ ans++; flag = 2; } }else{ if (a[i] < a[i+1]){ ans++; flag = 2; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 28 | ans++; | ^~~ | abs a.cc:33:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 33 | ans++; | ^~~ | abs a.cc:38:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 38 | cout << ans << endl; | ^~~ | abs
s478906030
p03745
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; ++i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i) #define all(v) v.begin(), v.end() #define mset(a, n) memset(a, n, sizeof(a)) typedef long long ll; typedef vector<int> vi; typedef pair<int, int> pii; const int INF = 1000000000; const int MOD = 1000000007; const double eps = 1e-9; int main(int argc, char *argv[]) { // cin.tie(0); // ios::sync_with_stdio(false); int N; cin >> N; vector<int> A(N); rep(i, N) cin >> A[i]; int ans = 0; rep(i, N) { while ( && A[i] == A[i+1]) ++i; if (i < N-1) { if (A[i] < A[i+1]) while (i < N-1 && A[i] <= A[i+1]) ++i; else if (A[i] > A[i+1]) while (i < N-1 && A[i] >= A[i+1]) ++i; } ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:28:21: error: expected ')' before '[' token 28 | while ( && A[i] == A[i+1]) ++i; | ~ ^ | ) a.cc: In lambda function: a.cc:28:25: error: expected '{' before '==' token 28 | while ( && A[i] == A[i+1]) ++i; | ^~ a.cc: In function 'int main(int, char**)': a.cc:28:25: error: no match for 'operator==' (operand types are 'main(int, char**)::<lambda()>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 28 | while ( && A[i] == A[i+1]) ++i; In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:28:33: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:28:33: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h: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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::pair<_T1, _T2>' 28 | while ( && A[i] == A[i+1]) ++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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::reverse_iterator<_Iterator>' 28 | while ( && A[i] == A[i+1]) ++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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::reverse_iterator<_Iterator>' 28 | while ( && A[i] == A[i+1]) ++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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::move_iterator<_IteratorL>' 28 | while ( && A[i] == A[i+1]) ++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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::move_iterator<_IteratorL>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::fpos<_StateT>' 28 | while ( && A[i] == A[i+1]) ++i; | ^ In file included from /usr/include/c++/14/string:43: /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:28:33: note: 'main(int, char**)::<lambda()>' is not derived from 'const std::allocator<_CharT>' 28 | while ( && A[i
s517263849
p03745
C++
#include <bits/stdc++.h> #define mod 1000000007 using namespace std; int main(void){ int N; cin >> N; long long int A[N], divide = 1; for(int i=0; i<N; i++) cin >> A[i]; for(int i=0; i<N-1; i++){ while(A[i] == A[i+1]) i++; if(i+1<N&&a[i]<a[i+1]){ while(i+1<N&&a[i]<=a[i+1]) i++; } else if(i+1<N&&a[i+1]<a[i]){ while(i+1<N&&a[i+1]<=a[i]) i++; } divide++; } cout << divide; return 0; }
a.cc: In function 'int main()': a.cc:21:27: error: 'a' was not declared in this scope 21 | if(i+1<N&&a[i]<a[i+1]){ | ^
s937065309
p03745
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) using namespace std; int main() { int N, a, b, ans = 0; bool first = true, up; cin >> N >> a; rep(i, N-1) { cin >> b; if (a == b) continue; if (first) { up = a < b first = false; } if (up) { if (a > b) { up = false; ans++; } } else { if (a < b) { up = true; ans++; } } a = b; } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:13:23: error: expected ';' before 'first' 13 | up = a < b | ^ | ; 14 | first = false; | ~~~~~
s052307664
p03745
C++
#include <iostream> #include <vector> #include <cmath> #include <algorithm> #include <iomanip> #include <set> #include <queue> #include <string> #include <string.h> #include <deque> #include <functional> #include <tuple> #include <stdio.h> using namespace std; typedef long long ll; typedef long double ld; typedef vector<ll> vec; typedef vector<vec> vec2; //for文 #define FOR(i,a,b) for(ll i = (ll)a;i < (ll)b;i++) #define FORE(i,a,b) for(ll i = (ll) a;i <= (ll) b;i++ ) #define REP(i,size_of_array) for(ll i =(ll)0;i<size_of_array;i++) #define REPE(i,size_of_array) for(ll i =(ll)0;i<=size_of_array;i++) #define REPR(i,size_of_array) for(ll i =(ll)size_of_array;i>=0;i--) //ソート #define ALL(vec) (vec).begin(),(vec).end() #define SORT(vec) sort(ALL(vec)) #define INVSORT(vec) sort((vec).rbegin(),(vec).rend()) //最大値最小値 #define MAX(vec) *max_element(ALL(vec)) #define UNIQ(vec) SORT(vec);vec.erase(unique(ALL(vec)),vec.end()) #define MIN(vec) *min_element(ALL(vec)) //表示 #define printl(a) cout << a << endl #define print(a) cout << a #define SP cout << " " //入力 #define inputV(vec) REP(i,vec.size()){cin >> vec[i];} #define input(a) cin >> a //型 #define float ld #define double ld #define P pair<ll,ll> #define vp vector<P> #define F first #define S second //特殊 #define int ll #define DEBUG(x) cerr << #x << ":" << x<<endl #define DEBUGV(V) REP(i,V.size()){cerr << #V[i] << ":" << V[i]<<endl;} template<class T> inline void umax(T &a,const T &b) { if(a < b) a = b; } template<class T> inline void uhmin(T &a,const T &b) { if(a > b) a = b; } const ll INF = LLONG_MAX; const ld EPS = 1e-8; signed main(){ ll N; input(N); vec A(N); inputV(A); ll cnt = 0; bool dec = false; bool inc = false; FOR(i,1,A.size()){ if(A[i-1] > A[i]) dec = true; else if(A[i-1] < A[i] ) inc = true; if(dec and inc){ dec = false; inc = false; cnt++; } DEBUG(cnt); } print(++cnt); }
a.cc:63:16: error: 'LLONG_MAX' was not declared in this scope 63 | const ll INF = LLONG_MAX; | ^~~~~~~~~ a.cc:12:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 11 | #include <functional> +++ |+#include <climits> 12 | #include <tuple>
s085201480
p03745
C++
#include <bits/stdc++.h> #define pb push_back #define ppb pop_back #define fi first #define se second #define mid ((x + y) / 2) #define left (ind * 2) #define right (ind * 2 + 1) #define mp make_pair #define timer ((double)clock() / CLOCKS_PER_SEC) #define endl "\n" #define spc " " #define d1(x) cerr<<#x<<":"<<x<<endl #define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl #define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl #define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) using namespace std; typedef long long int lli; typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<double, double> dd; const int N = (int)(1e6 + 5); const int LOG = (int)(20); int n, ar[N], ls, a[N], ans = 1, ans2 = 1; bool fl; int main() { fast_io(); // freopen("inp.in", "r", stdin); cin >> n; for(int i = 1; i <= n; i++) cin >> t[i]; int ind = 0; for(int i = 1; i < n; i++) { if(t[i] == t[i + 1]) continue; else ar[++ind] = t[i]; } n = ind; fl = ar[1] < ar[2]; for(int i = 2; i <= n; i++) { if(fl) { if(ar[i - 1] > ar[i]) { ans++; fl = ar[i] < ar[i + 1]; } } else { if(ar[i - 1] < ar[i]) { ans++; fl = ar[i] < ar[i + 1]; } } } cout << ans; }
a.cc: In function 'int main()': a.cc:36:24: error: 't' was not declared in this scope 36 | cin >> t[i]; | ^ a.cc:40:20: error: 't' was not declared in this scope 40 | if(t[i] == t[i + 1]) | ^
s494538823
p03745
C++
//todo 文字数を少なくする //mintより高速に計算したい時用に modmul() modadd (正の値限定) を作る //#pragma GCC optimize ("-O3") #include <bits/stdc++.h> using namespace std; //@起動時 struct initon { initon() { cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); srand((unsigned) clock() + (unsigned) time(NULL)); }; } __initon; //衝突対策 #define ws ___ws //@必須構造 struct T { int f, s, t; T() { f = -1, s = -1, t = -1; } T(int f, int s, int t) : f(f), s(s), t(t) {} bool operator<(const T &r) const { return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t; //return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順 } bool operator>(const T &r) const { return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; //return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順 } bool operator==(const T &r) const { return f == r.f && s == r.s && t == r.t; } bool operator!=(const T &r) const { return f != r.f || s != r.s || t != r.t; } int operator[](int i) { assert(i < 3); return i == 0 ? f : i == 1 ? s : t; } }; struct F { int a, b, c, d; F() { a = -1, b = -1, c = -1, d = -1; } F(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {} bool operator<(const F &r) const { return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; // return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; } bool operator>(const F &r) const { return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; // return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; } bool operator==(const F &r) const { return a == r.a && b == r.b && c == r.c && d == r.d; } bool operator!=(const F &r) const { return a != r.a || b != r.b || c != r.c || d != r.d; } int operator[](int i) { assert(i < 4); return i == 0 ? a : i == 1 ? b : i == 2 ? c : d; } }; T mt(int a, int b, int c) { return T(a, b, c); } //@マクロ省略系 型,構造 #define int long long #define ll long long #define double long double #define ull unsigned long long using dou = double; using itn = int; using str = string; using bo= bool; #define au auto using P = pair<ll, ll>; using pd =pair<dou, dou>; #define fi first #define se second #define vec vector #define beg begin #define rbeg rbegin #define con continue #define bre break #define brk break #define is == #define maxq 1 #define minq -1 #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MALLOC(type, len) (type*)malloc((len) * sizeof(type)) //マクロ省略系 コンテナ using vi = vector<int>; #define _overloadvvi(_1, _2, _3, _4, name, ...) name #define vvi0() vec<vi> #define vvi1(a) vec<vi> a #define vvi2(a, b) vec<vi> a(b) #define vvi3(a, b, c) vec<vi> a(b,vi(c)) #define vvi4(a, b, c, d) vec<vi> a(b,vi(c,d)) #define vvi(...) _overloadvvi(__VA_ARGS__,vvi4,vvi3,vvi2 ,vvi1,vvi0)(__VA_ARGS__) using vl = vector<ll>; #define _overloadvvl(_1, _2, _3, _4, name, ...) name #define vvl1(a) vec<vl> a #define vvl2(a, b) vec<vl> a(b) #define vvl3(a, b, c) vec<vl> a(b,vl(c)) #define vvl4(a, b, c, d) vec<vl> a(b,vl(c,d)) #define vvl(...) _overloadvvl(__VA_ARGS__,vvl4,vvl3,vvl2 ,vvl1)(__VA_ARGS__) using vb = vector<bool>; #define _overloadvvb(_1, _2, _3, _4, name, ...) name #define vvb1(a) vec<vb> a #define vvb2(a, b) vec<vb> a(b) #define vvb3(a, b, c) vec<vb> a(b,vb(c)) #define vvb4(a, b, c, d) vec<vb> a(b,vb(c,d)) #define vvb(...) _overloadvvb(__VA_ARGS__,vvb4,vvb3,vvb2 ,vvb1)(__VA_ARGS__) using vs = vector<string>; #define _overloadvvs(_1, _2, _3, _4, name, ...) name #define vvs1(a) vec<vs> a #define vvs2(a, b) vec<vs> a(b) #define vvs3(a, b, c) vec<vs> a(b,vs(c)) #define vvs4(a, b, c, d) vec<vs> a(b,vs(c,d)) #define vvs(...) _overloadvvs(__VA_ARGS__,vvs4,vvs3,vvs2 ,vvs1)(__VA_ARGS__) using vd = vector<double>; #define _overloadvvd(_1, _2, _3, _4, name, ...) name #define vvd1(a) vec<vd> a #define vvd2(a, b) vec<vd> a(b) #define vvd3(a, b, c) vec<vd> a(b,vd(c)) #define vvd4(a, b, c, d) vec<vd> a(b,vd(c,d)) #define vvd(...) _overloadvvd(__VA_ARGS__,vvd4,vvd3,vvd2 ,vvd1)(__VA_ARGS__) using vc=vector<char>; #define _overloadvvc(_1, _2, _3, _4, name, ...) name #define vvc1(a) vec<vc> a #define vvc2(a, b) vec<vc> a(b) #define vvc3(a, b, c) vec<vc> a(b,vc(c)) #define vvc4(a, b, c, d) vec<vc> a(b,vc(c,d)) #define vvc(...) _overloadvvc(__VA_ARGS__,vvc4,vvc3,vvc2 ,vvc1)(__VA_ARGS__) using vp = vector<P>; #define _overloadvvp(_1, _2, _3, _4, name, ...) name #define vvp1(a) vec<vp> a #define vvp2(a, b) vec<vp> a(b) #define vvp3(a, b, c) vec<vp> a(b,vp(c)) #define vvp4(a, b, c, d) vec<vp> a(b,vp(c,d)) #define vvp(...) _overloadvvp(__VA_ARGS__,vvp4,vvp3,vvp2 ,vvp1)(__VA_ARGS__) using vt = vector<T>; #define _overloadvvt(_1, _2, _3, _4, name, ...) name #define vvt1(a) vec<vt> a #define vvt2(a, b) vec<vt> a(b) #define vvt3(a, b, c) vec<vt> a(b,vt(c)) #define vvt4(a, b, c, d) vec<vt> a(b,vt(c,d)) #define vvt(...) _overloadvvt(__VA_ARGS__,vvt4,vvt3,vvt2 ,vvt1)(__VA_ARGS__) #define v3i(a, b, c, d) vector<vector<vi>> a(b, vector<vi>(c, vi(d))) #define v3d(a, b, c, d) vector<vector<vd>> a(b, vector<vd>(c, vd(d))) #define v3m(a, b, c, d) vector<vector<vm>> a(b, vector<vm>(c, vm(d))) #define _vvi vector<vi> #define _vvl vector<vl> #define _vvb vector<vb> #define _vvs vector<vs> #define _vvd vector<vd> #define _vvc vector<vc> #define _vvp vector<vp> template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<int>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) #define PQ priority_queue<ll, vector<ll>, greater<ll> > #define tos to_string using mapi = map<int, int>; using mapp = map<P, int>; using mapd = map<dou, int>; using mapc = map<char, int>; using maps = map<str, int>; using seti = set<int>; using setd = set<dou>; using setc = set<char>; using sets = set<str>; using qui = queue<int>; #define bset bitset #define uset unordered_set #define mset multiset #define umap unordered_map #define umapi unordered_map<int,int> #define umapp unordered_map<P,int> #define mmap multimap //マクロ 繰り返し #define _overloadrep(_1, _2, _3, _4, name, ...) name # define _rep(i, n) for(int i = 0,_lim=n; i < _lim ; i++) #define repi(i, m, n) for(int i = m,_lim=n; i < _lim ; i++) #define repadd(i, m, n, ad) for(int i = m,_lim=n; i < _lim ; i+= ad) #define rep(...) _overloadrep(__VA_ARGS__,repadd,repi,_rep,)(__VA_ARGS__) #define _rer(i, n) for(int i = n; i >= 0 ; i--) #define reri(i, m, n) for(int i = m,_lim=n; i >= _lim ; i--) #define rerdec(i, m, n, dec) for(int i = m,_lim=n; i >= _lim ; i-=dec) #define rer(...) _overloadrep(__VA_ARGS__,rerdec,reri,_rer,)(__VA_ARGS__) #define fora(a, b) for(auto&& a : b) #define forg(gi, ve) for (int gi = 0, f, t, c; gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); gi++) #define fort(gi, ve) for (int gi = 0, f, t, c; gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); gi++)if(t!=p) //#define fort(gi, ve) for (int gi = 0, f, t, c;gi<ve.size()&& (gi+= (ve[gi].t==p))< ve.size() && (f = ve[gi].f,t=ve[gi].t, c = ve[gi].c,true); gi++) //マクロ 定数 #define k3 1010 #define k4 10101 #define k5 101010 #define k6 1010101 #define k7 10101010 const int inf = (int) 1e9 + 100; const ll linf = (ll) 1e18 + 100; const char infc = '{'; const string infs = "{"; const double eps = 1e-9; const double PI = 3.1415926535897932384626433832795029L; ll ma = numeric_limits<ll>::min(); ll mi = numeric_limits<ll>::max(); const int y4[] = {-1, 1, 0, 0}; const int x4[] = {0, 0, -1, 1}; const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; //マクロ省略形 関数等 #define arsz(a) (sizeof(a)/sizeof(a[0])) #define sz(a) ((int)(a).size()) //#define rs resize #define mp make_pair #define pb push_back #define pf push_front #define eb emplace_back #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() constexpr bool ev(int a) { return !(a & 1); } constexpr bool od(int a) { return (a & 1); } //@拡張系 こう出来るべきというもの //埋め込み 存在を意識せずに機能を増やされているもの namespace std { template<> class hash<std::pair<signed, signed>> { public: size_t operator()(const std::pair<signed, signed> &x) const { return hash<ll>()(((ll) x.first << 32) + x.second); } }; template<> class hash<std::pair<ll, ll>> { public: //大きいllが渡されると、<<32でオーバーフローするがとりあえず問題ないと判断 size_t operator()(const std::pair<ll, ll> &x) const { return hash<ll>()(((ll) x.first << 32) + x.second); } }; } istream &operator>>(istream &iss, P &a) { iss >> a.first >> a.second; return iss; } template<typename T> istream &operator>>(istream &iss, vector<T> &vec) { for (T &x: vec) iss >> x; return iss; } template<class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { os << p.fi << " " << p.se << endl; return os; } ostream &operator<<(ostream &os, T p) { os << p.f << " " << p.s << " " << p.t; return os; } ostream &operator<<(ostream &os, F p) { os << p.a << " " << p.b << " " << p.c << " " << p.d; return os; } template<typename T> ostream &operator<<(ostream &os, vector <T> &vec) { for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template<typename T> ostream &operator<<(ostream &os, vector <vector<T>> &vec) { for (int i = 0; i < vec.size(); i++) { for (int j = 0; j < vec[0].size(); j++) { os << vec[i][j]; } os << endl; } return os; } template<typename V, typename H> void resize(vector<V> &vec, const H head) { vec.resize(head); } template<typename V, typename H, typename ... T> void resize(vector<V> &vec, const H &head, const T ... tail) { vec.resize(head); for (auto &v: vec) resize(v, tail...); } template<typename T, typename _Pr> bool all_of(const vector<T> &vec, _Pr pred) { return std::all_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> bool any_of(const vector<T> &vec, _Pr pred) { return std::any_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> bool none_of(const vector<T> &vec, _Pr pred) { return std::none_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> const typename vector<T>::const_iterator find_if(const vector<T> &vec, _Pr pred) { return std::find_if(vec.begin(), vec.end(), pred); } template<typename T> bool contains(const vector<T> &vec, const T &val) { return std::find(vec.begin(), vec.end(), val) != vec.end(); } template<typename T, typename _Pr> bool contains_if(const vector<T> &vec, _Pr pred) { return std::find_if(vec.begin(), vec.end(), pred) != vec.end(); } template<class T, class U> void replace(vector<T> &a, T key, U v) { replace(a.begin(), a.end(), key, v); } template<class T> void replace(str &a, T key, T v) { a.replace(all(a), key, v); } //keyと同じかどうか01で置き換える template<class T, class U> void replace(T &a, U k) { rep(i, sz(a)) a[i] = a[i] == k; } template<class T, class U> void replace(T &a) { replace(a, '#'); } template<class T> bool includes(vector<T> &a, vector<T> &b) { vi c = a; vi d = b; sort(all(c)); sort(all(d)); return includes(all(c), all(d)); } template<class T> bool is_permutation(vector<T> &a, vector<T> &b) { return is_permutation(all(a), all(b)); } template<class T> bool next_permutation(vector<T> &a) { return next_permutation(all(a)); } template<class T> T pop(set<T> &set) { T res = *set.begin(); set.erase(set.find(res)); return res; } template<class T> T pop(mset<T> &set) { T res = *set.begin(); set.erase(set.find(res)); return res; } template<class T> T popBack(set<T> &set) { T res = *set.rbegin(); set.erase(set.find(res)); return res; } template<class T> T popBack(mset<T> &set) { T res = *set.rbegin(); set.erase(set.find(res)); return res; } inline void sort(string &a) { sort(a.begin(), a.end()); } template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); } template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); } template<class T, class F> inline void sort(vector<T> &a, F f) { sort(a.begin(), a.end(), [&](T a, T b) { return f(a) < f(b); }); } enum ___pcomparator { fisi, fisd, fdsi, fdsd, sifi, sifd, sdfi, sdfd }; inline void sort(vector<P> &a, ___pcomparator type) { switch (type) { case fisi: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi < r.fi : l.se < r.se; }); break; case fisd: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi < r.fi : l.se > r.se; }); break; case fdsi: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi > r.fi : l.se < r.se; }); break; case fdsd: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi > r.fi : l.se > r.se; }); break; case sifi: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se < r.se : l.fi < r.fi; }); break; case sifd: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se < r.se : l.fi > r.fi; }); break; case sdfi: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se > r.se : l.fi < r.fi; }); break; case sdfd: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se > r.se : l.fi > r.fi; }); break; } }; inline void sort(vector<T> &a, ___pcomparator type) { switch (type) { case fisi: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f < r.f : l.s < r.s; }); break; case fisd: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f < r.f : l.s > r.s; }); break; case fdsi: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f > r.f : l.s < r.s; }); break; case fdsd: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f > r.f : l.s > r.s; }); break; case sifi: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s < r.s : l.f < r.f; }); break; case sifd: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s < r.s : l.f > r.f; }); break; case sdfi: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s > r.s : l.f < r.f; }); break; case sdfd: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s > r.s : l.f > r.f; }); break; } }; template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); }; template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); }; template<class U, class F> inline void rsort(vector<U> &a, F f) { sort(a.begin(), a.end(), [&](U l, U r) { return f(l) > f(r); }); }; template<class U> inline void sortp(vector<U> &a, vector<U> &b) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second;; } }; //F = T<T> //例えばreturn p.fi + p.se; template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, F f) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c, f); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, char type) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c, type); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U> inline void rsortp(vector<U> &a, vector<U> &b) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); rsort(c); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U, class F> inline void rsortp(vector<U> &a, vector<U> &b, F f) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); rsort(c, f); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U> inline void sortt(vector<U> &a, vector<U> &b, vector<U> &c) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); sort(r); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; template<class U, class F> inline void sortt(vector<U> &a, vector<U> &b, vector<U> &c, F f) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); sort(r, f); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; template<class U, class F> inline void rsortt(vector<U> &a, vector<U> &b, vector<U> &c, F f) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); rsort(r, f); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; //indexをつけてsortする (second) template<class T> auto sorti(vector<T> &a) { int n = sz(a); vp ret(n); rep(i, n)ret[i] = P(a[i], i); sort(ret); return ret; }; template<class T> auto rsorti(vector<T> &a) { int n = sz(a); vp ret(n); rep(i, n)ret[i] = P(a[i], i); rsort(ret); return ret; }; template<class T> inline void sort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)sort(a[i]); } template<class T> inline void rsort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)rsort(a[i]); } template<typename A, size_t N, typename T> inline void fill(A (&a)[N], const T &v) { rep(i, N)a[i] = v; } template<typename A, size_t N, size_t O, typename T> inline void fill(A (&a)[N][O], const T &v) { rep(i, N)rep(j, O)a[i][j] = v; } template<typename A, size_t N, size_t O, size_t P, typename T> inline void fill(A (&a)[N][O][P], const T &v) { rep(i, N)rep(j, O)rep(k, P)a[i][j][k] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, typename T> inline void fill(A (&a)[N][O][P][Q], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)a[i][j][k][l] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> inline void fill(A (&a)[N][O][P][Q][R], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)a[i][j][k][l][m] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> inline void fill(A (&a)[N][O][P][Q][R][S], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)a[i][j][k][l][m][n] = v; } template<typename V, typename T> void fill(V &xx, const T vall) { xx = vall; } template<typename V, typename T> void fill(vector<V> &vecc, const T vall) { for (auto &&vx: vecc) fill(vx, vall); } //@汎用便利関数 入力 inline int in() { int ret; // scanf("%lld", &ret); cin >> ret; return ret; } inline string sin() { string ret; cin >> ret; return ret; } template<class T> inline void in(T &head) { cin >> head; } template<class T, class... U> inline void in(T &head, U &... tail) { cin >> head; in(tail...); } #define _overloaddin(_1, _2, _3, _4, name, ...) name #define din1(a) int a;cin>>a #define din2(a, b) int a,b;cin>>a>> b #define din3(a, b, c) int a,b,c;cin>>a>>b>>c #define din4(a, b, c, d) int a,b,c,d;cin>>a>>b>>c>>d #define din(...) _overloaddin(__VA_ARGS__,din4,din3,din2 ,din1)(__VA_ARGS__) #define _overloaddind(_1, _2, _3, _4, name, ...) name #define din1d(a) din1(a);a-- #define din2d(a, b) din2(a,b);a--,b-- #define din3d(a, b, c) din3(a,b,c);a--,b--,c-- #define din4d(a, b, c, d) din4(a,b,c,d);a--,b--,c--,d-- #define dind(...) _overloaddind(__VA_ARGS__,din4d,din3d,din2d ,din1d)(__VA_ARGS__) #define _overloadout(_1, _2, _3, _4, name, ...) name #define out1(a) cout<<a<<endl #define out2(a, b) cout<<a<<" "<< b<<endl #define out3(a, b, c) cout<<a<<" "<<b<<" "<<c<<endl #define out4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl #define out(...) _overloadout(__VA_ARGS__,out4,out3,out2,out1)(__VA_ARGS__) #define _overloadoutl(_1, _2, _3, _4, name, ...) name #define outl1(a) cout<<a<<endl #define outl2(a, b) cout<<a<<endl<<b<<endl #define outl3(a, b, c) cout<<a<<endl<<b<<endl<<c<<endl #define outl4(a, b, c, d) cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl #define outl(...) _overloadout(__VA_ARGS__,outl4,outl3,outl2,outl1)(__VA_ARGS__) #define na(a, n) a.resize(n); rep(_i,n) cin >> a[_i]; #define nao(a, n) a.resize(n+1); rep(_i,n) cin >> a[_i+1]; #define nad(a, n) a.resize(n); rep(_i,n){ cin >> a[_i]; a[_i]--;} #define na2(a, b, n) a.resize(n),b.resize(n);rep(_i, n)cin >> a[_i] >> b[_i]; #define nao2(a, b, n) a.resize(n+1),b.resize(n+1);rep(_i, n)cin >> a[_i+1] >> b[_i+1]; #define na2d(a, b, n) a.resize(n),b.resize(n);rep(_i, n){cin >> a[_i] >> b[_i];a[_i]--,b[_i]--;} #define na3(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(_i, n)cin >> a[_i] >> b[_i] >> c[_i]; #define na3d(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(_i, n){cin >> a[_i] >> b[_i] >> c[_i];a[_i]--,b[_i]--,c[_i]--;} #define nt(a, h, w) resize(a,h,w);rep(_hi,h)rep(_wi,w) cin >> a[_hi][_wi]; #define ntd(a, h, w) rs(a,h,w);rep(_hi,h)rep(_wi,w) cin >> a[_hi][_wi], a[_hi][_wi]--; #define ntp(a, h, w) fill(a,'#');rep(_hi,1,h+1)rep(_wi,1,w+1) cin >> a[_hi][_wi]; //デバッグ #define sp << " " << #define debugName(VariableName) # VariableName #define _deb1(x) debugName(x)<<" = "<<x #define _deb2(x, ...) _deb1(x) <<", "<< _deb1(__VA_ARGS__) #define _deb3(x, ...) _deb1(x) <<", "<< _deb2(__VA_ARGS__) #define _deb4(x, ...) _deb1(x) <<", "<< _deb3(__VA_ARGS__) #define _deb5(x, ...) _deb1(x) <<", "<< _deb4(__VA_ARGS__) #define _deb6(x, ...) _deb1(x) <<", "<< _deb5(__VA_ARGS__) #define _deb7(x, ...) _deb1(x) <<", "<< _deb6(__VA_ARGS__) #define _deb8(x, ...) _deb1(x) <<", "<< _deb7(__VA_ARGS__) #define _deb9(x, ...) _deb1(x) <<", "<< _deb8(__VA_ARGS__) #define _deb10(x, ...) _deb1(x) <<", "<< _deb9(__VA_ARGS__) #define _overloadebug(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, name, ...) name #ifdef _DEBUG #define deb(...) cerr<< _overloadebug(__VA_ARGS__,_deb10,_deb9,_deb8,_deb7,_deb6,_deb5,_deb4,_deb3,_deb2,_deb1)(__VA_ARGS__) <<endl #else #define deb(...) ; #endif #define debugline(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n' //よく使うクラス、構造体 class UnionFind { public: vi par, rank, sizes; int n, trees; UnionFind(int n) : n(n), trees(n) { par.resize(n), rank.resize(n), sizes.resize(n); rep(i, n)par[i] = i, sizes[i] = 1; } int root(int x) { if (par[x] == x)return x; else return par[x] = root(par[x]); } int find(int x) { return root(x); } void unite(int x, int y) { x = root(x); y = root(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); trees--; par[y] = x; sizes[x] += sizes[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return sizes[root(x)]; } //順不同 umapなので vec<vi> sets() { vec<vi> res(trees); umap<int, vi> map; rep(i, n) map[root(i)].push_back(i); int i = 0; for (auto &&p:map) { int r = p.fi; res[i].push_back(r); for (auto &&v:p.se) { if (r == v)continue; res[i].push_back(v); } i++; } return res; } }; using bint =__int128; using u32 = unsigned int; using u64 = unsigned long long; using u128 = __uint128_t; std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } __int128 toi128(string &s) { __int128 ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } template<typename T> T minv(T a, T m); template<typename T> T minv(T a); template<typename T> class Modular { public: using Type = typename decay<decltype(T::value)>::type; constexpr Modular() : value() {} template<typename U> Modular(const U &x) { value = normalize(x); } template<typename U> static Type normalize(const U &x) { Type v; if (-mod() <= x && x < mod()) v = static_cast<Type>(x); else v = static_cast<Type>(x % mod()); if (v < 0) v += mod(); return v; } const Type &operator()() const { return value; } template<typename U> explicit operator U() const { return static_cast<U>(value); } constexpr static Type mod() { return T::value; } Modular &operator+=(const Modular &other) { if ((value += other.value) >= mod()) value -= mod(); return *this; } Modular &operator-=(const Modular &other) { if ((value -= other.value) < 0) value += mod(); return *this; } template<typename U> Modular &operator+=(const U &other) { return *this += Modular(other); } template<typename U> Modular &operator-=(const U &other) { return *this -= Modular(other); } Modular &operator++() { return *this += 1; } Modular &operator--() { return *this -= 1; } Modular operator++(signed) { Modular result(*this); *this += 1; return result; } Modular operator--(signed) { Modular result(*this); *this -= 1; return result; } Modular operator-() const { return Modular(-value); } template<typename U = T> typename enable_if<is_same<typename Modular<U>::Type, signed>::value, Modular>::type &operator*=(const Modular &rhs) { #ifdef _WIN32 uint64_t x = static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value); uint32_t xh = static_cast<uint32_t>(x >> 32), xl = static_cast<uint32_t>(x), d, m; asm( "divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod()) ); value = m; #else value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value)); #endif return *this; } template<typename U = T> typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value, Modular>::type &operator*=(const Modular &rhs) { int64_t q = static_cast<int64_t>(static_cast<double>(value) * rhs.value / mod()); value = normalize(value * rhs.value - q * mod()); return *this; } template<typename U = T> typename enable_if<!is_integral<typename Modular<U>::Type>::value, Modular>::type &operator*=(const Modular &rhs) { value = normalize(value * rhs.value); return *this; } Modular &operator/=(const Modular &other) { return *this *= Modular(minv(other.value)); } template<typename U> friend bool operator==(const Modular<U> &lhs, const Modular<U> &rhs); template<typename U> friend bool operator<(const Modular<U> &lhs, const Modular<U> &rhs); template<typename U> friend std::istream &operator>>(std::istream &stream, Modular<U> &number); operator int() { return normalize(value); } private: Type value; }; template<typename T> bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value == rhs.value; } template<typename T, typename U> bool operator==(const Modular<T> &lhs, U rhs) { return lhs == Modular<T>(rhs); } template<typename T, typename U> bool operator==(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) == rhs; } template<typename T> bool operator!=(const Modular<T> &lhs, const Modular<T> &rhs) { return !(lhs == rhs); } template<typename T, typename U> bool operator!=(const Modular<T> &lhs, U rhs) { return !(lhs == rhs); } template<typename T, typename U> bool operator!=(U lhs, const Modular<T> &rhs) { return !(lhs == rhs); } template<typename T> bool operator<(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value < rhs.value; } template<typename T> Modular<T> operator+(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; } template<typename T, typename U> Modular<T> operator+(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) += rhs; } template<typename T, typename U> Modular<T> operator+(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; } template<typename T> Modular<T> operator-(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; } template<typename T, typename U> Modular<T> operator-(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) -= rhs; } template<typename T, typename U> Modular<T> operator-(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; } template<typename T> Modular<T> operator*(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; } template<typename T, typename U> Modular<T> operator*(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) *= rhs; } template<typename T, typename U> Modular<T> operator*(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; } template<typename T> Modular<T> operator/(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; } template<typename T, typename U> Modular<T> operator/(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) /= rhs; } template<typename T, typename U> Modular<T> operator/(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; } constexpr signed MOD = 1e9 + 7;//MOD using mint = Modular<std::integral_constant<decay<decltype(MOD)>::type, MOD>>; constexpr int mint_len = 1400001; vi fac, finv, inv, p2; void setmod() { fac.resize(mint_len); finv.resize(mint_len); inv.resize(mint_len); p2.resize(mint_len); inv[1] = fac[0] = finv[0] = p2[0] = 1; for (int i = 2; i < mint_len; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i < mint_len; ++i) fac[i] = fac[i - 1] * i % MOD, finv[i] = finv[i - 1] * inv[i] % MOD, p2[i] = p2[i - 1] * 2 % MOD; } #define smod setmod inline mint com(int n, int r) { if (r < 0 || r > n) return 0; return mint(finv[r] * fac[n] % MOD * finv[n - r]); } inline mint pom(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return mint(fac[n] * finv[n - 1]); } inline mint npr(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return mint(fac[n] * finv[n - r]); } inline int nprin(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return fac[n] * finv[n - r] % MOD; } inline int icom(int n, int r) { const int NUM_ = 1400001; static ll fac[NUM_ + 1], finv[NUM_ + 1], inv[NUM_ + 1]; if (fac[0] == 0) { inv[1] = fac[0] = finv[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fac[i] = fac[i - 1] * i % MOD, finv[i] = finv[i - 1] * inv[i] % MOD; } if (r < 0 || r > n) return 0; return ((finv[r] * fac[n] % MOD) * finv[n - r]) % MOD; } #define ncr com #define ncri icom inline mint nhr(int n, int r) { return com(n + r - 1, r); } inline mint hom(int n, int r) { return com(n + r - 1, r); } inline int nhri(int n, int r) { return icom(n + r - 1, r); } template<typename T> inline T minv(T a, T m) { T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; } template<typename T> inline T minv(T a) { if (a < mint_len)return inv[a]; T u = 0, v = 1; int m = MOD; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; } template<typename T, typename U> inline Modular<T> mpow(const Modular<T> &a, const U &b) { assert(b >= 0); int x = a(), res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template<typename T, typename U, typename V> inline mint mpow(const T a, const U b, const V m = MOD) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= m; (x *= x) %= m; p >>= 1; } return res; } template<typename T, typename U> inline mint mpow(const T a, const U b) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template<typename T, typename U, typename V> inline int mpowi(const T &a, const U &b, const V &m = MOD) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= m; (x *= x) %= m; p >>= 1; } return res; } template<typename T> inline string to_string(const Modular<T> &number) { return to_string(number()); } template<typename T> std::ostream &operator<<(std::ostream &stream, const Modular<T> &number) { return stream << number(); } template<typename T> std::istream &operator>>(std::istream &stream, Modular<T> &number) { typename common_type<typename Modular<T>::Type, int64_t>::type x; stream >> x; number.value = Modular<T>::normalize(x); return stream; } using PM = pair<mint, mint>; using vm = vector<mint>; using mapm = map<int, mint>; using umapm = umap<int, mint>; #define _overloadvvm(_1, _2, _3, _4, name, ...) name #define vnm(name, ...) auto name = make_v<mint>(__VA_ARGS__) #define vvm1(a) vec<vm> a #define vvm2(a, b) vec<vm> a(b) #define vvm3(a, b, c) vec<vm> a(b,vm(c)) #define vvm4(a, b, c, d) vec<vm> a(b,vm(c,d)) #define vvm(...) _overloadvvm(__VA_ARGS__,vvm4,vvm3,vvm2 ,vvm1)(__VA_ARGS__) //エラー void ole() { #ifdef _DEBUG debugline("ole"); exit(0); #endif string a = "a"; rep(i, 30)a += a; rep(i, 1 << 17)cout << a << endl; cout << "OLE 出力長制限超過" << endl; exit(0); } void tle() { while (inf)cout << inf << endl; } //便利関数 //テスト用 char ranc() { return (char) ('a' + rand() % 26); } int rand(int min, int max) { assert(min <= max); if (min >= 0 && max >= 0) { return rand() % (max + 1 - min) + min; } else if (max < 0) { return -rand(-max, -min); } else { //+ if (rand() % 2) { return rand(0, max); //- } else { return -rand(0, -min); } } } vi ranv(int n, int min, int max) { vi v(n); rep(i, n)v[i] = rand(min, max); return v; } //単調増加 vi ranvi(int n, int min, int max) { vi v(n); bool bad = 1; while (bad) { bad = 0; v.resize(n); rep(i, n) { if (i && min > max - v[i - 1]) { bad = 1; break; } if (i)v[i] = v[i - 1] + rand(min, max - v[i - 1]); else v[i] = rand(min, max); } } return v; } void ranvlr(int n, int min, int max, vi &l, vi &r) { l.resize(n); r.resize(n); rep(i, n) { l[i] = rand(min, max); r[i] = l[i] + rand(0, max - l[i]); } } //便利 汎用 vp run_length(vi &a) { vp ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } vector<pair<char, int>> run_length(string &a) { vector<pair<char, int>> ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } template<class F> inline int mgr(int ok, int ng, F f) { #define _mgrbody int mid = (ok + ng) / 2; if (f(mid))ok = mid; else ng = mid; if (ok < ng)while (ng - ok > 1) { _mgrbody } else while (ok - ng > 1) { _mgrbody } return ok; } template<class F> inline int mgr(int ok, int ng, int second, F f) { #define _mgrbody2 int mid = (ok + ng) / 2; if (f(mid, second))ok = mid; else ng = mid; if (ok < ng) while (ng - ok > 1) { _mgrbody2 } else while (ok - ng > 1) { _mgrbody2 } return ok; } //strを整数として比較 string smax(str &a, str b) { if (sz(a) < sz(b)) { return b; } else if (sz(a) > sz(b)) { return a; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return b; } else if (a[i] > b[i])return a; } } return a; } //strを整数として比較 string smin(str &a, str b) { if (sz(a) < sz(b)) { return a; } else if (sz(a) > sz(b)) { return b; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return a; } else if (a[i] > b[i])return b; } } return a; } template<typename V, typename T> int find(vector<V> &a, const T key) { rep(i, sz(a))if (a[i] == key)return i; return -1; } template<typename V, typename T> P find(vector<vector<V>> &a, const T key) { rep(i, sz(a)) rep(j, sz(a[0]))if (a[i][j] == key)return mp(i, j); return mp(-1, -1); } template<typename V, typename U> T find(vector<vector<vector<V>>> &a, const U key) { rep(i, sz(a))rep(j, sz(a[0]))rep(k, sz(a[0][0]))if (a[i][j][k] == key)return mt(i, j, k); return mt(-1, -1, -1); } template<typename V, typename T> int count(V &a, const T k) { return a == k; } template<typename V, typename T> int count(vector<V> &a, const T k) { int ret = 0; fora(v, a)ret += count(v, k); return ret; } template<typename T> int count(char &a, const T k) { return a == k; } template<typename T> int count(str &a, const T k) { int ret = 0; rep(i, sz(a))ret += count(a[i], k); return ret; } template<typename V> int count_odd(V &a) { return a % 2; } template<typename V> int count_odd(vector<V> &a) { int ret = 0; fora(v, a)ret += count_odd(v); return ret; } template<typename V> int count_even(V &a) { return a % 2 == 0; } template<typename V> int count_even(vector<V> &a) { int ret = 0; fora(v, a)ret += count_even(v); return ret; } //algorythm void iota(vector<int> &ve, int s, int n) { ve.resize(n); iota(all(ve), s); } vi iota(int s, int n) { vi ve(n); iota(all(ve), s); return ve; } inline ll rev(ll a) { ll res = 0; while (a) { res *= 10; res += a % 10; a /= 10; } return res; } template<class T> inline void rev(vector<T> &a) { reverse(all(a)); } void inline rev(string &a) { reverse(all(a)); } int get(int a, int keta) { return (a / (int) pow(10, keta)) % 10; } int keta(int v) { int cou = 0; while (v) { cou++, v %= 10; } return cou; } int dsum(int v) { int ret = 0; for (; v; v /= 10)ret += v % 10; return ret; } inline int sumd(int v) { return dsum(v); } //変換系 template<class T, class U> inline vector<T> keys(vector<pair<T, U>> a) { vector<T> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> inline vector<U> keys(map<T, U> a) { vector<U> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> inline vector<U> keys(umap<T, U> a) { vector<U> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> vector<U> inline values(vector<pair<T, U>> a) { vector<U> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline vector<T> values(map<T, U> a) { vector<T> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline vector<T> values(umap<T, U> a) { vector<T> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline bool chma(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template<class U> inline bool chma(const U &b) { return chma(ma, b); } template<class T, class U> inline bool chmi(T &a, const U &b) { if (b < a) { a = b; return true; } return false; } template<class U> inline bool chmi(const U &b) { return chmi(mi, b); } template<class T> inline T min(T a, signed b) { return a < b ? a : b; } template<class T> inline T max(T a, signed b) { return a < b ? b : a; } template<class T> inline T min(T a, T b, T c) { return a >= b ? b >= c ? c : b : a >= c ? c : a; } template<class T> inline T max(T a, T b, T c) { return a <= b ? b <= c ? c : b : a <= c ? c : a; } template<class T> inline T min(vector<T> a) { return *min_element(all(a)); } template<class T> inline T mini(vector<T> a) { return min_element(all(a)) - a.begin(); } template<class T> inline T min(vector<T> a, int n) { return *min_element(a.begin(), a.begin() + min(n, sz(a))); } template<class T> inline T min(vector<T> a, int s, int n) { return *min_element(a.begin() + s, a.begin() + min(n, sz(a))); } template<class T> inline T max(vector<T> a) { return *max_element(all(a)); } template<class T> inline T maxi(vector<T> a) { return max_element(all(a)) - a.begin(); } template<class T> inline T max(vector<T> a, int n) { return *max_element(a.begin(), a.begin() + min(n, sz(a))); } template<class T> inline T max(vector<T> a, int s, int n) { return *max_element(a.begin() + s, a.begin() + min(n, sz(a))); } template<typename A, size_t N> inline A max(A (&a)[N]) { A res = a[0]; rep(i, N)res = max(res, a[i]); return res; } template<typename A, size_t N, size_t O> inline A max(A (&a)[N][O]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P> inline A max(A (&a)[N][O][P]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> inline A max(A (&a)[N][O][P][Q], const T &v) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A max(A (&a)[N][O][P][Q][R]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A max(A (&a)[N][O][P][Q][R][S]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N> inline A min(A (&a)[N]) { A res = a[0]; rep(i, N)res = min(res, a[i]); return res; } template<typename A, size_t N, size_t O> inline A min(A (&a)[N][O]) { A res = min(a[0]); rep(i, N)res = min(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P> inline A min(A (&a)[N][O][P]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> inline A min(A (&a)[N][O][P][Q], const T &v) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A min(A (&a)[N][O][P][Q][R]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A min(A (&a)[N][O][P][Q][R][S]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<class T> inline T sum(T &v) { return v; } template<class T> inline auto sum(vector<T> &v) { auto ret = sum(v[0]); rep(i, 1, sz(v))ret += sum(v[i]); return ret; } template<class T, class U, class... V> inline auto sum(vector<T> &v, U head, V... tail) { auto ret = sum(v[0], tail...); rep(i, 1, min(sz(v), head))ret += sum(v[i], tail...); return ret; } inline P sump(vp &v, int len = -1) { if (len == -1)len = v.size(); P res = {0, 0}; chmi(len, v.size()); rep(i, len) { res.fi += v[i].fi; res.se += v[i].se; } return res; } ///要素が0の時、返り値は0か1か template<class T> inline T mul(vector<T> &v, int len = -1) { if (len == -1)len = v.size(); T res = 1; chmi(len, v.size()); rep(i, len)res *= v[i]; return res; } inline void clear(PQ &q) { while (q.size())q.pop(); } template<class T> inline void clear(queue<T> &q) { while (q.size())q.pop(); } template<class T> inline T *negarr(int size) { T *body = (T *) malloc((size * 2 + 1) * sizeof(T)); return body + size; } template<class T> inline T *negarr2(int h, int w) { double **dummy1 = new double *[2 * h + 1]; double *dummy2 = new double[(2 * h + 1) * (2 * w + 1)]; dummy1[0] = dummy2 + w; for (int i = 1; i <= 2 * h + 1; i++) { dummy1[i] = dummy1[i - 1] + 2 * w + 1; } double **a = dummy1 + h; return a; } //imoは0-indexed //ruiは1-indexed template<class T> inline vector<T> imo(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1)ret[i + 1] += ret[i]; return ret; } //漸化的に最小を持つ template<class T> inline vector<T> imi(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1)chmi(ret[i + 1], ret[i]); return ret; } template<class T> struct ruiC { const vector<T> rui; ruiC(vector<T> &ru) : rui(ru) {} inline T operator()(int l, int r) { assert(l <= r); return rui[r] - rui[l]; } inline T operator[](int i) { return rui[i]; } }; template<class T> struct rruic { const T *rrui; rruic(T *ru) : rrui(ru) {} //n-1から-1へ inline T operator()(int l, int r) { assert(l >= r); return rrui[r] - rrui[l]; } inline T operator[](int i) { return rrui[i]; } }; template<class T> inline vector<T> ruiv(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] + a[i]; return ret; } template<class T> inline ruiC<T> ruic(vector<T> &a) { vector<T> ret = ruiv(a); return ruiC<T>(ret); } //kと同じものの数 template<class T, class U> inline vi ruiv(T &a, U k) { vi ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] + (a[i] == k); return ret; } template<class T, class U> inline ruiC<int> ruic(T &a, U k) { vi ret = ruiv(a, k); return ruiC<int>(ret); } //xor template<class T> inline vector<T> ruix(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] ^ a[i]; return ret; } template<class T> inline vector<T> ruim(vector<T> &a) { vector<T> res(a.size() + 1, 1); rep(i, a.size())res[i + 1] = res[i] * a[i]; return res; } //漸化的に最小を1indexで持つ template<class T> inline vector<T> ruimi(vector<T> &a) { int n = sz(a); vector<T> ret(n + 1); rep(i, 1, n) { ret[i] = a[i - 1]; chmi(ret[i + 1], ret[i]); } return ret; } //template<class T> T *rrui(vector<T> &a) { //右から左にかけての半開区間 (-1 n-1] template<class T> rruic<T> rrui(vector<T> &a) { int len = a.size(); T *body = (T *) malloc((len + 1) * sizeof(T)); T *res = body + 1; rer(i, len - 1)res[i - 1] = res[i] + a[i]; return rruic<T>(res); } //掛け算 template<class T> T *rruim(vector<T> &a) { int len = a.size(); T *body = (T *) malloc((len + 1) * sizeof(T)); T *res = body + 1; res[len - 1] = 1; rer(i, len - 1)res[i - 1] = res[i] * a[i]; return res; } template<class T, class U> void inc(T &a, U v = 1) { a += v; } template<class T, class U> void inc(vector<T> &a, U v = 1) { for (auto &u :a)inc(u, v); } template<class T> void inc(vector<T> &a) { for (auto &u :a)inc(u, 1); } template<class T, class U> void plus(T &a, U v = 1) { a += v; } template<class T, class U> void plus(vector<T> &a, U v = 1) { for (auto &u :a)inc(u, v); } template<class T> void plus(vector<T> &a) { for (auto &u :a)inc(u, 1); } template<class T, class U> void dec(T &a, U v = 1) { a -= v; } template<class T, class U> void dec(vector<T> &a, U v = 1) { for (auto &u :a)dec(u, v); } template<class T> void dec(vector<T> &a) { for (auto &u :a)dec(u, 1); } template<class T, class U> void minu(T &a, U v = 1) { a -= v; } template<class T, class U> void minu(vector<T> &a, U v = 1) { for (auto &u :a)dec(u, v); } template<class T> void minu(vector<T> &a) { for (auto &u :a)dec(u, 1); } template<class U> void minu(string &a, U v = 1) { for (auto &u :a)dec(u, v); } void minu(string &a) { for (auto &u :a)dec(u, 1); } inline bool inside(int h, int w, int H, int W) { return h >= 0 && w >= 0 && h < H && w < W; } inline bool inside(int l, int v, int r) { return l <= v && v < r; } #define ins inside ll u(ll a) { return a < 0 ? 0 : a; } template<class T> vector<T> u(const vector<T> &a) { vector<T> ret = a; fora(v, ret)v = u(v); return ret; } #define MIN(a) numeric_limits<a>::min() #define MAX(a) numeric_limits<a>::max() ll goldd(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll) ((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl < fr) { right = rm; rm = lm; fr = fl; lm = left + (ll) ((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } ll minScore = MAX(ll); ll resIndex = left; for (ll i = left; i < right + 1; i++) { ll score = calc(i); if (minScore > score) { minScore = score; resIndex = i; } } return resIndex; } ll goldt(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll) ((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl > fr) { right = rm; rm = lm; fr = fl; lm = left + (ll) ((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } if (left > right) { ll l = left; left = right; right = l; } ll maxScore = MIN(ll); ll resIndex = left; for (ll i = left; i < right + 1; i++) { ll score = calc(i); if (maxScore < score) { maxScore = score; resIndex = i; } } return resIndex; } template<class T> T min(vector<vector<T>> &a) { T res = MAX(T); rep(i, a.size())chmi(res, *min_element(all(a[i]))); return res; } template<class T> T max(vector<vector<T>> &a) { T res = MIN(T); rep(i, a.size())chma(res, *max_element(all(a[i]))); return res; } constexpr bool bget(ll m, int keta) { assert(keta < 64); return (m >> keta) & 1; } int bget(ll m, int keta, int sinsuu) { m /= (ll) pow(sinsuu, keta); return m % sinsuu; } inline ll bit(int n) { return (1LL << (n)); } inline ll bit(int n, int sinsuu) { return (ll) pow(sinsuu, n); } //int bcou(ll m) { return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32); } #define bcou __builtin_popcountll //最下位ビット int lbit(int n) { return n & -n; } //最上位ビット int hbit(int n) { n |= (n >> 1); n |= (n >> 2); n |= (n >> 4); n |= (n >> 8); n |= (n >> 16); n |= (n >> 32); return n - (n >> 1); } //初期化は0を渡す ll nextComb(ll &mask, int n, int r) { if (!mask)return mask = (1LL << r) - 1; ll x = mask & -mask; //最下位の1 ll y = mask + x; //連続した下の1を繰り上がらせる ll res = ((mask & ~y) / x >> 1) | y; if (bget(res, n))return mask = 0; else return mask = res; } //n桁以下でビットがr個立っているもののvectorを返す vl bitCombList(int n, int r) { vl res; int m = 0; while (nextComb(m, n, r)) { res.pb(m); } return res; } //大文字小文字を区別する int altoiaZ(char c) { if ('A' <= c && c <= 'Z')return c - 'A'; return c - 'a' + 26; } char itoalaZ(int i) { if (i < 26)return 'A' + i; return 'a' + i - 26; } //aもAも0を返す 基本小文字 int altoi(char c) { if ('A' <= c && c <= 'Z')return c - 'A'; return c - 'a'; } char itoal(int i) { return 'a' + i; } int ctoi(char c) { return c - '0'; } char itoc(int i) { return i + '0'; } int vtoi(vi &v) { int res = 0; if (sz(v) > 18) { debugline("vtoi"); deb(sz(v)); ole(); } rep(i, sz(v)) { res *= 10; res += v[i]; } return res; } vi itov(int i) { vi res; while (i) { res.pb(i % 10); i /= 10; } rev(res); return res; } vi stov(string &a) { int n = sz(a); vi ret(n); rep(i, n) { ret[i] = a[i] - '0'; } return ret; } vector<vector<int>> ctoi(vector<vector<char>> s, char c) { int n = sz(s), m = sz(s[0]); vector<vector<int>> res(n, vector<int>(m)); rep(i, n)rep(j, m)res[i][j] = s[i][j] == c; return res; } #define unique(v) v.erase( unique(v.begin(), v.end()), v.end() ); void compress(vi &a) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } void compress(int a[], int len) { vi b; for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } //要素が見つからなかったときに困る #define binarySearch(a, v) (binary_search(all(a),v)) #define lowerIndex(a, v) (lower_bound(all(a),v)-a.begin()) #define lowerBound(a, v) (*lower_bound(all(a),v)) #define upperIndex(a, v) (upper_bound(all(a),v)-a.begin()) #define upperBound(a, v) (*upper_bound(all(a),v)) #define ans(a) cout<<a<<endl;continue; #define poll(a) q.front();q.pop() #define dpoll(a) q.front();q.pop_front() #define pollLast(a) q.back();q.pop_back() #define pollBack(a) q.back();q.pop_back() template<class T> inline void fin(T s) { cout << s << endl, exit(0); } //便利 数学 math int mod(int a, int m) { return (a % m + m) % m; } int pow(int a) { return a * a; }; ll fact(int v) { return v <= 1 ? 1 : v * fact(v - 1); } ll comi(int n, int r) { assert(n < 100); static vvi(pas, 100, 100); if (pas[0][0])return pas[n][r]; pas[0][0] = 1; rep(i, 1, 100) { pas[i][0] = 1; rep(j, 1, i + 1)pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j]; } return pas[n][r]; } double comd(int n, int r) { assert(n < 2020); static vvd(comb, 2020, 2020); if (comb[0][0] == 0) { comb[0][0] = 1; rep(i, 2000) { comb[i + 1][0] = 1; rep(j, 1, i + 2) { comb[i + 1][j] = comb[i][j] + comb[i][j - 1]; } } } return comb[n][r]; } inline int gcd(int a, int b) { while (b) a %= b, swap(a, b); return a; } inline int gcd(vi b) { ll res = b[0]; for (auto &&v :b)res = gcd(v, res); return res; } inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } inline ll ceil(ll a, ll b) { if (b == 0) { debugline("ceil"); deb(a, b); ole(); return -1; } else if (a < 0) { return 0; } else { return (a + b - 1) / b; } } //v * v >= aとなる最小のvを返す ll sqrt(ll a) { if (a < 0) { debugline("sqrt"); deb(a); ole(); } ll res = (ll) std::sqrt(a); while (res * res < a)res++; return res; } double log(double e, double x) { return log(x) / log(e); } ll sig(ll t) { return (1 + t) * t / 2; } ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; } namespace pnumber_tools { #define Eratosthenes30_2 class Eratosthenes {public:virtual void initialize() {} virtual void generate(const int64_t x) = 0; virtual void generate(const int64_t from, const int64_t to) = 0; virtual int64_t count() = 0; virtual bool prime(int x) = 0; virtual int32_t version() = 0; inline uint64_t PopCnt(uint64_t); inline int BitToIndex(uint8_t); }; uint64_t Eratosthenes::PopCnt(uint64_t bits) { bits = (bits & 0x5555555555555555ULL) + ((bits >> 1) & 0x5555555555555555ULL); bits = (bits & 0x3333333333333333ULL) + ((bits >> 2) & 0x3333333333333333ULL); bits = (bits & 0x0f0f0f0f0f0f0f0fULL) + ((bits >> 4) & 0x0f0f0f0f0f0f0f0fULL); return (bits * 0x0101010101010101ULL) >> (64 - 8); } int Eratosthenes::BitToIndex(uint8_t b) { switch (b) { case 1 << 0: return 0; case 1 << 1: return 1; case 1 << 2: return 2; case 1 << 3: return 3; case 1 << 4: return 4; case 1 << 5: return 5; case 1 << 6: return 6; case 1 << 7: return 7; } return -1; } namespace { const uint64_t kSegmentSize = 1000000; const int32_t kMod30[] = {1, 7, 11, 13, 17, 19, 23, 29}; const int C1[] = {6, 4, 2, 4, 2, 4, 6, 2}; const int C0[][8] = { {0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 1, 1, 1, 1}, {2, 2, 0, 2, 0, 2, 2, 1}, {3, 1, 1, 2, 1, 1, 3, 1}, {3, 3, 1, 2, 1, 3, 3, 1}, {4, 2, 2, 2, 2, 2, 4, 1}, {5, 3, 1, 4, 1, 3, 5, 1}, {6, 4, 2, 4, 2, 4, 6, 1}, }; const uint8_t kMask[][8] = { {0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f}, {0xfd, 0xdf, 0xef, 0xfe, 0x7f, 0xf7, 0xfb, 0xbf}, {0xfb, 0xef, 0xfe, 0xbf, 0xfd, 0x7f, 0xf7, 0xdf}, {0xf7, 0xfe, 0xbf, 0xdf, 0xfb, 0xfd, 0x7f, 0xef}, {0xef, 0x7f, 0xfd, 0xfb, 0xdf, 0xbf, 0xfe, 0xf7}, {0xdf, 0xf7, 0x7f, 0xfd, 0xbf, 0xfe, 0xef, 0xfb}, {0xbf, 0xfb, 0xf7, 0x7f, 0xfe, 0xef, 0xdf, 0xfd}, {0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe}, }; const int64_t kSievedPrimes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23}; const int64_t kInitialSize = 7 * 11 * 13 * 17 * 19 * 23;class Eratosthenes2 final : public Eratosthenes { public: void generate(const int64_t x) override; void generate(const int64_t, const int64_t) override { assert(false); } bool prime(int x) override; int64_t count() override; int32_t version() override { return 2; } std::vector<uint8_t> flags_; }; void Eratosthenes2::generate(const int64_t x) { flags_.clear(); if (x > 10000000000) return; int64_t size = x / 30 + (x % 30 != 0); flags_.resize(size, 0xff); if (int r = x % 30) { if (r <= 1) flags_[size - 1] = 0x0; else if (r <= 7) flags_[size - 1] = 0x1; else if (r <= 11) flags_[size - 1] = 0x3; else if (r <= 13) flags_[size - 1] = 0x7; else if (r <= 17) flags_[size - 1] = 0xf; else if (r <= 19) flags_[size - 1] = 0x1f; else if (r <= 23) flags_[size - 1] = 0x3f; else if (r <= 29) flags_[size - 1] = 0x7f; } flags_[0] = 0xfe; const uint64_t sqrt_x = std::ceil(std::sqrt(x) + 0.1); const uint64_t sqrt_xi = sqrt_x / 30 + 1; for (uint64_t i = 0; i < sqrt_xi; ++i) { for (uint8_t flags = flags_[i]; flags; flags &= flags - 1) { uint8_t lsb = flags & (-flags); int ibit = BitToIndex(lsb); const int32_t m = kMod30[ibit]; int32_t pm = 30 * i + 2 * m; for (uint64_t j = i * pm + (m * m) / 30, k = ibit; j < flags_.size(); j += i * C1[k] + C0[ibit][k], k = (k + 1) & 7) { flags_[j] &= kMask[ibit][k]; } } } }int64_t Eratosthenes2::count() { if (flags_.empty()) return -1; int64_t ret = 3; for (uint8_t f : flags_) { ret += PopCnt(f); } return ret; } inline bool Eratosthenes2::prime(int x) { static unordered_map<int, int> imap = {{1, 0}, {7, 1}, {11, 2}, {13, 3}, {17, 4}, {19, 5}, {23, 6}, {29, 7}}; if (x == 2 || x == 3 || x == 5)return true; else if (!(x & 1) || x % 3 == 0 || x % 5 == 0)return false; return (flags_[x / 30] >> imap[x % 30]) & 1; }} Eratosthenes30_2 Eratosthenes2 era; int prime_len = 1e7; vector<int> primes; void setprime(int size = 1e7) { prime_len = size; era.generate(size); primes = {2, 3, 5}; int nums[129] = {}; nums[1] = 1; nums[2] = 7; nums[4] = 11; nums[8] = 13; nums[16] = 17; nums[32] = 19; nums[64] = 23; nums[128] = 29; //p = 30i + j int j = 0; int sflim = era.flags_.size(); int i30 = 0; for (int i = 0; i < sflim; i++, i30 += 30) { uint8_t m = era.flags_[i]; while (m) { j = m & -m; primes.push_back(i30 + nums[j]); m ^= j; } } } using u32 = unsigned int;//longlongになっていると思うが放置していいと思う using u64 = unsigned long long; using u128 = __uint128_t; //O(k log(n)^3) //32bit -> 270回程度 //64bit -> 1260回程度 //64bit以下で精度100% template<class BinOp> bool miller_rabin(const uint64_t &n, const uint64_t *witness, BinOp modmul) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; const int64_t m = n - 1, d = m / (m & -m); auto modpow = [&](int64_t a, int64_t b) { int64_t res = 1; for (; b; b /= 2) { if (b & 1) res = modmul(res, a); a = modmul(a, a); } return res; }; auto suspect = [&](uint64_t a, uint64_t t) { a = modpow(a, t); while (t != n - 1 && a != 1 && a != n - 1) { a = modmul(a, a); t = modmul(t, 2); } return a == n - 1 || t % 2 == 1; }; for (const uint64_t *w = witness; *w; w++) { if (*w % n != 0 && !suspect(*w, d)) return false; } return true; } //miller_rabin & エラトステネス bool prime(const int &n) { assert(n < 9223372036854775808ULL); if (!sz(primes))setprime(); //エラトステネスの篩 偶数省略ver //[i] = i*2+1 if (n < prime_len)return era.prime(n); if (n < 4294967296) { rep(i, 30) if (!(n % primes[i]))return false; constexpr uint64_t witness[] = {2, 7, 61, 0}; auto modmul = [&](uint64_t a, uint64_t b) -> uint64_t { return a * b % n; }; return miller_rabin(n, witness, modmul); } else { rep(i, 50) if (!(n % primes[i]))return false; constexpr uint64_t witness[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022, 0}; auto modmul = [&](uint64_t a, uint64_t b) -> uint64_t { return (uint64_t) ((__uint128_t) a * b % n); }; return miller_rabin(n, witness, modmul); } } vi divisors(int v) { vi res; double lim = std::sqrt(v); for (int i = 1; i <= lim; ++i) { if (v % i == 0) { res.pb(i); if (i != v / i)res.pb(v / i); } } return res; } vp factorization(int v) { assert(v); int tv = v; vp res; if (!sz(primes))setprime(); for (auto &&p :primes) { if (v % p == 0)res.eb(p, 0); while (v % p == 0) { v /= p; res.back().second++; } if (v == 1 || p * p > tv)break; } if (v > 1)res.eb(v, 1); return res; } //注意 gcdを取る間隔 i%10 が場合によってはtleを引き起こす //うまくいかなかったら%1で動かすように変更した vp rho(int v) { assert(v); if (v == 1)return vp(); vi ret; if (!sz(primes)) setprime(); int lim = 300; //64bit if (v < 4294967296)lim = 80; //32bit else if (v < 281474976710656LL)lim = 120; //48bit for (int i = 0; i < lim; i += 5) { //v<=1の判定回数を減らせる分高速化できる事を期待している while (v % primes[i] == 0) ret.pb(primes[i]), v /= primes[i]; while (v % primes[i + 1] == 0) ret.pb(primes[i + 1]), v /= primes[i + 1]; while (v % primes[i + 2] == 0) ret.pb(primes[i + 2]), v /= primes[i + 2]; while (v % primes[i + 3] == 0) ret.pb(primes[i + 3]), v /= primes[i + 3]; while (v % primes[i + 4] == 0) ret.pb(primes[i + 4]), v /= primes[i + 4]; if (v <= 1) { sort(ret);//試し割りだけで終わった時 return run_length(ret); } } int lower_prime_bound = primes[lim - 1] * primes[lim - 1]; //試し割りするか mt19937 mr; mr.seed(clock()); int c; auto fac = [&](int v, const int loop = 10) { // if (v == 4)return 2ll; //試し割りで消えた c = mr() % v; int x = mr() % v; int y = x; int d = 1; int lim = std::sqrt(v) + 2; //brentによる改良 差分を一操作で求められる for (int i = 1, mul = 1, next_2pow = 2; d == 1 && i <= lim; i++) { if (i == next_2pow) { y = x; next_2pow <<= 1; } x = ((u128) x * x + c) % v; mul = ((u128) mul * abs(x - y)) % v;//ユークリッドの互除法と同じ原理で因数は保たれる if (i % loop == 0) {//10とかなんとか iによっては死ぬ d = gcd(mul, v); mul = 1; } } if (d == v) return -1ll; return d; }; queue<int> q; q.push(v); while (!q.empty()) { int v = q.front(); q.pop(); if (prime(v)) { ret.pb(v); continue; } int d = -1; //基本loop回数10でやり、駄目なら1で for (int i = 0; d == -1 && i < 5; i++)d = fac(v, 10); if (d == -1)while (d == -1)d = fac(v, 1); int d2 = v / d; rep(_, 2) { if (d <= lower_prime_bound)ret.pb(d); else q.push(d); d = d2; } } sort(ret); return run_length(ret); } } using namespace pnumber_tools; //幾何 Pをcomplexとして扱う template<class T, class U> bool eq(T a, U b) { return fabs(a - b) < eps; } dou atan2(pd a) { return atan2(a.se, a.fi); } dou angle(pd f, pd t) { return atan2(t.se - f.se, t.fi - f.fi); } dou distance(pd a, pd b) { return hypot(a.fi - b.fi, a.se - b.se); } //bを中心とするabcのtheta aからcにかけて時計回り dou angle(pd a, pd b, pd c) { dou ax = a.fi - b.fi; dou ay = a.se - b.se; dou cx = c.fi - b.fi; dou cy = c.se - b.se; double ret = atan2(cy, cx) - atan2(ay, ax); if (ret < 0) ret += 2 * PI; return ret; } dou dot(pd a, pd b) { return a.fi * b.fi + a.se + b.se; } dou cro(pd a, pd b) { return a.fi * b.se - a.se + b.fi; } template<class T> struct edge { int f, t; T c; int id; int type; edge(int f, int t, T c = 1, int id = -1, int ty = -1) : f(f), t(t), c(c), id(id), type(ty) {} bool operator<(const edge &b) const { return c < b.c; } bool operator>(const edge &b) const { return c > b.c; } }; template<class T> ostream &operator<<(ostream &os, edge<T> &e) { os << e.f << " " << e.t << " " << e.c; return os; } template<typename T> class graph { protected: vector<bool> _used; public : vector<vector<edge<T>>> g; vector<edge<T>> edges; int n; graph(int n) : n(n) { g.resize(n), _used.resize(n); } void clear() { g.clear(), edges.clear(); } void resize(int n) { this->n = n; g.resize(n); _used.resize(n); } int size() { return g.size(); } vector<edge<T> > &operator[](int i) { return g[i]; } virtual void add(int f, int t, T c, int id, int ty) = 0; virtual bool used(edge<T> &e) = 0; virtual bool used(int id) = 0; virtual void del(edge<T> &e) = 0; virtual void del(int id) = 0; virtual void set_edges() = 0; }; template<typename T =ll> class digraph : public graph<T> { public: using graph<T>::g; using graph<T>::n; using graph<T>::edges; using graph<T>::_used; int eid = 0; digraph(int n) : graph<T>(n) {} void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("digraph add"); deb(f, t, c, id, ty); ole(); } if (id == -1)id = eid++; g[f].emplace_back(f, t, c, id, ty); edges.emplace_back(f, t, c, id, ty); } bool used(edge<T> &e) { return _used[e.id]; } bool used(int id) { return _used[id]; } void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; } void del(int id) { _used[id] = _used[id ^ 1] = 1; } void set_edges() { if (sz(edges))return; rep(i, n)fora(e, g[i])edges.pb(e); } }; template<class T=int> class undigraph : public graph<T> { public: using graph<T>::g; using graph<T>::n; using graph<T>::edges; using graph<T>::_used; int eid = 0; undigraph(int n) : graph<T>(n) { } void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("undigraph add"); deb(f, t, c, id, ty); ole(); } if (id == -1)id = eid, eid += 2; g[f].emplace_back(f, t, c, id, ty); g[t].emplace_back(t, f, c, id + 1, ty); edges.emplace_back(f, t, c, id, ty); edges.emplace_back(t, f, c, id + 1, ty); } void add(edge<T> &e) { int f = e.f, t = e.t, ty = e.type; T c = e.c; add(f, t, c, ty); } bool used(edge<T> &e) { return _used[e.id]; } bool used(int id) { return _used[id]; } void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; } void del(int id) { _used[id] = _used[id ^ 1] = 1; } void set_edges() { if (sz(edges))return; rep(i, n)fora(e, g[i])edges.pb(e); } }; template<typename T> struct radixheap { vector<pair<u64, T> > v[65]; u64 size, last; radixheap() : size(0), last(0) {} bool empty() const { return size == 0; } inline int getbit(int a) { return a ? 64 - __builtin_clzll(a) : 0; } void push(u64 key, const T &value) { ++size; v[getbit(key ^ last)].emplace_back(key, value); } pair<u64, T> pop() { if (v[0].empty()) { int idx = 1; while (v[idx].empty()) ++idx; last = min_element(begin(v[idx]), end(v[idx]))->first; for (auto &p : v[idx]) v[getbit(p.first ^ last)].emplace_back(p); v[idx].clear(); } --size; auto ret = v[0].back(); v[0].pop_back(); return ret; } }; vi dijkstra2(const graph<int> &g, int s, int cant_arrive = -1) { if (!(0 <= s && s < g.n)) { debugline("dijkstra"); deb(s, g.n); ole(); } int initValue = MAX(int); vi dis(g.n, initValue); radixheap<int> q; dis[s] = 0; q.push(0, s); while (!q.empty()) { int nowc, i; tie(nowc, i) = q.pop(); if (dis[i] != nowc)continue; for (auto &&e : g.g[i]) { int to = e.t; int c = nowc + e.c; if (dis[to] > c) { dis[to] = c; q.push(dis[to], to); } } } //基本、たどり着かないなら-1 if (cant_arrive == -1)for (auto &&d :dis) if (d == initValue)d = -1; return dis; } template<class T> vector<T> dijkstra(const graph<T> &g, int s, int cant_arrive = -1) { if (!(0 <= s && s < g.n)) { debugline("dijkstra"); deb(s, g.n); ole(); } T initValue = MAX(T); vector<T> dis(g.n, initValue); priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q; dis[s] = 0; q.emplace(0, s); while (q.size()) { T nowc = q.top().fi; int i = q.top().se; q.pop(); if (dis[i] != nowc)continue; for (auto &&e : g.g[i]) { int to = e.t; T c = nowc + e.c; if (dis[to] > c) { dis[to] = c; q.emplace(dis[to], to); } } } //基本、たどり着かないなら-1 if (cant_arrive == -1)for (auto &&d :dis) if (d == initValue)d = -1; return dis; } template<class T> vector<vector<T>> warshall(const graph<T> &g, int cant_arrive = -1) { int n = g.n; vector<vector<T> > dis(n, vector<T>(n, linf)); rep(i, n)fora(e, g.g[i])chmi(dis[e.f][e.t], e.c); rep(i, n)dis[i][i] = 0; rep(k, n)rep(i, n)rep(j, n)chmi(dis[i][j], dis[i][k] + dis[k][j]); //基本、たどり着かないなら-1 if (cant_arrive == -1)rep(i, n)rep(j, n) if (dis[i][j] == linf)dis[i][j] = -1; return dis; } template<class T=int> class tree : public undigraph<T> { public: using undigraph<T>::g; using undigraph<T>::n; using undigraph<T>::edges; using undigraph<T>::_used; vi disv; private: bool never = 1; int root = -1; vi dep;//到着した順の深さ vi vis;//到着した順 vi first;//初めてiに到着した時 vector<int> bestt;//タイミングを持つ int sn = 0;//seg木の底辺の長さ euler tourの長さ void built() { never = 0; n = g.size(); //euler tour disv.resize(n); first.resize(n); dep.resize(n * 2); vis.resize(n * 2); function<void(int, int, int, int &)> dfs = [&](int i, int p, int d, int &k) { first[i] = k; vis[k] = i; dep[k++] = d; forg(gi, g[i]) { if (t == p)continue; disv[t] = disv[i] + c; dfs(t, i, d + 1, k); vis[k] = i; dep[k++] = d; } }; int k = 0; dfs(root, -1, 0, k); //rmq sn = 1; while (sn < n * 2)sn *= 2; bestt.resize(2 * sn - 1); rep(i, k)bestt[i + sn - 1] = i;//時間を持つ rer(i, sn - 2) { if (dep[bestt[i * 2 + 1]] < dep[bestt[i * 2 + 2]]) { bestt[i] = bestt[i * 2 + 1]; } else { bestt[i] = bestt[i * 2 + 2]; } } } //最小の深さを持つタイミングが知りたい inline int lca_rmq(int l, int r) { int midv = inf; int midi = -1; l += sn - 1; r += sn - 1; while (l < r) { //右なら、次に右上へ移動してしまうので if (!(l & 1)) { if (chmi(midv, dep[bestt[l]])) { midi = bestt[l]; } } //右なら、左を取らないと機会を逃す if (!(r & 1)) { if (chmi(midv, dep[bestt[r - 1]])) { midi = bestt[r - 1]; } } l >>= 1; r = (r - 1) >> 1; } return vis[midi]; } public: tree(int n, int root = 0) : undigraph<T>(n), root(root) {} bool leaf(int v) { return sz(g[v]) == 1 && v != root; } int lca(int u, int v) { if (never)built(); if (first[u] > first[v])swap(u, v); return lca_rmq(first[u], first[v] + 1); } int dis(int u, int v) { if (never) built(); if (first[u] > first[v])swap(u, v); int p = lca_rmq(first[u], first[v] + 1); return disv[u] + disv[v] - disv[p] * 2; } }; //辺によりメモリを大量消費 // よってedgesを消している //頂点10^6でメモリを190MB(制限の8割)使う //軽量化のため、辺を持たないbig gridクラスがあってもいいかもしれない // template<class T=int> class grid_k6 : public undigraph<T> { public: using undigraph<T>::g; using undigraph<T>::n; using undigraph<T>::edges; using undigraph<T>::_used; int H, W; int eid = 0; void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("grid_k6 add"); deb(f, t, c, id, ty); ole(); } g[f].emplace_back(f, t, c, eid++, ty); g[t].emplace_back(t, f, c, eid++, ty); } int getid(int h, int w) { if (!inside(h, w, H, W))return -1; return W * h + w; } P get2(int id) { return mp(id / W, id % W); } P operator()(int id) { return get2(id); } int operator()(int h, int w) { return getid(h, w); } grid_k6(int H, int W) : H(H), W(W), undigraph<T>(H * W) { rep(h, H) { rep(w, W) { int f = getid(h, w); if (w + 1 < W) add(f, getid(h, w + 1)); if (h + 1 < H)add(f, getid(h + 1, w)); } } } grid_k6(_vvc ba, char wall = '#') : H(sz(ba)), W(sz(ba[0])), undigraph<T>(sz(ba) * sz(ba[0])) { rep(h, H) { rep(w, W) { if (ba[h][w] == wall)con; int f = getid(h, w); if (w + 1 < W && ba[h][w + 1] != wall) { add(f, getid(h, w + 1)); } if (h + 1 < H && ba[h + 1][w] != wall) { add(f, getid(h + 1, w)); } } } } void add(int fh, int fw, int th, int tw) { add(getid(fh, fw), getid(th, tw)); } void set_edges() { rep(i, n)fora(e, g[i])edges.pb(e); } }; //左上から右下に移動できる template<class T=int> class digrid_k6 : public digraph<T> { public: using digraph<T>::g; using digraph<T>::n; using digraph<T>::edges; using digraph<T>::_used; int H, W; int eid = 0; void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("digrid_k6 add"); deb(f, t, c, id, ty); ole(); } g[f].emplace_back(f, t, c, eid++, ty); } int getid(int h, int w) { if (!inside(h, w, H, W))return -1; return W * h + w; } P get2(int id) { return mp(id / W, id % W); } P operator()(int id) { return get2(id); } int operator()(int h, int w) { return getid(h, w); } digrid_k6(int H, int W) : H(H), W(W), digraph<T>(H * W) { rep(h, H) { rep(w, W) { int f = getid(h, w); if (w + 1 < W) add(f, getid(h, w + 1)); if (h + 1 < H)add(f, getid(h + 1, w)); } } } digrid_k6(_vvc ba, char wall = '#') : H(sz(ba)), W(sz(ba[0])), digraph<T>(sz(ba) * sz(ba[0])) { rep(h, H) { rep(w, W) { if (ba[h][w] == wall)con; int f = getid(h, w); if (w + 1 < W && ba[h][w + 1] != wall) { add(f, getid(h, w + 1)); } if (h + 1 < H && ba[h + 1][w] != wall) { add(f, getid(h + 1, w)); } } } } void add(int fh, int fw, int th, int tw) { add(getid(fh, fw), getid(th, tw)); } void set_edges() { rep(i, n)fora(e, g[i])edges.pb(e); } }; template<class T> bool nibu(const graph<T> &g) { int size = 0; rep(i, g.n)size += sz(g.g[i]); if (size == 0)return true; UnionFind uf(g.n * 2); rep(i, g.n)fora(e, g.g[i])uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t); rep(i, g.n)if (uf.same(i, i + g.n))return 0; return 1; } //二部グラフを色分けした際の頂点数を返す template<class T> vp nibug(graph<T> &g) { vp cg; if (!nibu(g)) { debugline("nibu"); ole(); } int _n = g.size(); vb _was(_n); queue<P> q; rep(i, _n) { if (_was[i])continue; q.push(mp(i, 1)); _was[i] = 1; int red = 0; int coun = 0; while (q.size()) { int now = q.front().fi; int col = q.front().se; red += col; coun++; q.pop(); forg(gi, g[now]) { if (_was[t])continue; q.push(mp(t, col ^ 1)); _was[t] = 1; } } cg.push_back(mp(red, coun - red)); } return cg; } template<class T> ostream &operator<<(ostream &os, graph<T> &g) { rep(i, sz(g)) { forg(gi, g[i]) { os << f << " " << t << " " << c << endl; } } return os; } //機能拡張 vp vtop(vi &a, vi &b) { vp res(sz(a)); rep(i, sz(a))res[i] = mp(a[i], b[i]); return res; } void ptov(vp &p, vi &a, vi &b) { a.resize(sz(p)); b.resize(sz(p)); rep(i, sz(p))a[i] = p[i].fi, b[i] = p[i].se; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(to_string(__rv)); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) { __lhs += to_string(__rv); } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(to_string(__rv)); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) { __lhs += to_string(__rv); } template<class T, class U> void operator+=(queue<T> &a, U v) { a.push(v); } template<class T, class U> void operator+=(deque<T> &a, U v) { a.push_back(v); } template<class T, class U> priority_queue<T, vector<T>, greater<T> > &operator+=(priority_queue<T, vector<T>, greater<T> > &a, U v) { a.push(v); return a; } template<class T, class U> priority_queue<T> &operator+=(priority_queue<T> &a, U v) { a.push(v); return a; } template<class T, class U> set<T> &operator+=(set<T> &a, U v) { a.insert(v); return a; } template<class T, class U> set<T, greater<T>> &operator+=(set<T, greater<T>> &a, U v) { a.insert(v); return a; } template<class T, class U> vector<T> &operator+=(vector<T> &a, U v) { a.pb(v); return a; } template<class T, class U> vector<T> operator+(const vector <T> &a, U v) { vector<T> ret = a; ret += v; return ret; } template<class T, class U> vector<T> operator+(U v, const vector <T> &a) { vector<T> ret = a; ret.insert(ret.begin(), v); return ret; } template<class T> vector<T> operator+(vector<T> &a, vector <T> &b) { vector<T> ret; ret = a; fora(v, b)ret += v; return ret; } template<class T> vector<T> &operator+=(vector<T> &a, vector <T> &b) { fora(v, b)a += v; return a; } template<class T, class U> vector<T> &operator+=(vector<T> &a, initializer_list<U> v) { for (auto &&va :v)a.pb(va); return a; } template<class T> vector<T> &operator-=(vector<T> &a, vector <T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-="); deb(a); deb(b); ole(); } rep(i, sz(a))a[i] -= b[i]; return a; } template<class T> vector<T> operator-(vector<T> &a, vector <T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-"); deb(a); deb(b); ole(); } vector<T> res(sz(a)); rep(i, sz(a))res[i] = a[i] - b[i]; return res; } template<typename T> void remove(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template<typename T> void remove(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template<typename T> void removen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template<typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template<typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template<typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, U t) { v.insert(v.begin() + i, t); } template<typename T, typename U> void push_front(vector<T> &v, U t) { v.insert(v.begin(), t); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, vector<T> list) { for (auto &&va :list)v.insert(v.begin() + i++, va); } template<typename T, typename U> void insert(vector<T> &v, initializer_list<U> list) { for (auto &&va :list)v.pb(va); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, initializer_list<U> list) { for (auto &&va :list)v.insert(v.begin() + i++, va); } template<typename T> void insert(set<T> &v, vector<T> list) { for (auto &&va :list)v.insert(va); } template<typename T> void insert(set<T> &v, initializer_list<T> list) { for (auto &&va :list)v.insert(va); } //閉路がなければtrue bool topo(vi &res, digraph<int> &g) { int n = g.g.size(); vi nyu(n); rep(i, n)for (auto &&e :g[i])nyu[e.t]++; queue<int> st; rep(i, n)if (nyu[i] == 0)st.push(i); while (st.size()) { int v = st.front(); st.pop(); res.pb(v); fora(e, g[v]) if (--nyu[e.t] == 0)st.push(e.t); } return res.size() == n; } //辞書順最小トポロジカルソート bool topos(vi &res, digraph<int> &g) { int n = g.g.size(); vi nyu(n); rep(i, n)for (auto &&e :g[i])nyu[e.t]++; //小さい順 priority_queue<int, vector<int>, greater<int> > q; rep(i, n)if (nyu[i] == 0)q.push(i); while (q.size()) { int i = q.top(); q.pop(); res.pb(i); fora(e, g[i])if (--nyu[e.t] == 0)q.push(e.t); } return res.size() == n; } vector<string> split(const string a, const char deli) { string b = a + deli; int l = 0, r = 0, n = b.size(); vector<string> res; rep(i, n) { if (b[i] == deli) { r = i; if (l < r)res.push_back(b.substr(l, r - l)); l = i + 1; } } return res; } vector<string> split(const string a, const string deli) { string b = a + deli; int l = 0, r = 0, n = b.size(), dn = deli.size(); vector<string> res; rep(i, n) { if (i + dn <= n && b.substr(i, i + dn) == deli) { r = i; if (l < r)res.push_back(b.substr(l, r - l)); i += dn - 1; l = i + 1; } } return res; } void yn(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; } void Yn(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; } void YN(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; } void fyn(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; exit(0); } void fYn(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; exit(0); } void fYN(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; exit(0); } void Possible(bool a) { if (a)cout << "Possible" << endl; else cout << "Impossible" << endl; exit(0); } int n, m, k, d, H, W, x, y, z, q; int cou; vi a, b, c; //vvi (s, 0, 0); vvc (ba, 0, 0); vp p; str s; void solve() { in(n); na(a,n); int res=1; int up=0,dn=0; rep(i,1,n){ if(a[i-1] < a[i])up=1; if(a[i-1] > a[i])dn=1; if(up&&dn){ up=0; dn=0; res++; } } std::cout << res << std::endl; } int my(int n, vi &a) { return 0; } int sister(int n, vi &a) { int ret = 0; return ret; } signed main() { solve(); #define _arg n,a #ifdef _DEBUG bool bad = 0; for (int i = 0, ok = 1; i < k5 && ok; i++) { int n = rand(1, 8); vi a = ranv(n, 1, 10); int myres = my(_arg); int res = sister(_arg); ok = myres == res; if (!ok) { outl(_arg); cerr << "正解 : " << res << endl; cerr << "自分 : " << myres << endl; bad = 1; break; } } if (!bad) { // cout << "完璧 : solveを書き直そう" << endl; // cout << " : そして、solve()を呼び出すのだ" << endl; // cout << " : cin>>n; na(a,n);も忘れるな" << endl; } #endif return 0; }; //todo 文字数を少なくする //mintより高速に計算したい時用に modmul() modadd (正の値限定) を作る //#pragma GCC optimize ("-O3") #include <bits/stdc++.h> using namespace std; //@起動時 struct initon { initon() { cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(16); srand((unsigned) clock() + (unsigned) time(NULL)); }; } __initon; //衝突対策 #define ws ___ws //@必須構造 struct T { int f, s, t; T() { f = -1, s = -1, t = -1; } T(int f, int s, int t) : f(f), s(s), t(t) {} bool operator<(const T &r) const { return f != r.f ? f < r.f : s != r.s ? s < r.s : t < r.t; //return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 大きい順 } bool operator>(const T &r) const { return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; //return f != r.f ? f > r.f : s != r.s ? s > r.s : t > r.t; 小さい順 } bool operator==(const T &r) const { return f == r.f && s == r.s && t == r.t; } bool operator!=(const T &r) const { return f != r.f || s != r.s || t != r.t; } int operator[](int i) { assert(i < 3); return i == 0 ? f : i == 1 ? s : t; } }; struct F { int a, b, c, d; F() { a = -1, b = -1, c = -1, d = -1; } F(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {} bool operator<(const F &r) const { return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; // return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; } bool operator>(const F &r) const { return a != r.a ? a > r.a : b != r.b ? b > r.b : c != r.c ? c > r.c : d > r.d; // return a != r.a ? a < r.a : b != r.b ? b < r.b : c != r.c ? c < r.c : d < r.d; } bool operator==(const F &r) const { return a == r.a && b == r.b && c == r.c && d == r.d; } bool operator!=(const F &r) const { return a != r.a || b != r.b || c != r.c || d != r.d; } int operator[](int i) { assert(i < 4); return i == 0 ? a : i == 1 ? b : i == 2 ? c : d; } }; T mt(int a, int b, int c) { return T(a, b, c); } //@マクロ省略系 型,構造 #define int long long #define ll long long #define double long double #define ull unsigned long long using dou = double; using itn = int; using str = string; using bo= bool; #define au auto using P = pair<ll, ll>; using pd =pair<dou, dou>; #define fi first #define se second #define vec vector #define beg begin #define rbeg rbegin #define con continue #define bre break #define brk break #define is == #define maxq 1 #define minq -1 #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MALLOC(type, len) (type*)malloc((len) * sizeof(type)) //マクロ省略系 コンテナ using vi = vector<int>; #define _overloadvvi(_1, _2, _3, _4, name, ...) name #define vvi0() vec<vi> #define vvi1(a) vec<vi> a #define vvi2(a, b) vec<vi> a(b) #define vvi3(a, b, c) vec<vi> a(b,vi(c)) #define vvi4(a, b, c, d) vec<vi> a(b,vi(c,d)) #define vvi(...) _overloadvvi(__VA_ARGS__,vvi4,vvi3,vvi2 ,vvi1,vvi0)(__VA_ARGS__) using vl = vector<ll>; #define _overloadvvl(_1, _2, _3, _4, name, ...) name #define vvl1(a) vec<vl> a #define vvl2(a, b) vec<vl> a(b) #define vvl3(a, b, c) vec<vl> a(b,vl(c)) #define vvl4(a, b, c, d) vec<vl> a(b,vl(c,d)) #define vvl(...) _overloadvvl(__VA_ARGS__,vvl4,vvl3,vvl2 ,vvl1)(__VA_ARGS__) using vb = vector<bool>; #define _overloadvvb(_1, _2, _3, _4, name, ...) name #define vvb1(a) vec<vb> a #define vvb2(a, b) vec<vb> a(b) #define vvb3(a, b, c) vec<vb> a(b,vb(c)) #define vvb4(a, b, c, d) vec<vb> a(b,vb(c,d)) #define vvb(...) _overloadvvb(__VA_ARGS__,vvb4,vvb3,vvb2 ,vvb1)(__VA_ARGS__) using vs = vector<string>; #define _overloadvvs(_1, _2, _3, _4, name, ...) name #define vvs1(a) vec<vs> a #define vvs2(a, b) vec<vs> a(b) #define vvs3(a, b, c) vec<vs> a(b,vs(c)) #define vvs4(a, b, c, d) vec<vs> a(b,vs(c,d)) #define vvs(...) _overloadvvs(__VA_ARGS__,vvs4,vvs3,vvs2 ,vvs1)(__VA_ARGS__) using vd = vector<double>; #define _overloadvvd(_1, _2, _3, _4, name, ...) name #define vvd1(a) vec<vd> a #define vvd2(a, b) vec<vd> a(b) #define vvd3(a, b, c) vec<vd> a(b,vd(c)) #define vvd4(a, b, c, d) vec<vd> a(b,vd(c,d)) #define vvd(...) _overloadvvd(__VA_ARGS__,vvd4,vvd3,vvd2 ,vvd1)(__VA_ARGS__) using vc=vector<char>; #define _overloadvvc(_1, _2, _3, _4, name, ...) name #define vvc1(a) vec<vc> a #define vvc2(a, b) vec<vc> a(b) #define vvc3(a, b, c) vec<vc> a(b,vc(c)) #define vvc4(a, b, c, d) vec<vc> a(b,vc(c,d)) #define vvc(...) _overloadvvc(__VA_ARGS__,vvc4,vvc3,vvc2 ,vvc1)(__VA_ARGS__) using vp = vector<P>; #define _overloadvvp(_1, _2, _3, _4, name, ...) name #define vvp1(a) vec<vp> a #define vvp2(a, b) vec<vp> a(b) #define vvp3(a, b, c) vec<vp> a(b,vp(c)) #define vvp4(a, b, c, d) vec<vp> a(b,vp(c,d)) #define vvp(...) _overloadvvp(__VA_ARGS__,vvp4,vvp3,vvp2 ,vvp1)(__VA_ARGS__) using vt = vector<T>; #define _overloadvvt(_1, _2, _3, _4, name, ...) name #define vvt1(a) vec<vt> a #define vvt2(a, b) vec<vt> a(b) #define vvt3(a, b, c) vec<vt> a(b,vt(c)) #define vvt4(a, b, c, d) vec<vt> a(b,vt(c,d)) #define vvt(...) _overloadvvt(__VA_ARGS__,vvt4,vvt3,vvt2 ,vvt1)(__VA_ARGS__) #define v3i(a, b, c, d) vector<vector<vi>> a(b, vector<vi>(c, vi(d))) #define v3d(a, b, c, d) vector<vector<vd>> a(b, vector<vd>(c, vd(d))) #define v3m(a, b, c, d) vector<vector<vm>> a(b, vector<vm>(c, vm(d))) #define _vvi vector<vi> #define _vvl vector<vl> #define _vvb vector<vb> #define _vvs vector<vs> #define _vvd vector<vd> #define _vvc vector<vc> #define _vvp vector<vp> template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); } template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); } #define vni(name, ...) auto name = make_v<int>(__VA_ARGS__) #define vnb(name, ...) auto name = make_v<bool>(__VA_ARGS__) #define vns(name, ...) auto name = make_v<string>(__VA_ARGS__) #define vnd(name, ...) auto name = make_v<double>(__VA_ARGS__) #define vnc(name, ...) auto name = make_v<char>(__VA_ARGS__) #define vnp(name, ...) auto name = make_v<P>(__VA_ARGS__) #define PQ priority_queue<ll, vector<ll>, greater<ll> > #define tos to_string using mapi = map<int, int>; using mapp = map<P, int>; using mapd = map<dou, int>; using mapc = map<char, int>; using maps = map<str, int>; using seti = set<int>; using setd = set<dou>; using setc = set<char>; using sets = set<str>; using qui = queue<int>; #define bset bitset #define uset unordered_set #define mset multiset #define umap unordered_map #define umapi unordered_map<int,int> #define umapp unordered_map<P,int> #define mmap multimap //マクロ 繰り返し #define _overloadrep(_1, _2, _3, _4, name, ...) name # define _rep(i, n) for(int i = 0,_lim=n; i < _lim ; i++) #define repi(i, m, n) for(int i = m,_lim=n; i < _lim ; i++) #define repadd(i, m, n, ad) for(int i = m,_lim=n; i < _lim ; i+= ad) #define rep(...) _overloadrep(__VA_ARGS__,repadd,repi,_rep,)(__VA_ARGS__) #define _rer(i, n) for(int i = n; i >= 0 ; i--) #define reri(i, m, n) for(int i = m,_lim=n; i >= _lim ; i--) #define rerdec(i, m, n, dec) for(int i = m,_lim=n; i >= _lim ; i-=dec) #define rer(...) _overloadrep(__VA_ARGS__,rerdec,reri,_rer,)(__VA_ARGS__) #define fora(a, b) for(auto&& a : b) #define forg(gi, ve) for (int gi = 0, f, t, c; gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); gi++) #define fort(gi, ve) for (int gi = 0, f, t, c; gi < ve.size() && (f = ve[gi].f, t = ve[gi].t, c = ve[gi].c, true); gi++)if(t!=p) //#define fort(gi, ve) for (int gi = 0, f, t, c;gi<ve.size()&& (gi+= (ve[gi].t==p))< ve.size() && (f = ve[gi].f,t=ve[gi].t, c = ve[gi].c,true); gi++) //マクロ 定数 #define k3 1010 #define k4 10101 #define k5 101010 #define k6 1010101 #define k7 10101010 const int inf = (int) 1e9 + 100; const ll linf = (ll) 1e18 + 100; const char infc = '{'; const string infs = "{"; const double eps = 1e-9; const double PI = 3.1415926535897932384626433832795029L; ll ma = numeric_limits<ll>::min(); ll mi = numeric_limits<ll>::max(); const int y4[] = {-1, 1, 0, 0}; const int x4[] = {0, 0, -1, 1}; const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; //マクロ省略形 関数等 #define arsz(a) (sizeof(a)/sizeof(a[0])) #define sz(a) ((int)(a).size()) //#define rs resize #define mp make_pair #define pb push_back #define pf push_front #define eb emplace_back #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() constexpr bool ev(int a) { return !(a & 1); } constexpr bool od(int a) { return (a & 1); } //@拡張系 こう出来るべきというもの //埋め込み 存在を意識せずに機能を増やされているもの namespace std { template<> class hash<std::pair<signed, signed>> { public: size_t operator()(const std::pair<signed, signed> &x) const { return hash<ll>()(((ll) x.first << 32) + x.second); } }; template<> class hash<std::pair<ll, ll>> { public: //大きいllが渡されると、<<32でオーバーフローするがとりあえず問題ないと判断 size_t operator()(const std::pair<ll, ll> &x) const { return hash<ll>()(((ll) x.first << 32) + x.second); } }; } istream &operator>>(istream &iss, P &a) { iss >> a.first >> a.second; return iss; } template<typename T> istream &operator>>(istream &iss, vector<T> &vec) { for (T &x: vec) iss >> x; return iss; } template<class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { os << p.fi << " " << p.se << endl; return os; } ostream &operator<<(ostream &os, T p) { os << p.f << " " << p.s << " " << p.t; return os; } ostream &operator<<(ostream &os, F p) { os << p.a << " " << p.b << " " << p.c << " " << p.d; return os; } template<typename T> ostream &operator<<(ostream &os, vector <T> &vec) { for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " "); return os; } template<typename T> ostream &operator<<(ostream &os, vector <vector<T>> &vec) { for (int i = 0; i < vec.size(); i++) { for (int j = 0; j < vec[0].size(); j++) { os << vec[i][j]; } os << endl; } return os; } template<typename V, typename H> void resize(vector<V> &vec, const H head) { vec.resize(head); } template<typename V, typename H, typename ... T> void resize(vector<V> &vec, const H &head, const T ... tail) { vec.resize(head); for (auto &v: vec) resize(v, tail...); } template<typename T, typename _Pr> bool all_of(const vector<T> &vec, _Pr pred) { return std::all_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> bool any_of(const vector<T> &vec, _Pr pred) { return std::any_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> bool none_of(const vector<T> &vec, _Pr pred) { return std::none_of(vec.begin(), vec.end(), pred); } template<typename T, typename _Pr> const typename vector<T>::const_iterator find_if(const vector<T> &vec, _Pr pred) { return std::find_if(vec.begin(), vec.end(), pred); } template<typename T> bool contains(const vector<T> &vec, const T &val) { return std::find(vec.begin(), vec.end(), val) != vec.end(); } template<typename T, typename _Pr> bool contains_if(const vector<T> &vec, _Pr pred) { return std::find_if(vec.begin(), vec.end(), pred) != vec.end(); } template<class T, class U> void replace(vector<T> &a, T key, U v) { replace(a.begin(), a.end(), key, v); } template<class T> void replace(str &a, T key, T v) { a.replace(all(a), key, v); } //keyと同じかどうか01で置き換える template<class T, class U> void replace(T &a, U k) { rep(i, sz(a)) a[i] = a[i] == k; } template<class T, class U> void replace(T &a) { replace(a, '#'); } template<class T> bool includes(vector<T> &a, vector<T> &b) { vi c = a; vi d = b; sort(all(c)); sort(all(d)); return includes(all(c), all(d)); } template<class T> bool is_permutation(vector<T> &a, vector<T> &b) { return is_permutation(all(a), all(b)); } template<class T> bool next_permutation(vector<T> &a) { return next_permutation(all(a)); } template<class T> T pop(set<T> &set) { T res = *set.begin(); set.erase(set.find(res)); return res; } template<class T> T pop(mset<T> &set) { T res = *set.begin(); set.erase(set.find(res)); return res; } template<class T> T popBack(set<T> &set) { T res = *set.rbegin(); set.erase(set.find(res)); return res; } template<class T> T popBack(mset<T> &set) { T res = *set.rbegin(); set.erase(set.find(res)); return res; } inline void sort(string &a) { sort(a.begin(), a.end()); } template<class T> inline void sort(vector<T> &a) { sort(a.begin(), a.end()); } template<class T> inline void sort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len); } template<class T, class F> inline void sort(vector<T> &a, F f) { sort(a.begin(), a.end(), [&](T a, T b) { return f(a) < f(b); }); } enum ___pcomparator { fisi, fisd, fdsi, fdsd, sifi, sifd, sdfi, sdfd }; inline void sort(vector<P> &a, ___pcomparator type) { switch (type) { case fisi: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi < r.fi : l.se < r.se; }); break; case fisd: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi < r.fi : l.se > r.se; }); break; case fdsi: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi > r.fi : l.se < r.se; }); break; case fdsd: sort(all(a), [&](P l, P r) { return l.fi != r.fi ? l.fi > r.fi : l.se > r.se; }); break; case sifi: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se < r.se : l.fi < r.fi; }); break; case sifd: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se < r.se : l.fi > r.fi; }); break; case sdfi: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se > r.se : l.fi < r.fi; }); break; case sdfd: sort(all(a), [&](P l, P r) { return l.se != r.se ? l.se > r.se : l.fi > r.fi; }); break; } }; inline void sort(vector<T> &a, ___pcomparator type) { switch (type) { case fisi: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f < r.f : l.s < r.s; }); break; case fisd: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f < r.f : l.s > r.s; }); break; case fdsi: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f > r.f : l.s < r.s; }); break; case fdsd: sort(all(a), [&](T l, T r) { return l.f != r.f ? l.f > r.f : l.s > r.s; }); break; case sifi: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s < r.s : l.f < r.f; }); break; case sifd: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s < r.s : l.f > r.f; }); break; case sdfi: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s > r.s : l.f < r.f; }); break; case sdfd: sort(all(a), [&](T l, T r) { return l.s != r.s ? l.s > r.s : l.f > r.f; }); break; } }; template<class T> inline void rsort(vector<T> &a) { sort(a.begin(), a.end(), greater<T>()); }; template<class T> inline void rsort(vector<T> &a, int len) { sort(a.begin(), a.begin() + len, greater<T>()); }; template<class U, class F> inline void rsort(vector<U> &a, F f) { sort(a.begin(), a.end(), [&](U l, U r) { return f(l) > f(r); }); }; template<class U> inline void sortp(vector<U> &a, vector<U> &b) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second;; } }; //F = T<T> //例えばreturn p.fi + p.se; template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, F f) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c, f); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U, class F> inline void sortp(vector<U> &a, vector<U> &b, char type) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); sort(c, type); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U> inline void rsortp(vector<U> &a, vector<U> &b) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); rsort(c); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U, class F> inline void rsortp(vector<U> &a, vector<U> &b, F f) { vp c; int n = sz(a); assert(n == sz(b)); rep(i, n)c.eb(a[i], b[i]); rsort(c, f); rep(i, n) { a[i] = c[i].first; b[i] = c[i].second; } }; template<class U> inline void sortt(vector<U> &a, vector<U> &b, vector<U> &c) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); sort(r); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; template<class U, class F> inline void sortt(vector<U> &a, vector<U> &b, vector<U> &c, F f) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); sort(r, f); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; template<class U, class F> inline void rsortt(vector<U> &a, vector<U> &b, vector<U> &c, F f) { vt r; int n = sz(a); assert(n == sz(b)); assert(n == sz(c)); rep(i, n)r.eb(a[i], b[i], c[i]); rsort(r, f); rep(i, n) { a[i] = r[i].f; b[i] = r[i].s; c[i] = r[i].t; } }; //indexをつけてsortする (second) template<class T> auto sorti(vector<T> &a) { int n = sz(a); vp ret(n); rep(i, n)ret[i] = P(a[i], i); sort(ret); return ret; }; template<class T> auto rsorti(vector<T> &a) { int n = sz(a); vp ret(n); rep(i, n)ret[i] = P(a[i], i); rsort(ret); return ret; }; template<class T> inline void sort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)sort(a[i]); } template<class T> inline void rsort2(vector<vector<T>> &a) { for (int i = 0, n = a.size(); i < n; i++)rsort(a[i]); } template<typename A, size_t N, typename T> inline void fill(A (&a)[N], const T &v) { rep(i, N)a[i] = v; } template<typename A, size_t N, size_t O, typename T> inline void fill(A (&a)[N][O], const T &v) { rep(i, N)rep(j, O)a[i][j] = v; } template<typename A, size_t N, size_t O, size_t P, typename T> inline void fill(A (&a)[N][O][P], const T &v) { rep(i, N)rep(j, O)rep(k, P)a[i][j][k] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, typename T> inline void fill(A (&a)[N][O][P][Q], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)a[i][j][k][l] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, typename T> inline void fill(A (&a)[N][O][P][Q][R], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)a[i][j][k][l][m] = v; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S, typename T> inline void fill(A (&a)[N][O][P][Q][R][S], const T &v) { rep(i, N)rep(j, O)rep(k, P)rep(l, Q)rep(m, R)rep(n, S)a[i][j][k][l][m][n] = v; } template<typename V, typename T> void fill(V &xx, const T vall) { xx = vall; } template<typename V, typename T> void fill(vector<V> &vecc, const T vall) { for (auto &&vx: vecc) fill(vx, vall); } //@汎用便利関数 入力 inline int in() { int ret; // scanf("%lld", &ret); cin >> ret; return ret; } inline string sin() { string ret; cin >> ret; return ret; } template<class T> inline void in(T &head) { cin >> head; } template<class T, class... U> inline void in(T &head, U &... tail) { cin >> head; in(tail...); } #define _overloaddin(_1, _2, _3, _4, name, ...) name #define din1(a) int a;cin>>a #define din2(a, b) int a,b;cin>>a>> b #define din3(a, b, c) int a,b,c;cin>>a>>b>>c #define din4(a, b, c, d) int a,b,c,d;cin>>a>>b>>c>>d #define din(...) _overloaddin(__VA_ARGS__,din4,din3,din2 ,din1)(__VA_ARGS__) #define _overloaddind(_1, _2, _3, _4, name, ...) name #define din1d(a) din1(a);a-- #define din2d(a, b) din2(a,b);a--,b-- #define din3d(a, b, c) din3(a,b,c);a--,b--,c-- #define din4d(a, b, c, d) din4(a,b,c,d);a--,b--,c--,d-- #define dind(...) _overloaddind(__VA_ARGS__,din4d,din3d,din2d ,din1d)(__VA_ARGS__) #define _overloadout(_1, _2, _3, _4, name, ...) name #define out1(a) cout<<a<<endl #define out2(a, b) cout<<a<<" "<< b<<endl #define out3(a, b, c) cout<<a<<" "<<b<<" "<<c<<endl #define out4(a, b, c, d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<endl #define out(...) _overloadout(__VA_ARGS__,out4,out3,out2,out1)(__VA_ARGS__) #define _overloadoutl(_1, _2, _3, _4, name, ...) name #define outl1(a) cout<<a<<endl #define outl2(a, b) cout<<a<<endl<<b<<endl #define outl3(a, b, c) cout<<a<<endl<<b<<endl<<c<<endl #define outl4(a, b, c, d) cout<<a<<endl<<b<<endl<<c<<endl<<d<<endl #define outl(...) _overloadout(__VA_ARGS__,outl4,outl3,outl2,outl1)(__VA_ARGS__) #define na(a, n) a.resize(n); rep(_i,n) cin >> a[_i]; #define nao(a, n) a.resize(n+1); rep(_i,n) cin >> a[_i+1]; #define nad(a, n) a.resize(n); rep(_i,n){ cin >> a[_i]; a[_i]--;} #define na2(a, b, n) a.resize(n),b.resize(n);rep(_i, n)cin >> a[_i] >> b[_i]; #define nao2(a, b, n) a.resize(n+1),b.resize(n+1);rep(_i, n)cin >> a[_i+1] >> b[_i+1]; #define na2d(a, b, n) a.resize(n),b.resize(n);rep(_i, n){cin >> a[_i] >> b[_i];a[_i]--,b[_i]--;} #define na3(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(_i, n)cin >> a[_i] >> b[_i] >> c[_i]; #define na3d(a, b, c, n) a.resize(n),b.resize(n),c.resize(n); rep(_i, n){cin >> a[_i] >> b[_i] >> c[_i];a[_i]--,b[_i]--,c[_i]--;} #define nt(a, h, w) resize(a,h,w);rep(_hi,h)rep(_wi,w) cin >> a[_hi][_wi]; #define ntd(a, h, w) rs(a,h,w);rep(_hi,h)rep(_wi,w) cin >> a[_hi][_wi], a[_hi][_wi]--; #define ntp(a, h, w) fill(a,'#');rep(_hi,1,h+1)rep(_wi,1,w+1) cin >> a[_hi][_wi]; //デバッグ #define sp << " " << #define debugName(VariableName) # VariableName #define _deb1(x) debugName(x)<<" = "<<x #define _deb2(x, ...) _deb1(x) <<", "<< _deb1(__VA_ARGS__) #define _deb3(x, ...) _deb1(x) <<", "<< _deb2(__VA_ARGS__) #define _deb4(x, ...) _deb1(x) <<", "<< _deb3(__VA_ARGS__) #define _deb5(x, ...) _deb1(x) <<", "<< _deb4(__VA_ARGS__) #define _deb6(x, ...) _deb1(x) <<", "<< _deb5(__VA_ARGS__) #define _deb7(x, ...) _deb1(x) <<", "<< _deb6(__VA_ARGS__) #define _deb8(x, ...) _deb1(x) <<", "<< _deb7(__VA_ARGS__) #define _deb9(x, ...) _deb1(x) <<", "<< _deb8(__VA_ARGS__) #define _deb10(x, ...) _deb1(x) <<", "<< _deb9(__VA_ARGS__) #define _overloadebug(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, name, ...) name #ifdef _DEBUG #define deb(...) cerr<< _overloadebug(__VA_ARGS__,_deb10,_deb9,_deb8,_deb7,_deb6,_deb5,_deb4,_deb3,_deb2,_deb1)(__VA_ARGS__) <<endl #else #define deb(...) ; #endif #define debugline(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n' //よく使うクラス、構造体 class UnionFind { public: vi par, rank, sizes; int n, trees; UnionFind(int n) : n(n), trees(n) { par.resize(n), rank.resize(n), sizes.resize(n); rep(i, n)par[i] = i, sizes[i] = 1; } int root(int x) { if (par[x] == x)return x; else return par[x] = root(par[x]); } int find(int x) { return root(x); } void unite(int x, int y) { x = root(x); y = root(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); trees--; par[y] = x; sizes[x] += sizes[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return sizes[root(x)]; } //順不同 umapなので vec<vi> sets() { vec<vi> res(trees); umap<int, vi> map; rep(i, n) map[root(i)].push_back(i); int i = 0; for (auto &&p:map) { int r = p.fi; res[i].push_back(r); for (auto &&v:p.se) { if (r == v)continue; res[i].push_back(v); } i++; } return res; } }; using bint =__int128; using u32 = unsigned int; using u64 = unsigned long long; using u128 = __uint128_t; std::ostream &operator<<(std::ostream &dest, __int128_t value) { std::ostream::sentry s(dest); if (s) { __uint128_t tmp = value < 0 ? -value : value; char buffer[128]; char *d = std::end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = std::end(buffer) - d; if (dest.rdbuf()->sputn(d, len) != len) { dest.setstate(std::ios_base::badbit); } } return dest; } __int128 toi128(string &s) { __int128 ret = 0; for (int i = 0; i < s.length(); i++) if ('0' <= s[i] && s[i] <= '9') ret = 10 * ret + s[i] - '0'; return ret; } template<typename T> T minv(T a, T m); template<typename T> T minv(T a); template<typename T> class Modular { public: using Type = typename decay<decltype(T::value)>::type; constexpr Modular() : value() {} template<typename U> Modular(const U &x) { value = normalize(x); } template<typename U> static Type normalize(const U &x) { Type v; if (-mod() <= x && x < mod()) v = static_cast<Type>(x); else v = static_cast<Type>(x % mod()); if (v < 0) v += mod(); return v; } const Type &operator()() const { return value; } template<typename U> explicit operator U() const { return static_cast<U>(value); } constexpr static Type mod() { return T::value; } Modular &operator+=(const Modular &other) { if ((value += other.value) >= mod()) value -= mod(); return *this; } Modular &operator-=(const Modular &other) { if ((value -= other.value) < 0) value += mod(); return *this; } template<typename U> Modular &operator+=(const U &other) { return *this += Modular(other); } template<typename U> Modular &operator-=(const U &other) { return *this -= Modular(other); } Modular &operator++() { return *this += 1; } Modular &operator--() { return *this -= 1; } Modular operator++(signed) { Modular result(*this); *this += 1; return result; } Modular operator--(signed) { Modular result(*this); *this -= 1; return result; } Modular operator-() const { return Modular(-value); } template<typename U = T> typename enable_if<is_same<typename Modular<U>::Type, signed>::value, Modular>::type &operator*=(const Modular &rhs) { #ifdef _WIN32 uint64_t x = static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value); uint32_t xh = static_cast<uint32_t>(x >> 32), xl = static_cast<uint32_t>(x), d, m; asm( "divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod()) ); value = m; #else value = normalize(static_cast<int64_t>(value) * static_cast<int64_t>(rhs.value)); #endif return *this; } template<typename U = T> typename enable_if<is_same<typename Modular<U>::Type, int64_t>::value, Modular>::type &operator*=(const Modular &rhs) { int64_t q = static_cast<int64_t>(static_cast<double>(value) * rhs.value / mod()); value = normalize(value * rhs.value - q * mod()); return *this; } template<typename U = T> typename enable_if<!is_integral<typename Modular<U>::Type>::value, Modular>::type &operator*=(const Modular &rhs) { value = normalize(value * rhs.value); return *this; } Modular &operator/=(const Modular &other) { return *this *= Modular(minv(other.value)); } template<typename U> friend bool operator==(const Modular<U> &lhs, const Modular<U> &rhs); template<typename U> friend bool operator<(const Modular<U> &lhs, const Modular<U> &rhs); template<typename U> friend std::istream &operator>>(std::istream &stream, Modular<U> &number); operator int() { return normalize(value); } private: Type value; }; template<typename T> bool operator==(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value == rhs.value; } template<typename T, typename U> bool operator==(const Modular<T> &lhs, U rhs) { return lhs == Modular<T>(rhs); } template<typename T, typename U> bool operator==(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) == rhs; } template<typename T> bool operator!=(const Modular<T> &lhs, const Modular<T> &rhs) { return !(lhs == rhs); } template<typename T, typename U> bool operator!=(const Modular<T> &lhs, U rhs) { return !(lhs == rhs); } template<typename T, typename U> bool operator!=(U lhs, const Modular<T> &rhs) { return !(lhs == rhs); } template<typename T> bool operator<(const Modular<T> &lhs, const Modular<T> &rhs) { return lhs.value < rhs.value; } template<typename T> Modular<T> operator+(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; } template<typename T, typename U> Modular<T> operator+(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) += rhs; } template<typename T, typename U> Modular<T> operator+(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) += rhs; } template<typename T> Modular<T> operator-(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; } template<typename T, typename U> Modular<T> operator-(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) -= rhs; } template<typename T, typename U> Modular<T> operator-(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) -= rhs; } template<typename T> Modular<T> operator*(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; } template<typename T, typename U> Modular<T> operator*(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) *= rhs; } template<typename T, typename U> Modular<T> operator*(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) *= rhs; } template<typename T> Modular<T> operator/(const Modular<T> &lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; } template<typename T, typename U> Modular<T> operator/(const Modular<T> &lhs, U rhs) { return Modular<T>(lhs) /= rhs; } template<typename T, typename U> Modular<T> operator/(U lhs, const Modular<T> &rhs) { return Modular<T>(lhs) /= rhs; } constexpr signed MOD = 1e9 + 7;//MOD using mint = Modular<std::integral_constant<decay<decltype(MOD)>::type, MOD>>; constexpr int mint_len = 1400001; vi fac, finv, inv, p2; void setmod() { fac.resize(mint_len); finv.resize(mint_len); inv.resize(mint_len); p2.resize(mint_len); inv[1] = fac[0] = finv[0] = p2[0] = 1; for (int i = 2; i < mint_len; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i < mint_len; ++i) fac[i] = fac[i - 1] * i % MOD, finv[i] = finv[i - 1] * inv[i] % MOD, p2[i] = p2[i - 1] * 2 % MOD; } #define smod setmod inline mint com(int n, int r) { if (r < 0 || r > n) return 0; return mint(finv[r] * fac[n] % MOD * finv[n - r]); } inline mint pom(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return mint(fac[n] * finv[n - 1]); } inline mint npr(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return mint(fac[n] * finv[n - r]); } inline int nprin(int n, int r) { // if (!sz(fac)) com(0, -1); if (r < 0 || r > n) return 0; return fac[n] * finv[n - r] % MOD; } inline int icom(int n, int r) { const int NUM_ = 1400001; static ll fac[NUM_ + 1], finv[NUM_ + 1], inv[NUM_ + 1]; if (fac[0] == 0) { inv[1] = fac[0] = finv[0] = 1; for (int i = 2; i <= NUM_; ++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD; for (int i = 1; i <= NUM_; ++i) fac[i] = fac[i - 1] * i % MOD, finv[i] = finv[i - 1] * inv[i] % MOD; } if (r < 0 || r > n) return 0; return ((finv[r] * fac[n] % MOD) * finv[n - r]) % MOD; } #define ncr com #define ncri icom inline mint nhr(int n, int r) { return com(n + r - 1, r); } inline mint hom(int n, int r) { return com(n + r - 1, r); } inline int nhri(int n, int r) { return icom(n + r - 1, r); } template<typename T> inline T minv(T a, T m) { T u = 0, v = 1; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; } template<typename T> inline T minv(T a) { if (a < mint_len)return inv[a]; T u = 0, v = 1; int m = MOD; while (a != 0) { T t = m / a; m -= t * a; swap(a, m); u -= t * v; swap(u, v); } assert(m == 1); return u; } template<typename T, typename U> inline Modular<T> mpow(const Modular<T> &a, const U &b) { assert(b >= 0); int x = a(), res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template<typename T, typename U, typename V> inline mint mpow(const T a, const U b, const V m = MOD) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= m; (x *= x) %= m; p >>= 1; } return res; } template<typename T, typename U> inline mint mpow(const T a, const U b) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= MOD; (x *= x) %= MOD; p >>= 1; } return res; } template<typename T, typename U, typename V> inline int mpowi(const T &a, const U &b, const V &m = MOD) { assert(b >= 0); int x = a, res = 1; U p = b; while (p > 0) { if (p & 1) (res *= x) %= m; (x *= x) %= m; p >>= 1; } return res; } template<typename T> inline string to_string(const Modular<T> &number) { return to_string(number()); } template<typename T> std::ostream &operator<<(std::ostream &stream, const Modular<T> &number) { return stream << number(); } template<typename T> std::istream &operator>>(std::istream &stream, Modular<T> &number) { typename common_type<typename Modular<T>::Type, int64_t>::type x; stream >> x; number.value = Modular<T>::normalize(x); return stream; } using PM = pair<mint, mint>; using vm = vector<mint>; using mapm = map<int, mint>; using umapm = umap<int, mint>; #define _overloadvvm(_1, _2, _3, _4, name, ...) name #define vnm(name, ...) auto name = make_v<mint>(__VA_ARGS__) #define vvm1(a) vec<vm> a #define vvm2(a, b) vec<vm> a(b) #define vvm3(a, b, c) vec<vm> a(b,vm(c)) #define vvm4(a, b, c, d) vec<vm> a(b,vm(c,d)) #define vvm(...) _overloadvvm(__VA_ARGS__,vvm4,vvm3,vvm2 ,vvm1)(__VA_ARGS__) //エラー void ole() { #ifdef _DEBUG debugline("ole"); exit(0); #endif string a = "a"; rep(i, 30)a += a; rep(i, 1 << 17)cout << a << endl; cout << "OLE 出力長制限超過" << endl; exit(0); } void tle() { while (inf)cout << inf << endl; } //便利関数 //テスト用 char ranc() { return (char) ('a' + rand() % 26); } int rand(int min, int max) { assert(min <= max); if (min >= 0 && max >= 0) { return rand() % (max + 1 - min) + min; } else if (max < 0) { return -rand(-max, -min); } else { //+ if (rand() % 2) { return rand(0, max); //- } else { return -rand(0, -min); } } } vi ranv(int n, int min, int max) { vi v(n); rep(i, n)v[i] = rand(min, max); return v; } //単調増加 vi ranvi(int n, int min, int max) { vi v(n); bool bad = 1; while (bad) { bad = 0; v.resize(n); rep(i, n) { if (i && min > max - v[i - 1]) { bad = 1; break; } if (i)v[i] = v[i - 1] + rand(min, max - v[i - 1]); else v[i] = rand(min, max); } } return v; } void ranvlr(int n, int min, int max, vi &l, vi &r) { l.resize(n); r.resize(n); rep(i, n) { l[i] = rand(min, max); r[i] = l[i] + rand(0, max - l[i]); } } //便利 汎用 vp run_length(vi &a) { vp ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } vector<pair<char, int>> run_length(string &a) { vector<pair<char, int>> ret; ret.eb(a[0], 1); rep(i, 1, sz(a)) { if (ret.back().fi == a[i]) { ret.back().se++; } else { ret.eb(a[i], 1); } } return ret; } template<class F> inline int mgr(int ok, int ng, F f) { #define _mgrbody int mid = (ok + ng) / 2; if (f(mid))ok = mid; else ng = mid; if (ok < ng)while (ng - ok > 1) { _mgrbody } else while (ok - ng > 1) { _mgrbody } return ok; } template<class F> inline int mgr(int ok, int ng, int second, F f) { #define _mgrbody2 int mid = (ok + ng) / 2; if (f(mid, second))ok = mid; else ng = mid; if (ok < ng) while (ng - ok > 1) { _mgrbody2 } else while (ok - ng > 1) { _mgrbody2 } return ok; } //strを整数として比較 string smax(str &a, str b) { if (sz(a) < sz(b)) { return b; } else if (sz(a) > sz(b)) { return a; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return b; } else if (a[i] > b[i])return a; } } return a; } //strを整数として比較 string smin(str &a, str b) { if (sz(a) < sz(b)) { return a; } else if (sz(a) > sz(b)) { return b; } else { rep(i, sz(a)) { if (a[i] < b[i]) { return a; } else if (a[i] > b[i])return b; } } return a; } template<typename V, typename T> int find(vector<V> &a, const T key) { rep(i, sz(a))if (a[i] == key)return i; return -1; } template<typename V, typename T> P find(vector<vector<V>> &a, const T key) { rep(i, sz(a)) rep(j, sz(a[0]))if (a[i][j] == key)return mp(i, j); return mp(-1, -1); } template<typename V, typename U> T find(vector<vector<vector<V>>> &a, const U key) { rep(i, sz(a))rep(j, sz(a[0]))rep(k, sz(a[0][0]))if (a[i][j][k] == key)return mt(i, j, k); return mt(-1, -1, -1); } template<typename V, typename T> int count(V &a, const T k) { return a == k; } template<typename V, typename T> int count(vector<V> &a, const T k) { int ret = 0; fora(v, a)ret += count(v, k); return ret; } template<typename T> int count(char &a, const T k) { return a == k; } template<typename T> int count(str &a, const T k) { int ret = 0; rep(i, sz(a))ret += count(a[i], k); return ret; } template<typename V> int count_odd(V &a) { return a % 2; } template<typename V> int count_odd(vector<V> &a) { int ret = 0; fora(v, a)ret += count_odd(v); return ret; } template<typename V> int count_even(V &a) { return a % 2 == 0; } template<typename V> int count_even(vector<V> &a) { int ret = 0; fora(v, a)ret += count_even(v); return ret; } //algorythm void iota(vector<int> &ve, int s, int n) { ve.resize(n); iota(all(ve), s); } vi iota(int s, int n) { vi ve(n); iota(all(ve), s); return ve; } inline ll rev(ll a) { ll res = 0; while (a) { res *= 10; res += a % 10; a /= 10; } return res; } template<class T> inline void rev(vector<T> &a) { reverse(all(a)); } void inline rev(string &a) { reverse(all(a)); } int get(int a, int keta) { return (a / (int) pow(10, keta)) % 10; } int keta(int v) { int cou = 0; while (v) { cou++, v %= 10; } return cou; } int dsum(int v) { int ret = 0; for (; v; v /= 10)ret += v % 10; return ret; } inline int sumd(int v) { return dsum(v); } //変換系 template<class T, class U> inline vector<T> keys(vector<pair<T, U>> a) { vector<T> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> inline vector<U> keys(map<T, U> a) { vector<U> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> inline vector<U> keys(umap<T, U> a) { vector<U> res; for (auto &&k :a)res.pb(k.fi); return res; } template<class T, class U> vector<U> inline values(vector<pair<T, U>> a) { vector<U> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline vector<T> values(map<T, U> a) { vector<T> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline vector<T> values(umap<T, U> a) { vector<T> res; for (auto &&k :a)res.pb(k.se); return res; } template<class T, class U> inline bool chma(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template<class U> inline bool chma(const U &b) { return chma(ma, b); } template<class T, class U> inline bool chmi(T &a, const U &b) { if (b < a) { a = b; return true; } return false; } template<class U> inline bool chmi(const U &b) { return chmi(mi, b); } template<class T> inline T min(T a, signed b) { return a < b ? a : b; } template<class T> inline T max(T a, signed b) { return a < b ? b : a; } template<class T> inline T min(T a, T b, T c) { return a >= b ? b >= c ? c : b : a >= c ? c : a; } template<class T> inline T max(T a, T b, T c) { return a <= b ? b <= c ? c : b : a <= c ? c : a; } template<class T> inline T min(vector<T> a) { return *min_element(all(a)); } template<class T> inline T mini(vector<T> a) { return min_element(all(a)) - a.begin(); } template<class T> inline T min(vector<T> a, int n) { return *min_element(a.begin(), a.begin() + min(n, sz(a))); } template<class T> inline T min(vector<T> a, int s, int n) { return *min_element(a.begin() + s, a.begin() + min(n, sz(a))); } template<class T> inline T max(vector<T> a) { return *max_element(all(a)); } template<class T> inline T maxi(vector<T> a) { return max_element(all(a)) - a.begin(); } template<class T> inline T max(vector<T> a, int n) { return *max_element(a.begin(), a.begin() + min(n, sz(a))); } template<class T> inline T max(vector<T> a, int s, int n) { return *max_element(a.begin() + s, a.begin() + min(n, sz(a))); } template<typename A, size_t N> inline A max(A (&a)[N]) { A res = a[0]; rep(i, N)res = max(res, a[i]); return res; } template<typename A, size_t N, size_t O> inline A max(A (&a)[N][O]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P> inline A max(A (&a)[N][O][P]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> inline A max(A (&a)[N][O][P][Q], const T &v) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A max(A (&a)[N][O][P][Q][R]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A max(A (&a)[N][O][P][Q][R][S]) { A res = max(a[0]); rep(i, N)res = max(res, max(a[i])); return res; } template<typename A, size_t N> inline A min(A (&a)[N]) { A res = a[0]; rep(i, N)res = min(res, a[i]); return res; } template<typename A, size_t N, size_t O> inline A min(A (&a)[N][O]) { A res = min(a[0]); rep(i, N)res = min(res, max(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P> inline A min(A (&a)[N][O][P]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q> inline A min(A (&a)[N][O][P][Q], const T &v) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R> inline A min(A (&a)[N][O][P][Q][R]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<typename A, size_t N, size_t O, size_t P, size_t Q, size_t R, size_t S> inline A min(A (&a)[N][O][P][Q][R][S]) { A res = min(a[0]); rep(i, N)res = min(res, min(a[i])); return res; } template<class T> inline T sum(T &v) { return v; } template<class T> inline auto sum(vector<T> &v) { auto ret = sum(v[0]); rep(i, 1, sz(v))ret += sum(v[i]); return ret; } template<class T, class U, class... V> inline auto sum(vector<T> &v, U head, V... tail) { auto ret = sum(v[0], tail...); rep(i, 1, min(sz(v), head))ret += sum(v[i], tail...); return ret; } inline P sump(vp &v, int len = -1) { if (len == -1)len = v.size(); P res = {0, 0}; chmi(len, v.size()); rep(i, len) { res.fi += v[i].fi; res.se += v[i].se; } return res; } ///要素が0の時、返り値は0か1か template<class T> inline T mul(vector<T> &v, int len = -1) { if (len == -1)len = v.size(); T res = 1; chmi(len, v.size()); rep(i, len)res *= v[i]; return res; } inline void clear(PQ &q) { while (q.size())q.pop(); } template<class T> inline void clear(queue<T> &q) { while (q.size())q.pop(); } template<class T> inline T *negarr(int size) { T *body = (T *) malloc((size * 2 + 1) * sizeof(T)); return body + size; } template<class T> inline T *negarr2(int h, int w) { double **dummy1 = new double *[2 * h + 1]; double *dummy2 = new double[(2 * h + 1) * (2 * w + 1)]; dummy1[0] = dummy2 + w; for (int i = 1; i <= 2 * h + 1; i++) { dummy1[i] = dummy1[i - 1] + 2 * w + 1; } double **a = dummy1 + h; return a; } //imoは0-indexed //ruiは1-indexed template<class T> inline vector<T> imo(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1)ret[i + 1] += ret[i]; return ret; } //漸化的に最小を持つ template<class T> inline vector<T> imi(vector<T> &v) { vector<T> ret = v; rep(i, sz(ret) - 1)chmi(ret[i + 1], ret[i]); return ret; } template<class T> struct ruiC { const vector<T> rui; ruiC(vector<T> &ru) : rui(ru) {} inline T operator()(int l, int r) { assert(l <= r); return rui[r] - rui[l]; } inline T operator[](int i) { return rui[i]; } }; template<class T> struct rruic { const T *rrui; rruic(T *ru) : rrui(ru) {} //n-1から-1へ inline T operator()(int l, int r) { assert(l >= r); return rrui[r] - rrui[l]; } inline T operator[](int i) { return rrui[i]; } }; template<class T> inline vector<T> ruiv(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] + a[i]; return ret; } template<class T> inline ruiC<T> ruic(vector<T> &a) { vector<T> ret = ruiv(a); return ruiC<T>(ret); } //kと同じものの数 template<class T, class U> inline vi ruiv(T &a, U k) { vi ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] + (a[i] == k); return ret; } template<class T, class U> inline ruiC<int> ruic(T &a, U k) { vi ret = ruiv(a, k); return ruiC<int>(ret); } //xor template<class T> inline vector<T> ruix(vector<T> &a) { vector<T> ret(a.size() + 1); rep(i, a.size())ret[i + 1] = ret[i] ^ a[i]; return ret; } template<class T> inline vector<T> ruim(vector<T> &a) { vector<T> res(a.size() + 1, 1); rep(i, a.size())res[i + 1] = res[i] * a[i]; return res; } //漸化的に最小を1indexで持つ template<class T> inline vector<T> ruimi(vector<T> &a) { int n = sz(a); vector<T> ret(n + 1); rep(i, 1, n) { ret[i] = a[i - 1]; chmi(ret[i + 1], ret[i]); } return ret; } //template<class T> T *rrui(vector<T> &a) { //右から左にかけての半開区間 (-1 n-1] template<class T> rruic<T> rrui(vector<T> &a) { int len = a.size(); T *body = (T *) malloc((len + 1) * sizeof(T)); T *res = body + 1; rer(i, len - 1)res[i - 1] = res[i] + a[i]; return rruic<T>(res); } //掛け算 template<class T> T *rruim(vector<T> &a) { int len = a.size(); T *body = (T *) malloc((len + 1) * sizeof(T)); T *res = body + 1; res[len - 1] = 1; rer(i, len - 1)res[i - 1] = res[i] * a[i]; return res; } template<class T, class U> void inc(T &a, U v = 1) { a += v; } template<class T, class U> void inc(vector<T> &a, U v = 1) { for (auto &u :a)inc(u, v); } template<class T> void inc(vector<T> &a) { for (auto &u :a)inc(u, 1); } template<class T, class U> void plus(T &a, U v = 1) { a += v; } template<class T, class U> void plus(vector<T> &a, U v = 1) { for (auto &u :a)inc(u, v); } template<class T> void plus(vector<T> &a) { for (auto &u :a)inc(u, 1); } template<class T, class U> void dec(T &a, U v = 1) { a -= v; } template<class T, class U> void dec(vector<T> &a, U v = 1) { for (auto &u :a)dec(u, v); } template<class T> void dec(vector<T> &a) { for (auto &u :a)dec(u, 1); } template<class T, class U> void minu(T &a, U v = 1) { a -= v; } template<class T, class U> void minu(vector<T> &a, U v = 1) { for (auto &u :a)dec(u, v); } template<class T> void minu(vector<T> &a) { for (auto &u :a)dec(u, 1); } template<class U> void minu(string &a, U v = 1) { for (auto &u :a)dec(u, v); } void minu(string &a) { for (auto &u :a)dec(u, 1); } inline bool inside(int h, int w, int H, int W) { return h >= 0 && w >= 0 && h < H && w < W; } inline bool inside(int l, int v, int r) { return l <= v && v < r; } #define ins inside ll u(ll a) { return a < 0 ? 0 : a; } template<class T> vector<T> u(const vector<T> &a) { vector<T> ret = a; fora(v, ret)v = u(v); return ret; } #define MIN(a) numeric_limits<a>::min() #define MAX(a) numeric_limits<a>::max() ll goldd(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll) ((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl < fr) { right = rm; rm = lm; fr = fl; lm = left + (ll) ((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } ll minScore = MAX(ll); ll resIndex = left; for (ll i = left; i < right + 1; i++) { ll score = calc(i); if (minScore > score) { minScore = score; resIndex = i; } } return resIndex; } ll goldt(ll left, ll right, function<ll(ll)> calc) { double GRATIO = 1.6180339887498948482045868343656; ll lm = left + (ll) ((right - left) / (GRATIO + 1.0)); ll rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); ll fl = calc(lm); ll fr = calc(rm); while (right - left > 10) { if (fl > fr) { right = rm; rm = lm; fr = fl; lm = left + (ll) ((right - left) / (GRATIO + 1.0)); fl = calc(lm); } else { left = lm; lm = rm; fl = fr; rm = lm + (ll) ((right - lm) / (GRATIO + 1.0)); fr = calc(rm); } } if (left > right) { ll l = left; left = right; right = l; } ll maxScore = MIN(ll); ll resIndex = left; for (ll i = left; i < right + 1; i++) { ll score = calc(i); if (maxScore < score) { maxScore = score; resIndex = i; } } return resIndex; } template<class T> T min(vector<vector<T>> &a) { T res = MAX(T); rep(i, a.size())chmi(res, *min_element(all(a[i]))); return res; } template<class T> T max(vector<vector<T>> &a) { T res = MIN(T); rep(i, a.size())chma(res, *max_element(all(a[i]))); return res; } constexpr bool bget(ll m, int keta) { assert(keta < 64); return (m >> keta) & 1; } int bget(ll m, int keta, int sinsuu) { m /= (ll) pow(sinsuu, keta); return m % sinsuu; } inline ll bit(int n) { return (1LL << (n)); } inline ll bit(int n, int sinsuu) { return (ll) pow(sinsuu, n); } //int bcou(ll m) { return __builtin_popcount(m & 0xFFFFFFFF) + __builtin_popcount(m >> 32); } #define bcou __builtin_popcountll //最下位ビット int lbit(int n) { return n & -n; } //最上位ビット int hbit(int n) { n |= (n >> 1); n |= (n >> 2); n |= (n >> 4); n |= (n >> 8); n |= (n >> 16); n |= (n >> 32); return n - (n >> 1); } //初期化は0を渡す ll nextComb(ll &mask, int n, int r) { if (!mask)return mask = (1LL << r) - 1; ll x = mask & -mask; //最下位の1 ll y = mask + x; //連続した下の1を繰り上がらせる ll res = ((mask & ~y) / x >> 1) | y; if (bget(res, n))return mask = 0; else return mask = res; } //n桁以下でビットがr個立っているもののvectorを返す vl bitCombList(int n, int r) { vl res; int m = 0; while (nextComb(m, n, r)) { res.pb(m); } return res; } //大文字小文字を区別する int altoiaZ(char c) { if ('A' <= c && c <= 'Z')return c - 'A'; return c - 'a' + 26; } char itoalaZ(int i) { if (i < 26)return 'A' + i; return 'a' + i - 26; } //aもAも0を返す 基本小文字 int altoi(char c) { if ('A' <= c && c <= 'Z')return c - 'A'; return c - 'a'; } char itoal(int i) { return 'a' + i; } int ctoi(char c) { return c - '0'; } char itoc(int i) { return i + '0'; } int vtoi(vi &v) { int res = 0; if (sz(v) > 18) { debugline("vtoi"); deb(sz(v)); ole(); } rep(i, sz(v)) { res *= 10; res += v[i]; } return res; } vi itov(int i) { vi res; while (i) { res.pb(i % 10); i /= 10; } rev(res); return res; } vi stov(string &a) { int n = sz(a); vi ret(n); rep(i, n) { ret[i] = a[i] - '0'; } return ret; } vector<vector<int>> ctoi(vector<vector<char>> s, char c) { int n = sz(s), m = sz(s[0]); vector<vector<int>> res(n, vector<int>(m)); rep(i, n)rep(j, m)res[i][j] = s[i][j] == c; return res; } #define unique(v) v.erase( unique(v.begin(), v.end()), v.end() ); void compress(vi &a) { vi b; int len = a.size(); for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } void compress(int a[], int len) { vi b; for (int i = 0; i < len; ++i) { b.push_back(a[i]); } sort(b); unique(b); for (int i = 0; i < len; ++i) { a[i] = lower_bound(all(b), a[i]) - b.begin(); } } //要素が見つからなかったときに困る #define binarySearch(a, v) (binary_search(all(a),v)) #define lowerIndex(a, v) (lower_bound(all(a),v)-a.begin()) #define lowerBound(a, v) (*lower_bound(all(a),v)) #define upperIndex(a, v) (upper_bound(all(a),v)-a.begin()) #define upperBound(a, v) (*upper_bound(all(a),v)) #define ans(a) cout<<a<<endl;continue; #define poll(a) q.front();q.pop() #define dpoll(a) q.front();q.pop_front() #define pollLast(a) q.back();q.pop_back() #define pollBack(a) q.back();q.pop_back() template<class T> inline void fin(T s) { cout << s << endl, exit(0); } //便利 数学 math int mod(int a, int m) { return (a % m + m) % m; } int pow(int a) { return a * a; }; ll fact(int v) { return v <= 1 ? 1 : v * fact(v - 1); } ll comi(int n, int r) { assert(n < 100); static vvi(pas, 100, 100); if (pas[0][0])return pas[n][r]; pas[0][0] = 1; rep(i, 1, 100) { pas[i][0] = 1; rep(j, 1, i + 1)pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j]; } return pas[n][r]; } double comd(int n, int r) { assert(n < 2020); static vvd(comb, 2020, 2020); if (comb[0][0] == 0) { comb[0][0] = 1; rep(i, 2000) { comb[i + 1][0] = 1; rep(j, 1, i + 2) { comb[i + 1][j] = comb[i][j] + comb[i][j - 1]; } } } return comb[n][r]; } inline int gcd(int a, int b) { while (b) a %= b, swap(a, b); return a; } inline int gcd(vi b) { ll res = b[0]; for (auto &&v :b)res = gcd(v, res); return res; } inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } inline ll ceil(ll a, ll b) { if (b == 0) { debugline("ceil"); deb(a, b); ole(); return -1; } else if (a < 0) { return 0; } else { return (a + b - 1) / b; } } //v * v >= aとなる最小のvを返す ll sqrt(ll a) { if (a < 0) { debugline("sqrt"); deb(a); ole(); } ll res = (ll) std::sqrt(a); while (res * res < a)res++; return res; } double log(double e, double x) { return log(x) / log(e); } ll sig(ll t) { return (1 + t) * t / 2; } ll sig(ll s, ll t) { return (s + t) * (t - s + 1) / 2; } namespace pnumber_tools { #define Eratosthenes30_2 class Eratosthenes {public:virtual void initialize() {} virtual void generate(const int64_t x) = 0; virtual void generate(const int64_t from, const int64_t to) = 0; virtual int64_t count() = 0; virtual bool prime(int x) = 0; virtual int32_t version() = 0; inline uint64_t PopCnt(uint64_t); inline int BitToIndex(uint8_t); }; uint64_t Eratosthenes::PopCnt(uint64_t bits) { bits = (bits & 0x5555555555555555ULL) + ((bits >> 1) & 0x5555555555555555ULL); bits = (bits & 0x3333333333333333ULL) + ((bits >> 2) & 0x3333333333333333ULL); bits = (bits & 0x0f0f0f0f0f0f0f0fULL) + ((bits >> 4) & 0x0f0f0f0f0f0f0f0fULL); return (bits * 0x0101010101010101ULL) >> (64 - 8); } int Eratosthenes::BitToIndex(uint8_t b) { switch (b) { case 1 << 0: return 0; case 1 << 1: return 1; case 1 << 2: return 2; case 1 << 3: return 3; case 1 << 4: return 4; case 1 << 5: return 5; case 1 << 6: return 6; case 1 << 7: return 7; } return -1; } namespace { const uint64_t kSegmentSize = 1000000; const int32_t kMod30[] = {1, 7, 11, 13, 17, 19, 23, 29}; const int C1[] = {6, 4, 2, 4, 2, 4, 6, 2}; const int C0[][8] = { {0, 0, 0, 0, 0, 0, 0, 1}, {1, 1, 1, 0, 1, 1, 1, 1}, {2, 2, 0, 2, 0, 2, 2, 1}, {3, 1, 1, 2, 1, 1, 3, 1}, {3, 3, 1, 2, 1, 3, 3, 1}, {4, 2, 2, 2, 2, 2, 4, 1}, {5, 3, 1, 4, 1, 3, 5, 1}, {6, 4, 2, 4, 2, 4, 6, 1}, }; const uint8_t kMask[][8] = { {0xfe, 0xfd, 0xfb, 0xf7, 0xef, 0xdf, 0xbf, 0x7f}, {0xfd, 0xdf, 0xef, 0xfe, 0x7f, 0xf7, 0xfb, 0xbf}, {0xfb, 0xef, 0xfe, 0xbf, 0xfd, 0x7f, 0xf7, 0xdf}, {0xf7, 0xfe, 0xbf, 0xdf, 0xfb, 0xfd, 0x7f, 0xef}, {0xef, 0x7f, 0xfd, 0xfb, 0xdf, 0xbf, 0xfe, 0xf7}, {0xdf, 0xf7, 0x7f, 0xfd, 0xbf, 0xfe, 0xef, 0xfb}, {0xbf, 0xfb, 0xf7, 0x7f, 0xfe, 0xef, 0xdf, 0xfd}, {0x7f, 0xbf, 0xdf, 0xef, 0xf7, 0xfb, 0xfd, 0xfe}, }; const int64_t kSievedPrimes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23}; const int64_t kInitialSize = 7 * 11 * 13 * 17 * 19 * 23;class Eratosthenes2 final : public Eratosthenes { public: void generate(const int64_t x) override; void generate(const int64_t, const int64_t) override { assert(false); } bool prime(int x) override; int64_t count() override; int32_t version() override { return 2; } std::vector<uint8_t> flags_; }; void Eratosthenes2::generate(const int64_t x) { flags_.clear(); if (x > 10000000000) return; int64_t size = x / 30 + (x % 30 != 0); flags_.resize(size, 0xff); if (int r = x % 30) { if (r <= 1) flags_[size - 1] = 0x0; else if (r <= 7) flags_[size - 1] = 0x1; else if (r <= 11) flags_[size - 1] = 0x3; else if (r <= 13) flags_[size - 1] = 0x7; else if (r <= 17) flags_[size - 1] = 0xf; else if (r <= 19) flags_[size - 1] = 0x1f; else if (r <= 23) flags_[size - 1] = 0x3f; else if (r <= 29) flags_[size - 1] = 0x7f; } flags_[0] = 0xfe; const uint64_t sqrt_x = std::ceil(std::sqrt(x) + 0.1); const uint64_t sqrt_xi = sqrt_x / 30 + 1; for (uint64_t i = 0; i < sqrt_xi; ++i) { for (uint8_t flags = flags_[i]; flags; flags &= flags - 1) { uint8_t lsb = flags & (-flags); int ibit = BitToIndex(lsb); const int32_t m = kMod30[ibit]; int32_t pm = 30 * i + 2 * m; for (uint64_t j = i * pm + (m * m) / 30, k = ibit; j < flags_.size(); j += i * C1[k] + C0[ibit][k], k = (k + 1) & 7) { flags_[j] &= kMask[ibit][k]; } } } }int64_t Eratosthenes2::count() { if (flags_.empty()) return -1; int64_t ret = 3; for (uint8_t f : flags_) { ret += PopCnt(f); } return ret; } inline bool Eratosthenes2::prime(int x) { static unordered_map<int, int> imap = {{1, 0}, {7, 1}, {11, 2}, {13, 3}, {17, 4}, {19, 5}, {23, 6}, {29, 7}}; if (x == 2 || x == 3 || x == 5)return true; else if (!(x & 1) || x % 3 == 0 || x % 5 == 0)return false; return (flags_[x / 30] >> imap[x % 30]) & 1; }} Eratosthenes30_2 Eratosthenes2 era; int prime_len = 1e7; vector<int> primes; void setprime(int size = 1e7) { prime_len = size; era.generate(size); primes = {2, 3, 5}; int nums[129] = {}; nums[1] = 1; nums[2] = 7; nums[4] = 11; nums[8] = 13; nums[16] = 17; nums[32] = 19; nums[64] = 23; nums[128] = 29; //p = 30i + j int j = 0; int sflim = era.flags_.size(); int i30 = 0; for (int i = 0; i < sflim; i++, i30 += 30) { uint8_t m = era.flags_[i]; while (m) { j = m & -m; primes.push_back(i30 + nums[j]); m ^= j; } } } using u32 = unsigned int;//longlongになっていると思うが放置していいと思う using u64 = unsigned long long; using u128 = __uint128_t; //O(k log(n)^3) //32bit -> 270回程度 //64bit -> 1260回程度 //64bit以下で精度100% template<class BinOp> bool miller_rabin(const uint64_t &n, const uint64_t *witness, BinOp modmul) { if (n == 2) return true; if (n < 2 || n % 2 == 0) return false; const int64_t m = n - 1, d = m / (m & -m); auto modpow = [&](int64_t a, int64_t b) { int64_t res = 1; for (; b; b /= 2) { if (b & 1) res = modmul(res, a); a = modmul(a, a); } return res; }; auto suspect = [&](uint64_t a, uint64_t t) { a = modpow(a, t); while (t != n - 1 && a != 1 && a != n - 1) { a = modmul(a, a); t = modmul(t, 2); } return a == n - 1 || t % 2 == 1; }; for (const uint64_t *w = witness; *w; w++) { if (*w % n != 0 && !suspect(*w, d)) return false; } return true; } //miller_rabin & エラトステネス bool prime(const int &n) { assert(n < 9223372036854775808ULL); if (!sz(primes))setprime(); //エラトステネスの篩 偶数省略ver //[i] = i*2+1 if (n < prime_len)return era.prime(n); if (n < 4294967296) { rep(i, 30) if (!(n % primes[i]))return false; constexpr uint64_t witness[] = {2, 7, 61, 0}; auto modmul = [&](uint64_t a, uint64_t b) -> uint64_t { return a * b % n; }; return miller_rabin(n, witness, modmul); } else { rep(i, 50) if (!(n % primes[i]))return false; constexpr uint64_t witness[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022, 0}; auto modmul = [&](uint64_t a, uint64_t b) -> uint64_t { return (uint64_t) ((__uint128_t) a * b % n); }; return miller_rabin(n, witness, modmul); } } vi divisors(int v) { vi res; double lim = std::sqrt(v); for (int i = 1; i <= lim; ++i) { if (v % i == 0) { res.pb(i); if (i != v / i)res.pb(v / i); } } return res; } vp factorization(int v) { assert(v); int tv = v; vp res; if (!sz(primes))setprime(); for (auto &&p :primes) { if (v % p == 0)res.eb(p, 0); while (v % p == 0) { v /= p; res.back().second++; } if (v == 1 || p * p > tv)break; } if (v > 1)res.eb(v, 1); return res; } //注意 gcdを取る間隔 i%10 が場合によってはtleを引き起こす //うまくいかなかったら%1で動かすように変更した vp rho(int v) { assert(v); if (v == 1)return vp(); vi ret; if (!sz(primes)) setprime(); int lim = 300; //64bit if (v < 4294967296)lim = 80; //32bit else if (v < 281474976710656LL)lim = 120; //48bit for (int i = 0; i < lim; i += 5) { //v<=1の判定回数を減らせる分高速化できる事を期待している while (v % primes[i] == 0) ret.pb(primes[i]), v /= primes[i]; while (v % primes[i + 1] == 0) ret.pb(primes[i + 1]), v /= primes[i + 1]; while (v % primes[i + 2] == 0) ret.pb(primes[i + 2]), v /= primes[i + 2]; while (v % primes[i + 3] == 0) ret.pb(primes[i + 3]), v /= primes[i + 3]; while (v % primes[i + 4] == 0) ret.pb(primes[i + 4]), v /= primes[i + 4]; if (v <= 1) { sort(ret);//試し割りだけで終わった時 return run_length(ret); } } int lower_prime_bound = primes[lim - 1] * primes[lim - 1]; //試し割りするか mt19937 mr; mr.seed(clock()); int c; auto fac = [&](int v, const int loop = 10) { // if (v == 4)return 2ll; //試し割りで消えた c = mr() % v; int x = mr() % v; int y = x; int d = 1; int lim = std::sqrt(v) + 2; //brentによる改良 差分を一操作で求められる for (int i = 1, mul = 1, next_2pow = 2; d == 1 && i <= lim; i++) { if (i == next_2pow) { y = x; next_2pow <<= 1; } x = ((u128) x * x + c) % v; mul = ((u128) mul * abs(x - y)) % v;//ユークリッドの互除法と同じ原理で因数は保たれる if (i % loop == 0) {//10とかなんとか iによっては死ぬ d = gcd(mul, v); mul = 1; } } if (d == v) return -1ll; return d; }; queue<int> q; q.push(v); while (!q.empty()) { int v = q.front(); q.pop(); if (prime(v)) { ret.pb(v); continue; } int d = -1; //基本loop回数10でやり、駄目なら1で for (int i = 0; d == -1 && i < 5; i++)d = fac(v, 10); if (d == -1)while (d == -1)d = fac(v, 1); int d2 = v / d; rep(_, 2) { if (d <= lower_prime_bound)ret.pb(d); else q.push(d); d = d2; } } sort(ret); return run_length(ret); } } using namespace pnumber_tools; //幾何 Pをcomplexとして扱う template<class T, class U> bool eq(T a, U b) { return fabs(a - b) < eps; } dou atan2(pd a) { return atan2(a.se, a.fi); } dou angle(pd f, pd t) { return atan2(t.se - f.se, t.fi - f.fi); } dou distance(pd a, pd b) { return hypot(a.fi - b.fi, a.se - b.se); } //bを中心とするabcのtheta aからcにかけて時計回り dou angle(pd a, pd b, pd c) { dou ax = a.fi - b.fi; dou ay = a.se - b.se; dou cx = c.fi - b.fi; dou cy = c.se - b.se; double ret = atan2(cy, cx) - atan2(ay, ax); if (ret < 0) ret += 2 * PI; return ret; } dou dot(pd a, pd b) { return a.fi * b.fi + a.se + b.se; } dou cro(pd a, pd b) { return a.fi * b.se - a.se + b.fi; } template<class T> struct edge { int f, t; T c; int id; int type; edge(int f, int t, T c = 1, int id = -1, int ty = -1) : f(f), t(t), c(c), id(id), type(ty) {} bool operator<(const edge &b) const { return c < b.c; } bool operator>(const edge &b) const { return c > b.c; } }; template<class T> ostream &operator<<(ostream &os, edge<T> &e) { os << e.f << " " << e.t << " " << e.c; return os; } template<typename T> class graph { protected: vector<bool> _used; public : vector<vector<edge<T>>> g; vector<edge<T>> edges; int n; graph(int n) : n(n) { g.resize(n), _used.resize(n); } void clear() { g.clear(), edges.clear(); } void resize(int n) { this->n = n; g.resize(n); _used.resize(n); } int size() { return g.size(); } vector<edge<T> > &operator[](int i) { return g[i]; } virtual void add(int f, int t, T c, int id, int ty) = 0; virtual bool used(edge<T> &e) = 0; virtual bool used(int id) = 0; virtual void del(edge<T> &e) = 0; virtual void del(int id) = 0; virtual void set_edges() = 0; }; template<typename T =ll> class digraph : public graph<T> { public: using graph<T>::g; using graph<T>::n; using graph<T>::edges; using graph<T>::_used; int eid = 0; digraph(int n) : graph<T>(n) {} void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("digraph add"); deb(f, t, c, id, ty); ole(); } if (id == -1)id = eid++; g[f].emplace_back(f, t, c, id, ty); edges.emplace_back(f, t, c, id, ty); } bool used(edge<T> &e) { return _used[e.id]; } bool used(int id) { return _used[id]; } void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; } void del(int id) { _used[id] = _used[id ^ 1] = 1; } void set_edges() { if (sz(edges))return; rep(i, n)fora(e, g[i])edges.pb(e); } }; template<class T=int> class undigraph : public graph<T> { public: using graph<T>::g; using graph<T>::n; using graph<T>::edges; using graph<T>::_used; int eid = 0; undigraph(int n) : graph<T>(n) { } void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("undigraph add"); deb(f, t, c, id, ty); ole(); } if (id == -1)id = eid, eid += 2; g[f].emplace_back(f, t, c, id, ty); g[t].emplace_back(t, f, c, id + 1, ty); edges.emplace_back(f, t, c, id, ty); edges.emplace_back(t, f, c, id + 1, ty); } void add(edge<T> &e) { int f = e.f, t = e.t, ty = e.type; T c = e.c; add(f, t, c, ty); } bool used(edge<T> &e) { return _used[e.id]; } bool used(int id) { return _used[id]; } void del(edge<T> &e) { _used[e.id] = _used[e.id ^ 1] = 1; } void del(int id) { _used[id] = _used[id ^ 1] = 1; } void set_edges() { if (sz(edges))return; rep(i, n)fora(e, g[i])edges.pb(e); } }; template<typename T> struct radixheap { vector<pair<u64, T> > v[65]; u64 size, last; radixheap() : size(0), last(0) {} bool empty() const { return size == 0; } inline int getbit(int a) { return a ? 64 - __builtin_clzll(a) : 0; } void push(u64 key, const T &value) { ++size; v[getbit(key ^ last)].emplace_back(key, value); } pair<u64, T> pop() { if (v[0].empty()) { int idx = 1; while (v[idx].empty()) ++idx; last = min_element(begin(v[idx]), end(v[idx]))->first; for (auto &p : v[idx]) v[getbit(p.first ^ last)].emplace_back(p); v[idx].clear(); } --size; auto ret = v[0].back(); v[0].pop_back(); return ret; } }; vi dijkstra2(const graph<int> &g, int s, int cant_arrive = -1) { if (!(0 <= s && s < g.n)) { debugline("dijkstra"); deb(s, g.n); ole(); } int initValue = MAX(int); vi dis(g.n, initValue); radixheap<int> q; dis[s] = 0; q.push(0, s); while (!q.empty()) { int nowc, i; tie(nowc, i) = q.pop(); if (dis[i] != nowc)continue; for (auto &&e : g.g[i]) { int to = e.t; int c = nowc + e.c; if (dis[to] > c) { dis[to] = c; q.push(dis[to], to); } } } //基本、たどり着かないなら-1 if (cant_arrive == -1)for (auto &&d :dis) if (d == initValue)d = -1; return dis; } template<class T> vector<T> dijkstra(const graph<T> &g, int s, int cant_arrive = -1) { if (!(0 <= s && s < g.n)) { debugline("dijkstra"); deb(s, g.n); ole(); } T initValue = MAX(T); vector<T> dis(g.n, initValue); priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q; dis[s] = 0; q.emplace(0, s); while (q.size()) { T nowc = q.top().fi; int i = q.top().se; q.pop(); if (dis[i] != nowc)continue; for (auto &&e : g.g[i]) { int to = e.t; T c = nowc + e.c; if (dis[to] > c) { dis[to] = c; q.emplace(dis[to], to); } } } //基本、たどり着かないなら-1 if (cant_arrive == -1)for (auto &&d :dis) if (d == initValue)d = -1; return dis; } template<class T> vector<vector<T>> warshall(const graph<T> &g, int cant_arrive = -1) { int n = g.n; vector<vector<T> > dis(n, vector<T>(n, linf)); rep(i, n)fora(e, g.g[i])chmi(dis[e.f][e.t], e.c); rep(i, n)dis[i][i] = 0; rep(k, n)rep(i, n)rep(j, n)chmi(dis[i][j], dis[i][k] + dis[k][j]); //基本、たどり着かないなら-1 if (cant_arrive == -1)rep(i, n)rep(j, n) if (dis[i][j] == linf)dis[i][j] = -1; return dis; } template<class T=int> class tree : public undigraph<T> { public: using undigraph<T>::g; using undigraph<T>::n; using undigraph<T>::edges; using undigraph<T>::_used; vi disv; private: bool never = 1; int root = -1; vi dep;//到着した順の深さ vi vis;//到着した順 vi first;//初めてiに到着した時 vector<int> bestt;//タイミングを持つ int sn = 0;//seg木の底辺の長さ euler tourの長さ void built() { never = 0; n = g.size(); //euler tour disv.resize(n); first.resize(n); dep.resize(n * 2); vis.resize(n * 2); function<void(int, int, int, int &)> dfs = [&](int i, int p, int d, int &k) { first[i] = k; vis[k] = i; dep[k++] = d; forg(gi, g[i]) { if (t == p)continue; disv[t] = disv[i] + c; dfs(t, i, d + 1, k); vis[k] = i; dep[k++] = d; } }; int k = 0; dfs(root, -1, 0, k); //rmq sn = 1; while (sn < n * 2)sn *= 2; bestt.resize(2 * sn - 1); rep(i, k)bestt[i + sn - 1] = i;//時間を持つ rer(i, sn - 2) { if (dep[bestt[i * 2 + 1]] < dep[bestt[i * 2 + 2]]) { bestt[i] = bestt[i * 2 + 1]; } else { bestt[i] = bestt[i * 2 + 2]; } } } //最小の深さを持つタイミングが知りたい inline int lca_rmq(int l, int r) { int midv = inf; int midi = -1; l += sn - 1; r += sn - 1; while (l < r) { //右なら、次に右上へ移動してしまうので if (!(l & 1)) { if (chmi(midv, dep[bestt[l]])) { midi = bestt[l]; } } //右なら、左を取らないと機会を逃す if (!(r & 1)) { if (chmi(midv, dep[bestt[r - 1]])) { midi = bestt[r - 1]; } } l >>= 1; r = (r - 1) >> 1; } return vis[midi]; } public: tree(int n, int root = 0) : undigraph<T>(n), root(root) {} bool leaf(int v) { return sz(g[v]) == 1 && v != root; } int lca(int u, int v) { if (never)built(); if (first[u] > first[v])swap(u, v); return lca_rmq(first[u], first[v] + 1); } int dis(int u, int v) { if (never) built(); if (first[u] > first[v])swap(u, v); int p = lca_rmq(first[u], first[v] + 1); return disv[u] + disv[v] - disv[p] * 2; } }; //辺によりメモリを大量消費 // よってedgesを消している //頂点10^6でメモリを190MB(制限の8割)使う //軽量化のため、辺を持たないbig gridクラスがあってもいいかもしれない // template<class T=int> class grid_k6 : public undigraph<T> { public: using undigraph<T>::g; using undigraph<T>::n; using undigraph<T>::edges; using undigraph<T>::_used; int H, W; int eid = 0; void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("grid_k6 add"); deb(f, t, c, id, ty); ole(); } g[f].emplace_back(f, t, c, eid++, ty); g[t].emplace_back(t, f, c, eid++, ty); } int getid(int h, int w) { if (!inside(h, w, H, W))return -1; return W * h + w; } P get2(int id) { return mp(id / W, id % W); } P operator()(int id) { return get2(id); } int operator()(int h, int w) { return getid(h, w); } grid_k6(int H, int W) : H(H), W(W), undigraph<T>(H * W) { rep(h, H) { rep(w, W) { int f = getid(h, w); if (w + 1 < W) add(f, getid(h, w + 1)); if (h + 1 < H)add(f, getid(h + 1, w)); } } } grid_k6(_vvc ba, char wall = '#') : H(sz(ba)), W(sz(ba[0])), undigraph<T>(sz(ba) * sz(ba[0])) { rep(h, H) { rep(w, W) { if (ba[h][w] == wall)con; int f = getid(h, w); if (w + 1 < W && ba[h][w + 1] != wall) { add(f, getid(h, w + 1)); } if (h + 1 < H && ba[h + 1][w] != wall) { add(f, getid(h + 1, w)); } } } } void add(int fh, int fw, int th, int tw) { add(getid(fh, fw), getid(th, tw)); } void set_edges() { rep(i, n)fora(e, g[i])edges.pb(e); } }; //左上から右下に移動できる template<class T=int> class digrid_k6 : public digraph<T> { public: using digraph<T>::g; using digraph<T>::n; using digraph<T>::edges; using digraph<T>::_used; int H, W; int eid = 0; void add(int f, int t, T c = 1, int id = -1, int ty = -1) { if (!(0 <= f && f < n && 0 <= t && t < n)) { debugline("digrid_k6 add"); deb(f, t, c, id, ty); ole(); } g[f].emplace_back(f, t, c, eid++, ty); } int getid(int h, int w) { if (!inside(h, w, H, W))return -1; return W * h + w; } P get2(int id) { return mp(id / W, id % W); } P operator()(int id) { return get2(id); } int operator()(int h, int w) { return getid(h, w); } digrid_k6(int H, int W) : H(H), W(W), digraph<T>(H * W) { rep(h, H) { rep(w, W) { int f = getid(h, w); if (w + 1 < W) add(f, getid(h, w + 1)); if (h + 1 < H)add(f, getid(h + 1, w)); } } } digrid_k6(_vvc ba, char wall = '#') : H(sz(ba)), W(sz(ba[0])), digraph<T>(sz(ba) * sz(ba[0])) { rep(h, H) { rep(w, W) { if (ba[h][w] == wall)con; int f = getid(h, w); if (w + 1 < W && ba[h][w + 1] != wall) { add(f, getid(h, w + 1)); } if (h + 1 < H && ba[h + 1][w] != wall) { add(f, getid(h + 1, w)); } } } } void add(int fh, int fw, int th, int tw) { add(getid(fh, fw), getid(th, tw)); } void set_edges() { rep(i, n)fora(e, g[i])edges.pb(e); } }; template<class T> bool nibu(const graph<T> &g) { int size = 0; rep(i, g.n)size += sz(g.g[i]); if (size == 0)return true; UnionFind uf(g.n * 2); rep(i, g.n)fora(e, g.g[i])uf.unite(e.f, e.t + g.n), uf.unite(e.f + g.n, e.t); rep(i, g.n)if (uf.same(i, i + g.n))return 0; return 1; } //二部グラフを色分けした際の頂点数を返す template<class T> vp nibug(graph<T> &g) { vp cg; if (!nibu(g)) { debugline("nibu"); ole(); } int _n = g.size(); vb _was(_n); queue<P> q; rep(i, _n) { if (_was[i])continue; q.push(mp(i, 1)); _was[i] = 1; int red = 0; int coun = 0; while (q.size()) { int now = q.front().fi; int col = q.front().se; red += col; coun++; q.pop(); forg(gi, g[now]) { if (_was[t])continue; q.push(mp(t, col ^ 1)); _was[t] = 1; } } cg.push_back(mp(red, coun - red)); } return cg; } template<class T> ostream &operator<<(ostream &os, graph<T> &g) { rep(i, sz(g)) { forg(gi, g[i]) { os << f << " " << t << " " << c << endl; } } return os; } //機能拡張 vp vtop(vi &a, vi &b) { vp res(sz(a)); rep(i, sz(a))res[i] = mp(a[i], b[i]); return res; } void ptov(vp &p, vi &a, vi &b) { a.resize(sz(p)); b.resize(sz(p)); rep(i, sz(p))a[i] = p[i].fi, b[i] = p[i].se; } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(to_string(__rv)); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const int __rv) { __lhs += to_string(__rv); } template<typename _CharT, typename _Traits, typename _Alloc> basic_string<_CharT, _Traits, _Alloc> operator+(const basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) { basic_string<_CharT, _Traits, _Alloc> __str(__lhs); __str.append(to_string(__rv)); return __str; } template<typename _CharT, typename _Traits, typename _Alloc> void operator+=(basic_string<_CharT, _Traits, _Alloc> &__lhs, const signed __rv) { __lhs += to_string(__rv); } template<class T, class U> void operator+=(queue<T> &a, U v) { a.push(v); } template<class T, class U> void operator+=(deque<T> &a, U v) { a.push_back(v); } template<class T, class U> priority_queue<T, vector<T>, greater<T> > &operator+=(priority_queue<T, vector<T>, greater<T> > &a, U v) { a.push(v); return a; } template<class T, class U> priority_queue<T> &operator+=(priority_queue<T> &a, U v) { a.push(v); return a; } template<class T, class U> set<T> &operator+=(set<T> &a, U v) { a.insert(v); return a; } template<class T, class U> set<T, greater<T>> &operator+=(set<T, greater<T>> &a, U v) { a.insert(v); return a; } template<class T, class U> vector<T> &operator+=(vector<T> &a, U v) { a.pb(v); return a; } template<class T, class U> vector<T> operator+(const vector <T> &a, U v) { vector<T> ret = a; ret += v; return ret; } template<class T, class U> vector<T> operator+(U v, const vector <T> &a) { vector<T> ret = a; ret.insert(ret.begin(), v); return ret; } template<class T> vector<T> operator+(vector<T> &a, vector <T> &b) { vector<T> ret; ret = a; fora(v, b)ret += v; return ret; } template<class T> vector<T> &operator+=(vector<T> &a, vector <T> &b) { fora(v, b)a += v; return a; } template<class T, class U> vector<T> &operator+=(vector<T> &a, initializer_list<U> v) { for (auto &&va :v)a.pb(va); return a; } template<class T> vector<T> &operator-=(vector<T> &a, vector <T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-="); deb(a); deb(b); ole(); } rep(i, sz(a))a[i] -= b[i]; return a; } template<class T> vector<T> operator-(vector<T> &a, vector <T> &b) { if (sz(a) != sz(b)) { debugline("vector<T> operator-"); deb(a); deb(b); ole(); } vector<T> res(sz(a)); rep(i, sz(a))res[i] = a[i] - b[i]; return res; } template<typename T> void remove(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template<typename T> void remove(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template<typename T> void removen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template<typename T> void erase(vector<T> &v, unsigned int i) { v.erase(v.begin() + i); } template<typename T> void erase(vector<T> &v, unsigned int s, unsigned int e) { v.erase(v.begin() + s, v.begin() + e); } template<typename T> void erasen(vector<T> &v, unsigned int s, unsigned int n) { v.erase(v.begin() + s, v.begin() + s + n); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, U t) { v.insert(v.begin() + i, t); } template<typename T, typename U> void push_front(vector<T> &v, U t) { v.insert(v.begin(), t); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, vector<T> list) { for (auto &&va :list)v.insert(v.begin() + i++, va); } template<typename T, typename U> void insert(vector<T> &v, initializer_list<U> list) { for (auto &&va :list)v.pb(va); } template<typename T, typename U> void insert(vector<T> &v, unsigned int i, initializer_list<U> list) { for (auto &&va :list)v.insert(v.begin() + i++, va); } template<typename T> void insert(set<T> &v, vector<T> list) { for (auto &&va :list)v.insert(va); } template<typename T> void insert(set<T> &v, initializer_list<T> list) { for (auto &&va :list)v.insert(va); } //閉路がなければtrue bool topo(vi &res, digraph<int> &g) { int n = g.g.size(); vi nyu(n); rep(i, n)for (auto &&e :g[i])nyu[e.t]++; queue<int> st; rep(i, n)if (nyu[i] == 0)st.push(i); while (st.size()) { int v = st.front(); st.pop(); res.pb(v); fora(e, g[v]) if (--nyu[e.t] == 0)st.push(e.t); } return res.size() == n; } //辞書順最小トポロジカルソート bool topos(vi &res, digraph<int> &g) { int n = g.g.size(); vi nyu(n); rep(i, n)for (auto &&e :g[i])nyu[e.t]++; //小さい順 priority_queue<int, vector<int>, greater<int> > q; rep(i, n)if (nyu[i] == 0)q.push(i); while (q.size()) { int i = q.top(); q.pop(); res.pb(i); fora(e, g[i])if (--nyu[e.t] == 0)q.push(e.t); } return res.size() == n; } vector<string> split(const string a, const char deli) { string b = a + deli; int l = 0, r = 0, n = b.size(); vector<string> res; rep(i, n) { if (b[i] == deli) { r = i; if (l < r)res.push_back(b.substr(l, r - l)); l = i + 1; } } return res; } vector<string> split(const string a, const string deli) { string b = a + deli; int l = 0, r = 0, n = b.size(), dn = deli.size(); vector<string> res; rep(i, n) { if (i + dn <= n && b.substr(i, i + dn) == deli) { r = i; if (l < r)res.push_back(b.substr(l, r - l)); i += dn - 1; l = i + 1; } } return res; } void yn(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; } void Yn(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; } void YN(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; } void fyn(bool a) { if (a)cout << "yes" << endl; else cout << "no" << endl; exit(0); } void fYn(bool a) { if (a)cout << "Yes" << endl; else cout << "No" << endl; exit(0); } void fYN(bool a) { if (a)cout << "YES" << endl; else cout << "NO" << endl; exit(0); } void Possible(bool a) { if (a)cout << "Possible" << endl; else cout << "Impossible" << endl; exit(0); } int n, m, k, d, H, W, x, y, z, q; int cou; vi a, b, c; //vvi (s, 0, 0); vvc (ba, 0, 0); vp p; str s; void solve() { in(n); na(a,n); int res=1; int up=0,dn=0; rep(i,1,n){ if(a[i-1] < a[i])up=1; if(a[i-1] > a[i])dn=1; if(up&&dn){ up=0; dn=0; res++; } } std::cout << res << std::endl; } int my(int n, vi &a) { return 0; } int sister(int n, vi &a) { int ret = 0; return ret; } signed main() { solve(); #define _arg n,a #ifdef _DEBUG bool bad = 0; for (int i = 0, ok = 1; i < k5 && ok; i++) { int n = rand(1, 8); vi a = ranv(n, 1, 10); int myres = my(_arg); int res = sister(_arg); ok = myres == res; if (!ok) { outl(_arg); cerr << "正解 : " << res << endl; cerr << "自分 : " << myres << endl; bad = 1; break; } } if (!bad) { // cout << "完璧 : solveを書き直そう" << endl; // cout << " : そして、solve()を呼び出すのだ" << endl; // cout << " : cin>>n; na(a,n);も忘れるな" << endl; } #endif return 0; };
a.cc:2751:8: error: redefinition of 'struct initon' 2751 | struct initon { | ^~~~~~ a.cc:7:8: note: previous definition of 'struct initon' 7 | struct initon { | ^~~~~~ a.cc:2759:3: error: conflicting declaration 'int __initon' 2759 | } __initon; | ^~~~~~~~ a.cc:15:3: note: previous declaration as 'initon __initon' 15 | } __initon; | ^~~~~~~~ a.cc:2764:8: error: redefinition of 'struct T' 2764 | struct T { | ^ a.cc:20:8: note: previous definition of 'struct T' 20 | struct T { | ^ a.cc:2787:8: error: redefinition of 'struct F' 2787 | struct F { | ^ a.cc:43:8: note: previous definition of 'struct F' 43 | struct F { | ^ a.cc:2924:32: error: redefinition of 'template<class T> std::vector<_Tp> make_v(size_t)' 2924 | template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); } | ^~~~~~ a.cc:180:32: note: 'template<class T> std::vector<_Tp> make_v(size_t)' previously declared here 180 | template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); } | ^~~~~~ a.cc:2925:43: error: redefinition of 'template<class T, class ... Ts> auto make_v(size_t, Ts ...)' 2925 | template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { | ^~~~~~ a.cc:181:43: note: 'template<class T, class ... Ts> auto make_v(size_t, Ts ...)' previously declared here 181 | template<typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { | ^~~~~~ a.cc:2976:11: error: redefinition of 'const long long int inf' 2976 | const int inf = (int) 1e9 + 100; | ^~~ a.cc:232:11: note: 'const long long int inf' previously defined here 232 | const int inf = (int) 1e9 + 100; | ^~~ a.cc:2977:10: error: redefinition of 'const long long int linf' 2977 | const ll linf = (ll) 1e18 + 100; | ^~~~ a.cc:233:10: note: 'const long long int linf' previously defined here 233 | const ll linf = (ll) 1e18 + 100; | ^~~~ a.cc:2978:12: error: redefinition of 'const char infc' 2978 | const char infc = '{'; | ^~~~ a.cc:234:12: note: 'const char infc' previously defined here 234 | const char infc = '{'; | ^~~~ a.cc:2979:14: error: redefinition of 'const std::string infs' 2979 | const string infs = "{"; | ^~~~ a.cc:235:14: note: 'const std::string infs' previously declared here 235 | const string infs = "{"; | ^~~~ a.cc:2980:14: error: redefinition of 'const long double eps' 2980 | const double eps = 1e-9; | ^~~ a.cc:236:14: note: 'const long double eps' previously defined here 236 | const double eps = 1e-9; | ^~~ a.cc:2981:14: error: redefinition of 'const long double PI' 2981 | const double PI = 3.1415926535897932384626433832795029L; | ^~ a.cc:237:14: note: 'const long double PI' previously defined here 237 | const double PI = 3.1415926535897932384626433832795029L; | ^~ a.cc:2982:4: error: redefinition of 'long long int ma' 2982 | ll ma = numeric_limits<ll>::min(); | ^~ a.cc:238:4: note: 'long long int ma' previously defined here 238 | ll ma = numeric_limits<ll>::min(); | ^~ a.cc:2983:4: error: redefinition of 'long long int mi' 2983 | ll mi = numeric_limits<ll>::max(); | ^~ a.cc:239:4: note: 'long long int mi' previously defined here 239 | ll mi = numeric_limits<ll>::max(); | ^~ a.cc:2984:11: error: redefinition of 'const long long int y4 []' 2984 | const int y4[] = {-1, 1, 0, 0}; | ^~ a.cc:240:11: note: 'const long long int y4 [4]' previously defined here 240 | const int y4[] = {-1, 1, 0, 0}; | ^~ a.cc:2985:11: error: redefinition of 'const long long int x4 []' 2985 | const int x4[] = {0, 0, -1, 1}; | ^~ a.cc:241:11: note: 'const long long int x4 [4]' previously defined here 241 | const int x4[] = {0, 0, -1, 1}; | ^~ a.cc:2986:11: error: redefinition of 'const long long int y8 []' 2986 | const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; | ^~ a.cc:242:11: note: 'const long long int y8 [8]' previously defined here 242 | const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; | ^~ a.cc:2987:11: error: redefinition of 'const long long int x8 []' 2987 | const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; | ^~ a.cc:243:11: note: 'const long long int x8 [8]' previously defined here 243 | const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; | ^~ a.cc:3000:16: error: redefinition of 'constexpr bool ev(long long int)' 3000 | constexpr bool ev(int a) { return !(a & 1); } | ^~ a.cc:256:16: note: 'constexpr bool ev(long long int)' previously defined here 256 | constexpr bool ev(int a) { return !(a & 1); } | ^~ a.cc:3001:16: error: redefinition of 'constexpr bool od(long long int)' 3001 | constexpr bool od(int a) { return (a & 1); } | ^~ a.cc:257:16: note: 'constexpr bool od(long long int)' previously defined here 257 | constexpr bool od(int a) { return (a & 1); } | ^~ a.cc:3006:22: error: redefinition of 'class std::hash<std::pair<int, int> >' 3006 | template<> class hash<std::pair<signed, signed>> { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:262:22: note: previous definition of 'class std::hash<std::pair<int, int> >' 262 | template<> class hash<std::pair<signed, signed>> { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:3012:22: error: redefinition of 'class std::hash<std::pair<long long int, long long int> >' 3012 | template<> class hash<std::pair<ll, ll>> { | ^~~~~~~~~~~~~~~~~~~~~~~ a.cc:268:22: note: previous definition of 'class std::hash<std::pair<long long int, long long int> >' 268 | template<> class hash<std::pair<ll, ll>> { | ^~~~~~~~~~~~~~~~~~~~~~~ a.cc:3020:10: error: redefinition of 'std::istream& operator>>(std::istream&, P&)' 3020 | istream &operator>>(istream &iss, P &a) { | ^~~~~~~~ a.cc:276:10: note: 'std::istream& operator>>(std::istream&, P&)' previously defined here 276 | istream &operator>>(istream &iss, P &a) { | ^~~~~~~~ a.cc:3024:31: error: redefinition of 'template<class T> std::istream& operator>>(std::istream&, std::vector<_Tp>&)' 3024 | template<typename T> istream &operator>>(istream &iss, vector<T> &vec) { | ^~~~~~~~ a.cc:280:31: note: 'template<class T> std::istream& operator>>(std::istream&, std::vector<_Tp>&)' previously declared here 280 | template<typename T> istream &operator>>(istream &iss, vector<T> &vec) { | ^~~~~~~~ a.cc:3028:37: error: redefinition of 'template<class T, class U> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)' 3028 | template<class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { | ^~~~~~~~ a.cc:284:37: note: 'template<class T, class U> std::ostream& operator<<(std::ostream&, std::pair<_T1, _T2>)' previously declared here 284 | template<class T, class U> ostream &operator<<(ostream &os, pair<T, U> p) { | ^~~~~~~~ a.cc:3032:10: error: redefinition of 'std::ostream& operator<<(std::ostream&, T)' 3032 | ostream &operator<<(ostream &os, T p) { | ^~~~~~~~ a.cc:288:10: note: 'std::ostream& operator<<(std::ostream&, T)' previously defined here 288 | ostream &operator<<(ostream &os, T p) { | ^~~~~~~~ a.cc:3036:10: error: redefinition of 'std::ostream& operator<<(std::ostream&, F)' 3036 | ostream &operator<<(ostream &os, F p) { | ^~~~~~~~ a.cc:292:10: note: 'std::ostream& operator<<(std::ostream&, F)' previously defined here 292 | ostream &operator<<(ostream &os, F p) { | ^~~~~~~~ a.cc:3040:31: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)' 3040 | template<typename T> ostream &operator<<(ostream &os, vector <T> &vec) { | ^~~~~~~~ a.cc:296:31: note: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)' previously declared here 296 | template<typename T> ostream &operator<<(ostream &os, vector <T> &vec) { | ^~~~~~~~ a.cc:3044:31: error: redefinition of 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<std::vector<_Tp> >&)' 3044 | template<typename T> ostream &operator<<(ostream &os, vector <vector<T>> &vec) { | ^~~~~~~~ a.cc:300:31: note: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<std::vector<_Tp> >&)' previously declared here 300 | template<typename T> ostream &operator<<(ostream &os, vector <vector<T>> &vec) { | ^~~~~~~~ a.cc:3053:39: error: redefinition of 'template<class V, class H> void resize(std::vector<_Tp>&, H)' 3053 | template<typename V, typename H> void resize(vector<V> &vec, const H head) { vec.resize(head); } | ^~~~~~ a.cc:309:39: note: 'template<class V, class H> void resize(std::vector<_Tp>&, H)' previously declared here 309 | template<typename V, typename H> void resize(vector<V> &vec, const H head) { vec.resize(head); } | ^~~~~~ a.cc:3054:55: error: redefinition of 'template<class V, class H, class ... T> void resize(std::vector<_Tp>&, const H&, const T ...)' 3054 | template<typename V, typename H, typename ... T> void resize(vector<V> &vec, const H &head, const T ... tail) { | ^~~~~~ a.cc:310:55: note: 'template<class V, class H, class ... T> void resize(std::vector<_Tp>&, const H&, const T ...)' previously declared here 310 | template<typename V, typename H, typenam
s081640828
p03745
C++
#include<iostream> using namespace std; int main(){ int n; cin >> n; int a[n]; for(int i = 0; i < n; i++)cin >> a[i]; int b[n]; for(int i = 0; i < n-1; i++)b[i] = a[i+1]-a[i]; int cnt = 1; for(int i = 1; i < n-1; i++){ if(b[i]*b[i-1]<0 && sign(b[i]) != 0 && sign(b[i-1]) != 0){ cnt += 1; i++; } } cout<<cnt<<endl; }
a.cc: In function 'int main()': a.cc:15:25: error: 'sign' was not declared in this scope; did you mean 'signed'? 15 | if(b[i]*b[i-1]<0 && sign(b[i]) != 0 && sign(b[i-1]) != 0){ | ^~~~ | signed
s807042762
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<long long> A(N); vector<int> A1(0) for (int i = 0; i<N; i++) cin >> A[i]; for (int i = 0; i<N-1; i++) { if(A[i+1]>A[i]) A1.push_back(1); else if(A[i+1]<A[i]) A1.push_back(-1); } int cnt = 0; for (int i = 0; i<A1.size()-1; i++) if(A1[i+1]!=A1[i]) cnt++; cout << cnt; }
a.cc: In function 'int main()': a.cc:8:3: error: expected ',' or ';' before 'for' 8 | for (int i = 0; i<N; i++) cin >> A[i]; | ^~~ a.cc:8:19: error: 'i' was not declared in this scope 8 | for (int i = 0; i<N; i++) cin >> A[i]; | ^
s879516990
p03745
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() typedef long long ll; using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #include<bits/stdc++.h> #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() typedef long long ll; using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll INF = 1LL<<58; int main(){ ll N; ll ans = 0; cin >> N; vector<ll> A(N); rep(i,A){ cin >> A[i]; } rep(i,A){ ans++; while(i+1<n&&a[i]==a[i+1]) i++; if(i==n-1) break; if(a[i]<=a[i+1]){ while(i+1<n&&a[i]<=a[i+1]) i++; }else{ while(i+1<n&&a[i]>=a[i+1]) i++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:33:15: error: cannot convert 'std::vector<long long int>' to 'int' in initialization 33 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:9:40: note: in definition of macro 'rep' 9 | #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:36:15: error: cannot convert 'std::vector<long long int>' to 'int' in initialization 36 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:9:40: note: in definition of macro 'rep' 9 | #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:38:17: error: 'n' was not declared in this scope 38 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:38:20: error: 'a' was not declared in this scope 38 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:39:13: error: 'n' was not declared in this scope 39 | if(i==n-1) break; | ^ a.cc:40:10: error: 'a' was not declared in this scope 40 | if(a[i]<=a[i+1]){ | ^ a.cc:41:19: error: 'n' was not declared in this scope 41 | while(i+1<n&&a[i]<=a[i+1]) i++; | ^ a.cc:43:20: error: 'n' was not declared in this scope 43 | while(i+1<n&&a[i]>=a[i+1]) i++; | ^
s254029613
p03745
C++
#include<bits/stdc++.h> #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll INF = 1LL<<58; int main(){ ll N; ll ans = 0; cin >> N; vector<ll> A(N); rep(i,N){ cin >> A[i]; } rep(i,N){ ans++; while(i+1<n&&A[i]==A[i+1]) i++; if(i==n-1) break; if(A[i]<A[i+1]){ while(i+1<n&&A[i]<=A[i+1]) i++; }else{ while(i+1<n&&A[i]>=A[i+1]) i++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:31:17: error: 'n' was not declared in this scope 31 | while(i+1<n&&A[i]==A[i+1]) i++; | ^ a.cc:32:13: error: 'n' was not declared in this scope 32 | if(i==n-1) break; | ^ a.cc:34:19: error: 'n' was not declared in this scope 34 | while(i+1<n&&A[i]<=A[i+1]) i++; | ^ a.cc:36:20: error: 'n' was not declared in this scope 36 | while(i+1<n&&A[i]>=A[i+1]) i++; | ^
s903922644
p03745
C++
#include<bits/stdc++.h> #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll INF = 1LL<<58; int main(){ ll N; ll ans = 0; cin >> N; vector<ll> A(N); rep(i,N){ cin >> A[i]; } rep(i,N){ ans++; while(i+1<n&&a[i]==a[i+1]) i++; if(i==n-1) break; if(a[i]<a[i+1]){ while(i+1<n&&a[i]<=a[i+1]) i++; }else{ while(i+1<n&&a[i]>=a[i+1]) i++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:31:17: error: 'n' was not declared in this scope 31 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:31:20: error: 'a' was not declared in this scope 31 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:32:13: error: 'n' was not declared in this scope 32 | if(i==n-1) break; | ^ a.cc:33:10: error: 'a' was not declared in this scope 33 | if(a[i]<a[i+1]){ | ^ a.cc:34:19: error: 'n' was not declared in this scope 34 | while(i+1<n&&a[i]<=a[i+1]) i++; | ^ a.cc:36:20: error: 'n' was not declared in this scope 36 | while(i+1<n&&a[i]>=a[i+1]) i++; | ^
s018504073
p03745
C++
#include<bits/stdc++.h> #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll INF = 1LL<<58; int main(){ ll N; ll ans = 0; cin >> N; vector<ll> A(N); rep(i,A){ cin >> A[i]; } rep(i,A){ ans++; while(i+1<n&&a[i]==a[i+1]) i++; if(i==n-1) break; if(a[i]<a[i+1]){ while(i+1<n&&a[i]<=a[i+1]) i++; }else{ while(i+1<n&&a[i]>=a[i+1]) i++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:26:15: error: cannot convert 'std::vector<long long int>' to 'll' {aka 'long long int'} in initialization 26 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:4:39: note: in definition of macro 'rep' 4 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:29:15: error: cannot convert 'std::vector<long long int>' to 'll' {aka 'long long int'} in initialization 29 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:4:39: note: in definition of macro 'rep' 4 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:31:17: error: 'n' was not declared in this scope 31 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:31:20: error: 'a' was not declared in this scope 31 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:32:13: error: 'n' was not declared in this scope 32 | if(i==n-1) break; | ^ a.cc:33:10: error: 'a' was not declared in this scope 33 | if(a[i]<a[i+1]){ | ^ a.cc:34:19: error: 'n' was not declared in this scope 34 | while(i+1<n&&a[i]<=a[i+1]) i++; | ^ a.cc:36:20: error: 'n' was not declared in this scope 36 | while(i+1<n&&a[i]>=a[i+1]) i++; | ^
s771410850
p03745
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() typedef long long ll; using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #include<bits/stdc++.h> #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll INF = 1LL<<58; int main(){ ll N; ll ans = 0; cin >> N; vector<ll> A(N); rep(i,A){ cin >> A[i]; } rep(i,A){ ans++; while(i+1<n&&a[i]==a[i+1]) i++; if(i==n-1) break; if(a[i]<a[i+1]){ while(i+1<n&&a[i]<=a[i+1]) i++; }else{ while(i+1<n&&a[i]>=a[i+1]) i++; } } cout << ans << endl; }
a.cc:11:9: warning: "rep" redefined 11 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) | ^~~ a.cc:2:9: note: this is the location of the previous definition 2 | #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) | ^~~ a.cc: In function 'int main()': a.cc:33:15: error: cannot convert 'std::vector<long long int>' to 'll' {aka 'long long int'} in initialization 33 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:11:39: note: in definition of macro 'rep' 11 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:36:15: error: cannot convert 'std::vector<long long int>' to 'll' {aka 'long long int'} in initialization 36 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:11:39: note: in definition of macro 'rep' 11 | #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:38:17: error: 'n' was not declared in this scope 38 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:38:20: error: 'a' was not declared in this scope 38 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:39:13: error: 'n' was not declared in this scope 39 | if(i==n-1) break; | ^ a.cc:40:10: error: 'a' was not declared in this scope 40 | if(a[i]<a[i+1]){ | ^ a.cc:41:19: error: 'n' was not declared in this scope 41 | while(i+1<n&&a[i]<=a[i+1]) i++; | ^ a.cc:43:20: error: 'n' was not declared in this scope 43 | while(i+1<n&&a[i]>=a[i+1]) i++; | ^
s220338909
p03745
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() typedef long long ll; using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #include<bits/stdc++.h> #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) #define all(x) (x).begin(),(x).end() typedef long long ll; using namespace std; #define sz(x) ((int)(x).size()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMSET(v, h) memset((v), h, sizeof(v)) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define pb push_back #define mp make_pair #define y0 y3487465 #define y1 y8687969 #define j0 j1347829 #define j1 j234892 ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll INF = 1LL<<58; int main(){ ll N; ll ans = 0; cin >> N; vector<ll> A(N); rep(i,A){ cin >> A[i]; } rep(i,A){ ans++; while(i+1<n&&a[i]==a[i+1]) i++; if(i==n-1) break; if(a[i]<a[i+1]){ while(i+1<n&&a[i]<=a[i+1]) i++; }else{ while(i+1<n&&a[i]>=a[i+1]) i++; } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:33:15: error: cannot convert 'std::vector<long long int>' to 'int' in initialization 33 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:9:40: note: in definition of macro 'rep' 9 | #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:36:15: error: cannot convert 'std::vector<long long int>' to 'int' in initialization 36 | rep(i,A){ | ^ | | | std::vector<long long int> a.cc:9:40: note: in definition of macro 'rep' 9 | #define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i) | ^ a.cc:38:17: error: 'n' was not declared in this scope 38 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:38:20: error: 'a' was not declared in this scope 38 | while(i+1<n&&a[i]==a[i+1]) i++; | ^ a.cc:39:13: error: 'n' was not declared in this scope 39 | if(i==n-1) break; | ^ a.cc:40:10: error: 'a' was not declared in this scope 40 | if(a[i]<a[i+1]){ | ^ a.cc:41:19: error: 'n' was not declared in this scope 41 | while(i+1<n&&a[i]<=a[i+1]) i++; | ^ a.cc:43:20: error: 'n' was not declared in this scope 43 | while(i+1<n&&a[i]>=a[i+1]) i++; | ^
s019304130
p03745
C++
1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 | ^
s720672087
p03745
C++
#include<bits/stdc++.h> sing namespce std; #tyepdef long long ll; int main(){ ll N; cin>>N; vctor<ll> A{ }(N); for(ll i=0;i<N;i++){ cin>>A[i]; } bool up=false,down=false; int CNT=1; for(ll i-1;i<N;i++){ if(A[i]>A[i-1]){ up=true; if(down){ CNT++; up=false; down=false } } else if(A[i]<A[i-1]){ down=true; if(up){ CNT++; up=false; down=false; } } } cout<<CNT<<endl; }
a.cc:3:2: error: invalid preprocessing directive #tyepdef 3 | #tyepdef long long ll; | ^~~~~~~ a.cc:2:1: error: 'sing' does not name a type 2 | sing namespce std; | ^~~~ a.cc: In function 'int main()': a.cc:6:3: error: 'll' was not declared in this scope 6 | ll N; | ^~ a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 7 | cin>>N; | ^~~ | std::cin In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146, from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:7:8: error: 'N' was not declared in this scope 7 | cin>>N; | ^ a.cc:8:3: error: 'vctor' was not declared in this scope 8 | vctor<ll> A{ | ^~~~~ a.cc:8:13: error: 'A' was not declared in this scope 8 | vctor<ll> A{ | ^ a.cc:11:9: error: expected ';' before 'i' 11 | for(ll i=0;i<N;i++){ | ^~ | ; a.cc:11:14: error: 'i' was not declared in this scope 11 | for(ll i=0;i<N;i++){ | ^ a.cc:16:9: error: expected ';' before 'i' 16 | for(ll i-1;i<N;i++){ | ^~ | ; a.cc:16:14: error: 'i' was not declared in this scope 16 | for(ll i-1;i<N;i++){ | ^ a.cc:22:19: error: expected ';' before '}' token 22 | down=false | ^ | ; 23 | } | ~ a.cc:34:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 34 | cout<<CNT<<endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:34:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 34 | cout<<CNT<<endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s196946638
p03745
C++
#include <bits/stdc++.h> using namespace std; int getSign(int i){ int res=(i==0:0?(i>0:1?-1)); return res; } int main(){ int N; cin >> N; vector<int> A(N); for (int i=0;i<N;i++){ cin >> A[i]; } int pre=A[0]; int sign0=0; int sign1; int cnt=1; for (int i=1;i<N;i++){ sign1=getSign(A[i]-pre); if(sign0*sign1<0){ cnt++; sign0=0; }else{ if(sign0==0 and sign1 !=0)sign0=sign1; } pre=A[i]; } cout <<cnt <<endl; return 0; }
a.cc: In function 'int getSign(int)': a.cc:5:18: error: expected ')' before ':' token 5 | int res=(i==0:0?(i>0:1?-1)); | ~ ^ | )
s954213365
p03745
C++
#include <bits/stdc++.h> using namespace std; int getSign(int i){ return (i==0:0?(i>0:1?-1));} int main(){ int N; cin >> N; vector<int> A(N); for (int i=0;i<N;i++){ cin >> A[i]; } int pre=A[0]; int sign0=0; int sign1; int cnt=1; for (int i=1;i<N;i++){ sign1=getSign(A[i]-pre); if(sign0*sign1<0){ cnt++; sign0=0; }else{ if(sign0==0 and sign1 !=0)sign0=sign1; } pre=A[i]; } cout <<cnt <<endl; return 0; }
a.cc: In function 'int getSign(int)': a.cc:5:17: error: expected ')' before ':' token 5 | return (i==0:0?(i>0:1?-1));} | ~ ^ | )
s651490727
p03745
C++
#include<iostream> using namespace std; int main() { int n; cin>>n; int ans=1; int flag=0; int bef; cin>>bef; for(int i=1;i<n;i++) { int a; cin>>a; if(flag==0) { if(a>bef)flag=1; if(a<bef)flag=2; } else if(flag==1) { if(a<bef) { ans++; flag=0; } } else { if(a>bef) { ans++; flag=0; } } bef=a; } cour<<ans<<endl; }
a.cc: In function 'int main()': a.cc:40:3: error: 'cour' was not declared in this scope 40 | cour<<ans<<endl; | ^~~~
s473161075
p03745
C
//#include "pch.h" #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #define ll long long #define fr(i,l,r) for(i=(l);i<(r);i++) #define min(p,q) ((p)<(q)?(p):(q)) #define max(p,q) ((p)>(q)?(p):(q)) #define INF 1000000000000//10^12 int main(void) { //変数の宣言 int n; int a[100010]; //よく使う変数 int i,j,k,l; int flag=0; int ans=0; int count=0; int temp,temp1,temp2; int max,min; int len; int sum=0; //データの読み込み scanf("%d",&n); // scanf_s("%d",&n); for(i=0;i<n;i++){ // scanf("%d",&a[i]); scanf_s("%d",&a[i]); } // printf("nは%dです\n", n); // printf("データの読み込み終了\n"); //実際の処理 temp=0; ans=1; for(i=1;i<n;i++){ if(temp==0){ if(a[i]>a[i-1]){ temp=1; }else if(a[i]<a[i-1]){ temp=-1; } }else if(a[i]>a[i-1]&&temp==-1){ ans++; temp=0; }else if(a[i]<a[i-1]&&temp==1){ ans++; temp=0; } } // printf("計算部分終了\n"); //出力 printf("%d",ans); // printf("結果の出力終了\n"); return 0; }
main.c: In function 'main': main.c:39:17: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration] 39 | scanf_s("%d",&a[i]); | ^~~~~~~ | scanf
s968293191
p03745
C++
int main() { int n; cin >> n; long a[110000]; bool u; bool d; int c = 1; for(int i = 0; i < n; i++) cin >> a[i]; for(int i = 0; i < n - 1; i++) { if(a[i] < a[i+1]) u = true; if(a[i] > a[i+1]) d = true; if(u && d){ u = d = false; c++; } } cout << c << endl; }
a.cc: In function 'int main()': a.cc:3:5: error: 'cin' was not declared in this scope 3 | cin >> n; | ^~~ a.cc:18:5: error: 'cout' was not declared in this scope 18 | cout << c << endl; | ^~~~ a.cc:18:18: error: 'endl' was not declared in this scope 18 | cout << c << endl; | ^~~~
s026007460
p03745
C++
#include <stdio.h> #include <cstdlib> #include <iostream> using namespace std; int count(const int *array, int size) { enum Arranged { None = -1, Ascending, Descending }; int splitNum = 0; Arranged arranged = array[0] < array[1] ? Ascending : Descending; Arranged prevState = arranged; for (int i = 1; i < size - 1; ++i) { if ((arranged == Ascending && array[i] > array[i + 1]) || (arranged == Descending && array[i] < array[i + 1])) { splitNum++; i++; arranged = array[i] < array[i + 1] ? Ascending : Descending; } } return splitNum + 1; } int main() { int *array; int array_len; cin>>array_len; if (array_len == 1) { printf("0"); return 0; } array = (int*)malloc((size_t)array_len); for (int i = 0; i < size; ++i) cin>>array[i]; printf("%d", count(array, array_len)); free(array); return 0; }
a.cc: In function 'int main()': a.cc:39:23: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<' 39 | for (int i = 0; i < size; ++i) cin>>array[i]; | ~~^~~~~~
s449412981
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i ++) { cin >> a.at(i); } decltype(v)::iterator result = unique(a.begin(), a.end()); a.erase(result, a.end()); int cnt = 1; for (int i = 1; i < a.size(); i ++) { bool incre1 = a.at(i - 1) < a.at(i); bool incre2 = a.at(i) < a.at(i + 1); if (incre1 != incre2) { cnt ++; i ++; } } cout << cnt << endl; }
a.cc: In function 'int main()': a.cc:11:12: error: 'v' was not declared in this scope 11 | decltype(v)::iterator result = unique(a.begin(), a.end()); | ^ a.cc:11:25: error: expected initializer before 'result' 11 | decltype(v)::iterator result = unique(a.begin(), a.end()); | ^~~~~~ a.cc:12:11: error: 'result' was not declared in this scope 12 | a.erase(result, a.end()); | ^~~~~~
s754809820
p03745
C++
#include <bits/stdc++.h> using namespace std; long long n,a[100010]; int main(){ cin>>n; for(int i=0;i<n;++i){cin>>k[i];} long long ans=1,mon=0; for(int i=0;i<n-1;++i){ if(mon==0){ if(k[i]<k[i+1]) mon=1; else if(k[i]>k[i+1]) mon=-1; } else if(mon>0){ if(k[i]>k[i+1]){ ++ans; mon=0; } } else if(mon<0){ if(k[i]<k[i+1]){ ++ans; mon=0; } } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:6:29: error: 'k' was not declared in this scope 6 | for(int i=0;i<n;++i){cin>>k[i];} | ^ a.cc:10:10: error: 'k' was not declared in this scope 10 | if(k[i]<k[i+1]) | ^ a.cc:16:10: error: 'k' was not declared in this scope 16 | if(k[i]>k[i+1]){ | ^ a.cc:22:10: error: 'k' was not declared in this scope 22 | if(k[i]<k[i+1]){ | ^
s959556827
p03745
C++
#include<iostream> using namespace std; int main() { long long n,a[10005],cnt=1,flag=2; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<n;i++) { if(a[i]<a[i+1]&&flag!=1) flag=0; if(a[i]>a[i+1]&&flag!=0) flag=1; if(a[i]<a[i+1]&&flag==1) { cnt++; flag=2; } if(a[i]>a[i+1]&&flag==0) { cnt++; flag=2; } } cout<<cnt<<endl; return 0; } flag=2; } if(a[i]>a[i+1]&&flag==0) { cnt++; flag=2; } } cout<<cnt<<endl; return 0; }
a.cc:26:25: error: 'flag' does not name a type 26 | flag=2; | ^~~~ a.cc:27:17: error: expected declaration before '}' token 27 | } | ^ a.cc:28:17: error: expected unqualified-id before 'if' 28 | if(a[i]>a[i+1]&&flag==0) | ^~ a.cc:33:9: error: expected declaration before '}' token 33 | } | ^ a.cc:34:9: error: 'cout' does not name a type 34 | cout<<cnt<<endl; | ^~~~ a.cc:35:9: error: expected unqualified-id before 'return' 35 | return 0; | ^~~~~~ a.cc:36:1: error: expected declaration before '}' token 36 | } | ^
s847732854
p03745
C++
import pdb def main(): num = int(input()) array = [] tmp = input() for i in range(num): array.append(int(tmp.split()[i])) ans = 1 div = 0 prev = 0 count = 0 #pdb.set_trace() for tmp in array: if(count == 0): prev = tmp count = 1 continue if prev < tmp and div == -1: ans += 1 div = 0 prev = tmp continue elif prev > tmp and div == 1: ans += 1 div = 0 prev = tmp continue if div == 0: if prev < tmp: div = 1 elif prev > tmp: div = -1 prev = tmp print(ans) if __name__ == '__main__': main()
a.cc:16:6: error: invalid preprocessing directive #pdb 16 | #pdb.set_trace() | ^~~ a.cc:45:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 45 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import pdb | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'