submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s209540103
p03747
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } using i64=int64_t; i64 n,l,t; i64 calc_count(i64 a,i64 b){ i64 d; if(a<b) d=b-a; else d=l-a+b; if(2*t<d) return 0; return 1+(2*t-(d+d%2))/l; } void solve(){ cin >> n >> l >> t; vector<i64> x(n),w(n); rep(i,0,n) cin >> x[i] >> w[i]; i64 num=0; rep(i,1,n){ if(w[i]==w[0]) continue; i64 a=x[0],b=x[i]; if(w[i]==1) swap(a,b); num=((num+calc_count(a,b)*(w[0]==1?1:-1)%n)%n+n)%n; } vector<pair<i64,int>> y(n); rep(i,0,n) y[i]=make_pair(((x[i]+t*(w[i]==1?1:-1))%l+l)%l,w[i]); auto tmp=make_pair(y[0],w[0]); sort(y.begin(),y.end()); int j=find(y.begin(),y.end(),tmp)-y.begin(); vector<i64> ans(n); rep(i,0,n) ans[(num+i)%n]=y[(i+j)%n].first; rep(i,0,n) cout << ans[i] << endl; } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_equals_val<_Value>::operator()(_Iterator) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long int, int>*, std::vector<std::pair<long int, int> > >; _Value = const std::pair<std::pair<long int, int>, long int>]': /usr/include/c++/14/bits/stl_algobase.h:2107:14: required from '_RandomAccessIterator std::__find_if(_RandomAccessIterator, _RandomAccessIterator, _Predicate, random_access_iterator_tag) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long int, int>*, vector<pair<long int, int> > >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const pair<pair<long int, int>, long int> >]' 2107 | if (__pred(__first)) | ~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:2152:23: required from '_Iterator std::__find_if(_Iterator, _Iterator, _Predicate) [with _Iterator = __gnu_cxx::__normal_iterator<pair<long int, int>*, vector<pair<long int, int> > >; _Predicate = __gnu_cxx::__ops::_Iter_equals_val<const pair<pair<long int, int>, long int> >]' 2152 | return __find_if(__first, __last, __pred, | ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 2153 | std::__iterator_category(__first)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:3850:28: required from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = __gnu_cxx::__normal_iterator<pair<long int, int>*, vector<pair<long int, int> > >; _Tp = pair<pair<long int, int>, long int>]' 3850 | return std::__find_if(__first, __last, | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ 3851 | __gnu_cxx::__ops::__iter_equals_val(__val)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:54:15: required from here 54 | int j=find(y.begin(),y.end(),tmp)-y.begin(); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:270:24: error: no match for 'operator==' (operand types are 'std::pair<long int, int>' and 'const std::pair<std::pair<long int, int>, long int>') 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1208:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator==(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1208 | operator==(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1208:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1216:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator==(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1216 | operator==(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1216:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181: /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'const std::pair<std::pair<long int, int>, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'const std::pair<std::pair<long int, int>, long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: 'std::pair<long int, int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /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: /usr/include/c++/14/bits/predefined_ops.h:270:24: note: deduced conflicting types for parameter '_T1' ('long int' and 'std::pair<long int, int>') 270 | { return *__it == _M_value; } | ~~~~~~^~~~~~~~~~~ /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
s538431395
p03747
C++
#include <vector> #include <algorithm> using namespace std; long long int n, l, t, f, m, k; vector<long long int> x[2]; vector<long long int> y; int main(){ scanf("%lld %lld %lld", &n, &l, &t); for(int i=0; i<n; ++i){ long long int a, b; scanf("%lld %lld", &a, &b); x[b-1].push_back(a); y.push_back(((3-2*b)*(t%l)+a+l)%l); if(i==0 && b==1) f=1; } k=y[0]; sort(y.begin(), y.end()); for(int i=0; i<x[f].size(); ++i) if((-f*(x[f][i]-x[1-f][0])+l)%l<2*t) ++m; for(int i=0; i<n; ++i) if(y[i]==k){ for(int j=0; j<n; ++j) printf("%lld\n", y[(i+j+(1-2*f)*m+n)%n]); break; } }
a.cc: In function 'int main()': a.cc:10:9: error: 'scanf' was not declared in this scope 10 | scanf("%lld %lld %lld", &n, &l, &t); | ^~~~~ a.cc:25:33: error: 'printf' was not declared in this scope 25 | printf("%lld\n", y[(i+j+(1-2*f)*m+n)%n]); | ^~~~~~ a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 2 | #include <algorithm> +++ |+#include <cstdio> 3 | using namespace std;
s002169854
p03747
C++
/* #pragma region GNUC //https://yukicoder.me/wiki/auto_vectorization #ifdef __GNUC__ #pragma GCC optimize ("O3") #pragma GCC target ("avx") #endif #pragma endregion */ #define _USE_MATH_DEFINES #pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <string> #include <cstring> #include <vector> #include <tuple> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; ///////// #pragma region Math #pragma region template<class T> inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;} #pragma endregion // 最大公約数 gcd #pragma region template<class T> inline T lcm(T a, T b){return a / gcd(a, b) * b;} #pragma endregion // 最小公倍数 lcm #pragma region LL powMod(LL num,LL n,LL mod=(LL)MOD){ if( n == 0 ){ return (LL)1; } LL mul = num; LL ans = (LL)1; while(n){ if( n&1 ){ ans = (ans*mul)%mod; } mul = (mul*mul)%mod; n >>= 1; } return ans; } #pragma endregion //繰り返し二乗法 powMod #pragma region template<class T> vector<T> getDivisor(T n){ vector<T> v; for(int i=1;i*i<=n;++i){ if( n%i == 0 ){ v.push_back(i); if( i != n/i ){//平方数で重複して数えないように v.push_back(n/i); } } } sort(v.begin(), v.end()); return v; } #pragma endregion //約数列挙 getDivisor(n):O(√n) #pragma endregion //math //Utility:便利な奴 #pragma region template<class T> void UNIQUE(vector<T>& vec){ sort(vec.begin(),vec.end()); vec.erase(unique(vec.begin(),vec.end()),vec.end() ); } #pragma endregion // sort erase unique //////////////////////////////// #pragma region long long bitcount64(long long bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >>16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >>32 & 0x00000000ffffffff); } #pragma endregion //その他 //////////////////////////////// struct edge_base{int to;LL cost;}; edge_base make_edge_base(int to,LL cost){ edge_base ret = {to,cost}; return ret; } #pragma region GRL #pragma region //グラフ template<class T,class EDGE> void dijkstra(int root,int V,vector<T>& dist, vector< vector<EDGE> > G ){ priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > > que; dist.assign(V,LINF); dist[root] = 0; que.push(pair<T,int>(0,root));//距離、頂点番号 while( !que.empty() ){ pair<T,int> p = que.top();que.pop(); int v = p.second; if( dist[v] < p.first ) continue; for(int i=0;i < (int)G[v].size();++i){ EDGE e = G[v][i]; if( dist[e.to] > dist[v] + e.cost ){ dist[e.to] = dist[v] + e.cost; que.push(pair<T,int>(dist[e.to],e.to)); } } } } #pragma endregion //ダイクストラ法:O(|E|log|V|) #pragma region //グラフ void warshall_floyd(vector<vector<LL> >& dist,int V,const LL INF=LINF){ for(int k=0;k<V;++k){ for(int i=0;i<V;++i){ if( dist[i][k] >= INF ) continue; for(int j=0;j<V;++j){ if( dist[k][j] >= INF )continue; dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]); } } } } #pragma endregion //ワーシャルフロイド:O(|V|**3) #pragma region namespace FLOW{ //vector< vector<FLOW:edge> > G; struct edge_flow : public edge_base{ int cap; int rev; }; edge_flow make_edge_flow(int to,int cap,int rev,LL cost=1){ edge_flow ret; ret.to = to; ret.cost = cost; ret.cap = cap; ret.rev = rev; return ret; } class Graph{ public: int V; vector< vector<FLOW::edge_flow> > G; vector< LL > dist; vector< int > iter; void init(int v){ V = v; G.resize(V); } //directed graph void add_edge(int from,int to,int cap){ G[from].push_back( FLOW::make_edge_flow(to,cap,G[to].size()) ); G[to].push_back( FLOW::make_edge_flow(from,0,G[from].size()-1) ); } private: //sから最短距離をBFSで計算する void bfs(int s){//許容量もチェックしている queue<int> que; dist = vector<LL>(V,-1); dist[s] = 0; que.push(s); while(!que.empty()){ int v = que.front();que.pop(); for(int i=0;i<(int)G[v].size();++i){ edge_flow &e = G[v][i]; if( e.cap > 0 && dist[e.to] < 0 ){ dist[e.to] = dist[v] + 1; que.push(e.to); } } } } private: //増加パスをDFSで探す int dfs(int v,int t,int f){ if( v==t ) return f; for(int &i = iter[v];i<(int)G[v].size();++i){//? FLOW::edge_flow &e = G[v][i]; if( e.cap>0 && dist[v] < dist[e.to]){ int d = this->dfs(e.to, t, min(f,e.cap) ); if( d > 0){ e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } public: //sからtへの最大流量を求める int max_flow(int s,int t){ int flow = 0; for(;;){ this->bfs(s); if( dist[t] < 0 ) return flow; iter = vector<int>(V,0); int f; while( (f = this->dfs(s,t,INF) ) > 0 ){ flow += f; } } } }; } #pragma endregion //dinic :O(|E||V|^2) #pragma region //グラフ bool is_bipartite(int v,int c,vector< vector<int> >& G,vector<int>& Color){ Color[v] = c; for(int i=0;i < (int)G[v].size();++i){//隣接グラフ if(Color[ G[v][i] ] == c ) return false; if(Color[ G[v][i] ] == 0 && !is_bipartite(G[v][i],-c,G,Color) ){ return false; } } return true; } bool is_bipartite(int Root,vector< vector<int> >& Graph){ int GraphSize = Graph.size(); vector<int> Color(GraphSize,0); const int ColorNo = 1; return is_bipartite(Root,ColorNo,Graph,Color); } #pragma endregion //二部グラフチェック is_bipartite(root,GraphList) #pragma endregion // #pragma region //http://sugarknri.hatenablog.com/entry/2016/07/16/165715 void makeinv(vector<LL>& inv,const LL P){ int i; const int varMAX = 1000000; inv = vector<LL>( varMAX+1,0); inv[1]=1; for(i=2;i<=varMAX;i++){ inv[i] = (inv[P%i] * (P-P/i)%P ) % P;//OVF //inv[i] = powMod(i,P-2,P); } } LL nCk(LL N,LL k,LL mod = MOD){ static vector<LL> inv;//modの逆元 if( inv.size() == 0 ){ makeinv(inv,mod);//modは素数を入れる } k = min(k,N-k); if( k < 0 ){return 0;} if( k == 0 ){return 1;} if( k == 1 ){return N%mod;} LL ret = 1; for(int i=1;i<=k;++i){ ret = (ret * ((N+1-i)%mod) )%mod;//ret*N:OVF ret = (ret * inv[i] )%mod; //ret *= ((N+1-i)*inv[i])%mod;//OVF //ret %= mod; } return ret; } LL nCk_once(LL N,LL k,LL mod = MOD){//modは素数 k = min(k,N-k); if( k < 0 ){return 0;} if( k == 0 ){return 1;} if( k == 1 ){return N%mod;} LL ret = 1; LL A=1; for(LL i=0;i<k;++i){ A = (A * ((N-i)%mod) ) % mod; } LL B=1; for(LL i=2;i<=k;++i){ B = (B * (i%mod) ) % mod; } ret = ( A * powMod(B,mod-2,mod) ) % mod; return ret; } #pragma endregion //組み合わせnCk(,10^5) #pragma region vector< vector<LL> > NCK; LL nCk_base(int N,int K,LL mod=MOD){ K = min(K,N-K); if( K==0 ){return 1%mod;} if( K==1 ){return N%mod;}//%MOD; if( N<=10000 && NCK[N][K] ){ return NCK[N][K]; } //N個目を使わない:nCk(N-1,k) //N個目を使う :nCk(N-1,k-1) LL ans = (nCk_base(N-1,K)+nCk_base(N-1,K-1) )%mod;//%MOD; if( N<=10000 ){ NCK[N][K] = ans; } return ans; } #pragma endregion //組み合わせ メモ? #pragma region CGL class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y){} Point operator + (Point p){return Point(add(x,p.x),add(y,p.y));} void operator += (Point p){x=add(x,p.x);y=add(y,p.y);} Point operator - (Point p){return Point(add(x,-p.x),add(y,-p.y));} void operator -= (Point p){x=add(x,-p.x);y=add(y,-p.y);} Point operator * (double a){return Point(x*a,y*a);} double operator * (Point p){return dot(p);} Point operator / (double a){return Point(x/a,y/a);} double norm(){return sqrt(x*x+y*y);} double dot(Point p){return add(x*p.x,y*p.y);} double rot(Point p){return add(x*p.y,-y*p.x);} double add(double a,double b){ double EPS = 1e-10; if( abs(a+b) < EPS*(abs(a)+abs(b)) ){ return 0; } return a+b; } }; istream& operator>>(istream& in,Point& P){ in >> P.x >> P.y; return in; } //線分で表した直線の交差判定 bool is_cross(Point p1,Point p2,Point q1,Point q2){ double res = (p2-p1).rot(q2-q1); return res != 0;//平行なら0 } /*ccwへ//線分p1-p2上に点qがあるか判定 bool on_seg(Point p1,Point p2,Point q){ return (p1-q).rot(p2-q) == 0 && (p1-q).dot(p2-q) <= 0; }*/ //直線p1-p2と直線q1-q2の交点 //交差判定をしてから使う:0除算 Point intersection(Point p1,Point p2,Point q1,Point q2){ return p1+(p2-p1)*((q2-q1).rot(q1-p1)/(q2-q1).rot(p2-p1)); } //線分ABに対する点C enum PointPotion{ONLINE_BACK=-2,CLOCKWISE,ON_SEGMENT,COUNTER_CLOCKWISE,ONLINE_FRONT}; PointPotion ccw(Point A,Point B,Point C){ B -= A;C -=A; if( B.rot(C) > 0 ) return COUNTER_CLOCKWISE;//+1 if( B.rot(C) < 0 ) return CLOCKWISE;//-1 if( B.dot(C) < 0 ) return ONLINE_BACK;//-2 if( B.norm() < C.norm() ) return ONLINE_FRONT;//+2 return ON_SEGMENT;//0 } //線分p1-p2,と線分q1-q2の交差判定 //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B bool intersect(Point p1,Point p2,Point q1,Point q2){ return (ccw(p1,p2,q1) * ccw(p1,p2,q2) <= 0) && (ccw(q1,q2,p1) * ccw(q1,q2,p2) <= 0); } /// //直線p1-p2と点q1の距離 double dist_LineP(Point p1,Point p2,Point q1){ return abs( (p2-p1).rot(q1-p1) )/(p2-p1).norm(); } //線分p1-p2と点q1の距離 double dist_SegP(Point p1,Point p2,Point q1){ //(日) if( (p2-p1).dot(q1-p1) < 0 ){ return (q1-p1).norm();//p1から見てp2と逆方向 } if( (p1-p2).dot(q1-p2) < 0 ){ return (q1-p2).norm();//p2から見てp1と逆方向 } return dist_LineP(p1,p2,q1);//垂線下ろす } // 線分同士の最短距離 //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D //http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=862507#1 double dist_segseg(Point A1,Point A2,Point B1,Point B2){ if( intersect(A1,A2,B1,B2) ){ return 0; } return min( min(dist_SegP(A1,A2,B1), dist_SegP(A1,A2,B2) ), min(dist_SegP(B1,B2,A1), dist_SegP(B1,B2,A2) ) ); } #pragma endregion //class Point #pragma region CGL //多角形内なら2,線上なら1,外なら0 //http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_3_C //http://www.prefield.com/algorithm/geometry/contains.html //点Pから半直線を引く、ガウス int contains(vector<Point>& v,Point& P){ bool in = false; const int N = v.size(); for(int i=0;i<N;++i){ Point A = (v[i]-P); Point B = (v[(i+1)%N]-P); if( A.y > B.y ) swap(A,B); if( A.y <= 0 && 0 < B.y ){ if( A.rot(B) < 0 ) in =!in; } if( A.rot(B) == 0 && A.dot(B) <= 0 ){ return 1;//ON 線上 } } return in ? 2:0;//中:外 } #pragma endregion //contains #pragma region CGL //辞書順で比較 bool cmp_x(const Point& p,const Point& q){ if( p.x != q.x ) return p.x < q.x; return p.y < q.y; } //凸包を求める vector<Point> convex_hull(vector<Point> ps,int n){ sort(ps.begin(),ps.end(), cmp_x); int k = 0;//凸包の頂点数 vector<Point> qs(n*2);//構築中の凸包 //下側の凸包の作成 for(int i=0;i<n;++i){ while(k>1 && (qs[k-1]-qs[k-2]).rot(ps[i]-qs[k-1]) <=0){//<で線上も加える k--; } qs[k++] = ps[i]; } //上側凸包の作成 for(int i=n-2,t=k;i>=0;i--){ while(k>t && (qs[k-1]-qs[k-2]).rot(ps[i]-qs[k-1]) <=0){//< k--; } qs[k++] = ps[i]; } qs.resize(k-1); return qs; } #pragma endregion //凸包 #pragma region DSL #pragma region DSL class UnionFind{ public: int cNum;//要素数 vector<int> parent; vector<int> count; vector< vector<int> > GList; UnionFind(int n){ cNum = n; parent = vector<int>(n); count = vector<int>(n,1); GList.resize(n); for(int i=0;i<n;++i){ parent[i] = i; GList[i].push_back(i); } } int find(int x){ if( parent[x] == x ){return x;} return parent[x] = find( parent[x] ); } bool same(int x,int y){return find(x) == find(y);} int Count(int x){return count[find(x)];} void add(int x,int y){//union x = find(x); y = find(y); if( x==y )return; parent[x] = y; count[y] += count[x]; if( GList[y].size() < GList[x].size() ){ swap(GList[x],GList[y]); } GList[y].insert( GList[y].end(), GList[x].begin(),GList[x].end() ); } }; #pragma endregion //UnionFind #pragma region DSL class segment{ int n; int OTHER_VAL; int NUM_NULL; vector< int > dat; public: int getN(){return n;} void init(int size,int num=INF,int num_null=-1){//N:要素数,最大値 OTHER_VAL = num; NUM_NULL = num_null; n = 2; while(n < size ){ n <<= 1; } dat.assign(n<<1, OTHER_VAL ); } void init(vector<int> vec,int size,int num=INF){ OTHER_VAL = num; n = 2; while(n < size ){ n <<= 1; } dat.assign(n<<1,OTHER_VAL ); for(int i=0;i<size;++i){ update(i,vec[i]); } } int SELECT(int L,int R){ return min(L,R); } void update(int i,int x){ i += n; while(i){ dat[i] = SELECT(dat[i],x); i >>= 1; } } void update(int X,int Y,int VAL){ //全体の範囲は閉区間、 update(1,0,n-1,X,Y,VAL); } private: void update(int t,int L,int R,int X,int Y,int VAL){ //親から子へ進んでいく if( L == X && R == Y){ dat[t] = VAL; }else{ int mid = (L+R)/2; if( dat[t] != NUM_NULL ){//値の伝播 dat[t*2+0] = dat[t]; dat[t*2+1] = dat[t]; dat[t] = NUM_NULL; } if( Y <= mid ){ update(t*2+0,L,mid,X,Y,VAL); }else if( X > mid ){ update(t*2+1,mid+1,R,X,Y,VAL); }else{ update(t*2+0,L,mid,X,mid,VAL); update(t*2+1,mid+1,R,mid+1,Y,VAL); } } } public: //query(a,b,0,0,n)//[a,b)半開区間 int query(int a,int b){ return query(a,b,1,0,n);//n==getNを使う } private: int query(int a,int b,int k,int l,int r){ if(r<=a || b<=l)return OTHER_VAL;//交差しない if(a<=l && r<=b && dat[k]!=NUM_NULL)return dat[k]; int res = OTHER_VAL; int mid = (l+r)>>1; if( a < mid ) res = SELECT(res,query(a,b,k*2+0,l,mid) ); if( mid < b ) res = SELECT(res,query(a,b,k*2+1,mid,r) ); return res; } }; #pragma endregion //segment tree #pragma region DSL class BITree{//1-index int N; vector<LL> bit; public: BITree(int n){ N = n; bit = vector<LL>(N+1,0);//1-index } void add(int a,LL w){ for(int i=a;i<=N;i += i & -i){ bit[i] += w; } } LL sum(int a){//[1,a)の和 LL ret = 0; for(int i=a; i > 0; i -= i & -i){ ret += bit[i]; } return ret; } }; #pragma endregion //BIndexTree #pragma endregion // #pragma region template<class T,class U> istream& operator>>(istream& in,pair<T,U>& P){ in >> P.first >> P.second; return in; } #pragma endregion //cin pair<T,U> #pragma region template<class T> istream& operator>>(istream& in,vector<T>& v){ int size = v.size(); for(int i=0;i<size;++i){ in >> v[i]; } return in; } #pragma endregion //cin vector<int> #pragma region //行列の積 template<class T> vector< vector<T> > operator*( vector<vector<T> >& A,vector< vector<T> >& B){ LL mod = MOD; int R = A.size(); int cen = A[0].size(); int C = B[0].size(); vector< vector<T> > ans(R,vector<T>(C,0) ); for(int row=0;row<R;++row){ for(int col=0;col<C;++col){ for(int inner=0;inner< cen;++inner){ ans[row][col] = (ans[row][col] + A[row][inner]*B[inner][col])%mod; //ans[row][col] = (ans[row][col] + A[row][inner]*B[inner][col]); } } } return ans; } template<class T> vector< vector<T> > powMod(vector< vector<T> > mat,LL N){ int R = mat.size(); int C = mat[0].size(); //R==C vector< vector<T> > I(R,vector<T>(C,0));//単位元 for(int i=0;i<R && i<C;++i){ I[i][i] = 1; } if( N == 0 ){ return I; } vector< vector<T> > mul(R,vector<T>(C)),ans(R,vector<T>(C)); ans = I; mul = mat; while(N){ if( N & 1 ){ ans = ans*mul; } N >>= 1; mul = mul*mul; } return ans; } #pragma endregion //行列 #pragma region namespace TIME{ time_t start,limit; void time_start(){start = time(NULL);} void time_set(int num){limit = num;}//秒 bool check(){return (time(NULL)-start < limit);} } #pragma endregion //時間計測 /* #pragma region namespace RAND{ mt19937 mt; void rand_init(){ random_device rnd; mt = mt19937(rnd()); } int rand(){ return mt(); } } #pragma endregion //乱数 */ #pragma region #pragma endregion // //////////////////// #pragma region double area(vector<Point> poly){ int size = poly.size(); double ans = 0; for(int i=1;i<size-1;++i){ ans += (poly[i]-poly[0]).rot(poly[i+1]-poly[0])/2; } return ans; } #pragma endregion //多角形の面積 //////////////////// #pragma region CGL bool compare_x(Point A,Point B){ return A.x < B.x; } bool compare_y(Point A,Point B){ return A.y < B.y; } //vecはx座標の昇順で渡される double closest_pair(vector<Point>::iterator itr,int N){ if( N <= 1 ) return INF; int m = N/2; double x = (itr+m)->x; double d = min(closest_pair(itr,m), closest_pair((itr+m),N-m) ); inplace_merge(itr,itr+m,itr+N,compare_y); vector<Point> B; for(int i=0;i<N;++i){ if(fabs((itr+i)->x - x) >= d) continue; int Bsize = B.size(); for(int j=0;j<Bsize;j++){ double dx,dy; dx = (itr+i)->x - B[Bsize-j-1].x; dy = (itr+i)->y - B[Bsize-j-1].y; if( dy >= d ) break; d = min(d,hypot(dx,dy)); } B.push_back(*(itr+i)); } return d; } #pragma endregion //最近対 2D //////////////////// #pragma region int CircleIntersection(Point A,double AR,Point B,double BR){ double D = (B-A).norm(); if( D > AR+BR ){ return 4; }else if( D == AR+BR ){ return 3; }else if( abs(AR-BR) < D ){//&& D<AR+BR return 2; }else if(D == abs(AR-BR)){ return 1; }else if(D+AR < BR || D+BR<AR){ return 0; } return 0;// } #pragma endregion //円と円の位置関係 #pragma region vector<Point> CircleLine(Point C,double CR,Point A,Point B){ vector<Point> ans(2);//同じ交点なら同じ値 double a,b,c; a = -(A.y-B.y); b = A.x-B.x; c = -(a*A.x+b*A.y); double l,k,d; l = a*a+b*b; k = a*C.x + b*C.y+ c; d = l*CR*CR-k*k; if(d>0){ double ds = sqrt(d); double apl = a/l; double bpl = b/l; double xc = C.x-apl*k; double yc = C.y-bpl*k; double xd = bpl*ds; double yd = apl*ds; Point temp; ans[0].x = xc-xd; ans[0].y = yc+yd; ans[1].x = xc+xd; ans[1].y = yc-yd; }else if(d==0){ Point temp; temp.x = C.x-a*k/l; temp.y = C.y-b*k/l; ans[0] = temp; ans[1] = temp; }else{ Point temp; temp.x = INF; temp.y = INF; ans[0] = temp; ans[1] = temp; } return ans; } #pragma endregion //円と直線の交点,距離チェックする。 ////////////////// //行列式 ///////////////// void solve(){ int N,L,T; cin >> N >> L >> T; vector<LL> X(N),W(N); vector<LL> pos(N); LL cnt = 0; for(int i=0;i<N;++i){ cin >> X[i] >> W[i]; if( W[i] == 2 ){ W[i] = -1; } pos[i] = X[i] + T*W[i]; if( W[i]==1 ){ cnt += pos[i]/L; /*int t=T; t = t-(L-X[i]); if(t>=0){ cnt += t/L + 1; }* }else{ //int res = (T-X[i]-1+L)/L; //cnt -= res/L; int t=T; t = t-(X[i]+1); if(t>=0){ cnt -= t/L + 1; } } pos[i] = (pos[i]%L+L)%L; } sort(pos.begin(), pos.end()); cnt = (cnt%N+N)%N; for(int i=0;i<N;++i){ cout << pos[(i+cnt)%N] << endl; } } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
a.cc:838:25: error: unterminated comment 838 | /*int t=T; | ^ a.cc: In function 'void solve()': a.cc:837:41: error: expected '}' at end of input 837 | cnt += pos[i]/L; | ^ a.cc:836:30: note: to match this '{' 836 | if( W[i]==1 ){ | ^ a.cc:837:41: error: expected '}' at end of input 837 | cnt += pos[i]/L; | ^ a.cc:830:29: note: to match this '{' 830 | for(int i=0;i<N;++i){ | ^ a.cc:837:41: error: expected '}' at end of input 837 | cnt += pos[i]/L; | ^ a.cc:824:13: note: to match this '{' 824 | void solve(){ | ^
s272789977
p03747
C++
#include <iostream> using namespace std; struct ant { int x; int zekken; }; int main() { int N, L, T; int antX[100000]; int antW[100000]; cin >> N >> L >> T; for (int i = 0; i < N; ++i) { cin >> antX[i] >> antW[i]; } // srand(0); // N = rand() % 100000 + 1; // L = rand() % 1000000000 + 1; // T = rand() % 1000000000 + 1; // cout << N << " " << L << " " << T << endl; // for (int i = 0; i < N; ++i) { // antX[i] = i; // antW[i] = 1; // } ant ants[100000]; int suretigai[100000]; for (int i = 0; i < N; ++i) { if (antW[i] == 1) { ants[i].x = antX[i] + T; } else { ants[i].x = antX[i] - T; } if (ants[i].x >= L) { ants[i].x = ants[i].x % L; } else if (ants[i].x < 0) { ants[i].x = (L + ants[i].x) % L; } for (int j = 0; j < N; ++j) { if (i == j) { continue; } if (antW[i] != antW[j]) { double firstTime; double diff = antX[i] - antX[j]; if (diff < 0) { diff += L; } firstTime = diff / 2.0; if (firstTime > 0) { suretigai[i] += 1; } suretigai[i] += (int) (2 * (T - firstTime)) / L; } } if (antW[i] == 1) { ants[i].zekken = i + suretigai[i]; } else { ants[i].zekken = i - suretigai[i]; if (ants[i].zekken < 0) { ants[i].zekken = (N + ants[i].zekken) % N; } } ants[i].zekken = ants[i].zekken % N; } sort(ants, ants + N, [](const ant& x, const ant& y) { return x.zekken < y.zekken;}); for (int i = 0; i < N; ++i) { cout << ants[ants[i].zekken].x << endl; } return 0; }
a.cc: In function 'int main()': a.cc:70:5: error: 'sort' was not declared in this scope; did you mean 'short'? 70 | sort(ants, ants + N, [](const ant& x, const ant& y) { return x.zekken < y.zekken;}); | ^~~~ | short
s353519849
p03747
C++
#include<iostream> #include<bits/stdc++.h> #define pq priority_queue using namespace std; #define MZ 1000000007 int num[200005]; int w[200005]; int n,l,t; struct GG { int dis,no; }nums[100005]; bool cmp(GG x1,GG x2) { return x1.dis<x2.dis; } int main() { int gg=0,gl; int cnt=0,ct,wtf; scanf("%d%d%d",&n,&l,&t); for(int i=0;i<n;i++) { scanf("%d%d",num+i,w+i); num[i+n]=num[i]+l; w[i+n]=w[i]; } for(int i=0;i<n;i++) { if(w[i]!=w[0]) cnt++; } ct=t%l; gg=int((1LL*(t/l)*2*cnt)%n); if(w[0]==1) { for(int i=0;i<2*n;i++) { if(w[i]!=w[0] && ct*2>=num[i]-num[0]) gg++; } } else { for(int i=0;i<2*n;i++) { if(w[i]!=w[0] && ct*2>=num[0]-num[i]+2*l) gg++; } } gg%=n; if(w[0]==2) gg=(n-gg)%n; nums[0].no=gg; for(int i=0;i<n;i++) { if(w[i]==1) nums[i].dis=(num[i]+t)%l; else nums[i].dis=((num[i]-t)%l+l)%l; } sort(nums,nums+n,cmp); for(int i=0;i<n;i++) { if(num[i].no==gg) gl=i; } for(int i=0;i<n;i++) { wtf=(gl+l-gg+i)%l; printf("%d\n",gg[wtf].dis); } return 0; }
a.cc: In function 'int main()': a.cc:65:19: error: request for member 'no' in 'num[i]', which is of non-class type 'int' 65 | if(num[i].no==gg) | ^~ a.cc:71:25: error: invalid types 'int[int]' for array subscript 71 | printf("%d\n",gg[wtf].dis); | ^
s111254579
p03747
C++
//C #include<bits/stdc++.h> #include<unordered_map> #include<unordered_set> using namespace std; #define MAX 100002 int n; int l; int t; struct st{ int X; int dir; int id; int nex(int tim){ tim %= l; if (dir == 1){ } else{ tim = l - tim; } X += tim; X %= l; return X; } }; deque<st> v; deque<int> pos; bool cmp(st a, st b){ return a.X < b.X; } int dist(int a, int b){ b += l; b -= a; b %= l; if (b == 0)return l; return b; } vector<st> V1; vector<st> V2; int ans[MAX]; void outt(){ for (int i = 0; i < n; i++){ printf("%d\n", ans[i]); } } int main(){ cin >> n >> l >> t; int cnt1 = 0; int cnt2 = 0; for (int i = 0; i < n; i++){ int x, w; scanf("%d%d", &x, &w); v.push_back({ x, w, i }); if (w == 1)cnt1++; else cnt2++; } if (cnt1 == 0 || cnt2 == 0){ for (int i = 0; i < v.size(); i++){ printf("%d\n", v[i].nex(t)); } return 0; } sort(pos.begin(), pos.end()); sort(v.begin(), v.end(), cmp); int cur = 0; t *= 2; while (v[0].dir == 2){ v.push_back(v.front()); v.pop_front(); pos.push_back(pos.front()); pos.pop_front(); } int nex = 0; for (int i = 0; i < v.size(); i++){ if (v[i].dir == 1){ V1.push_back(v[i]); } if (v[i].dir == 2){ V2.push_back(v[i]); } } int mini = INT_MAX; for (int i = 0; i < V2.size(); i++){ if (dist(V1[cur].X, V2[i].X) < mini){ mini = dist(V1[cur].X, V2[cur].X); nex = i; } } t -= dist(V1[0].X,V2[nex].X); if (t < 0){ for (int i = 0; i < pos.size(); i++){ ans[v[i].id] = pos[i]; } outt(); return 0; } bool flag = false; int op = 0; while (t>=0){ if (flag==false){ int go = cur + V1.size() - 1; go %= V1.size(); t -= dist(V1[go].X, V1[cur].X); if (t < 0)break; op++; cur = go; } else{ int go = nex + 1; go %= V2.size(); t -= dist(V2[nex].X, V2[go].X); if (t < 0)break; op++; nex = go; } flag ^= true; } int ans = 0; if (op % 2){ ans= } return 0; }
a.cc: In function 'int main()': a.cc:130:9: error: expected primary-expression before '}' token 130 | } | ^
s545029497
p03747
C++
#include <iostream> #include <vector> using namespace std; int main(void){ int N,T,L; int X[100000] = {}; int W[100000] = {}; int i; cin >> N >> L >> T; //cout << N << L << T << endl; for(i=0;i<N;i++){ cin >> X[i] >> W[i]; //cout << X[i] << W[i] << endl; } vector<int> v; for(i=0;i<N;i++){ if(W[i]==1){ v.push_back((X[i] + T) % L); } if(W[i]==2){ v.push_back((((X[i] - T) % L) + L) % L); } //cout << v[i] << endl; } int cross = 0; if(W[0]==1){ for(i=1;i<N;i++){ if(W[i]==2){ if((X[i] - X[0])/2.0 - 0.001 < T){cross++;} cross += (int)((T - (X[i] - X[0])/2.0 - 0.001)/L); } } } if(W[0]==2){ for(i=1;i<N;i++){ if(W[i]==1){ if((L - X[i] + X[0])/2.0-0.001 < T){cross++;} cross += (int)((T - (L - X[i] + X[0])/2.0 - 0.001)/L); } } } cross %= N; int tmp = v[0]; sort(v.begin(), v.end()); vector<int>::iterator iter = find(v.begin(), v.end(), tmp); int index = distance(v.begin(), iter); for(i=0;i<N;i++){ cout << v[index-cross+i] << endl; } return 0; }
a.cc: In function 'int main()': a.cc:46:5: error: 'sort' was not declared in this scope; did you mean 'short'? 46 | sort(v.begin(), v.end()); | ^~~~ | short a.cc:47:38: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' 47 | vector<int>::iterator iter = find(v.begin(), v.end(), tmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:47:38: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 47 | vector<int>::iterator iter = find(v.begin(), v.end(), tmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s904726573
p03747
C++
#include <iostream> #include <vector> using namespace std; struct Ant { int X; int W; }; int mod2L(int n, int L) { return (n + L * 2) % (L * 2); } int main() { int N, L, T; cin >> N >> L >> T; int tog = 0; vector<vector<int>> A(L * 2); fill(A[0].begin(), A[0].end(), 0); fill(A[1].begin(), A[1].end(), 0); int f; for (int i = 0; i < N; i++) { int X, W; cin >> X >> W; A1[X * 2] = W; if (i == 0) { f = X; } } for (int i = 0; i < T * 2; i++) { int got = 1 - tog; bool flg; for (int j = f; j < f + L * 2; j++) { flg = false; int jj = mod2L(j); if (A[tog][jj] | 1) { A[got][mod2L(j + 1, L)] += 1; if (!flg) { flg = true; f = mod2L(f - 1); } } if (A[tog][jj] | 2) { A[got][mod2L(j - 1, L)] += 2; if (!flg) { flg = true; f = mod2L(f + 1); } } } fill(A[tog].begin(), A[tog].end(), 0); tog = got; } for (int i = f; i < f + L * 2; i++) { int ii = mod2L(i); if (A[tog][ii] != 0) { cout << A[tog][ii] << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:28:5: error: 'A1' was not declared in this scope; did you mean 'A'? 28 | A1[X * 2] = W; | ^~ | A a.cc:41:21: error: too few arguments to function 'int mod2L(int, int)' 41 | int jj = mod2L(j); | ~~~~~^~~ a.cc:10:5: note: declared here 10 | int mod2L(int n, int L) { | ^~~~~ a.cc:46:20: error: too few arguments to function 'int mod2L(int, int)' 46 | f = mod2L(f - 1); | ~~~~~^~~~~~~ a.cc:10:5: note: declared here 10 | int mod2L(int n, int L) { | ^~~~~ a.cc:53:20: error: too few arguments to function 'int mod2L(int, int)' 53 | f = mod2L(f + 1); | ~~~~~^~~~~~~ a.cc:10:5: note: declared here 10 | int mod2L(int n, int L) { | ^~~~~ a.cc:62:19: error: too few arguments to function 'int mod2L(int, int)' 62 | int ii = mod2L(i); | ~~~~~^~~ a.cc:10:5: note: declared here 10 | int mod2L(int n, int L) { | ^~~~~
s958380570
p03747
C++
#include<iostream> #include<vector> #include<map> #include<set> #include<algorithm> #include<numeric> #include<limits> #include<bitset> namespace lib { template<std::uint64_t Mod>struct modnum; template<class T>constexpr T pow(T base, std::size_t p) { if (p == 0) { return T(1); } else if (p == 1) { return base; } else if (p == 2) { return base*base; } else if (p % 2 == 0) { return pow(pow(base, p / 2), 2); } else { return pow(pow(base, p / 2), 2)*base; } } template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&); template<std::uint64_t Mod>struct modnum { static constexpr auto mod = Mod; std::uint64_t val; modnum() = default; constexpr modnum(std::uint64_t v) :val(v) { } constexpr modnum& operator+=(modnum const& v) { val += v.val; val %= mod; return *this; } constexpr modnum& operator-=(modnum const& v) { val += mod - v.val; val %= mod; return *this; } constexpr modnum& operator*=(modnum const& v) { val *= v.val; val %= mod; return *this; } constexpr modnum& operator/=(modnum const& v) { return operator*=(inverse(v)); } }; template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) { return lhs += rhs; } template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) { return lhs -= rhs; } template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) { return lhs *= rhs; } template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) { return lhs /= rhs; } template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base) { return pow(base, Mod - 2); } template<class T>constexpr auto clamp(T v) { return std::max(v, T()); } template<class T>void sort(std::vector<T>& vec) { std::sort(vec.begin(), vec.end()); } } void Main(); int main() { std::cin.sync_with_stdio(false); Main(); } typedef lib::modnum<1000000007> mod_t; void Main() { std::int64_t N, L, T, X, W; std::cin >> N >> L >> T >> X >> W; std::vector<std::int64_t> result; int h{}; if (W == 1) { result.emplace_back((X + T) % L); } else { auto v = X - T; if (v < 0) { v %= L; v = L - v; } result.emplace_back(v); } for (int i = 1; i < N; ++i) { int x, w; std::cin >> x >> w; if (w == 1) { result.emplace_back((x + T) % L); } else { auto v = x - T; if (v < 0) { v %= L; v = L - v; } result.emplace_back(v); } if (w != W) { if (W == 1) { auto p = (x - X) / 2; h += lib::clamp((T - p) / L); } else { auto p = L / 2 - (x - X) / 2; h += lib::clamp((T - p) / L); } h %= N; } } lib::sort(result); if (W == 1) { X += T; X %= L; } else { X += L - T%L; X %= L; } auto ite = std::lower_bound(result.begin(), result.end(), X); auto s = std::distance(result.begin(), ite); for (int i{}; i < N; ++i) { std::cout << result[(s + N - h) % ].val << std::endl; } }
a.cc:12:18: error: 'std::uint64_t' has not been declared 12 | template<std::uint64_t Mod>struct modnum; | ^~~ a.cc:36:18: error: 'std::uint64_t' has not been declared 36 | template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&); | ^~~ a.cc:36:66: error: 'Mod' was not declared in this scope 36 | template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&); | ^~~ a.cc:36:69: error: template argument 1 is invalid 36 | template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod> const&); | ^ a.cc:38:18: error: 'std::uint64_t' has not been declared 38 | template<std::uint64_t Mod>struct modnum | ^~~ a.cc:71:18: error: 'std::uint64_t' has not been declared 71 | template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:71:68: error: 'Mod' was not declared in this scope 71 | template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:71:71: error: template argument 1 is invalid 71 | template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:71:85: error: 'Mod' was not declared in this scope 71 | template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:71:88: error: template argument 1 is invalid 71 | template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:71:51: error: 'constexpr auto lib::operator+(int, const int&)' must have an argument of class or enumerated type 71 | template<std::uint64_t Mod>constexpr auto operator+(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~~~~~~ a.cc:75:18: error: 'std::uint64_t' has not been declared 75 | template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:75:68: error: 'Mod' was not declared in this scope 75 | template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:75:71: error: template argument 1 is invalid 75 | template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:75:85: error: 'Mod' was not declared in this scope 75 | template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:75:88: error: template argument 1 is invalid 75 | template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:75:51: error: 'constexpr auto lib::operator-(int, const int&)' must have an argument of class or enumerated type 75 | template<std::uint64_t Mod>constexpr auto operator-(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~~~~~~ a.cc:79:18: error: 'std::uint64_t' has not been declared 79 | template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:79:68: error: 'Mod' was not declared in this scope 79 | template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:79:71: error: template argument 1 is invalid 79 | template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:79:85: error: 'Mod' was not declared in this scope 79 | template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:79:88: error: template argument 1 is invalid 79 | template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:79:51: error: 'constexpr auto lib::operator*(int, const int&)' must have an argument of class or enumerated type 79 | template<std::uint64_t Mod>constexpr auto operator*(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~~~~~~ a.cc:83:18: error: 'std::uint64_t' has not been declared 83 | template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:83:68: error: 'Mod' was not declared in this scope 83 | template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:83:71: error: template argument 1 is invalid 83 | template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:83:85: error: 'Mod' was not declared in this scope 83 | template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~ a.cc:83:88: error: template argument 1 is invalid 83 | template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^ a.cc:83:51: error: 'constexpr auto lib::operator/(int, const int&)' must have an argument of class or enumerated type 83 | template<std::uint64_t Mod>constexpr auto operator/(modnum<Mod> lhs, modnum<Mod>const& rhs) | ^~~~~~~~ a.cc:88:18: error: 'std::uint64_t' has not been declared 88 | template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base) | ^~~ a.cc:88:66: error: 'Mod' was not declared in this scope 88 | template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base) | ^~~ a.cc:88:69: error: template argument 1 is invalid 88 | template<std::uint64_t Mod>constexpr auto inverse(modnum<Mod>const& base) | ^ a.cc: In function 'constexpr auto lib::inverse(const int&)': a.cc:90:34: error: 'Mod' was not declared in this scope 90 | return pow(base, Mod - 2); | ^~~ a.cc: In function 'void Main()': a.cc:115:14: error: 'int64_t' is not a member of 'std'; did you mean 'int64_t'? 115 | std::int64_t N, L, T, X, W; | ^~~~~~~ In file included from /usr/include/x86_64-linux-gnu/sys/types.h:155, from /usr/include/stdlib.h:514, from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here 27 | typedef __int64_t int64_t; | ^~~~~~~ a.cc:116:21: error: 'N' was not declared in this scope 116 | std::cin >> N >> L >> T >> X >> W; | ^ a.cc:116:26: error: 'L' was not declared in this scope 116 | std::cin >> N >> L >> T >> X >> W; | ^ a.cc:116:31: error: 'T' was not declared in this scope 116 | std::cin >> N >> L >> T >> X >> W; | ^ a.cc:116:36: error: 'X' was not declared in this scope 116 | std::cin >> N >> L >> T >> X >> W; | ^ a.cc:116:41: error: 'W' was not declared in this scope 116 | std::cin >> N >> L >> T >> X >> W; | ^ a.cc:117:26: error: 'int64_t' is not a member of 'std'; did you mean 'int64_t'? 117 | std::vector<std::int64_t> result; | ^~~~~~~ /usr/include/x86_64-linux-gnu/bits/stdint-intn.h:27:19: note: 'int64_t' declared here 27 | typedef __int64_t int64_t; | ^~~~~~~ a.cc:117:33: error: template argument 1 is invalid 117 | std::vector<std::int64_t> result; | ^ a.cc:117:33: error: template argument 2 is invalid a.cc:121:24: error: request for member 'emplace_back' in 'result', which is of non-class type 'int' 121 | result.emplace_back((X + T) % L); | ^~~~~~~~~~~~ a.cc:131:24: error: request for member 'emplace_back' in 'result', which is of non-class type 'int' 131 |
s186002195
p03747
C++
left.push_back
a.cc:1:9: error: 'left' does not name a type 1 | left.push_back | ^~~~
s106190270
p03747
C++
#include <iostream> #include <stdlib.h> #define FOR(i,a,b) for(long long i = (a);i<(b);++i) #define REP(i,n) FOR(i,0,n) x#define debug(x) cout << #x << " = " << x << endl; #define N 100001 using namespace std; pair <int,int> ant[N]; int loc[N]; int main(void){ int n,l,t; cin >> n >> l >> t; REP(i,n){ loc[i] = i; } REP(i,n){ int coordinate; int direction; cin >> coordinate >> direction; ant[i] = make_pair(coordinate,direction); } int collideCnt = 0; REP(i,t){ REP(k,n){ FOR(h,k+1,n){ if(ant[k].second == 1 && ant[h].second == 2){ if(ant[h].first - ant[k].first <=1 || (ant[h].first+1 == n &&ant[k].first == 0) ){ swap(loc[k],loc[h]); collideCnt++; break; } } } if(ant[k].second == 1){ ant[k].first++; ant[k].first = ant[k].first % l; }else{ ant[k].first--; if(ant[k].first < 0){ ant[k].first = ant[k].first + l; } } } } REP(i,n){ if(collideCnt % 2 == 1){ loc[i]--; if(loc[i] < 0) loc[i] = loc[i]+n; }else{ loc[i]++; loc[i] %= n; } } REP(i,n){ REP(k,n){ if(i == loc[k]){ cout << ant[k].first << endl; } } } return 0; }
a.cc:6:2: error: stray '#' in program 6 | x#define debug(x) cout << #x << " = " << x << endl; | ^ a.cc:6:27: error: stray '#' in program 6 | x#define debug(x) cout << #x << " = " << x << endl; | ^ a.cc:6:1: error: 'x' does not name a type 6 | x#define debug(x) cout << #x << " = " << x << endl; | ^
s148314275
p03747
C++
int main(void){ llint N,L,T,i,j,a,b; vector<llint> ant; vector<llint> muki; vector<llint> gont; scanf("%lld %lld %lld",&N,&L,&T); gont.resize(N); for(i=0;i<N;i++){ scanf("%lld %lld",&a,&b); ant.pub(a); muki.pub(b); } if(muki[0]==1){ a=1;b=0;j=0;//aはアリ bは答え jは周回 while(-1){ if(ant[0]+2*T<=ant[a]+j*L){break;} if(muki[0]!=muki[a]){b++;} a++; if(a>=N){a-=N;j++;} } } else{ a=N-1;b=0;j=-1;//aはアリ bは答え jは周回 while(-1){ if(ant[0]-2*T>ant[a]+j*L){break;} if(muki[0]!=muki[a]){b--;} a--; if(a<0){a+=N;j--;} } } //ant[N-b]が本物の0番 for(i=0;i<N;i++){ if(muki[i]==1){gont[i]=(((L+ant[i]+T)%L)+L)%L;} else{gont[i]=(((L+ant[i]-T)%L)+L)%L;} } a=gont[0]; sort(gont.begin(),gont.end()); int hon=lower_bound(gont.begin(),gont.end(),a)-gont.begin(); b=(hon-b+N)%N;//これが本当の0 for(i=0;i<N;i++){ printf("%lld\n",gont[b]); b++; b%=N; } return 0; }
a.cc: In function 'int main()': a.cc:2:9: error: 'llint' was not declared in this scope; did you mean 'int'? 2 | llint N,L,T,i,j,a,b; | ^~~~~ | int a.cc:3:9: error: 'vector' was not declared in this scope 3 | vector<llint> ant; | ^~~~~~ a.cc:3:23: error: 'ant' was not declared in this scope; did you mean 'int'? 3 | vector<llint> ant; | ^~~ | int a.cc:4:23: error: 'muki' was not declared in this scope 4 | vector<llint> muki; | ^~~~ a.cc:5:23: error: 'gont' was not declared in this scope 5 | vector<llint> gont; | ^~~~ a.cc:6:33: error: 'N' was not declared in this scope 6 | scanf("%lld %lld %lld",&N,&L,&T); | ^ a.cc:6:36: error: 'L' was not declared in this scope 6 | scanf("%lld %lld %lld",&N,&L,&T); | ^ a.cc:6:39: error: 'T' was not declared in this scope 6 | scanf("%lld %lld %lld",&N,&L,&T); | ^ a.cc:6:9: error: 'scanf' was not declared in this scope 6 | scanf("%lld %lld %lld",&N,&L,&T); | ^~~~~ a.cc:8:13: error: 'i' was not declared in this scope 8 | for(i=0;i<N;i++){ | ^ a.cc:9:36: error: 'a' was not declared in this scope 9 | scanf("%lld %lld",&a,&b); | ^ a.cc:9:39: error: 'b' was not declared in this scope 9 | scanf("%lld %lld",&a,&b); | ^ a.cc:14:17: error: 'a' was not declared in this scope 14 | a=1;b=0;j=0;//aはアリ bは答え jは周回 | ^ a.cc:14:21: error: 'b' was not declared in this scope 14 | a=1;b=0;j=0;//aはアリ bは答え jは周回 | ^ a.cc:14:25: error: 'j' was not declared in this scope 14 | a=1;b=0;j=0;//aはアリ bは答え jは周回 | ^ a.cc:22:17: error: 'a' was not declared in this scope 22 | a=N-1;b=0;j=-1;//aはアリ bは答え jは周回 | ^ a.cc:22:23: error: 'b' was not declared in this scope 22 | a=N-1;b=0;j=-1;//aはアリ bは答え jは周回 | ^ a.cc:22:27: error: 'j' was not declared in this scope 22 | a=N-1;b=0;j=-1;//aはアリ bは答え jは周回 | ^ a.cc:31:13: error: 'i' was not declared in this scope 31 | for(i=0;i<N;i++){ | ^ a.cc:35:9: error: 'a' was not declared in this scope 35 | a=gont[0]; | ^ a.cc:36:9: error: 'sort' was not declared in this scope; did you mean 'short'? 36 | sort(gont.begin(),gont.end()); | ^~~~ | short a.cc:37:17: error: 'lower_bound' was not declared in this scope 37 | int hon=lower_bound(gont.begin(),gont.end(),a)-gont.begin(); | ^~~~~~~~~~~ a.cc:38:9: error: 'b' was not declared in this scope 38 | b=(hon-b+N)%N;//これが本当の0 | ^ a.cc:39:13: error: 'i' was not declared in this scope 39 | for(i=0;i<N;i++){ | ^ a.cc:40:17: error: 'printf' was not declared in this scope 40 | printf("%lld\n",gont[b]); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main(void){
s533450371
p03747
C++
#include <bits/stdc++.h> using namespace std; #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back((a)) #define all(x) (x).begin(),(x).end() #define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x)) #define fi first #define se second #define dbg(x) cout<<#x" = "<<((x))<<endl template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;} template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;} #define INF 2147483600 int main(){ long n,l,t; cin>>n>>l>>t; vector<long> x(n), w(n); rep(i,n) cin>>x[i]>>w[i]; vector<long> v(n); rep(i,n){ if(w[i]==1) v[i] = (x[i] + t)%l; else v[i] = (x[i] - t%l + l) % l; } sort(all(v)); int init = 0; if(w[0]==1){ int cnt = 0; repl(i,1,n) if(w[i]==2) cnt++; cnt *= (2*t)/l; int q = (x[0] + 2*t)%l; for(int i=0; (i<n)&&(x[i]<q); i++) if(w[i]==2) cnt++; int id = lower_bound(all(v), (x[0]+t)%l) - v.begin(); init = (id - cnt%n + n)%n; } else { int cnt = 0; repl(i,1,n) if(w[i]==1) cnt++; cnt *= (2*t)/l; int q = (x[0] - 2*t%l + l)%l; // q = (x[0]-2*t)%l; for(int i=n-1; (i>=0)&&(x[i]>q; i--) if(w[i]==1) cnt++; // dbg(cnt); int id = lower_bound(all(v), (x[0]-t%l+l)%l) - v.begin(); if(v[id]==v[id+1]) id = id+1; init = (id + cnt%n)%n; } rep(i,n) cout << v[(init+i)%n] << endl; return 0; }
a.cc: In function 'int main()': a.cc:48:35: error: expected ')' before ';' token 48 | for(int i=n-1; (i>=0)&&(x[i]>q; i--) if(w[i]==1) cnt++; | ~ ^ | )
s698022359
p03747
C++
#include <iostream> #include <algorithm> using namespace std; const int N = 300011; typedef long long intl; int s[N], d[N]; int e[N]; pair <int, int> p[N]; int ans[N]; int main() { ios :: sync_with_stdio(false); int n, m; intl t; cin >> n >> m >> t; for(int i = 0; i < n; i ++) { char c; cin >> s[i] >> c; d[i] = (c == '2'); p[i] = {s[i], i}; } intl shift = 0; for(int i = 0; i < n; i ++) { if(d[i] == 1) { e[i] = ((s[i] - t) % m + m) % m; shift += (s[i] - t - e[i]) / m; } else { e[i] = (s[i] + t) % m; shift += (s[i] + t - e[i]) / m; } shift = (shift % n + n) % n; } sort(p, p + n); sort(e, e + n); for(int i = 0; i < n; i ++) ans[p[i].second] = e[(i + shift) % n]; for(int i = 0; i < n; i ++) cout << ans[i] << '\n‘; return 0; }
a.cc:48:35: warning: missing terminating ' character 48 | cout << ans[i] << '\n‘; | ^ a.cc:48:35: error: missing terminating ' character 48 | cout << ans[i] << '\n‘; | ^~~~~ a.cc: In function 'int main()': a.cc:50:9: error: expected primary-expression before 'return' 50 | return 0; | ^~~~~~
s040782960
p03748
C++
#include <bits/stdc++.h> using namespace std; inline int read() { int x=0,f=1,c=getchar(); while(c<48) c=='-'&&(f=-1),c=getchar(); while(c>47) x=x*10+c-'0',c=getchar(); return x*f; } const int MAXN = 5005; const int mod = 1e9+7; int f[MAXN][MAXN]; int n,m; inline int dp(int x,int y,int ret=0) { memset(f,0,sizeof(f)); for(int i=0;i<=x;++i) f[0][i]=1; for(int i=1;i<=y;++i) for(int j=0;j<=x;++j) { if(j<x) (f[i][j]+=f[i-1][j+1])%=mod,(f[i][j]+=f[i-1][j])%=mod; if(j) (f[i][j]+=f[i-1][j])%=mod,(f[i][j]+=f[i-1][j-1])%=mod; } for(int i=0;i<=x;++i) (ret+=f[y][i])%=mod; return ret; } int main(int argc, char const *argv[]) { n=read(); m=read();` printf("%d\n", (dp(n,m)-dp(n-1,m)+mod)%mod); return 0; }
a.cc:33:28: error: stray '`' in program 33 | n=read(); m=read();` | ^
s122759643
p03748
C++
#include <bits/stdc++.h> using namespace std; constexpr int mod = 1000000007; using ll = long long; // return a^n % mod ll mod_pow(ll a, ll n) { if(n == 0) return 1; ll ret = 0; ll tmp = a; while(n > 0) { if(n % 2) { ret += tmp; ret %= mod; } tmp = tmp * tmp; tmp %= mod; n /= 2; } return ret; } int main () { int n, m; cin >> n >> m; if(n == 1) { cout << mod_pow(2, m) << endl; return 0; } if(m == 1) { cout << 4 << endl; return 0; } n--; m--; if(n == 1) { ll ans = 0, tmp = 1; for(int i = 1; i <= m; i++) { ans += 2 * tmp * mod_pow(3, m - i); ans %= mod; tmp *= 2; tmp %= mod; } ans += tmp; cout << 4 * ans << endl; return 0; } vector<vector<vector<>> dp(m + 1, vector<vector<int>>(n + 1, vector<int>(2, 0))); for(int i = 1; i <= m; i++) for(int j = 0; j <= n; j++) for(int k = 0; k <= 1; k++) { if(i == 1) { // 初期条件 if(k == 1) { if(j == 0) dp[i][j][k] = 2; if(j == 1) dp[i][j][k] = 1; } else { if(j == 0) dp[i][j][k] = 1; else if(j == n) dp[i][j][k] = 3; else if(j == 1) dp[i][j][k] = 3; else dp[i][j][k] = 4; } } else { // 遷移 ll val = 0; if(k == 1) { if(j == 0) val = 2LL * (dp[i - 1][j][0] + dp[i - 1][j][1]) + dp[i - 1][j + 1][1]; else if(j == n) val = 2LL * dp[i - 1][j][1] + dp[i - 1][j - 1][1]; else if(j == 1) val = 2LL * dp[i - 1][j][1] + (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]) + dp[i - 1][j + 1][1]; else val = 2LL * dp[i - 1][j][1] + dp[i - 1][j - 1][1] + dp[i - 1][j + 1][1]; } else { if(j == 0) val = dp[i - 1][j + 1][0]; else if(j == n) val = 2LL * dp[i - 1][j][0] + dp[i - 1][j - 1][0]; else if(j == 1) val = 2LL * dp[i - 1][j][0] + dp[i - 1][j + 1][0]; else val = 2LL * dp[i - 1][j][0] + dp[i - 1][j - 1][0] + dp[i - 1][j + 1][0]; } dp[i][j][k] = val % mod; } } ll ans = 0; for(int i = 0; i <= n; i++) ans += dp[m][i][1]; ans += dp[m][0][0]; cout << (4LL * ans) % mod << endl; // 問題の言い換えで答えが 1/4 になっていたので }
a.cc: In function 'int main()': a.cc:45:25: error: wrong number of template arguments (0, should be at least 1) 45 | vector<vector<vector<>> dp(m + 1, vector<vector<int>>(n + 1, vector<int>(2, 0))); | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:428:11: note: provided for 'template<class _Tp, class _Alloc> class std::vector' 428 | class vector : protected _Vector_base<_Tp, _Alloc> | ^~~~~~ a.cc:45:26: error: template argument 1 is invalid 45 | vector<vector<vector<>> dp(m + 1, vector<vector<int>>(n + 1, vector<int>(2, 0))); | ^~ a.cc:45:26: error: template argument 2 is invalid a.cc:45:84: error: template argument 1 is invalid 45 | vector<vector<vector<>> dp(m + 1, vector<vector<int>>(n + 1, vector<int>(2, 0))); | ^ a.cc:45:84: error: template argument 2 is invalid a.cc:49:28: error: 'dp' was not declared in this scope; did you mean 'dup'? 49 | if(j == 0) dp[i][j][k] = 2; | ^~ | dup a.cc:50:28: error: 'dp' was not declared in this scope; did you mean 'dup'? 50 | if(j == 1) dp[i][j][k] = 1; | ^~ | dup a.cc:52:28: error: 'dp' was not declared in this scope; did you mean 'dup'? 52 | if(j == 0) dp[i][j][k] = 1; | ^~ | dup a.cc:53:33: error: 'dp' was not declared in this scope; did you mean 'dup'? 53 | else if(j == n) dp[i][j][k] = 3; | ^~ | dup a.cc:54:33: error: 'dp' was not declared in this scope; did you mean 'dup'? 54 | else if(j == 1) dp[i][j][k] = 3; | ^~ | dup a.cc:55:22: error: 'dp' was not declared in this scope; did you mean 'dup'? 55 | else dp[i][j][k] = 4; | ^~ | dup a.cc:60:41: error: 'dp' was not declared in this scope; did you mean 'dup'? 60 | if(j == 0) val = 2LL * (dp[i - 1][j][0] + dp[i - 1][j][1]) + dp[i - 1][j + 1][1]; | ^~ | dup a.cc:61:45: error: 'dp' was not declared in this scope; did you mean 'dup'? 61 | else if(j == n) val = 2LL * dp[i - 1][j][1] + dp[i - 1][j - 1][1]; | ^~ | dup a.cc:62:45: error: 'dp' was not declared in this scope; did you mean 'dup'? 62 | else if(j == 1) val = 2LL * dp[i - 1][j][1] + (dp[i - 1][j - 1][0] + dp[i - 1][j - 1][1]) + dp[i - 1][j + 1][1]; | ^~ | dup a.cc:63:34: error: 'dp' was not declared in this scope; did you mean 'dup'? 63 | else val = 2LL * dp[i - 1][j][1] + dp[i - 1][j - 1][1] + dp[i - 1][j + 1][1]; | ^~ | dup a.cc:65:34: error: 'dp' was not declared in this scope; did you mean 'dup'? 65 | if(j == 0) val = dp[i - 1][j + 1][0]; | ^~ | dup a.cc:66:45: error: 'dp' was not declared in this scope; did you mean 'dup'? 66 | else if(j == n) val = 2LL * dp[i - 1][j][0] + dp[i - 1][j - 1][0]; | ^~ | dup a.cc:67:45: error: 'dp' was not declared in this scope; did you mean 'dup'? 67 | else if(j == 1) val = 2LL * dp[i - 1][j][0] + dp[i - 1][j + 1][0]; | ^~ | dup a.cc:68:34: error: 'dp' was not declared in this scope; did you mean 'dup'? 68 | else val = 2LL * dp[i - 1][j][0] + dp[i - 1][j - 1][0] + dp[i - 1][j + 1][0]; | ^~ | dup a.cc:70:13: error: 'dp' was not declared in this scope; did you mean 'dup'? 70 | dp[i][j][k] = val % mod; | ^~ | dup a.cc:74:40: error: 'dp' was not declared in this scope; did you mean 'dup'? 74 | for(int i = 0; i <= n; i++) ans += dp[m][i][1]; | ^~ | dup a.cc:75:12: error: 'dp' was not declared in this scope; did you mean 'dup'? 75 | ans += dp[m][0][0]; | ^~ | dup
s748276040
p03748
C++
#include<bits/stdc++.h> #define mo 1000000007 using namespace std; long long n,m,i,j,k,ans,f[3005][3005][2]; int main(){ cin >> n >> m; f[0][0][1]=1; for(i=1;i<=n;i++) f[0][i][0]=1; for(i=1;i<=m;i++) for(j=0;j<=n;j++) for(k=0;k<=1;k++){ if(j!=0){ f[i][j][k|(j==1)]=(f[i][j][k|(j==1)]+f[i-1][j][k])%mo; f[i][j-1][k|(j==1)]=(f[i][j-1][k|(j==1)]+f[i-1][j][k])%mo; } if(n-j!=0){ f[i][j+1][k]=(f[i][j+1][k]+f[i-1][j][k])%mo; f[i][j][k]=(f[i][j][k]+f[i-1][j][k])%mo; } } for(i=0;i<=n;i++) ans=(ans+f[m][i][1])%mo; pus(ans,2); return 0; }
a.cc: In function 'int main()': a.cc:24:9: error: 'pus' was not declared in this scope; did you mean 'puts'? 24 | pus(ans,2); | ^~~ | puts
s866424770
p03748
C++
//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <iostream> #include <vector> #include <algorithm> #include <assert.h> #include <string> #include <stdio.h> #include <time.h> using namespace std; typedef long long ll; typedef unsigned long long ull; const int inf_int = 1e9 + 100; const ll inf_ll = 1e18; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef long double dbl; #define pb push_back #define eb emplace_back const double pi = 3.1415926535898; #define dout if(debug) cout #define fi first #define se second #define sp setprecision #define sz(a) (int(a.size())) #define mp make_pair #define all(a) a.begin(),a.end() bool debug = 0; const int MAXN = 4e5 + 100; const int LOG = 21; const int mod = 1e9 + 7; const int MX = (1e7 + 100) * 1.5; typedef long long li; const li MOD = 1000000000949747713ll; template<class T1, class T2> std::ostream &operator<<(std::ostream &out, const std::pair<T1, T2> &rhs) { out << "( " << rhs.first << " , " << rhs.second << " )"; return out; } ll dp[2][3010][2]; void solve() { int n, m; cin >> n >> m; for (int i = 0; i <= n; ++i) { dp[0][i][0] = 1; } for (int i = 1; i <= m; ++i) { int nxt = i & 1; memset(dp[nxt], 0, sizeof dp[nxt]); for (int j = 0; j <= n; ++j) { for (int k = 0; k < 2; ++k) { dp[nxt ^ 1][j][k] %= mod; //RR if (j > 1) { dp[nxt][j - 1][k] += dp[nxt ^ 1][j][k]; } else if (j == 1) { dp[nxt][j - 1][1] += dp[nxt ^ 1][j][k]; } //RB if (j > 1) { dp[nxt][j][k] += dp[nxt ^ 1][j][k]; } else if (j == 1) { dp[nxt][j][1] += dp[nxt ^ 1][j][k]; } //BR if (j + 1 <= n && j > 0) { dp[nxt][j][k] += dp[nxt ^ 1][j][k]; } else if (j == 0) { dp[nxt][j][1] += dp[nxt ^ 1][j][k]; } //BB if (j + 1 <= n && j > 0) { dp[nxt][j + 1][k] += dp[nxt ^ 1][j][k]; } else if (j == 0) { dp[nxt][j + 1][1] += dp[nxt ^ 1][j][k]; } } } } ll ans = 0; for (int i = 0; i <= n; ++i) { ans += dp[m & 1][i][1]; } ans %= mod; cout << ans; } signed main() { #ifdef zxc debug = 0; // freopen("../input.txt", "r", stdin); // freopen("../output.txt", "w", stdout); #else #endif //zxc ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20); debug = 1; int t = 1; while (t--) solve(); if (debug) cerr << endl << "time : " << (1.0 * clock() / CLOCKS_PER_SEC) << endl; }
a.cc: In function 'void solve()': a.cc:57:9: error: 'memset' was not declared in this scope 57 | memset(dp[nxt], 0, sizeof dp[nxt]); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <assert.h> +++ |+#include <cstring> 7 | #include <string>
s080515930
p03748
C++
#include "bits/stdc++.h" #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; using ll = std::int_fast64_t; using P = pair<ll, ll>; constexpr ll inf = 1000000000; constexpr ll mod = 1000000007; constexpr long double eps = 1e-15; template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p) { os << to_string(p.first) << " " << to_string(p.second); return os; } template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { REP(i, v.size()) { if(i) os << " "; os << to_string(v[i]); } return os; } struct modint { ll n; public: modint(const ll n = 0) : n((n % mod + mod) % mod) {} static modint pow(modint a, int m) { modint r = 1; while(m > 0) { if(m & 1) { r *= a; } a = (a * a); m /= 2; } return r; } modint &operator++() { *this += 1; return *this; } modint &operator--() { *this -= 1; return *this; } modint operator++(int) { modint ret = *this; *this += 1; return ret; } modint operator--(int) { modint ret = *this; *this -= 1; return ret; } modint operator~() const { return (this -> pow(n, mod - 2)); } // inverse friend bool operator==(const modint& lhs, const modint& rhs) { return lhs.n == rhs.n; } friend bool operator<(const modint& lhs, const modint& rhs) { return lhs.n < rhs.n; } friend bool operator>(const modint& lhs, const modint& rhs) { return lhs.n > rhs.n; } friend modint &operator+=(modint& lhs, const modint& rhs) { lhs.n += rhs.n; if (lhs.n >= mod) lhs.n -= mod; return lhs; } friend modint &operator-=(modint& lhs, const modint& rhs) { lhs.n -= rhs.n; if (lhs.n < 0) lhs.n += mod; return lhs; } friend modint &operator*=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * rhs.n) % mod; return lhs; } friend modint &operator/=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * (~rhs).n) % mod; return lhs; } friend modint operator+(const modint& lhs, const modint& rhs) { return modint(lhs.n + rhs.n); } friend modint operator-(const modint& lhs, const modint& rhs) { return modint(lhs.n - rhs.n); } friend modint operator*(const modint& lhs, const modint& rhs) { return modint(lhs.n * rhs.n); } friend modint operator/(const modint& lhs, const modint& rhs) { return modint(lhs.n * (~rhs).n); } }; istream& operator>>(istream& is, modint m) { is >> m.n; return is; } ostream& operator<<(ostream& os, modint m) { os << m.n; return os; } #define MAX_N 3030303 long long extgcd(long long a, long long b, long long& x, long long& y) { long long d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } long long mod_inverse(long long a, long long m) { long long x, y; if(extgcd(a, m, x, y) == 1) return (m + x % m) % m; else return -1; } vector<long long> fact(MAX_N+1, inf); long long mod_fact(long long n, long long& e) { if(fact[0] == inf) { fact[0]=1; if(MAX_N != 0) fact[1]=1; for(ll i = 2; i <= MAX_N; ++i) { fact[i] = (fact[i-1] * i) % mod; } } e = 0; if(n == 0) return 1; long long res = mod_fact(n / mod, e); e += n / mod; if((n / mod) % 2 != 0) return (res * (mod - fact[n % mod])) % mod; return (res * fact[n % mod]) % mod; } // return nCk long long mod_comb(long long n, long long k) { if(n < 0 || k < 0 || n < k) return 0; long long e1, e2, e3; long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3); if(e1 > e2 + e3) return 0; return (a1 * mod_inverse((a2 * a3) % mod, mod)) % mod; } using mi = modint; mi dp1[3030][3030][2][2]; mi dp2[3030][3030][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; if(n == 1) { mi ans = 2; REP(i, n) ans *= 2; cout << ans << endl; return 0; } for(int i = 0; i <= m; i++) for(int j = 0; j <= n; j++) { REP(k, 2) REP(l, 2) { if(i == 0) { if(k && l) dp1[i][j][k][l] = 1; else dp1[i][j][k][l] = 0; } else { if(j) { if(j - 1 == 0) dp1[i][j][k][l] += dp1[i - 1][j - 1][1][l] + dp1[i - 1][j][1][l]; else dp1[i][j][k][l] += dp1[i - 1][j - 1][k][l] + dp1[i - 1][j][k][l]; } if(j < n) { if(j + 1 == n) dp1[i][j][k][l] += dp1[i - 1][j + 1][k][1] + dp1[i - 1][j][k][1]; else dp1[i][j][k][l] += dp1[i - 1][j + 1][k][l] + dp1[i - 1][j][k][l]; } } } } for(int i = 0; i <= m; i++) for(int j = 0; j <= n - 1; j++) { REP(k, 2) { if(i == 0) { if(k) dp2[i][j][k] = 1; else dp2[i][j][k] = 0; } else { if(j) { if(j - 1 == 0) dp2[i][j][k] += dp2[i - 1][j - 1][1] + dp2[i - 1][j][1]; else dp2[i][j][k] += dp2[i - 1][j - 1][k] + dp2[i - 1][j][k]; } if(j < n - 1) { dp2[i][j][k] += dp2[i - 1][j + 1][k] + dp2[i - 1][j][k]; } } } } mi ans = 0; REP(i, n + 1) { if(i == 0) ans += dp1[m][i][1][0]; else if(i == n) ans += dp1[m][i][0][1]; else ans += dp1[m][i][0][0]; }#include <iostream> #include <vector> #include <queue> #include <math.h> #include <set> #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; using ll = std::int_fast64_t; using P = pair<ll, ll>; constexpr ll inf = 1000000000; constexpr ll mod = 1000000007; constexpr long double eps = 1e-15; template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p) { os << to_string(p.first) << " " << to_string(p.second); return os; } template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { REP(i, v.size()) { if(i) os << " "; os << to_string(v[i]); } return os; } struct modint { ll n; public: modint(const ll n = 0) : n((n % mod + mod) % mod) {} static modint pow(modint a, int m) { modint r = 1; while(m > 0) { if(m & 1) { r *= a; } a = (a * a); m /= 2; } return r; } modint &operator++() { *this += 1; return *this; } modint &operator--() { *this -= 1; return *this; } modint operator++(int) { modint ret = *this; *this += 1; return ret; } modint operator--(int) { modint ret = *this; *this -= 1; return ret; } modint operator~() const { return (this -> pow(n, mod - 2)); } // inverse friend bool operator==(const modint& lhs, const modint& rhs) { return lhs.n == rhs.n; } friend bool operator<(const modint& lhs, const modint& rhs) { return lhs.n < rhs.n; } friend bool operator>(const modint& lhs, const modint& rhs) { return lhs.n > rhs.n; } friend modint &operator+=(modint& lhs, const modint& rhs) { lhs.n += rhs.n; if (lhs.n >= mod) lhs.n -= mod; return lhs; } friend modint &operator-=(modint& lhs, const modint& rhs) { lhs.n -= rhs.n; if (lhs.n < 0) lhs.n += mod; return lhs; } friend modint &operator*=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * rhs.n) % mod; return lhs; } friend modint &operator/=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * (~rhs).n) % mod; return lhs; } friend modint operator+(const modint& lhs, const modint& rhs) { return modint(lhs.n + rhs.n); } friend modint operator-(const modint& lhs, const modint& rhs) { return modint(lhs.n - rhs.n); } friend modint operator*(const modint& lhs, const modint& rhs) { return modint(lhs.n * rhs.n); } friend modint operator/(const modint& lhs, const modint& rhs) { return modint(lhs.n * (~rhs).n); } }; istream& operator>>(istream& is, modint m) { is >> m.n; return is; } ostream& operator<<(ostream& os, modint m) { os << m.n; return os; } #define MAX_N 3030303 long long extgcd(long long a, long long b, long long& x, long long& y) { long long d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } long long mod_inverse(long long a, long long m) { long long x, y; if(extgcd(a, m, x, y) == 1) return (m + x % m) % m; else return -1; } vector<long long> fact(MAX_N+1, inf); long long mod_fact(long long n, long long& e) { if(fact[0] == inf) { fact[0]=1; if(MAX_N != 0) fact[1]=1; for(ll i = 2; i <= MAX_N; ++i) { fact[i] = (fact[i-1] * i) % mod; } } e = 0; if(n == 0) return 1; long long res = mod_fact(n / mod, e); e += n / mod; if((n / mod) % 2 != 0) return (res * (mod - fact[n % mod])) % mod; return (res * fact[n % mod]) % mod; } // return nCk long long mod_comb(long long n, long long k) { if(n < 0 || k < 0 || n < k) return 0; long long e1, e2, e3; long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3); if(e1 > e2 + e3) return 0; return (a1 * mod_inverse((a2 * a3) % mod, mod)) % mod; } using mi = modint; mi dp1[3030][3030][2][2]; mi dp2[3030][3030][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; if(n == 1) { mi ans = 2; REP(i, n) ans *= 2; cout << ans << endl; return 0; } for(int i = 0; i <= m; i++) for(int j = 0; j <= n; j++) { REP(k, 2) REP(l, 2) { if(i == 0) { if(k && l) dp1[i][j][k][l] = 1; else dp1[i][j][k][l] = 0; } else { if(j) { if(j - 1 == 0) dp1[i][j][k][l] += dp1[i - 1][j - 1][1][l] + dp1[i - 1][j][1][l]; else dp1[i][j][k][l] += dp1[i - 1][j - 1][k][l] + dp1[i - 1][j][k][l]; } if(j < n) { if(j + 1 == n) dp1[i][j][k][l] += dp1[i - 1][j + 1][k][1] + dp1[i - 1][j][k][1]; else dp1[i][j][k][l] += dp1[i - 1][j + 1][k][l] + dp1[i - 1][j][k][l]; } } } } for(int i = 0; i <= m; i++) for(int j = 0; j <= n - 1; j++) { REP(k, 2) { if(i == 0) { if(k) dp2[i][j][k] = 1; else dp2[i][j][k] = 0; } else { if(j) { if(j - 1 == 0) dp2[i][j][k] += dp2[i - 1][j - 1][1] + dp2[i - 1][j][1]; else dp2[i][j][k] += dp2[i - 1][j - 1][k] + dp2[i - 1][j][k]; } if(j < n - 1) { dp2[i][j][k] += dp2[i - 1][j + 1][k] + dp2[i - 1][j][k]; } } } } mi ans = 0; REP(i, n + 1) { if(i == 0) ans += dp1[m][i][1][0]; else if(i == n) ans += dp1[m][i][0][1]; else ans += dp1[m][i][0][0]; } REP(i, n + 1) { if(i == 0) ans += dp2[m][i][1]; else ans += dp2[m][i][0]; } cout << ans << endl; return 0; } REP(i, n + 1) { if(i == 0) ans += dp2[m][i][1]; else ans += dp2[m][i][0]; } cout << ans << endl; return 0; }
a.cc:187:6: error: stray '#' in program 187 | }#include <iostream> | ^ a.cc: In function 'int main()': a.cc:187:7: error: 'include' was not declared in this scope 187 | }#include <iostream> | ^~~~~~~ a.cc:187:24: error: expected primary-expression before '>' token 187 | }#include <iostream> | ^ In file included from a.cc:190: /usr/include/c++/14/math.h:38:1: error: expected primary-expression before 'using' 38 | using std::abs; | ^~~~~ a.cc:202:1: error: a template declaration cannot appear at block scope 202 | template<typename T1, typename T2> | ^~~~~~~~ a.cc:233:17: error: cannot define friend function 'operator==' in a local class definition 233 | friend bool operator==(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:233:17: error: 'bool main()::modint::operator==(const main()::modint&, const main()::modint&)' must have exactly one argument a.cc:236:17: error: cannot define friend function 'operator<' in a local class definition 236 | friend bool operator<(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:236:17: error: 'bool main()::modint::operator<(const main()::modint&, const main()::modint&)' must have exactly one argument a.cc:239:17: error: cannot define friend function 'operator>' in a local class definition 239 | friend bool operator>(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:239:17: error: 'bool main()::modint::operator>(const main()::modint&, const main()::modint&)' must have exactly one argument a.cc:242:20: error: cannot define friend function 'operator+=' in a local class definition 242 | friend modint &operator+=(modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:242:20: error: 'main()::modint& main()::modint::operator+=(main()::modint&, const main()::modint&)' must have exactly one argument a.cc:247:20: error: cannot define friend function 'operator-=' in a local class definition 247 | friend modint &operator-=(modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:247:20: error: 'main()::modint& main()::modint::operator-=(main()::modint&, const main()::modint&)' must have exactly one argument a.cc:252:20: error: cannot define friend function 'operator*=' in a local class definition 252 | friend modint &operator*=(modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:252:20: error: 'main()::modint& main()::modint::operator*=(main()::modint&, const main()::modint&)' must have exactly one argument a.cc:256:20: error: cannot define friend function 'operator/=' in a local class definition 256 | friend modint &operator/=(modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:256:20: error: 'main()::modint& main()::modint::operator/=(main()::modint&, const main()::modint&)' must have exactly one argument a.cc:260:19: error: cannot define friend function 'operator+' in a local class definition 260 | friend modint operator+(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:260:19: error: 'main()::modint main()::modint::operator+(const main()::modint&, const main()::modint&)' must have either zero or one argument a.cc:263:19: error: cannot define friend function 'operator-' in a local class definition 263 | friend modint operator-(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:263:19: error: 'main()::modint main()::modint::operator-(const main()::modint&, const main()::modint&)' must have either zero or one argument a.cc:266:19: error: cannot define friend function 'operator*' in a local class definition 266 | friend modint operator*(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:266:19: error: 'main()::modint main()::modint::operator*(const main()::modint&, const main()::modint&)' must have either zero or one argument a.cc:269:19: error: cannot define friend function 'operator/' in a local class definition 269 | friend modint operator/(const modint& lhs, const modint& rhs) { | ^~~~~~~~ a.cc:269:19: error: 'main()::modint main()::modint::operator/(const main()::modint&, const main()::modint&)' must have exactly one argument a.cc: In static member function 'static main()::modint main()::modint::pow(main()::modint, int)': a.cc:223:27: error: no match for 'operator*=' (operand types are 'main()::modint' and 'main()::modint') 223 | if(m & 1) { r *= a; } | ~~^~~~ a.cc:224:20: error: no match for 'operator*' (operand types are 'main()::modint' and 'main()::modint') 224 | a = (a * a); m /= 2; | ~ ^ ~ | | | | | main()::modint | main()::modint In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)' 400 | operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:400:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::complex<_Tp>' 224 | a = (a * a); m /= 2; | ^ /usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)' 409 | operator*(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:409:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::complex<_Tp>' 224 | a = (a * a); m /= 2; | ^ /usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)' 418 | operator*(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:418:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::complex<_Tp>' 224 | a = (a * a); m /= 2; | ^ 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:407:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 224 | a = (a * a); m /= 2; | ^ /usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 224 | a = (a * a); m /= 2; | ^ /usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 224 | a = (a * a); m /= 2; | ^ /usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed: a.cc:224:22: note: 'main()::modint' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 224 | a = (a * a); m /= 2; | ^ /usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 407 | _DEFINE_EXPR_BIN
s963558099
p03748
C++
#include <iostream> #include <vector> #include <queue> #include <math.h> #include <set> #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; using ll = std::int_fast64_t; using P = pair<ll, ll>; constexpr ll inf = 1000000000; constexpr ll mod = 1000000007; constexpr long double eps = 1e-15; template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p) { os << to_string(p.first) << " " << to_string(p.second); return os; } template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { REP(i, v.size()) { if(i) os << " "; os << to_string(v[i]); } return os; } struct modint { ll n; public: modint(const ll n = 0) : n((n % mod + mod) % mod) {} static modint pow(modint a, int m) { modint r = 1; while(m > 0) { if(m & 1) { r *= a; } a = (a * a); m /= 2; } return r; } modint &operator++() { *this += 1; return *this; } modint &operator--() { *this -= 1; return *this; } modint operator++(int) { modint ret = *this; *this += 1; return ret; } modint operator--(int) { modint ret = *this; *this -= 1; return ret; } modint operator~() const { return (this -> pow(n, mod - 2)); } // inverse friend bool operator==(const modint& lhs, const modint& rhs) { return lhs.n == rhs.n; } friend bool operator<(const modint& lhs, const modint& rhs) { return lhs.n < rhs.n; } friend bool operator>(const modint& lhs, const modint& rhs) { return lhs.n > rhs.n; } friend modint &operator+=(modint& lhs, const modint& rhs) { lhs.n += rhs.n; if (lhs.n >= mod) lhs.n -= mod; return lhs; } friend modint &operator-=(modint& lhs, const modint& rhs) { lhs.n -= rhs.n; if (lhs.n < 0) lhs.n += mod; return lhs; } friend modint &operator*=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * rhs.n) % mod; return lhs; } friend modint &operator/=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * (~rhs).n) % mod; return lhs; } friend modint operator+(const modint& lhs, const modint& rhs) { return modint(lhs.n + rhs.n); } friend modint operator-(const modint& lhs, const modint& rhs) { return modint(lhs.n - rhs.n); } friend modint operator*(const modint& lhs, const modint& rhs) { return modint(lhs.n * rhs.n); } friend modint operator/(const modint& lhs, const modint& rhs) { return modint(lhs.n * (~rhs).n); } }; istream& operator>>(istream& is, modint m) { is >> m.n; return is; } ostream& operator<<(ostream& os, modint m) { os << m.n; return os; } #define MAX_N 3030303 long long extgcd(long long a, long long b, long long& x, long long& y) { long long d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } long long mod_inverse(long long a, long long m) { long long x, y; if(extgcd(a, m, x, y) == 1) return (m + x % m) % m; else return -1; } vector<long long> fact(MAX_N+1, inf); long long mod_fact(long long n, long long& e) { if(fact[0] == inf) { fact[0]=1; if(MAX_N != 0) fact[1]=1; for(ll i = 2; i <= MAX_N; ++i) { fact[i] = (fact[i-1] * i) % mod; } } e = 0; if(n == 0) return 1; long long res = mod_fact(n / mod, e); e += n / mod; if((n / mod) % 2 != 0) return (res * (mod - fact[n % mod])) % mod; return (res * fact[n % mod]) % mod; } // return nCk long long mod_comb(long long n, long long k) { if(n < 0 || k < 0 || n < k) return 0; long long e1, e2, e3; long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3); if(e1 > e2 + e3) return 0; return (a1 * mod_inverse((a2 * a3) % mod, mod)) % mod; } using mi = modint; mi dp1[3030][3030][2][2]; mi dp2[3030][3030][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; if(n == 1) { mi ans = 2; REP(i, n) ans *= 2; cout << ans << endl; return 0; } for(int i = 0; i <= m; i++) for(int j = 0; j <= n; j++) { REP(k, 2) REP(l, 2) { if(i == 0) { if(k && l) dp1[i][j][k][l] = 1; else dp1[i][j][k][l] = 0; } else { if(j) { if(j - 1 == 0) dp1[i][j][k][l] += dp1[i - 1][j - 1][1][l] + dp1[i - 1][j][1][l]; else dp1[i][j][k][l] += dp1[i - 1][j - 1][k][l] + dp1[i - 1][j][k][l]; } if(j < n) { if(j + 1 == n) dp1[i][j][k][l] += dp1[i - 1][j + 1][k][1] + dp1[i - 1][j][k][1]; else dp1[i][j][k][l] += dp1[i - 1][j + 1][k][l] + dp1[i - 1][j][k][l]; } } } } for(int i = 0; i <= m; i++) for(int j = 0; j <= n - 1; j++) { REP(k, 2) { if(i == 0) { if(k) dp2[i][j][k] = 1; else dp2[i][j][k] = 0; } else { if(j) { if(j - 1 == 0) dp2[i][j][k] += dp2[i - 1][j - 1][1] + dp2[i - 1][j][1]; else dp2[i][j][k] += dp2[i - 1][j - 1][k] + dp2[i - 1][j][k]; } if(j < n - 1) { dp2[i][j][k] += dp2[i - 1][j + 1][k] + dp2[i - 1][j][k]; } } } } mi ans = 0; REP(i, n + 1) { if(i == 0) ans += dp1[m][i][1][0]; else if(i == n) ans += dp1[m][i][0][1]; else ans += dp1[m][i][0][0]; }#include <iostream> #include <vector> #include <queue> #include <math.h> #include <set> #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; using ll = std::int_fast64_t; using P = pair<ll, ll>; constexpr ll inf = 1000000000; constexpr ll mod = 1000000007; constexpr long double eps = 1e-15; template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1, T2> p) { os << to_string(p.first) << " " << to_string(p.second); return os; } template<typename T> ostream& operator<<(ostream& os, vector<T>& v) { REP(i, v.size()) { if(i) os << " "; os << to_string(v[i]); } return os; } struct modint { ll n; public: modint(const ll n = 0) : n((n % mod + mod) % mod) {} static modint pow(modint a, int m) { modint r = 1; while(m > 0) { if(m & 1) { r *= a; } a = (a * a); m /= 2; } return r; } modint &operator++() { *this += 1; return *this; } modint &operator--() { *this -= 1; return *this; } modint operator++(int) { modint ret = *this; *this += 1; return ret; } modint operator--(int) { modint ret = *this; *this -= 1; return ret; } modint operator~() const { return (this -> pow(n, mod - 2)); } // inverse friend bool operator==(const modint& lhs, const modint& rhs) { return lhs.n == rhs.n; } friend bool operator<(const modint& lhs, const modint& rhs) { return lhs.n < rhs.n; } friend bool operator>(const modint& lhs, const modint& rhs) { return lhs.n > rhs.n; } friend modint &operator+=(modint& lhs, const modint& rhs) { lhs.n += rhs.n; if (lhs.n >= mod) lhs.n -= mod; return lhs; } friend modint &operator-=(modint& lhs, const modint& rhs) { lhs.n -= rhs.n; if (lhs.n < 0) lhs.n += mod; return lhs; } friend modint &operator*=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * rhs.n) % mod; return lhs; } friend modint &operator/=(modint& lhs, const modint& rhs) { lhs.n = (lhs.n * (~rhs).n) % mod; return lhs; } friend modint operator+(const modint& lhs, const modint& rhs) { return modint(lhs.n + rhs.n); } friend modint operator-(const modint& lhs, const modint& rhs) { return modint(lhs.n - rhs.n); } friend modint operator*(const modint& lhs, const modint& rhs) { return modint(lhs.n * rhs.n); } friend modint operator/(const modint& lhs, const modint& rhs) { return modint(lhs.n * (~rhs).n); } }; istream& operator>>(istream& is, modint m) { is >> m.n; return is; } ostream& operator<<(ostream& os, modint m) { os << m.n; return os; } #define MAX_N 3030303 long long extgcd(long long a, long long b, long long& x, long long& y) { long long d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } long long mod_inverse(long long a, long long m) { long long x, y; if(extgcd(a, m, x, y) == 1) return (m + x % m) % m; else return -1; } vector<long long> fact(MAX_N+1, inf); long long mod_fact(long long n, long long& e) { if(fact[0] == inf) { fact[0]=1; if(MAX_N != 0) fact[1]=1; for(ll i = 2; i <= MAX_N; ++i) { fact[i] = (fact[i-1] * i) % mod; } } e = 0; if(n == 0) return 1; long long res = mod_fact(n / mod, e); e += n / mod; if((n / mod) % 2 != 0) return (res * (mod - fact[n % mod])) % mod; return (res * fact[n % mod]) % mod; } // return nCk long long mod_comb(long long n, long long k) { if(n < 0 || k < 0 || n < k) return 0; long long e1, e2, e3; long long a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3); if(e1 > e2 + e3) return 0; return (a1 * mod_inverse((a2 * a3) % mod, mod)) % mod; } using mi = modint; mi dp1[3030][3030][2][2]; mi dp2[3030][3030][2]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; if(n == 1) { mi ans = 2; REP(i, n) ans *= 2; cout << ans << endl; return 0; } for(int i = 0; i <= m; i++) for(int j = 0; j <= n; j++) { REP(k, 2) REP(l, 2) { if(i == 0) { if(k && l) dp1[i][j][k][l] = 1; else dp1[i][j][k][l] = 0; } else { if(j) { if(j - 1 == 0) dp1[i][j][k][l] += dp1[i - 1][j - 1][1][l] + dp1[i - 1][j][1][l]; else dp1[i][j][k][l] += dp1[i - 1][j - 1][k][l] + dp1[i - 1][j][k][l]; } if(j < n) { if(j + 1 == n) dp1[i][j][k][l] += dp1[i - 1][j + 1][k][1] + dp1[i - 1][j][k][1]; else dp1[i][j][k][l] += dp1[i - 1][j + 1][k][l] + dp1[i - 1][j][k][l]; } } } } for(int i = 0; i <= m; i++) for(int j = 0; j <= n - 1; j++) { REP(k, 2) { if(i == 0) { if(k) dp2[i][j][k] = 1; else dp2[i][j][k] = 0; } else { if(j) { if(j - 1 == 0) dp2[i][j][k] += dp2[i - 1][j - 1][1] + dp2[i - 1][j][1]; else dp2[i][j][k] += dp2[i - 1][j - 1][k] + dp2[i - 1][j][k]; } if(j < n - 1) { dp2[i][j][k] += dp2[i - 1][j + 1][k] + dp2[i - 1][j][k]; } } } } mi ans = 0; REP(i, n + 1) { if(i == 0) ans += dp1[m][i][1][0]; else if(i == n) ans += dp1[m][i][0][1]; else ans += dp1[m][i][0][0]; } REP(i, n + 1) { if(i == 0) ans += dp2[m][i][1]; else ans += dp2[m][i][0]; } cout << ans << endl; return 0; } REP(i, n + 1) { if(i == 0) ans += dp2[m][i][1]; else ans += dp2[m][i][0]; } cout << ans << endl; return 0; }
a.cc:191:6: error: stray '#' in program 191 | }#include <iostream> | ^ a.cc:11:17: error: 'int_fast64_t' in namespace 'std' does not name a type 11 | using ll = std::int_fast64_t; | ^~~~~~~~~~~~ a.cc:12:16: error: 'll' was not declared in this scope 12 | using P = pair<ll, ll>; | ^~ a.cc:12:20: error: 'll' was not declared in this scope 12 | using P = pair<ll, ll>; | ^~ a.cc:12:22: error: template argument 1 is invalid 12 | using P = pair<ll, ll>; | ^ a.cc:12:22: error: template argument 2 is invalid a.cc:13:11: error: 'll' does not name a type 13 | constexpr ll inf = 1000000000; | ^~ a.cc:14:11: error: 'll' does not name a type 14 | constexpr ll mod = 1000000007; | ^~ a.cc: In function 'std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)': a.cc:6:26: error: 'll' was not declared in this scope 6 | #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) | ^~ a.cc:7:19: note: in expansion of macro 'FOR' 7 | #define REP(i, n) FOR(i, 0, n) | ^~~ a.cc:23:5: note: in expansion of macro 'REP' 23 | REP(i, v.size()) { | ^~~ a.cc:23:9: error: 'i' was not declared in this scope 23 | REP(i, v.size()) { | ^ a.cc:6:36: note: in definition of macro 'FOR' 6 | #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) | ^ a.cc:23:5: note: in expansion of macro 'REP' 23 | REP(i, v.size()) { | ^~~ a.cc: At global scope: a.cc:31:5: error: 'll' does not name a type 31 | ll n; | ^~ a.cc:33:18: error: 'll' does not name a type 33 | modint(const ll n = 0) : n((n % mod + mod) % mod) {} | ^~ a.cc: In constructor 'modint::modint(int)': a.cc:33:30: error: class 'modint' does not have any field named 'n' 33 | modint(const ll n = 0) : n((n % mod + mod) % mod) {} | ^ a.cc:33:37: error: 'mod' was not declared in this scope; did you mean 'modf'? 33 | modint(const ll n = 0) : n((n % mod + mod) % mod) {} | ^~~ | modf a.cc: In member function 'modint modint::operator~() const': a.cc:46:52: error: 'n' was not declared in this scope; did you mean 'yn'? 46 | modint operator~() const { return (this -> pow(n, mod - 2)); } // inverse | ^ | yn a.cc:46:55: error: 'mod' was not declared in this scope; did you mean 'modf'? 46 | modint operator~() const { return (this -> pow(n, mod - 2)); } // inverse | ^~~ | modf a.cc: In function 'bool operator==(const modint&, const modint&)': a.cc:48:20: error: 'const struct modint' has no member named 'n' 48 | return lhs.n == rhs.n; | ^ a.cc:48:29: error: 'const struct modint' has no member named 'n' 48 | return lhs.n == rhs.n; | ^ a.cc: In function 'bool operator<(const modint&, const modint&)': a.cc:51:20: error: 'const struct modint' has no member named 'n' 51 | return lhs.n < rhs.n; | ^ a.cc:51:28: error: 'const struct modint' has no member named 'n' 51 | return lhs.n < rhs.n; | ^ a.cc: In function 'bool operator>(const modint&, const modint&)': a.cc:54:20: error: 'const struct modint' has no member named 'n' 54 | return lhs.n > rhs.n; | ^ a.cc:54:28: error: 'const struct modint' has no member named 'n' 54 | return lhs.n > rhs.n; | ^ a.cc: In function 'modint& operator+=(modint&, const modint&)': a.cc:57:13: error: 'struct modint' has no member named 'n' 57 | lhs.n += rhs.n; | ^ a.cc:57:22: error: 'const struct modint' has no member named 'n' 57 | lhs.n += rhs.n; | ^ a.cc:58:17: error: 'struct modint' has no member named 'n' 58 | if (lhs.n >= mod) lhs.n -= mod; | ^ a.cc:58:22: error: 'mod' was not declared in this scope; did you mean 'modf'? 58 | if (lhs.n >= mod) lhs.n -= mod; | ^~~ | modf a.cc:58:31: error: 'struct modint' has no member named 'n' 58 | if (lhs.n >= mod) lhs.n -= mod; | ^ a.cc: In function 'modint& operator-=(modint&, const modint&)': a.cc:62:13: error: 'struct modint' has no member named 'n' 62 | lhs.n -= rhs.n; | ^ a.cc:62:22: error: 'const struct modint' has no member named 'n' 62 | lhs.n -= rhs.n; | ^ a.cc:63:17: error: 'struct modint' has no member named 'n' 63 | if (lhs.n < 0) lhs.n += mod; | ^ a.cc:63:28: error: 'struct modint' has no member named 'n' 63 | if (lhs.n < 0) lhs.n += mod; | ^ a.cc:63:33: error: 'mod' was not declared in this scope; did you mean 'modf'? 63 | if (lhs.n < 0) lhs.n += mod; | ^~~ | modf a.cc: In function 'modint& operator*=(modint&, const modint&)': a.cc:67:13: error: 'struct modint' has no member named 'n' 67 | lhs.n = (lhs.n * rhs.n) % mod; | ^ a.cc:67:22: error: 'struct modint' has no member named 'n' 67 | lhs.n = (lhs.n * rhs.n) % mod; | ^ a.cc:67:30: error: 'const struct modint' has no member named 'n' 67 | lhs.n = (lhs.n * rhs.n) % mod; | ^ a.cc:67:35: error: 'mod' was not declared in this scope; did you mean 'modf'? 67 | lhs.n = (lhs.n * rhs.n) % mod; | ^~~ | modf a.cc: In function 'modint& operator/=(modint&, const modint&)': a.cc:71:13: error: 'struct modint' has no member named 'n' 71 | lhs.n = (lhs.n * (~rhs).n) % mod; | ^ a.cc:71:22: error: 'struct modint' has no member named 'n' 71 | lhs.n = (lhs.n * (~rhs).n) % mod; | ^ a.cc:71:33: error: 'struct modint' has no member named 'n' 71 | lhs.n = (lhs.n * (~rhs).n) % mod; | ^ a.cc:71:38: error: 'mod' was not declared in this scope; did you mean 'modf'? 71 | lhs.n = (lhs.n * (~rhs).n) % mod; | ^~~ | modf a.cc: In function 'modint operator+(const modint&, const modint&)': a.cc:75:27: error: 'const struct modint' has no member named 'n' 75 | return modint(lhs.n + rhs.n); | ^ a.cc:75:35: error: 'const struct modint' has no member named 'n' 75 | return modint(lhs.n + rhs.n); | ^ a.cc: In function 'modint operator-(const modint&, const modint&)': a.cc:78:27: error: 'const struct modint' has no member named 'n' 78 | return modint(lhs.n - rhs.n); | ^ a.cc:78:35: error: 'const struct modint' has no member named 'n' 78 | return modint(lhs.n - rhs.n); | ^ a.cc: In function 'modint operator*(const modint&, const modint&)': a.cc:81:27: error: 'const struct modint' has no member named 'n' 81 | return modint(lhs.n * rhs.n); | ^ a.cc:81:35: error: 'const struct modint' has no member named 'n' 81 | return modint(lhs.n * rhs.n); | ^ a.cc: In function 'modint operator/(const modint&, const modint&)': a.cc:84:27: error: 'const struct modint' has no member named 'n' 84 | return modint(lhs.n * (~rhs).n); | ^ a.cc:84:38: error: 'struct modint' has no member named 'n' 84 | return modint(lhs.n * (~rhs).n); | ^ a.cc: In function 'std::istream& operator>>(std::istream&, modint)': a.cc:87:54: error: 'struct modint' has no member named 'n' 87 | istream& operator>>(istream& is, modint m) { is >> m.n; return is; } | ^ a.cc: In function 'std::ostream& operator<<(std::ostream&, modint)': a.cc:88:54: error: 'struct modint' has no member named 'n' 88 | ostream& operator<<(ostream& os, modint m) { os << m.n; return os; } | ^ a.cc: At global scope: a.cc:106:33: error: 'inf' was not declared in this scope; did you mean 'ynf'? 106 | vector<long long> fact(MAX_N+1, inf); | ^~~ | ynf a.cc: In function 'long long int mod_fact(long long int, long long int&)': a.cc:108:19: error: 'inf' was not declared in this scope; did you mean 'ynf'? 108 | if(fact[0] == inf) { | ^~~ | ynf a.cc:111:13: error: 'll' was not declared in this scope 111 | for(ll i = 2; i <= MAX_N; ++i) { | ^~ a.cc:111:23: error: 'i' was not declared in this scope 111 | for(ll i = 2; i <= MAX_N; ++i) { | ^ a.cc:112:41: error: 'mod' was not declared in this scope; did you mean 'modf'? 112 | fact[i] = (fact[i-1] * i) % mod; | ^~~ | modf a.cc:117:34: error: 'mod' was not declared in this scope; did you mean 'modf'? 117 | long long res = mod_fact(n / mod, e); | ^~~ | modf a.cc: In function 'long long int mod_comb(long long int, long long in
s015812080
p03748
C++
#include <bits/stdc++.h> using namespace std; #ifdef DEBUG_MODE #define DBG(n) n; #else #define DBG(n) ; #endif #define REP(i,n) for(ll (i) = (0);(i) < (n);++i) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() #define Decimal fixed<<setprecision(20) #define INF 1000000000 #define LLINF 1000000000000000000 #define MOD 1000000007 typedef long long ll; typedef pair<ll,ll> P; void seica_add(ll &a,ll &b){ a += b; if(a >= MOD)a -= MOD; } int dp[3333][3333][2]; int main(){ ll n,m;cin >> n >> m; REP(i,n+1){ if(i == 0)dp[0][i][1] = 1; else dp[0][i][0] = 1; } REP(i,m){ REP(j,n+1){ REP(k,2){ if(dp[i][j][k]){ if(j > 0){ if(j == 1){ seica_add(dp[i+1][j-1][1],dp[i][j][k]); seica_add(dp[i+1][j][1],dp[i][j][k]); } else{ seica_add(dp[i+1][j-1][k],dp[i][j][k]); seica_add(dp[i+1][j][k],dp[i][j][k]); } } if(j < n){ seica_add(dp[i+1][j+1][k],dp[i][j][k]); seica_add(dp[i+1][j][k],dp[i][j][k]); } } } } } ll ans = 0; REP(i,n+1)seica_add(ans,dp[m][i][1]); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:48:81: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 48 | seica_add(dp[i+1][j-1][1],dp[i][j][k]); | ~~~~~~~~~~~~~~^ a.cc:26:20: note: initializing argument 1 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^ a.cc:49:79: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 49 | seica_add(dp[i+1][j][1],dp[i][j][k]); | ~~~~~~~~~~~~^ a.cc:26:20: note: initializing argument 1 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^ a.cc:52:81: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 52 | seica_add(dp[i+1][j-1][k],dp[i][j][k]); | ~~~~~~~~~~~~~~^ a.cc:26:20: note: initializing argument 1 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^ a.cc:53:79: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 53 | seica_add(dp[i+1][j][k],dp[i][j][k]); | ~~~~~~~~~~~~^ a.cc:26:20: note: initializing argument 1 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^ a.cc:58:73: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 58 | seica_add(dp[i+1][j+1][k],dp[i][j][k]); | ~~~~~~~~~~~~~~^ a.cc:26:20: note: initializing argument 1 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^ a.cc:59:71: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 59 | seica_add(dp[i+1][j][k],dp[i][j][k]); | ~~~~~~~~~~~~^ a.cc:26:20: note: initializing argument 1 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^ a.cc:68:43: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to a value of type 'int' 68 | REP(i,n+1)seica_add(ans,dp[m][i][1]); | ~~~~~~~~~~^ a.cc:26:26: note: initializing argument 2 of 'void seica_add(ll&, ll&)' 26 | void seica_add(ll &a,ll &b){ | ~~~~^
s999995958
p03748
C++
l#include<bits/stdc++.h> typedef long long ll; const ll N = 3010; const ll moder = 1e9 + 7; ll dp[N][N << 1]; ll &getdp(ll i, ll j){ return dp[i][j + N]; } void add(ll &a, ll b){ a += b; a -= a >= moder ? moder : 0; a += a < 0 ? moder : 0; } void addmult(ll &a, ll b, ll c){ a = (a + 1ll * b * c) % moder; a += a < 0 ? moder : 0; } int main(){ ll n, m; scanf("%lld%lld", &n, &m); getdp(0, 0) = 1; for (ll i = 0; i < m - 1; ++ i){ for (ll j = 1 - n; j <= n - 1; ++ j){ addmult(getdp(i + 1, j), 2, getdp(i, j)); add(getdp(i + 1, j - 1), getdp(i, j)); add(getdp(i + 1, j + 1), getdp(i, j)); } } ll ans = 0; for (ll i = 1 - n; i <= n - 1; ++ i){ addmult(ans, 4, getdp(m - 1, i)); } printf("%lld\n", ans); return 0; }
a.cc:1:2: error: stray '#' in program 1 | l#include<bits/stdc++.h> | ^ a.cc:1:1: error: 'l' does not name a type 1 | l#include<bits/stdc++.h> | ^ a.cc:5:7: error: 'll' does not name a type 5 | const ll N = 3010; | ^~ a.cc:6:7: error: 'll' does not name a type 6 | const ll moder = 1e9 + 7; | ^~ a.cc:8:1: error: 'll' does not name a type 8 | ll dp[N][N << 1]; | ^~ a.cc:10:1: error: 'll' does not name a type 10 | ll &getdp(ll i, ll j){ | ^~ a.cc:14:6: error: variable or field 'add' declared void 14 | void add(ll &a, ll b){ | ^~~ a.cc:14:10: error: 'll' was not declared in this scope 14 | void add(ll &a, ll b){ | ^~ a.cc:14:14: error: 'a' was not declared in this scope 14 | void add(ll &a, ll b){ | ^ a.cc:14:17: error: 'll' was not declared in this scope 14 | void add(ll &a, ll b){ | ^~ a.cc:20:6: error: variable or field 'addmult' declared void 20 | void addmult(ll &a, ll b, ll c){ | ^~~~~~~ a.cc:20:14: error: 'll' was not declared in this scope 20 | void addmult(ll &a, ll b, ll c){ | ^~ a.cc:20:18: error: 'a' was not declared in this scope 20 | void addmult(ll &a, ll b, ll c){ | ^ a.cc:20:21: error: 'll' was not declared in this scope 20 | void addmult(ll &a, ll b, ll c){ | ^~ a.cc:20:27: error: 'll' was not declared in this scope 20 | void addmult(ll &a, ll b, ll c){ | ^~ a.cc: In function 'int main()': a.cc:26:5: error: 'll' was not declared in this scope 26 | ll n, m; | ^~ a.cc:27:24: error: 'n' was not declared in this scope 27 | scanf("%lld%lld", &n, &m); | ^ a.cc:27:28: error: 'm' was not declared in this scope 27 | scanf("%lld%lld", &n, &m); | ^ a.cc:27:5: error: 'scanf' was not declared in this scope 27 | scanf("%lld%lld", &n, &m); | ^~~~~ a.cc:28:5: error: 'getdp' was not declared in this scope 28 | getdp(0, 0) = 1; | ^~~~~ a.cc:29:12: error: expected ';' before 'i' 29 | for (ll i = 0; i < m - 1; ++ i){ | ^~ | ; a.cc:29:20: error: 'i' was not declared in this scope 29 | for (ll i = 0; i < m - 1; ++ i){ | ^ a.cc:30:16: error: expected ';' before 'j' 30 | for (ll j = 1 - n; j <= n - 1; ++ j){ | ^~ | ; a.cc:30:28: error: 'j' was not declared in this scope 30 | for (ll j = 1 - n; j <= n - 1; ++ j){ | ^ a.cc:31:13: error: 'addmult' was not declared in this scope 31 | addmult(getdp(i + 1, j), 2, getdp(i, j)); | ^~~~~~~ a.cc:32:13: error: 'add' was not declared in this scope 32 | add(getdp(i + 1, j - 1), getdp(i, j)); | ^~~ a.cc:36:7: error: expected ';' before 'ans' 36 | ll ans = 0; | ^~~~ | ; a.cc:37:12: error: expected ';' before 'i' 37 | for (ll i = 1 - n; i <= n - 1; ++ i){ | ^~ | ; a.cc:37:24: error: 'i' was not declared in this scope 37 | for (ll i = 1 - n; i <= n - 1; ++ i){ | ^ a.cc:38:17: error: 'ans' was not declared in this scope 38 | addmult(ans, 4, getdp(m - 1, i)); | ^~~ a.cc:38:9: error: 'addmult' was not declared in this scope 38 | addmult(ans, 4, getdp(m - 1, i)); | ^~~~~~~ a.cc:40:22: error: 'ans' was not declared in this scope 40 | printf("%lld\n", ans); | ^~~ a.cc:40:5: error: 'printf' was not declared in this scope 40 | printf("%lld\n", ans); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | l#include<bits/stdc++.h>
s459825522
p03748
C++
#include<iostream> #include<cstdio> using namespace std; int n,m; int dp[2][3010][2]; int ans; const int md=1e9+7; void add(int &a,int b) { a+=b; if(a>=md)a-=md; } int main() { scanf("%d%d",&n,&m); for(int i=0;i<=n;i++)dp[0][i][0]=1; for(int i=1;i<=m;i++) { int ii=i&1; memset(dp[ii],0,sizeof(dp[ii])); for(int j=0;j<=n;j++) { for(int st=0;st<2;st++) { int nst; if(j>=1) { nst=st; if(j==1)nst=1; add(dp[ii][j-1][nst],dp[ii^1][j][st]);//rr add(dp[ii][j][nst],dp[ii^1][j][st]);//rb } if(j<n) { nst=st; if(!j)nst=1; add(dp[ii][j+1][nst],dp[ii^1][j][st]);//bb add(dp[ii][j][nst],dp[ii^1][j][st]);//br } } } } for(int i=0;i<=n;i++)add(ans,dp[m&1][i][1]); printf("%d",ans); return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'memset' was not declared in this scope 20 | memset(dp[ii],0,sizeof(dp[ii])); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<cstdio> +++ |+#include <cstring> 3 | using namespace std;
s420056184
p03748
C++
At least 50 characters At least 50 characters At least 50 characters At least 50 characters At least 50 characters At least 50 characters At least 50 characters
a.cc:1:1: error: 'At' does not name a type 1 | At least 50 characters | ^~
s796017409
p03748
C++
#include<bits/stdc++.h> using namespace std; const int mod = 1000000007; int N, M; vector<vector<vector<int> > > cc; int dp(int m, int r, int z) { int &ret = cc[m][r][z]; if(ret != -1) return ret; if(m == 0) return ret = z | (r == 0); ret = 2 * dp(m - 1, r, z | (r == 0)) % mod; if(r != 0) ret = (ret + dp(m - 1, r - 1, z | (r == 0))) % mod; if(r != N) ret = (ret + dp(m - 1, r + 1, z | (r == 0))) % mod; return ret; } int main() { scanf("%d %d", &N, &M); N--; M--; cc = vector<vector<vector<int> > >(M + 1, vector<vector<int> >(N + 1, vector<int>(2, -1))); ll ans = 0; for(int i = 0; i <= N; i++) { ans += dp(M, i, 0); ans %= mod; } ans = ans * 4 % mod; printf("%lld", ans); }
a.cc: In function 'int main()': a.cc:25:5: error: 'll' was not declared in this scope 25 | ll ans = 0; | ^~ a.cc:27:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 27 | ans += dp(M, i, 0); | ^~~ | abs a.cc:30:5: error: 'ans' was not declared in this scope; did you mean 'abs'? 30 | ans = ans * 4 % mod; | ^~~ | abs
s404605118
p03749
C++
#include <bits/stdc++.h> using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define PQ priority_queue #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it) #define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it) template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- template<typename T, int N> struct Matrix { vector<vector<T>> a; Matrix(const vector<vector<T>> & v = { }) { init(v); } void init(const vector<vector<T>> & v) { a = vector<vector<T>>(N, vector<T>(N, 0)); assert(v.size() <= N); inc(i, v.size()) { assert(v[i].size() <= N); inc(j, v[i].size()) { a[i][j] = v[i][j]; } } } vector<T> & operator[](int i) { return a[i]; } Matrix id() { Matrix e; inc(i, N) { e[i][i] = 1; } return e; } Matrix tp() { Matrix b; inc(i, N) { inc(j, N) { b[j][i] = a[i][j]; } } return b; } Matrix & operator+=(const Matrix & b) { inc(i, N) { inc(j, N) { a[i][j] += b.a[i][j]; } } return (*this); } Matrix & operator*=(T b) { inc(i, N) { inc(j, N) { a[i][j] *= b; } } return (*this); } Matrix & operator*=(const Matrix & b) { Matrix c; inc(i, N) { inc(j, N) { inc(k, N) { c[i][j] += a[i][k] * b.a[k][j]; } } } return (*this) = c; } Matrix & operator^=(LU b) { Matrix t[64], c = id(); int D = 64; inc(i, D) { if((b >> i) == 0) { D = i; break; } } inc(i, D) { t[i] = (i == 0 ? (*this) : t[i - 1] * t[i - 1]); } inc(i, D) { if((b >> i) & 1) { c *= t[i]; } } return (*this) = c; } Matrix operator+(const Matrix & b) const { Matrix c = a; return c += b; } Matrix operator*( T b) const { Matrix c = a; return c *= b; } Matrix operator*(const Matrix & b) const { Matrix c = a; return c *= b; } Matrix operator^( LU b) const { Matrix c = a; return c ^= b; } }; template<typename T, int N> Matrix<T, N> operator*(T a, const Matrix<T, N> & b) { return b * a; } template<typename T, int N> ostream & operator<<(ostream & os, const Matrix<T, N> & m) { inc(i, N) { inc(j, N) { os << m.a[i][j] << " "; } os << endl; } return os; } // ---- ---- template<int N = 0> class ModInt { private: LL v = 0; static LL m; public: ModInt() { } ModInt(LL vv) { setval(vv); } // ModInt & setval(LL vv) { v = (inID(vv, 0, m) ? vv : vv % m); if(v < 0) { v += m; } return (*this); } ModInt & setval(LL vv) { v = (vv < (1 << 30) ? vv : vv % m); return (*this); } //////// static void setmod(LL mm) { m = mm; } LL getval() const { return v; } ModInt & operator+=(const ModInt & b) { return setval(v + b.v); } ModInt & operator-=(const ModInt & b) { return setval(v - b.v); } ModInt & operator*=(const ModInt & b) { return setval(v * b.v); } ModInt & operator/=(const ModInt & b) { return setval(v * b.inv()); } ModInt & operator^=( LU b) { return setval(ex(v, b)); } ModInt operator+ ( ) const { return ModInt(+v); } ModInt operator- ( ) const { return ModInt(-v); } ModInt operator+ (const ModInt & b) const { return ModInt(v + b.v); } ModInt operator- (const ModInt & b) const { return ModInt(v - b.v); } ModInt operator* (const ModInt & b) const { return ModInt(v * b.v); } ModInt operator/ (const ModInt & b) const { return ModInt(v * b.inv()); } ModInt operator^ ( LU b) const { return ModInt(ex(v, b)); } LL inv() const { LL x = (ex_gcd(v, m).FI + m) % m; assert(v * x % m == 1); return x; } LL ex(LL a, LU b) const { LL D = 64, x[64], y = 1; inc(i, D) { if((b >> i) == 0) { D = i; break; } } inc(i, D) { x[i] = (i == 0 ? a : x[i - 1] * x[i - 1]) % m; } inc(i, D) { if((b >> i) & 1) { (y *= x[i]) %= m; } } return y; } pair<LL, LL> ex_gcd(LL a, LL b) const { if(b == 0) { return MP(1, 0); } auto p = ex_gcd(b, a % b); return MP(p.SE, p.FI - (a / b) * p.SE); } }; template<int N> LL ModInt<N>::m; template<int N> ModInt<N> operator+(LL a, const ModInt<N> & b) { return b + a; } template<int N> ModInt<N> operator-(LL a, const ModInt<N> & b) { return -b + a; } template<int N> ModInt<N> operator*(LL a, const ModInt<N> & b) { return b * a; } template<int N> ModInt<N> operator/(LL a, const ModInt<N> & b) { return a * b.inv(); } template<int N> istream & operator>>(istream & is, ModInt<N> & b) { LL v; is >> v; b.setval(v); return is; } template<int N> ostream & operator<<(ostream & os, const ModInt<N> & b) { return (os << b.getval()); } // ---- ---- int n, m, x[100002]; int main() { cin >> n >> m; x[0] = 0; inc1(i, m) { cin >> x[i]; } x[m + 1] = n; ModInt<>::setmod(1e9 + 7); Matrix<ModInt<>, 3> a({ { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 1 } }); Matrix<ModInt<>, 3> b({ { 2, 3, 2 }, { 1, 1, 0 }, { 0, 1, 1 } }); Matrix<ModInt<>, 3> c({ { 0, 1, 2 } }); incII(i, 0, m) { c *= a * (b ^ (x[i + 1] - x[i] - 1)); } cout << c[0][0].getval() % (1e9 + 7) << endl; return 0; }
a.cc: In function 'int main()': a.cc:185:34: error: invalid operands of types 'LL' {aka 'long long int'} and 'double' to binary 'operator%' 185 | cout << c[0][0].getval() % (1e9 + 7) << endl; | ~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~ | | | | | double | LL {aka long long int}
s166261848
p03749
C++
#include <bits/stdc++.h> using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define PQ priority_queue #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it) #define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it) template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- template<typename T, int N> struct Matrix { vector<vector<T>> a; Matrix(const vector<vector<T>> & v = { }) { init(v); } void init(const vector<vector<T>> & v) { a = vector<vector<T>>(N, vector<T>(N, 0)); assert(v.size() <= N); inc(i, v.size()) { assert(v[i].size() <= N); inc(j, v[i].size()) { a[i][j] = v[i][j]; } } } vector<T> & operator[](int i) { return a[i]; } Matrix id() { Matrix e; inc(i, N) { e[i][i] = 1; } return e; } Matrix tp() { Matrix b; inc(i, N) { inc(j, N) { b[j][i] = a[i][j]; } } return b; } Matrix & operator+=(const Matrix & b) { inc(i, N) { inc(j, N) { a[i][j] += b.a[i][j]; } } return (*this); } Matrix & operator*=(T b) { inc(i, N) { inc(j, N) { a[i][j] *= b; } } return (*this); } Matrix & operator*=(const Matrix & b) { Matrix c; inc(i, N) { inc(j, N) { inc(k, N) { c[i][j] += a[i][k] * b.a[k][j]; } } } return (*this) = c; } Matrix & operator^=(LU b) { Matrix t[64], c = id(); int D = 64; inc(i, D) { if((b >> i) == 0) { D = i; break; } } inc(i, D) { t[i] = (i == 0 ? (*this) : t[i - 1] * t[i - 1]); } inc(i, D) { if((b >> i) & 1) { c *= t[i]; } } return (*this) = c; } Matrix operator+(const Matrix & b) const { Matrix c = a; return c += b; } Matrix operator*( T b) const { Matrix c = a; return c *= b; } Matrix operator*(const Matrix & b) const { Matrix c = a; return c *= b; } Matrix operator^( LU b) const { Matrix c = a; return c ^= b; } }; template<typename T, int N> Matrix<T, N> operator*(T a, const Matrix<T, N> & b) { return b * a; } template<typename T, int N> ostream & operator<<(ostream & os, const Matrix<T, N> & m) { inc(i, N) { inc(j, N) { os << m.a[i][j] << " "; } os << endl; } return os; } // ---- ---- template<int N = 0> class ModInt { private: LL v = 0; static LL m; public: ModInt() { } ModInt(LL vv) { setval(vv); } // ModInt & setval(LL vv) { v = (inID(vv, 0, m) ? vv : vv % m); if(v < 0) { v += m; } return (*this); } ModInt & setval(LL vv) { v = (vv < (1 << 30) ? vv : vv % m); return (*this); } //////// static void setmod(LL mm) { m = mm; } LL getval() const { return v; } ModInt & operator+=(const ModInt & b) { return setval(v + b.v); } ModInt & operator-=(const ModInt & b) { return setval(v - b.v); } ModInt & operator*=(const ModInt & b) { return setval(v * b.v); } ModInt & operator/=(const ModInt & b) { return setval(v * b.inv()); } ModInt & operator^=( LU b) { return setval(ex(v, b)); } ModInt operator+ ( ) const { return ModInt(+v); } ModInt operator- ( ) const { return ModInt(-v); } ModInt operator+ (const ModInt & b) const { return ModInt(v + b.v); } ModInt operator- (const ModInt & b) const { return ModInt(v - b.v); } ModInt operator* (const ModInt & b) const { return ModInt(v * b.v); } ModInt operator/ (const ModInt & b) const { return ModInt(v * b.inv()); } ModInt operator^ ( LU b) const { return ModInt(ex(v, b)); } LL inv() const { LL x = (ex_gcd(v, m).FI + m) % m; assert(v * x % m == 1); return x; } LL ex(LL a, LU b) const { LL D = 64, x[64], y = 1; inc(i, D) { if((b >> i) == 0) { D = i; break; } } inc(i, D) { x[i] = (i == 0 ? a : x[i - 1] * x[i - 1]) % m; } inc(i, D) { if((b >> i) & 1) { (y *= x[i]) %= m; } } return y; } pair<LL, LL> ex_gcd(LL a, LL b) const { if(b == 0) { return MP(1, 0); } auto p = ex_gcd(b, a % b); return MP(p.SE, p.FI - (a / b) * p.SE); } }; template<int N> LL ModInt<N>::m; template<int N> ModInt<N> operator+(LL a, const ModInt<N> & b) { return b + a; } template<int N> ModInt<N> operator-(LL a, const ModInt<N> & b) { return -b + a; } template<int N> ModInt<N> operator*(LL a, const ModInt<N> & b) { return b * a; } template<int N> ModInt<N> operator/(LL a, const ModInt<N> & b) { return a * b.inv(); } template<int N> istream & operator>>(istream & is, ModInt<N> & b) { LL v; is >> v; b.setval(v); return is; } template<int N> ostream & operator<<(ostream & os, const ModInt<N> & b) { return (os << b.getval()); } // ---- ---- int n, m, x[100002]; int main() { cin >> n >> m; x[0] = 0; inc1(i, m) { cin >> x[i]; } x[m + 1] = n; ModInt<>::setmod(1e9 + 7); Matrix<ModInt<>, 3> a({ { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 1 } }); Matrix<ModInt<>, 3> b({ { 2, 3, 2 }, { 1, 1, 0 }, { 0, 1, 1 } }); Matrix<ModInt<>, 3> c({ { 0, 1, 2 } }); incII(i, 0, m) { c *= a * (b ^ (x[i + 1] - x[i] - 1)); } cout << c[0][0] % (1'000'000'007) << endl; return 0; }
a.cc: In function 'int main()': a.cc:185:25: error: no match for 'operator%' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} and 'int') 185 | cout << c[0][0] % (1'000'000'007) << endl; 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:409:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:41: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:41: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:41: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:41: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:41: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const valarray<_Tp>&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:185:41: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::valarray<_Tp>' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:185:41: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::valarray<_Tp>' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:185:41: note: mismatched types 'const std::valarray<_Tp>' and 'int' 185 | cout << c[0][0] % (1'000'000'007) << endl; | ^
s745735888
p03749
C++
#include <bits/stdc++.h> using namespace std; typedef long long signed int LL; typedef long long unsigned int LU; #define incID(i, l, r) for(int i = (l) ; i < (r); i++) #define incII(i, l, r) for(int i = (l) ; i <= (r); i++) #define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--) #define decII(i, l, r) for(int i = (r) ; i >= (l); i--) #define inc(i, n) incID(i, 0, n) #define inc1(i, n) incII(i, 1, n) #define dec(i, n) decID(i, 0, n) #define dec1(i, n) decII(i, 1, n) #define inII(v, l, r) ((l) <= (v) && (v) <= (r)) #define inID(v, l, r) ((l) <= (v) && (v) < (r)) #define PB push_back #define EB emplace_back #define MP make_pair #define FI first #define SE second #define PQ priority_queue #define ALL(v) v.begin(), v.end() #define RALL(v) v.rbegin(), v.rend() #define FOR(it, v) for(auto it = v.begin(); it != v.end(); ++it) #define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it) template<typename T> bool setmin(T & a, T b) { if(b < a) { a = b; return true; } else { return false; } } template<typename T> bool setmax(T & a, T b) { if(b > a) { a = b; return true; } else { return false; } } template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } } template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } } template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); } template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; } // ---- ---- template<typename T, int N> struct Matrix { vector<vector<T>> a; Matrix(const vector<vector<T>> & v = { }) { init(v); } void init(const vector<vector<T>> & v) { a = vector<vector<T>>(N, vector<T>(N, 0)); assert(v.size() <= N); inc(i, v.size()) { assert(v[i].size() <= N); inc(j, v[i].size()) { a[i][j] = v[i][j]; } } } vector<T> & operator[](int i) { return a[i]; } Matrix id() { Matrix e; inc(i, N) { e[i][i] = 1; } return e; } Matrix tp() { Matrix b; inc(i, N) { inc(j, N) { b[j][i] = a[i][j]; } } return b; } Matrix & operator+=(const Matrix & b) { inc(i, N) { inc(j, N) { a[i][j] += b.a[i][j]; } } return (*this); } Matrix & operator*=(T b) { inc(i, N) { inc(j, N) { a[i][j] *= b; } } return (*this); } Matrix & operator*=(const Matrix & b) { Matrix c; inc(i, N) { inc(j, N) { inc(k, N) { c[i][j] += a[i][k] * b.a[k][j]; } } } return (*this) = c; } Matrix & operator^=(LU b) { Matrix t[64], c = id(); int D = 64; inc(i, D) { if((b >> i) == 0) { D = i; break; } } inc(i, D) { t[i] = (i == 0 ? (*this) : t[i - 1] * t[i - 1]); } inc(i, D) { if((b >> i) & 1) { c *= t[i]; } } return (*this) = c; } Matrix operator+(const Matrix & b) const { Matrix c = a; return c += b; } Matrix operator*( T b) const { Matrix c = a; return c *= b; } Matrix operator*(const Matrix & b) const { Matrix c = a; return c *= b; } Matrix operator^( LU b) const { Matrix c = a; return c ^= b; } }; template<typename T, int N> Matrix<T, N> operator*(T a, const Matrix<T, N> & b) { return b * a; } template<typename T, int N> ostream & operator<<(ostream & os, const Matrix<T, N> & m) { inc(i, N) { inc(j, N) { os << m.a[i][j] << " "; } os << endl; } return os; } // ---- ---- template<int N = 0> class ModInt { private: LL v = 0; static LL m; public: ModInt() { } ModInt(LL vv) { setval(vv); } // ModInt & setval(LL vv) { v = (inID(vv, 0, m) ? vv : vv % m); if(v < 0) { v += m; } return (*this); } ModInt & setval(LL vv) { v = (vv < (1 << 30) ? vv : vv % m); return (*this); } //////// static void setmod(LL mm) { m = mm; } LL getval() const { return v; } ModInt & operator+=(const ModInt & b) { return setval(v + b.v); } ModInt & operator-=(const ModInt & b) { return setval(v - b.v); } ModInt & operator*=(const ModInt & b) { return setval(v * b.v); } ModInt & operator/=(const ModInt & b) { return setval(v * b.inv()); } ModInt & operator^=( LU b) { return setval(ex(v, b)); } ModInt operator+ ( ) const { return ModInt(+v); } ModInt operator- ( ) const { return ModInt(-v); } ModInt operator+ (const ModInt & b) const { return ModInt(v + b.v); } ModInt operator- (const ModInt & b) const { return ModInt(v - b.v); } ModInt operator* (const ModInt & b) const { return ModInt(v * b.v); } ModInt operator/ (const ModInt & b) const { return ModInt(v * b.inv()); } ModInt operator^ ( LU b) const { return ModInt(ex(v, b)); } LL inv() const { LL x = (ex_gcd(v, m).FI + m) % m; assert(v * x % m == 1); return x; } LL ex(LL a, LU b) const { LL D = 64, x[64], y = 1; inc(i, D) { if((b >> i) == 0) { D = i; break; } } inc(i, D) { x[i] = (i == 0 ? a : x[i - 1] * x[i - 1]) % m; } inc(i, D) { if((b >> i) & 1) { (y *= x[i]) %= m; } } return y; } pair<LL, LL> ex_gcd(LL a, LL b) const { if(b == 0) { return MP(1, 0); } auto p = ex_gcd(b, a % b); return MP(p.SE, p.FI - (a / b) * p.SE); } }; template<int N> LL ModInt<N>::m; template<int N> ModInt<N> operator+(LL a, const ModInt<N> & b) { return b + a; } template<int N> ModInt<N> operator-(LL a, const ModInt<N> & b) { return -b + a; } template<int N> ModInt<N> operator*(LL a, const ModInt<N> & b) { return b * a; } template<int N> ModInt<N> operator/(LL a, const ModInt<N> & b) { return a * b.inv(); } template<int N> istream & operator>>(istream & is, ModInt<N> & b) { LL v; is >> v; b.setval(v); return is; } template<int N> ostream & operator<<(ostream & os, const ModInt<N> & b) { return (os << b.getval()); } // ---- ---- int n, m, x[100002]; int main() { cin >> n >> m; x[0] = 0; inc1(i, m) { cin >> x[i]; } x[m + 1] = n; ModInt<>::setmod(1e9 + 7); Matrix<ModInt<>, 3> a({ { 1, 0, 0 }, { 1, 1, 0 }, { 0, 1, 1 } }); Matrix<ModInt<>, 3> b({ { 2, 3, 2 }, { 1, 1, 0 }, { 0, 1, 1 } }); Matrix<ModInt<>, 3> c({ { 0, 1, 2 } }); incII(i, 0, m) { c *= a * (b ^ (x[i + 1] - x[i] - 1)); } cout << c[0][0] % (1e9 + 7) << endl; return 0; }
a.cc: In function 'int main()': a.cc:185:25: error: no match for 'operator%' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} and 'double') 185 | cout << c[0][0] % (1e9 + 7) << endl; 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:409:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:35: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:35: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:35: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'double' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:35: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/bits/valarray_after.h:409:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__modulus, typename _Dom1::value_type>::result_type> std::operator%(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 409 | _DEFINE_EXPR_BINARY_OPERATOR(%, struct std::__modulus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:409:5: note: template argument deduction/substitution failed: a.cc:185:35: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'double' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const valarray<_Tp>&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:185:35: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::valarray<_Tp>' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:185:35: note: '__gnu_cxx::__alloc_traits<std::allocator<ModInt<> >, ModInt<> >::value_type' {aka 'ModInt<>'} is not derived from 'const std::valarray<_Tp>' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^ /usr/include/c++/14/valarray:1200:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__modulus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__modulus, _Tp>::result_type> std::operator%(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1200 | _DEFINE_BINARY_OPERATOR(%, __modulus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1200:1: note: template argument deduction/substitution failed: a.cc:185:35: note: mismatched types 'const std::valarray<_Tp>' and 'double' 185 | cout << c[0][0] % (1e9 + 7) << endl; | ^
s925576622
p03749
C++
10 9 1 2 3 4 5 6 7 8 9
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 10 9 | ^~
s449439612
p03749
C++
#include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<vector> #include<iostream> const long long mod=1000000007; using namespace std; long long pos[100003]; long long n,m; struct node{ long long x[3][3]; inline void operator *=(const node &a){ long long c[3][3]={0}; for(int i=0;i<=2;i++){ for(int j=0;j<=2;j++){ for(int k=0;k<=2;k++){ c[i][j]=(c[i][j]+x[i][k]*a.x[k][j]%mod)mod; } } } for(int i=0;i<=2;i++){ for(int j=0;j<=2;j++){ x[i][j]=c[i][j]; } } } }e,a,e1,e2; inline void fsp(node &x,node y,long long t){ node y1=y; for(;t;t>>=1){ if(t&1){ x*=y1; } } } long long A[3],B[3]; int main(){ cin>>n>>m; for(int i=1;i<=m;i++){ cin>>pos[i]; } e.x[0][0]=e.x[1][1]=e.x[2][2]=e.x[1][2]=e.x[0][2]=1; e.x[0][1]=2; e2.x[0][0]=e2.x[1][1]=e2.x[2][2]=e2.x[2][0]=1; e1=e; e1*=e2; pos[m+1]=n; B[0]=1; for(int l=1;l<=m+1;l++){ int s=pos[l]-pos[l-1]-1; memset(a.x,0,sizeof(a.x)); for(int i=0;i<3;i++){ a.x[i][i]=1; } fsp(a,e1,s); a*=e; for(int i=0;i<=2;i++){ A[i]=0; for(int j=0;j<=2;j++){ A[i]=(A[i]+B[j]*a.x[j][i])%mod; } } for(int i=0;i<=2;i++){ B[i]=A[i]; } } cout<<B[2]<<endl; return 0; } /* in: 10 9 1 2 3 4 5 6 7 8 9 out: 100 */ //f[i][0]=f[i-1][0]; //f[i][1]=f[i-1][0]+f[i-1][1]; //f[i][2]=2*f[i-1][1]+f[i-1][2]+f[i-1][0]; i-1到i无隔板 //f[i][0]=f[i-1][2]; //f[i][1]=f[i-1][2]; //f[i][2]=f[i-1][2]; i-1到i有隔板
a.cc: In member function 'void node::operator*=(const node&)': a.cc:18:80: error: expected ';' before 'mod' 18 | c[i][j]=(c[i][j]+x[i][k]*a.x[k][j]%mod)mod; | ^~~
s611451557
p03749
C++
#include<bits/stdc++.h> using namespace std; typedef long long giant; inline char nchar() { static const int bufl=1<<20; static char buf[bufl],*a=NULL,*b=NULL; return a==b && (b=(a=buf)+fread(buf,1,bufl,stdin),a==b)?EOF:*a++; } inline int read() { int x=0,f=1; char c=nchar(); for (;!isdigit(c);c=nchar()) if (c=='-') f=-1; for (;isdigit(c);c=nchar()) x=x*10+c-'0'; return x*f; } const int q=1e9+7; const giant mod=(LLONG_MAX/q-1)*q; const int maxn=3; const int maxm=1e5+1; const int maxj=31; int n,m,c[maxm]; struct mat { int n,m; int a[maxn][maxn]; mat () {clear();} mat (int _n,int _m):n(_n),m(_m) {clear();} inline void clear() { memset(a,0,sizeof a); } void init_A() { n=m=3; a[0][0]=2,a[0][1]=2,a[0][2]=1; a[1][0]=1,a[1][1]=1,a[1][2]=1; a[2][0]=1,a[2][1]=0,a[2][2]=1; } void init_B() { n=m=3; a[0][0]=1,a[0][1]=2,a[0][2]=1; a[1][0]=0,a[1][1]=1,a[1][2]=1; a[2][0]=0,a[2][1]=0,a[2][2]=1; } void init_f() { n=3,m=1; a[0][0]=1,a[1][0]=1,a[2][0]=1; } inline void eye(int _n,int _m) { n=_n,m=_m; assert(n==m); clear(); for (int i=0;i<n;++i) a[i][i]=1; } mat operator * (const mat &b) const { assert(m==b.n); mat ret(n,b.m); for (int i=0;i<n;++i) for (int j=0;j<b.m;++j) { giant tmp(0); for (int k=0;k<m;++k) if ((tmp+=1ll*a[i][k]*b.a[k][j])>=mod) tmp-=mod; ret.a[i][j]=tmp%q; } return ret; } } mi[maxj],A,B,f; mat go(int y) { mat ret; ret.eye(3,3); for (int j=0;j<maxj;++j) if (y>>j&1) ret=ret*mi[j]; return ret; } int main() { n=read(),m=read(),generate_n(c+1,m,read); A.init_A(),B.init_B(),f.init_f(); mi[0]=A; for (int j=1;j<maxj;++j) mi[j]=mi[j-1]*mi[i-1]; int now=1; for (int i=1;i<=m;++i) { f=B*go(c[i]-now)*f; now=c[i]+1; } f=go(n-now)*f; int ans=f.a[0][0]; printf("%d\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:70:37: error: no matching function for call to 'generate_n(int*, int&, <unresolved overloaded function type>)' 70 | n=read(),m=read(),generate_n(c+1,m,read); | ~~~~~~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:4378:5: note: candidate: 'template<class _OIter, class _Size, class _Generator> _OIter std::generate_n(_OIter, _Size, _Generator)' 4378 | generate_n(_OutputIterator __first, _Size __n, _Generator __gen) | ^~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4378:5: note: template argument deduction/substitution failed: a.cc:70:37: note: couldn't deduce template parameter '_Generator' 70 | n=read(),m=read(),generate_n(c+1,m,read); | ~~~~~~~~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:204:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Size, class _Generator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::generate_n(_ExecutionPolicy&&, _ForwardIterator, _Size, _Generator)' 204 | generate_n(_ExecutionPolicy&& __exec, _ForwardIterator __first, _Size count, _Generator __g); | ^~~~~~~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:204:1: note: candidate expects 4 arguments, 3 provided a.cc:73:51: error: 'i' was not declared in this scope 73 | for (int j=1;j<maxj;++j) mi[j]=mi[j-1]*mi[i-1]; | ^
s359295276
p03749
C++
#include <stdio.h> const long long mod = 1000000007; struct mat { long long a[3][3]; mat operator -(mat t) { mat r; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++){ r.a[i][j] = (a[i][j] + mod - t.a[i][j]) % mod; } return r; } mat operator *(mat t){ mat r; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++){ r.a[i][j] = 0; for (int k = 0; k < 3; k++) { r.a[i][j] = (r.a[i][j] + a[i][k] * t.a[k][j]) % mod; } } return r; } }; mat pow(mat a, int p) { mat r; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) r.a[i][j] = 0; for (int i = 0; i < 3; i++) r.a[i][i] = 1; while (p) { if (p & 1) r = r * a; a = a * a; p /= 2; } return r; } int N, M, X[100100]; long long D[100100]; long long get(mat &t) { return (t.a[2][0] * 5 + t.a[2][1]) % mod; } int main() { scanf("%d %d", &N, &M); for (int t = 1; t <= M; t++) scanf("%d", &X[t]); X[M + 1] = N; mat base = { 4,mod - 2,1,1,0,0,0,1,0 }; mat sum = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int i = 1; i <= M + 1; i++) { sum = sum * pow(base, X[i] - X[i-1]); D[i] = get(pow(base, X[i]) - sum); for (int k = 0; k < 3; k++) sum.a[k][k] = (sum.a[k][k] + D[i]) % mod; } printf("%lld\n", D[M+1]); return 0; }
a.cc: In function 'int main()': a.cc:59:44: error: cannot bind non-const lvalue reference of type 'mat&' to an rvalue of type 'mat' 59 | D[i] = get(pow(base, X[i]) - sum); | ~~~~~~~~~~~~~~~~^~~~~ a.cc:44:20: note: initializing argument 1 of 'long long int get(mat&)' 44 | long long get(mat &t) { | ~~~~~^
s692836369
p03749
C++
#include <stdio.h> const long long mod = 1000000007; struct mat { long long a[3][3]; mat operator -(const mat& t) const { mat r; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++){ r.a[i][j] = (a[i][j] + mod - t.a[i][j]) % mod; } return r; } mat operator *(const mat& t) const { mat r; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++){ r.a[i][j] = 0; for (int k = 0; k < 3; k++) { r.a[i][j] = (r.a[i][j] + a[i][k] * t.a[k][j]) % mod; } } return r; } }; mat pow(mat a, int p) { mat r; for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) r.a[i][j] = 0; for (int i = 0; i < 3; i++) r.a[i][i] = 1; while (p) { if (p & 1) r = r * a; a = a * a; p /= 2; } return r; } int N, M, X[100100]; long long D[100100]; long long get(mat &t) { return (t.a[2][0] * 5 + t.a[2][1]) % mod; } int main() { scanf("%d %d", &N, &M); for (int t = 1; t <= M; t++) scanf("%d", &X[t]); X[M + 1] = N; mat base = { 4,mod - 2,1,1,0,0,0,1,0 }; mat sum = { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; for (int i = 1; i <= M + 1; i++) { sum = sum * pow(base, X[i] - X[i-1]); D[i] = get(pow(base, X[i]) - sum); for (int k = 0; k < 3; k++) sum.a[k][k] = (sum.a[k][k] + D[i]) % mod; } printf("%lld\n", D[M+1]); return 0; }
a.cc: In function 'int main()': a.cc:59:44: error: cannot bind non-const lvalue reference of type 'mat&' to an rvalue of type 'mat' 59 | D[i] = get(pow(base, X[i]) - sum); | ~~~~~~~~~~~~~~~~^~~~~ a.cc:44:20: note: initializing argument 1 of 'long long int get(mat&)' 44 | long long get(mat &t) { | ~~~~~^
s339412427
p03749
C++
// This amazing code is by Eric Sunli Chen. #include <algorithm> #include <bitset> #include <cmath> #include <cstring> #include <cstdio> #include <cstdlib> #include <ctime> #include <iomanip> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <utility> #include <vector> using namespace std; template<typename T> void get_int(T &x) { char t=getchar(); bool neg=false; x=0; for(; (t>'9'||t<'0')&&t!='-'; t=getchar()); if(t=='-')neg=true,t=getchar(); for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0'; if(neg)x=-x; } template<typename T> void print_int(T x) { if(x<0)putchar('-'),x=-x; short a[20]= {},sz=0; while(x>0)a[sz++]=x%10,x/=10; if(sz==0)putchar('0'); for(int i=sz-1; i>=0; i--)putchar('0'+a[i]); } #define ff first #define ss second #define pb push_back #define mp make_pair #define get1(a) get_int(a) #define get2(a,b) get1(a),get1(b) #define get3(a,b,c) get1(a),get2(b,c) #define printendl(a) print_int(a),puts("") typedef int LL; typedef unsigned int uLL; typedef pair<int,int> pii; const int inf=0x3f3f3f3f; const LL Linf=1ll<<61; const double pi=acos(-1.0); const LL mod=1e9+7; struct matrix { int a[3][3]; void clear(int x=0) { for(int i=0;i<3;i++)for(int j=0;j<3;j++)a[i][j]=(i==j)*x; } matrix(){clear();} int *operator [](int x) { return a[x]; } }sum,tran; matrix operator *(matrix a,matrix b) { matrix ret; ret.clear(0); for(int i=0;i<3;i++)for(int j=0;j<3;j++)for(int k=0;k<3;k++) ret[i][j]=(ret[i][j]+1ll*a[i][k]*b[k][j])%mod; return ret; } matrix power(matrix x,int y) { matrix ret;ret.clear(1); while(y) { if(y&1)ret=ret*x; x=x*x; y>>=1; } return ret; } int calc(int x) { matrix t;t.clear();t[0][0]=0;t[1][0]=1;t[2][0]=5; t=power(tran,x)*t; return t[0][0]; } int f[100111],n,x[100111],m; int main() { sum.clear();tran.clear();tran[0][1]=1;tran[1][2]=1;tran[2][0]=1;tran[2][1]=mod-2;tran[2][2]=4; get2(n,m); for(int i=1;i<=m;i++)get1(x[i]); x[++m]=n; for(int i=1;i<=m;i++) { sum=power(tran,x[i]-x[i-1])*sum; f[i]=calc(x[i])-sum[0][0]; if(f[i]< sum[1][0]=(sum[1][0]+f[i])%mod; sum[2][0]=(sum[2][0]+5ll*f[i])%mod; } printendl(f[m]); return 0; }
a.cc:48:18: warning: overflow in conversion from 'long long int' to 'LL' {aka 'int'} changes value from '2305843009213693952' to '0' [-Woverflow] 48 | const LL Linf=1ll<<61; | ~~~^~~~ a.cc: In function 'int main()': a.cc:102:24: error: lvalue required as left operand of assignment 102 | if(f[i]< | ~~~~^ 103 | | 104 | sum[1][0]=(sum[1][0]+f[i])%mod; | ~~~~~~~~~ a.cc:105:51: error: expected ')' before ';' token 105 | sum[2][0]=(sum[2][0]+5ll*f[i])%mod; | ^ | ) a.cc:102:19: note: to match this '(' 102 | if(f[i]< | ^
s270364205
p03750
C++
#include <cstring> #include <utility> #include <cstdio> #include <queue> std::priority_queue<std::pair<int, int> > que; int a[100005], b[100005], c[100005], pre[100005], lst[100005]; int ans[100005], flg[100005]; bool up[100005]; int main() { // freopen("AGC013-F.in", "r", stdin); memset(lst, -1, sizeof(lst)); int n, q, lazy = 0; scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d%d", a + i, b + i); for (int i = 1; i <= n + 1; i++) scanf("%d", c + i); scanf("%d", &q); std::sort(c + 1, c + n + 2); for (int i = 0; i < n; i++) { a[i] = std::lower_bound(c + 1, c + n + 2, a[i]) - c; b[i] = std::lower_bound(c + 1, c + n + 2, b[i]) - c; flg[a[i] - 1]--; if (b[i] < a[i]) { pre[i] = lst[a[i] - 1]; lst[a[i] - 1] = i; } up[i] = true; } for (int i = n + 1, cur = -1; i; i--, cur++) { cur += flg[i]; for (int j = lst[i]; ~j; j = pre[j]) que.push({-b[j], j}); while (cur < -1) { if (que.empty() || -que.top().first > i) { while (q--) { puts("-1"); return 0; } } up[que.top().second] = false; flg[-que.top().first - 1]--; que.pop(); cur++; lazy++; } } memset(flg, 0, sizeof(flg)); memset(lst, -1, sizeof(lst)); while (!que.empty()) que.pop(); for (int i = 0; i < n; i++) { flg[up[i] ? a[i] : b[i]]++; if (up[i]) { pre[i] = lst[b[i]]; lst[b[i]] = i; } } for (int i = 1, en = 0; i <= n + 1; i++) { flg[i] += flg[i - 1]; ans[i] = ans[i - 1]; for (int j = lst[i]; ~j; j = pre[j]) que.push({a[j] - 1, j}); if (flg[i] - i == -1 && en < i) { if (que.empty() || que.top().first < i) ans[i] = 1e9; else { en = que.top().first; que.pop(); ans[i]++; } } } while (q--) { int l, r; scanf("%d%d", &l, &r); l = std::lower_bound(c + 1, c + n + 2, l) - c; r = std::lower_bound(c + 1, c + n + 2, r) - c; int res = std::min(ans[l - 1], ans[r - 1] + 1) + lazy; if (res > n + 1) puts("-1"); else printf("%d\n", n + 1 - res); } return 0; }
a.cc: In function 'int main()': a.cc:20:14: error: 'sort' is not a member of 'std' 20 | std::sort(c + 1, c + n + 2); | ^~~~
s619256912
p03750
C++
#include<set> #include<map> #include<deque> #include<queue> #include<stack> #include<cmath> #include<ctime> #include<bitset> #include<string> #include<vector> #include<cstdio> #include<cstdlib> #include<cstring> #include<climits> #include<complex> #include<iostream> #include<algorithm> #define ll long long #define inf 1e9 using namespace std; const int maxn = 210000; int n,m; int A[maxn],B[maxn],C[maxn]; struct node{int x,i;}; inline bool operator <(const node x,const node y){return x.x<y.x;} set<node>S; set<node>::iterator it; int p[maxn],q[maxn]; struct L{int l,i;}; vector<L>vl[maxn]; inline bool operator <(const L x,const L y){return x.l>y.l;} priority_queue<L>q1; struct R{int r,i;}; vector<R>vr[maxn]; inline bool operator <(const R x,const R y){return x.r<y.r;} priority_queue<R>q2; bool use[maxn],flag; int ans[maxn],re; int solve(const int k,const int ad){ return ans[k]==-1?-1:n-ans[k]+ad; } int main() { scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%d%d",&A[i],&B[i]); for(int i=0;i<=n;i++) scanf("%d",&C[i]); sort(C,C+n+1); C[n+1]=-1; for(int i=n;i>=0;i--) if(C[i]!=C[i+1]) S.insert((node){C[i],i}); S.insert((node){inf+1,n+1}); for(int i=1;i<=n;i++) { it=S.lower_bound((node){A[i],0}); A[i]=(*it).i; p[A[i]]++; it=S.lower_bound((node){B[i],0}); B[i]=(*it).i; if(A[i]>B[i]) { swap(A[i],B[i]); B[i]--; vl[B[i]].push_back((L){A[i],i}); vr[A[i]].push_back((R){B[i],i}); } } for(int i=0;i<=n;i++) p[i]--; for(int i=1;i<=n+1;i++) p[i]+=p[i-1]; int ad=0; for(int i=n+1;i>=0;i--) { ad+=q[i]; p[i]+=ad; q[i]=0; for(int j=0;j<vl[i].size();j++) q1.push(vl[i][j]); if(p[i]<-1&&i!=n+1) { while(!q1.empty()&&p[i]<-1) { const L now=q1.top(); q1.pop(); if(now.l>i) break; use[now.i]=true; p[i]++; ad++; if(now.l) q[now.l-1]--; if(B[now.i]>i) q[i+1]++,q[B[now.i+1]]--; re++; } if(p[i]<-1) { flag=true; break; } } } if(flag) for(int i=0;i<=n+1;i++) ans[i]=-1; else { ad=0; for(int i=0;i<=n;i++) ad+=q[i],q[i]=0,p[i]+=ad; for(int i=0;i<=n;i++) q[i]=0; ad=0; for(int i=0;i<=n;i++) { ans[i]=re; ad+=q[i]; p[i]+=ad; for(int j=0;j<vr[i].size();j++) if(!use[vr[i][j].i]) q2.push(vr[i][j]); if(p[i]<0) { while(!q2.empty()&&p[i]<0) { const R now=q2.top(); q2.pop(); if(now.r<i) break; ad++; p[i]++; q[now.r+1]--; re++; } if(p[i]<0) { for(int j=i+1;j<=n+1;j++) ans[j]=-1; break; } } } if(ans[n+1]!=-1) ans[n+1]=re; } scanf("%d",&m); while(m--) { int x,y; scanf("%d%d",&x,&y); it=S.lower_bound((node){x,0}); x=(*it).i; it=S.lower_bound((node){y,0}); y=(*it).i; printf("%d\n",max(solve(x,1),solve(y,0))); } return 0; }
a.cc: In function 'int main()': a.cc:53:28: error: narrowing conversion of '1.000000001e+9' from 'double' to 'int' [-Wnarrowing] 53 | S.insert((node){inf+1,n+1}); | ^
s714626090
p03750
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,Q; int A[101010],B[101010],C[101010]; int D[101010],E[101010]; int dp[101010]; vector<int> ev[101010]; template<class V, int ME> class BIT { public: V bit[1<<ME]; V operator()(int e) {V s=0;e++;while(e) s+=bit[e-1],e-=e&-e; return s;} V add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;} }; BIT<int,20> bt; int hoge(int v) { ZERO(bt.bit); int i; FOR(i,N+1) bt.add(i,-1); bt.add(v,1); FOR(i,N) bt.add(A[i],1); priority_queue<pair<int,int>> P; int ret=N; FOR(i,N+1) { FORR(e,ev[i]) P.push({A[e],e}); while(bt(i)<0) { if(P.empty()) return -10; int x=P.top().second; P.pop(); bt.add(B[x],1); bt.add(A[x],-1); ret--; } } return ret; } void solve() { int i,j,k,l,r,x,y; string s; cin>>N; FOR(i,N) cin>>A[i]>>B[i]; FOR(i,N+1) cin>>C[i]; FOR(i,N+2) dp[i]=-3; sort(C,C+N+1); FOR(i,N) { B[i]=min(A[i],B[i]); A[i]=lower_bound(C,C+N+1,A[i])-C; B[i]=lower_bound(C,C+N+1,B[i])-C; if(B[i]<A[i]) ev[B[i]].push_back(i); } cin>>Q; asert(N*Q<=1000000); FOR(i,Q) { cin>>x>>y; x=lower_bound(C,C+N+1,x)-C; y=lower_bound(C,C+N+1,y)-C; cout<<max({-1,hoge(x)+1,hoge(y)})<<endl; //cout<<max({-1,dp[x]+1,dp[y]})<<endl; } } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:72:9: error: 'asert' was not declared in this scope; did you mean 'assert'? 72 | asert(N*Q<=1000000); | ^~~~~ | assert a.cc: In instantiation of 'V BIT<V, ME>::add(int, V) [with V = int; int ME = 20]': a.cc:33:19: required from here 33 | FOR(i,N+1) bt.add(i,-1); | ~~~~~~^~~~~~ a.cc:25:69: warning: no return statement in function returning non-void [-Wreturn-type] 25 | V add(int e,V v) { e++; while(e<=1<<ME) bit[e-1]+=v,e+=e&-e;} | ^
s478234046
p03750
C++
#include<iostream> #include<vector> #include<algorithm> #include<cstring> #include<cstdio> #include<cmath> #include<cstdlib> #include<ctime> #include<queue> #include<set> using namespace std; typedef long long LL; const int N=2e5; int gi() { int w=0;bool q=1;char c=getchar(); while ((c<'0'||c>'9') && c!='-') c=getchar(); if (c=='-') q=0,c=getchar(); while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar(); return q? w:-w; } int a[N],b[N],c[N]; int suf[N],d[N],f[N]; pair<int,int>p[N]; int head[N],next[N]; bool side[N]; #define x first #define y second int main() { int n=gi(),m,i,j,s,l,r,all=0,cur=0; priority_queue< pair<int,int> >q; for (i=1;i<=n;i++) a[i]=gi(),b[i]=gi(); for (i=1;i<=n+1;i++) c[i]=gi(); sort(c+1,c+1+n+1); for (i=1;i<=n;i++) { a[i]=lower_bound(c+1,c+1+n+1,a[i])-c; b[i]=lower_bound(c+1,c+1+n+1,b[i])-c; d[a[i]-1]--; if (b[i]<a[i]) next[i]=head[a[i]-1],head[a[i]-1]=i; side[i]=true; } for (s=-1,i=n+1;i;i--,s++) {//一开始多了一个,每一轮可以抵消一个 s+=d[i]; for (j=head[i];j;j=next[j]) q.push(make_pair(-b[j],j)); while (s<-1) //如果<-1则必须把某一个变小 if (q.empty()||-q.top().x>i) { for (m=gi();m--;) puts("-1"); return 0; } else side[q.top().y]=false,s++,d[i]++,d[-q.top().x-1]--,all++,q.pop(); } m=gi(); for (i=n+1;i>=0;i--) d[i]=0; for (i=1;i<=n;i++) d[side[i]?a[i]:b[i]]++; for (i=2;i<=n+1;i++) d[i]+=d[i-1]; while (!q.empty()) q.pop(); for (i=n+1;i;i--) head[i]=0; for (i=1;i<=n;i++) if (side[i]) next[i]=head[b[i]],head[b[i]]=i; for (i=1;i<=n+1;i++) { for (j=head[i];j;j=next[j]) q.push(make_pair(a[j]-1,j)); f[i]=f[i-1]; if (d[i]-i==-1&&cur<i) { if (q.empty()||q.top().x<i) f[i]=1<<30; else cur=q.top().x,f[i]++,q.pop(); } } while (m--) { l=lower_bound(c+1,c+1+n+1,gi())-c; r=lower_bound(c+1,c+1+n+1,gi())-c; l=f[l-1]+all; r=f[r-1]+all; l=min(l,r+1); if (l>n+1) puts("-1"); else printf("%d\n",n+1-l); } return 0; }
a.cc: In function 'int main()': a.cc:40:25: error: reference to 'next' is ambiguous 40 | next[i]=head[a[i]-1],head[a[i]-1]=i; | ^~~~ In file included from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:24:13: note: 'int next [200000]' 24 | int head[N],next[N]; | ^~~~ a.cc:45:36: error: reference to 'next' is ambiguous 45 | for (j=head[i];j;j=next[j]) q.push(make_pair(-b[j],j)); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:24:13: note: 'int next [200000]' 24 | int head[N],next[N]; | ^~~~ a.cc:56:41: error: reference to 'next' is ambiguous 56 | for (i=1;i<=n;i++) if (side[i]) next[i]=head[b[i]],head[b[i]]=i; | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:24:13: note: 'int next [200000]' 24 | int head[N],next[N]; | ^~~~ a.cc:58:36: error: reference to 'next' is ambiguous 58 | for (j=head[i];j;j=next[j]) q.push(make_pair(a[j]-1,j)); | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:24:13: note: 'int next [200000]' 24 | int head[N],next[N]; | ^~~~
s194599255
p03751
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n,k;cin>>n>>k; vector<long long> A(n);for(int i = 0; n > i; i++)cin>>A[i]; long long ans = 1000000000000000LL; for(int bit = 0; (1<<(n-1)) > bit; bit++){ if(__builtin_popcount(bit)+1 != k)continue; long long he = A[0]; long long tmp = 0; for(int i = 0; n > i; i++){ if(bit & (1<<i)){ if(he < A[i+1]){ he = A[i+1]; }else{ he++; tmp +=he-A[i+1]; } }else{ he = max(he,A[i+1]); } ans = min(ans,tmp); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:26:2: error: expected '}' at end of input 26 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s142527901
p03751
C++
#include <iostream> #include <vector> #include <set> #include <utility> #include <algorithm> #define llint long long #define inf 1000000000000LL using namespace std; typedef pair<string, llint> P; llint n; string s[10005]; string t; vector<P> vec; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) cin >> s[i]; cin >> t; llint l; for(int i = 1; i <= n; i++){ string S = s[i]; for(int i = 0; i < S.size(); i++){ if(S[i] == '?') S[i] = 'z'; } vec.push_back(P(S, i)); } string T = t; for(int i = 0; i < t.size(); i++){ if(T[i] == '?') T[i] = 'a'; } vec.push_back(P(T, 0)); sort(vec.begin(), vec.end()); for(int i = 0; i < vec.size(); i++){ if(vec[i].second == 0){ l = i+1; break; } } vec.clear(); llint r; for(int i = 1; i <= n; i++){ string S = s[i]; for(int i = 0; i < S.size(); i++){ if(S[i] == '?') S[i] = 'a'; } vec.push_back(P(S, i)); } string T = t; for(int i = 0; i < t.size(); i++){ if(T[i] == '?') T[i] = 'z'; } vec.push_back(P(T, inf)); sort(vec.begin(), vec.end()); for(int i = 0; i < vec.size(); i++){ if(vec[i].second == inf){ r = i+1; break; } } for(int i = l; i <= r; i++) cout << i << " "; cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:57:10: error: redeclaration of 'std::string T' 57 | string T = t; | ^ a.cc:34:10: note: 'std::string T' previously declared here 34 | string T = t; | ^
s891919306
p03751
C++
#include <iostream> #include <vector> #include <set> #include <utility> #define llint long long #define inf 1000000000000LL using namespace std; typedef pair<string, llint> P; llint n; string s[100005]; string t; vector<P> vec; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 1; i <= n; i++) cin >> s[i]; cin >> t; llint l; for(int i = 1; i <= n; i++){ string S = s[i]; for(int i = 0; i < S.size(); i++){ if(S[i] == '?') S[i] = 'z'; } vec.push_back(P(S, i)); } string T = t; for(int i = 0; i < t.size(); i++){ if(T[i] == '?') T[i] = 'a'; } vec.push_back(P(T, 0)); sort(vec.begin(), vec.end()); for(int i = 0; i < vec.size(); i++){ if(vec[i].second == 0){ l = i+1; break; } } vec.clear(); llint r; for(int i = 1; i <= n; i++){ string S = s[i]; for(int i = 0; i < S.size(); i++){ if(S[i] == '?') S[i] = 'a'; } vec.push_back(P(S, i)); } for(int i = 0; i < t.size(); i++){ string T = t; if(T[i] == '?') T[i] = 'z'; } vec.push_back(P(T, inf)); sort(vec.begin(), vec.end()); for(int i = 0; i < vec.size(); i++){ if(vec[i].second == inf){ r = i+1; break; } } for(int i = l; i <= r; i++) cout << i << " "; cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:38:3: error: 'sort' was not declared in this scope; did you mean 'short'? 38 | sort(vec.begin(), vec.end()); | ^~~~ | short
s515713102
p03751
C++
#include <iostream> using namespace std; int main(){ int n;cin>>n; string a[n]; for(int i = 0; n > i; i++){ cin>>a[i]; } //上にしかいない、下にしかいないを探す string m;cin>>m; int uponly = 0; int downonly = 0; for(int i = 0; n > i; i++){ bool up = false; bool down = false; if(a[i]==a[j]){ up = true; down = true; } for(int j = 0; min(m.size(),a[i].size()) > j; j++){ if(up&&down)break; if(a[i][j]=='?'){ if(m[j]=='a'){ down = true; }else if(m[j]=='z'){ up = true; }else{ down = true; up = true; } }else{ if(a[i][j]>m[j]){ up = true; break; }else if(a[i][j] < m[j]){ down = true; break; } } } if((!up)&&down){ downonly++; }else if((!down)&&up){ uponly++; } } for(int i = uponly; downonly+2 > i; i++){ cout << i; if(i+1!=n+2)cout << " "; } cout << endl; }
a.cc: In function 'int main()': a.cc:16:16: error: 'j' was not declared in this scope 16 | if(a[i]==a[j]){ | ^
s940073026
p03751
C++
#include <iostream> using namespace std; int main(){ int n;cin>>n; string a[n]; for(int i = 0; n > i; i++){ cin>>a[i]; } //上にしかいない、下にしかいないを探す string m;cin>>m; int uponly = 0; int dwnonly = 0; for(int i = 0; n > i; i++){ bool up = false; bool down = false; if(a[i]==a[j]){ up = true; down = true; } for(int j = 0; min(m.size(),a[i].size()) > j; j++){ if(up&&down)break; if(a[i][j]=='?'){ if(m[j]=='a'){ down = true; }else if(m[j]=='z'){ up = true; }else{ down = true; up = true; } }else{ if(a[i][j]>n[j]){ up = true; break; }else if(a[i][j] < n[j]){ down = true; break; } } } if((!up)&&down){ downonly++; }else if((!down)&&up){ uponly++; } } for(int i = uponly; n+2 > i; i++){ cout << i; if(i+1!=n+2)cout << " "; } cout << endl; }
a.cc: In function 'int main()': a.cc:16:16: error: 'j' was not declared in this scope 16 | if(a[i]==a[j]){ | ^ a.cc:32:21: error: invalid types 'int[int]' for array subscript 32 | if(a[i][j]>n[j]){ | ^ a.cc:35:29: error: invalid types 'int[int]' for array subscript 35 | }else if(a[i][j] < n[j]){ | ^ a.cc:42:7: error: 'downonly' was not declared in this scope; did you mean 'dwnonly'? 42 | downonly++; | ^~~~~~~~ | dwnonly
s721919099
p03751
C++
#include<iostream> #include<vector> #include<cstring> #include<queue> #include<algorithm> #include<string> #include<cstdio> #include<cstdlib> #include <math.h> using namespace std; char s[10001][30],s1[30]; int ans[10000],len,kk=0,n; int strcmp1(const char *str1,const char *str2) { if(*str1=='?'&&*str2!='z') return 0; //printf("!!"); while((*str1 == *str2)||(*str1=='?'&&*str2=='z')) { //printf("!!!\n"); if(*str1 == '\0') return 0; str1++; str2++; } if(*str1=='?'&&*str2!='z') return 0; return *str1 - *str2; } void solve(int k,int sum) { if(k==n) { ans[kk++]=sum; return; } int j=strcmp1(s[k],s1); //printf("%d\n",j); if(j<0) { // printf("%s %s\n",s[k],s1); solve(k+1,sum+1); } else if(j==0) { solve(k+1,sum+1); solve(k+1,sum); } else { solve(k+1,sum); } } int main() { scanf("%d",&n); getchar(); for(int i=0;i<n;i++) { scanf("%s",s[i]); getchar(); } gets(s1); int len=strlen(s1); solve(0,1); sort(ans,ans+kk); int fag=1,flag=1; /* for(int i=0;i<strlen(s1);i++) { if(s1[i]!='z') fag=1; if(s1[i]!='a') flag=1; } if(fag==1) printf("1\n"); else if(flag==1) printf("%d\n",n+1);*/ int jj=0; for(int i=0;i<kk;i++) { if(ans[i]!=ans[i-1]||i==0) { if(jj==1) printf(" %d",ans[i]); else printf("%d",ans[i]); jj=1; } } printf("\n"); }
a.cc: In function 'int main()': a.cc:63:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 63 | gets(s1); | ^~~~ | getw
s125947868
p03751
C++
#include <bits/stdc++.h> using namespace std; string s[10001], smin[10001], smax[10001], target; int strict, pos, n; int main(){ cin>>n; for(int i=0; i<n; i++){ cin>>s[i]; smin[i]=s[i]; smax[i]=s[i]; for(int j=0; j<s[i].size(); j++){ if(s[i][j]=='?')smin[i][j]='a'; if(s[i][j]=='?')smax[i][j]='z'; } } cin>>target; for(int i=0; i<n; i++){ if(smin[i]<=target && target<=smax[i]){ pos++; } if(smax[i]<target){ strict++; } } for(int i=0; i<pos; i++){ cout<<strict+i+1<<" "; } cout << strict+i+pos; }
a.cc: In function 'int main()': a.cc:31:20: error: 'i' was not declared in this scope 31 | cout << strict+i+pos; | ^
s635107086
p03751
C
#include<stdio.h> char s[10000][21],t[21]; int main(int argc, char const *argv[]){ int n,a=0,b=0,i,j,bf,nf; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s",s[i]); } scanf("%s",t); for(i=0;i<n;i++){ af=1; bf=1; for(j=0;j<20;j++){ if(s[i][j]=='\0'){ if(t[j]!='\0'){ if(af) a++; } break; }else if(t[j]=='\0'){ if(bf) b++; break; }else if(s[i][j]=='?'){ if(t[j]=='a') bf=0; else if(t[j]=='z') af=0; else break; }else if(s[i][j]>t[j]){ if(bf) b++; }else if(s[i][j]<t[j]){ if(af) a++; } } } printf("%d",a+1); for(i=a+1;i<n+1-b;i++){ printf(" %d",i); } printf("\n"); return 0; }
main.c: In function 'main': main.c:11:17: error: 'af' undeclared (first use in this function); did you mean 'nf'? 11 | af=1; | ^~ | nf main.c:11:17: note: each undeclared identifier is reported only once for each function it appears in
s277842832
p03751
C++
#include<iostream> using namespace std; #include<algorithm> #include<vector> bool c(string a,string b) { for(int i=0;i<a.size();i++)a[i]=='?'&&(a[i]='z'); return b<=a; } bool d(string a,string b) { for(int i=0;i<a.size();i++)a[i]=='?'&&(a[i]='a'); return a<=b; } main() { vector<string>a;int n;cin>>n; string t; for(int i=0;i<n;i++) { cin>>t; a.push_back(t); } cin>>t; sort(a.begin(),a.end()); vector<int>ans; for(int i=0;i<n;i++) { if(c(a[i],t))ans.push_back(i+1); if(d(a[i],t)&&(i==n-1||c(a[i+1],t))ans.push_back(i+2); } sort(ans.begin(),ans.end()); ans.erase(unique(ans.begin(),ans.end()),ans.end()); for(int i=0;i<ans.size();i++) { cout<<(i?" ":"")<<ans[i]; } cout<<endl; }
a.cc:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 15 | main() | ^~~~ a.cc: In function 'int main()': a.cc:30:52: error: expected ';' before 'ans' 30 | if(d(a[i],t)&&(i==n-1||c(a[i+1],t))ans.push_back(i+2); | ^~~ | ; a.cc:31:9: error: expected primary-expression before '}' token 31 | } | ^ a.cc:30:71: error: expected ')' before '}' token 30 | if(d(a[i],t)&&(i==n-1||c(a[i+1],t))ans.push_back(i+2); | ~ ^ | ) 31 | } | ~ a.cc:31:9: error: expected primary-expression before '}' token 31 | } | ^
s590935108
p03751
C++
#include <bits/stdc++.h> using namespace std; string s[10001], smin[10001], smax[10001], target; int strict, pos, n; int main(){ cin>>n; for(int i=0, i<n; i++){ cin>>s[i]; smin[i]=s[i]; smax[i]=s[i]; for(int j=0; j<s[i].size(); j++){ if(s[i][j]=='?')smin[i][j]='a'; if(s[i][j]=='?')smax[i][j]='z'; } } cin>>target; for(int i=0, i<n; i++){ if(smin[i]<=target && target<=smax[i]){ pos++; } if(smax[i]<target){ strict++; } } for(int i=0, i<pos; i++){ cout<<strict+i+1<<" "; } }
a.cc: In function 'int main()': a.cc:10:15: error: expected ';' before '<' token 10 | for(int i=0, i<n; i++){ | ^ | ; a.cc:10:15: error: expected primary-expression before '<' token a.cc:20:15: error: expected ';' before '<' token 20 | for(int i=0, i<n; i++){ | ^ | ; a.cc:20:15: error: expected primary-expression before '<' token a.cc:28:15: error: expected ';' before '<' token 28 | for(int i=0, i<pos; i++){ | ^ | ; a.cc:28:15: error: expected primary-expression before '<' token
s962962544
p03751
C++
#include <vector> #include <string.h> #include<iostream> #include<set> #include<map> #include<unordered_map> #include<string.h> #include<algorithm> #include <stdlib.h> #include<queue> using namespace std; int main(){ int n; int before=0,after=0i, ambiguous=0; cin>>n; vector<string>vec(n); for(int i=0;i<n;i++){ cin>>vec[i]; } string name; cin>>name; priority_queue<int>str_has_q; for(int i=0;i<n;i++){ string s,s2; s=vec[i],s2=vec[i]; s2=s; bool q=false; for(int j=0;j<s.length();j++){ if(s[j]=='?'){ s[j]='a'; s2[j]='z'; q=true; } } if(q){ if(s<name&&s2<name){ before++; } else if(s>name&&s2>name){ after++; } else { ambiguous++; } str_has_q.push(i); } } while(str_has_q.size()){ int to=str_has_q.top(); str_has_q.pop(); vec.erase(vec.begin()+to); } sort(vec.begin(),vec.end()); bool out=false; if(vec[0]>name){ for(int i=max(0,before-after);i<before;i++) cout<<1+i<<" "; cout<<1+before<<endl; return 0; } vector<int>ans; for(int i=0;i<vec.size();i++){ if(name==vec[i]){ ans.push_back(i+1); out=true; } if(i>0&&vec[i]>name&&name>=vec[i-1]){ ans.push_back(i+1); set<int>ind; for(int i=0;i<=ambiguous;i++){ for(auto a:ans){ ind.insert(before+i+a); } } vector<int>ult; for(auto a:ind){ ult.push_back(a); } for(int i=0;i<ult.size()-1;i++){ cout<<ult[i]<<" "; } cout<<ult[ult.size()-1]<<endl; return 0; } } ans.push_back(vec.size()+1); set<int>ind; for(int i=0;i<=ambiguous;i++){ for(auto a:ans){ ind.insert(before+i+a); } } vector<int>ult; for(auto a:ind){ ult.push_back(a); } for(int i=0;i<ult.size()-1;i++){ cout<<ult[i]<<" "; } cout<<ult[ult.size()-1]<<endl; //else cout<<endl; return 0; }
a.cc: In function 'int main()': a.cc:18:24: error: cannot convert '__complex__ int' to 'int' in initialization 18 | int before=0,after=0i, ambiguous=0; | ^~
s704167684
p03751
C++
#include <iostream> #include <cstring> #define offcin ios::sync_with_stdio(false) using namespace std; const int maxn = 1e4 + 5; string s[maxn], a[maxn], b[maxn]; int main(int argc, const char * argv[]) { offcin; int N; cin>>N; for (int i = 1; i <= N; i ++) { cin>>s[i]; long len = s[i].length(); for (int j = 0; j < len; j ++) { if (s[i][j] == '?') a[i] += 'a', b[i] += 'z'; else a[i] += s[i][j], b[i] += s[i][j]; } } string t; cin>>t; // a[N + 1] = b[N + 1] = t; sort(a + 1, a + N + 1); sort(b + 1, b + N + 1); int l1 = 1, l2 = 1; while (l1 <= N && a[l1] < t) l1 ++; while (l2 <= N && b[l2] <= t) l2 ++; if (l1 > l2) swap(l1, l2); for (long i = l1; i <= l2; i ++) cout<<i<<" "; return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:25:5: error: 'sort' was not declared in this scope; did you mean 'short'? 25 | sort(a + 1, a + N + 1); | ^~~~ | short
s121472744
p03751
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; string s[n]; for (int i = 0; i < n; i++) { cin >> s[i]; } string t; cin >> t; sort(s.begin(), s.end()); for (int i = 0; i < n; i++) { if (t < s[i]) { cout << i + 1 << endl; return 0; } } }
a.cc: In function 'int main()': a.cc:13:12: error: request for member 'begin' in 's', which is of non-class type 'std::string [n]' {aka 'std::__cxx11::basic_string<char> [n]'} 13 | sort(s.begin(), s.end()); | ^~~~~ a.cc:13:23: error: request for member 'end' in 's', which is of non-class type 'std::string [n]' {aka 'std::__cxx11::basic_string<char> [n]'} 13 | sort(s.begin(), s.end()); | ^~~
s974244420
p03751
C++
#include <bits/stdc++.h> using namespace std; int n; string s[100010], t; int main() { cin >> n; for(int i = 1; i <= n; i ++) cin >> s[i]; cin >> t; int ansl = 1, ansr = 1; for(int i = 1; i <= n; i ++) { bool L = 0, R = 0; string x = s[i]; for(int j = 0; j < x.size(); j ++) if(s[i][j] == '?') x[j] = 'z'; if(x >= t) R = 1; for(int j = 0; j < x.size(); j ++) if(s[i][j] == '?') x[j] = 'a'; if(x <= t) L = 1; if(L && R) ansr ++; else if(L) ansl ++, ansr ++; } for(int i = ansl; i <= ansr; i ++) cout<<i<<" \n"[i==r]; return 0; }
a.cc: In function 'int main()': a.cc:27:35: error: 'r' was not declared in this scope 27 | cout<<i<<" \n"[i==r]; | ^
s730486901
p03751
C++
#include <bits/stdc++.h> #define using namespace std; int n; string s[100010], t; int main() { cin >> n; for(int i = 1; i <= n; i ++) cin >> s[i]; cin >> t; int ansl = 1, ansr = 1; for(int i = 1; i <= n; i ++) { bool L = 0, R = 0; string x = s[i]; for(int j = 0; j < x.size(); j ++) if(s[i][j] == '?') x[j] = 'z'; if(x >= t) R = 1; for(int j = 0; j < x.size(); j ++) if(s[i][j] == '?') x[j] = 'a'; if(x <= t) L = 1; if(L && R) ansr ++; else if(L) ansl ++, ansr ++; } for(int i = ansl; i <= ansr; i ++) cout << i << " "; }
a.cc:2:9: error: no macro name given in #define directive 2 | #define | ^
s099949644
p03751
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int,int> pint; typedef vector<pint> vpint; #define rep(i,n) for(int i=0;i<(n);i++) #define REP(i,n) for(int i=n-1;i>=(0);i--) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) #define all(v) (v).begin(),(v).end() #define eall(v) unique(all(v), v.end()) #define pb push_back #define mp make_pair #define fi first #define se second #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) const int MOD = 1e9 + 7; const int INF = 1e9; const ll INFF = 1e18; int N; string s[10010]; string t; int main(void){ cin >> N; rep(i, N)cin >> s[i]; cin >> t; string tmp = t; while(t.size() < 20){ t += 'A'; } int mae = 0, usi = 0; rep(k, N){ string d = s[k]; bool fmae = false, fusi = false; if(d != tmp){ rep(i, s.size()){ if(d[i] != '?' && d[i] < t[i]){ fmae = true; break; }else if(d[i] != '?' && d[i] > t[i]){ fusi = true; break; }else if(d[i] == '?' && t[i] != 'a' && t[i] != 'z'){ // printf("k\n"); fmae = true; fusi = true; break; }else if(d[i] == '?' && t[i] != 'z'){ fusi = true; }else if(d[i] == '?' && t[i] != 'a'){ fmae = true; } } }else{ fmae = true; fusi = true; } if(fmae) mae++; if(fusi) usi++; } // printf("%d %d\n", mae, usi); int r = mae + 1; int l = N - usi + 1; // printf("%d\n", r - l); reps(i, l, r + 1){ if(i != r)printf("%d ", i); else printf("%d\n", i); } return 0; }
a.cc: In function 'int main()': a.cc:41:34: error: request for member 'size' in 's', which is of non-class type 'std::string [10010]' {aka 'std::__cxx11::basic_string<char> [10010]'} 41 | rep(i, s.size()){ | ^~~~ a.cc:7:33: note: in definition of macro 'rep' 7 | #define rep(i,n) for(int i=0;i<(n);i++) | ^
s584414021
p03751
C++
import java.util.Scanner; public class Main { static boolean win(StringBuilder a, StringBuilder b){ StringBuilder c = new StringBuilder(a); StringBuilder d = new StringBuilder(b); for(int i=0; i<c.length(); i++){ if(c.charAt(i) == '?') c.setCharAt(i, 'a'); } for(int i=0; i<d.length(); i++){ if(d.charAt(i) == '?') d.setCharAt(i, 'z'); } for(int i=0; i<c.length() && i<d.length(); i++){ if(c.charAt(i) != d.charAt(i)){ return c.charAt(i) < d.charAt(i); } } return c.length() <= d.length(); } public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); StringBuilder s[] = new StringBuilder[n]; StringBuilder t; for(int i=0; i<n; i++) s[i] = new StringBuilder(sc.next()); t = new StringBuilder(sc.next()); int low = 0, high = 0; for(int i=0; i<n; i++){ boolean p1 = win(t, s[i]); boolean p2 = win(s[i], t); if(p1 && p2){ high++; } else if(p2){ low++; high++; } } sc.close(); for(int i=low+1; i<=high+1; i++){ System.out.print(i); if(i <= high) System.out.print(" "); else System.out.println(""); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Scanner; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~
s554951685
p03751
C++
#include<stdio.h> #include<string.h> int main (){ char moji[10003][21],s[10003][21],tmp[21]; int n,i,j,a; scanf("%d",&n) ; for(i=0;i<n+1;i++){ scanf("%s",moji[i]); } a=n; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if(strcmp(moji[j-1], moji[j])>0){ strcpy(tmp, moji[j-1]); strcpy(moji[j-1], moji[j]); strcpy(moji[j], tmp); if (j==a) a=j-1; } } } printf("%d\n",a+1); for(i=a;i>=0;i--){ if (strcmp(moji[i-1],moji[i])==0) printf("%d\n",i); if else break; } return 0; }
a.cc: In function 'int main()': a.cc:24:4: error: expected '(' before 'else' 24 | if else break; | ^~~~ | (
s438064014
p03751
C++
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; bool win(string a, string b){ for(auto &i : a) if(i == '?') i = 'a'; for(auto &i : b) if(i == '?') i = 'z'; return a <= b; } int n; string a, b[10005]; int main(){ cin >> n; for(int i=0; i<n; i++) cin >> b[i]; cin >> a; int l = 0, h = 0; for(int i=0; i<n; i++){ if(win(a, b[i]) && win(b[i], a)) h++; else if(win(b[i], a)) l++, h++; } for(int i=l+1; i<=h+1; i++){ cout << i; if(i <= h) cout << " "; }
a.cc: In function 'int main()': a.cc:28:2: error: expected '}' at end of input 28 | } | ^ a.cc:16:11: note: to match this '{' 16 | int main(){ | ^
s618425134
p03752
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) #define rrep(i,n) for (int i = 1; i <= (n); i++) using ll = long long; using Graph = vector<vector<int>>; using P = pair<int,int>; using Pl = pair<ll,ll>; int main(){ ll n,k; cin >> n >> k; ll a[n]; rep(i,n) cin >> a[i]; ll ans=1e18; rep(bit,1<<n){ if(__builtin_popcount(bit)<k || bit%2==0)continue; vector<ll> s; rep(i,n) { if(bit>>j&1) s.push_back(i); } ll l = 0,total = 0; rep(j,s.size()){ l = max(l+1,*max_element(a+s[j],a+s[j+1])); total += l - a[s[j]]; } ans = min(ans,total); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:20:15: error: 'j' was not declared in this scope 20 | if(bit>>j&1) s.push_back(i); | ^
s974348388
p03752
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) #define rrep(i,n) for (int i = 1; i <= (n); i++) using ll = long long; using Graph = vector<vector<int>>; using P = pair<int,int>; using Pl = pair<ll,ll>; int main(){ ll n,k; cin >> n >> k; ll a[n]; rep(i,n) cin >> a[i]; ll ans=1e18; rep(bit,1<<n){ if(__builtin_popcount(bit)<k || bit%2==0)continue; vector<ll> s; rep(i,n) { if(bit>>j&1) s.push_back(i); } ll l = 0,total = 0; rep(j,s.size()){ l = max(l+1,*max_element(a+s[j],a+s[j+1])); total += l - a[s[j]]; } ans = min(ans,total); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:20:15: error: 'j' was not declared in this scope 20 | if(bit>>j&1) s.push_back(i); | ^
s259293708
p03752
Java
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { //int t = sc.nextInt(); //while(t-- > 0) solve(); out.close(); } private static void solve() { //String s = sc.next(); int n = sc.nextInt(); int kk = sc.nextInt(); int[] arr = sc.readArray(n); if(kk < 1) { out.println(0); return; } int[] leftMax = new int[n]; leftMax[0] = arr[0]; int[] canSeeCnt = new int[n]; canSeeCnt[0] = 1; for(int i = 1; i < n; i++) { leftMax[i] = Math.max(leftMax[i-1], arr[i]); canSeeCnt[i] = canSeeCnt[i-1]; if(arr[i] > leftMax[i-1]) canSeeCnt[i]++; } int minCost = Integer.MAX_VALUE; for(int i = 1; i < n; i++) { int need = kk - canSeeCnt[i-1]; int len = n - i; for(int j = 0; j < (1 << len); j++) { int cost = 0; int bitCnt = Integer.bitCount(j); if(bitCnt != need) continue; int[] leftMaxLocal = leftMax.clone(); for(int k = 0; k < len; k++) { if(((j >> (len - k - 1)) & 1) == 1) { int idx = k + i; if(arr[idx] > leftMaxLocal[idx - 1]) { cost = cost; } else { cost += leftMaxLocal[idx - 1] + 1 - arr[idx]; leftMaxLocal[idx] = leftMaxLocal[idx - 1] + 1; } } else { leftMaxLocal[k+i] = Math.max(leftMaxLocal[k+i-1], leftMaxLocal[k+i]); } } minCost = Math.min(minCost, cost); } } out.println(minCost); } public static void sort(int[] a) { int l = 0, r = a.length; ArrayList<Integer> list=new ArrayList<>(); for (int i=l ; i<r; i++) list.add(a[i]); Collections.sort(list); for (int i=l; i<r; i++) a[i]=list.get(i-l); } private static String mkArr(int[] arr) { StringBuilder sb = new StringBuilder(); for(int a : arr) { sb.append(a + " "); } return sb.toString(); } private static String mkList(List<Integer> arr) { StringBuilder sb = new StringBuilder(); for(int a : arr) { sb.append(a + " "); } return sb.toString(); } private static int gcd(int a, int b) { if(b == 0) return a; return gcd(b, a % b); } static int mod = 1_000_000_007; private static long C(int n, int k) { long res1 = factor(n-k+1, n); long res2 = factor(1, k); long reverse = reverse(res2); return (res1 * reverse) % mod; } private static long reverse(long a) { return powMod(a, mod - 2); } private static long factor(int left, int right){ long res = 1; for(int i = left; i <= right; i++) res = (res * i) % mod; return res; } public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static FastScanner sc = new FastScanner(); static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } static long pow(long a, long N) { if (N == 0) return 1; else if (N == 1) return a; else { long R = pow(a,N/2); if (N % 2 == 0) { return R*R; } else { return R*R*a; } } } static long powMod(long a, long N) { if (N == 0) return 1; else if (N == 1) return a % mod; else { long R = powMod(a,N/2) % mod; R = (R * R) % mod; if (N % 2 == 1) { R = (R * a) % mod; } return R % mod; } } static void mergeSort(int[] A){ // low to hi sort, single array only int n = A.length; if (n < 2) return; int[] l = new int[n/2]; int[] r = new int[n - n/2]; for (int i = 0; i < n/2; i++){ l[i] = A[i]; } for (int j = n/2; j < n; j++){ r[j-n/2] = A[j]; } mergeSort(l); mergeSort(r); merge(l, r, A); } static void merge(int[] l, int[] r, int[] a){ int i = 0, j = 0, k = 0; while (i < l.length && j < r.length && k < a.length){ if (l[i] < r[j]){ a[k] = l[i]; i++; } else{ a[k] = r[j]; j++; } k++; } while (i < l.length){ a[k] = l[i]; i++; k++; } while (j < r.length){ a[k] = r[j]; j++; k++; } } private static class Edge { int src; int dest; int weight; public Edge(int s, int d, int w) { this.src = s; this.dest = d; this.weight = w; } } private static int[] prim(Map<Integer, List<Edge>> graph) { int n = graph.size(); // number of the nodes Edge[] edges = new Edge[n]; for(int i = 0; i < n; i++) edges[i] = new Edge(-1, i, Integer.MAX_VALUE); edges[0].weight = 0; int[] parents = new int[n]; parents[0] = -1; TreeSet<Edge> treeSet = new TreeSet<>((a, b) -> a.weight - b.weight); treeSet.add(edges[0]); boolean[] visited = new boolean[n]; while(treeSet.size() > 0) { Edge e = treeSet.pollFirst(); visited[e.dest] = true; for(Edge child : graph.get(e.dest)) { if(visited[child.dest]) continue; if(edges[child.dest].weight > child.weight) { treeSet.remove(edges[child.dest]); edges[child.dest].weight = child.weight; treeSet.add(edges[child.dest]); parents[child.dest] = e.dest; } } } return parents; } private static void testDijkstr() { Map<Integer, List<Edge>> graph = new HashMap<>(); for(int i = 0; i < 9; i++) graph.put(i, new ArrayList<>()); addEdge(0, 1, 4 , graph); addEdge(0, 7, 8 , graph); addEdge(1, 2, 8 , graph); addEdge(1, 7, 11, graph); addEdge(2, 3, 7 , graph); addEdge(2, 8, 2 , graph); addEdge(2, 5, 4 , graph); addEdge(3, 4, 9 , graph); addEdge(3, 5, 14, graph); addEdge(4, 5, 10, graph); addEdge(5, 6, 2 , graph); addEdge(6, 7, 1 , graph); addEdge(6, 8, 6 , graph); addEdge(7, 8, 7 , graph); Edge[] es = dijkstra(graph); for(int i = 0; i < 9; i++) out.println(i + ": " + es[i].weight); } private static void addEdge(int a, int b, int w, Map<Integer, List<Edge>> graph) { graph.get(a).add(new Edge(a, b, w)); graph.get(b).add(new Edge(b, a, w)); } private static Edge[] dijkstra(Map<Integer, List<Edge>> graph) { int n = graph.size(); Edge[] es = new Edge[n]; for(int i = 0; i < n; i++) es[i] = new Edge(-1, i, Integer.MAX_VALUE); es[0].weight = 0; TreeSet<Edge> treeSet = new TreeSet<>((a, b) -> a.weight - b.weight); treeSet.add(es[0]); boolean[] visited = new boolean[n]; while(treeSet.size() > 0) { Edge e = treeSet.pollFirst(); visited[e.dest] = true; for(Edge ed : graph.get(e.dest)) { if(visited[ed.dest] || ed.weight + es[e.dest].weight >= es[ed.dest].weight) continue; treeSet.remove(es[ed.dest]); es[ed.dest].weight = ed.weight + es[e.dest].weight; treeSet.add(es[ed.dest]); } } return es; } private static Edge[] kruskal(int v, Edge[] edges) { Edge[] res = new Edge[v-1]; int[] p = new int[v]; for(int i = 0; i < v; i++) p[i] = i; int[] rank = new int[v]; Arrays.fill(rank, 1); Arrays.sort(edges, (e1, e2) -> e1.weight - e2.weight); for(int i = 0, idx = 0; i < res.length;) { Edge e = edges[idx++]; if(union(p, rank, e.src, e.dest)) { res[i++] = e; } } return res; } private static boolean union(int[] root, int[] rank, int u, int v) { int rootA = find(root, u); int rootB = find(root, v); if(rootA == rootB) return false; if(rank[rootA] > rank[rootB]) { rank[rootA] += rank[rootB]; root[rootB] = rootA; } else { rank[rootB] += rank[rootA]; root[rootA] = rootB; } return true; } private static int find(int[] root, int node) { if(root[node] != node) { root[node] = find(root, root[node]); } return root[node]; } static class BIT { int n; int[] nums; int[] bit; public BIT(int[] nums) { this.nums = nums; this.n = nums.length; this.bit = new int[n + 1]; for(int i = 0; i < n; i++) init(i, nums[i]); } void init(int i, int val) { i++; while(i <= n) { bit[i] += val; i += (i & -i); // (i & (-i)): get moet least significate digit } } void update(int i, int val) { int diff = val - nums[i]; nums[i] = val; init(i, diff); } int getSum(int i) { int sum = 0; i++; while(i > 0) { sum += bit[i]; i -= (i & -i); // ex: 1100 -> 1000 -> 0000. subtract moet least significate digit } return sum; } int sumRange(int i, int j) { return getSum(j) - getSum(i - 1); } } }import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { //int t = sc.nextInt(); //while(t-- > 0) solve(); out.close(); } private static void solve() { //String s = sc.next(); int n = sc.nextInt(); int kk = sc.nextInt(); int[] arr = sc.readArray(n); if(kk < 1) { out.println(0); return; } int[] leftMax = new int[n]; leftMax[0] = arr[0]; int[] canSeeCnt = new int[n]; canSeeCnt[0] = 1; for(int i = 1; i < n; i++) { leftMax[i] = Math.max(leftMax[i-1], arr[i]); canSeeCnt[i] = canSeeCnt[i-1]; if(arr[i] > leftMax[i-1]) canSeeCnt[i]++; } int minCost = Integer.MAX_VALUE; for(int i = 1; i < n; i++) { int need = kk - canSeeCnt[i-1]; int len = n - i; for(int j = 0; j < (1 << len); j++) { int cost = 0; int bitCnt = Integer.bitCount(j); if(bitCnt != need) continue; int[] leftMaxLocal = leftMax.clone(); for(int k = 0; k < len; k++) { if(((j >> (len - k - 1)) & 1) == 1) { int idx = k + i; if(arr[idx] > leftMaxLocal[idx - 1]) { cost = cost; } else { cost += leftMaxLocal[idx - 1] + 1 - arr[idx]; leftMaxLocal[idx] = leftMaxLocal[idx - 1] + 1; } } else { leftMaxLocal[k+i] = Math.max(leftMaxLocal[k+i-1], leftMaxLocal[k+i]); } } minCost = Math.min(minCost, cost); } } out.println(minCost); } public static void sort(int[] a) { int l = 0, r = a.length; ArrayList<Integer> list=new ArrayList<>(); for (int i=l ; i<r; i++) list.add(a[i]); Collections.sort(list); for (int i=l; i<r; i++) a[i]=list.get(i-l); } private static String mkArr(int[] arr) { StringBuilder sb = new StringBuilder(); for(int a : arr) { sb.append(a + " "); } return sb.toString(); } private static String mkList(List<Integer> arr) { StringBuilder sb = new StringBuilder(); for(int a : arr) { sb.append(a + " "); } return sb.toString(); } private static int gcd(int a, int b) { if(b == 0) return a; return gcd(b, a % b); } static int mod = 1_000_000_007; private static long C(int n, int k) { long res1 = factor(n-k+1, n); long res2 = factor(1, k); long reverse = reverse(res2); return (res1 * reverse) % mod; } private static long reverse(long a) { return powMod(a, mod - 2); } private static long factor(int left, int right){ long res = 1; for(int i = left; i <= right; i++) res = (res * i) % mod; return res; } public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); public static FastScanner sc = new FastScanner(); static class FastScanner { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st=new StringTokenizer(""); String next() { while (!st.hasMoreTokens()) try { st=new StringTokenizer(br.readLine()); } catch (IOException e) { e.printStackTrace(); } return st.nextToken(); } int nextInt() { return Integer.parseInt(next()); } int[] readArray(int n) { int[] a=new int[n]; for (int i=0; i<n; i++) a[i]=nextInt(); return a; } long nextLong() { return Long.parseLong(next()); } } static long pow(long a, long N) { if (N == 0) return 1; else if (N == 1) return a; else { long R = pow(a,N/2); if (N % 2 == 0) { return R*R; } else { return R*R*a; } } } static long powMod(long a, long N) { if (N == 0) return 1; else if (N == 1) return a % mod; else { long R = powMod(a,N/2) % mod; R = (R * R) % mod; if (N % 2 == 1) { R = (R * a) % mod; } return R % mod; } } static void mergeSort(int[] A){ // low to hi sort, single array only int n = A.length; if (n < 2) return; int[] l = new int[n/2]; int[] r = new int[n - n/2]; for (int i = 0; i < n/2; i++){ l[i] = A[i]; } for (int j = n/2; j < n; j++){ r[j-n/2] = A[j]; } mergeSort(l); mergeSort(r); merge(l, r, A); } static void merge(int[] l, int[] r, int[] a){ int i = 0, j = 0, k = 0; while (i < l.length && j < r.length && k < a.length){ if (l[i] < r[j]){ a[k] = l[i]; i++; } else{ a[k] = r[j]; j++; } k++; } while (i < l.length){ a[k] = l[i]; i++; k++; } while (j < r.length){ a[k] = r[j]; j++; k++; } } private static class Edge { int src; int dest; int weight; public Edge(int s, int d, int w) { this.src = s; this.dest = d; this.weight = w; } } private static int[] prim(Map<Integer, List<Edge>> graph) { int n = graph.size(); // number of the nodes Edge[] edges = new Edge[n]; for(int i = 0; i < n; i++) edges[i] = new Edge(-1, i, Integer.MAX_VALUE); edges[0].weight = 0; int[] parents = new int[n]; parents[0] = -1; TreeSet<Edge> treeSet = new TreeSet<>((a, b) -> a.weight - b.weight); treeSet.add(edges[0]); boolean[] visited = new boolean[n]; while(treeSet.size() > 0) { Edge e = treeSet.pollFirst(); visited[e.dest] = true; for(Edge child : graph.get(e.dest)) { if(visited[child.dest]) continue; if(edges[child.dest].weight > child.weight) { treeSet.remove(edges[child.dest]); edges[child.dest].weight = child.weight; treeSet.add(edges[child.dest]); parents[child.dest] = e.dest; } } } return parents; } private static void testDijkstr() { Map<Integer, List<Edge>> graph = new HashMap<>(); for(int i = 0; i < 9; i++) graph.put(i, new ArrayList<>()); addEdge(0, 1, 4 , graph); addEdge(0, 7, 8 , graph); addEdge(1, 2, 8 , graph); addEdge(1, 7, 11, graph); addEdge(2, 3, 7 , graph); addEdge(2, 8, 2 , graph); addEdge(2, 5, 4 , graph); addEdge(3, 4, 9 , graph); addEdge(3, 5, 14, graph); addEdge(4, 5, 10, graph); addEdge(5, 6, 2 , graph); addEdge(6, 7, 1 , graph); addEdge(6, 8, 6 , graph); addEdge(7, 8, 7 , graph); Edge[] es = dijkstra(graph); for(int i = 0; i < 9; i++) out.println(i + ": " + es[i].weight); } private static void addEdge(int a, int b, int w, Map<Integer, List<Edge>> graph) { graph.get(a).add(new Edge(a, b, w)); graph.get(b).add(new Edge(b, a, w)); } private static Edge[] dijkstra(Map<Integer, List<Edge>> graph) { int n = graph.size(); Edge[] es = new Edge[n]; for(int i = 0; i < n; i++) es[i] = new Edge(-1, i, Integer.MAX_VALUE); es[0].weight = 0; TreeSet<Edge> treeSet = new TreeSet<>((a, b) -> a.weight - b.weight); treeSet.add(es[0]); boolean[] visited = new boolean[n]; while(treeSet.size() > 0) { Edge e = treeSet.pollFirst(); visited[e.dest] = true; for(Edge ed : graph.get(e.dest)) { if(visited[ed.dest] || ed.weight + es[e.dest].weight >= es[ed.dest].weight) continue; treeSet.remove(es[ed.dest]); es[ed.dest].weight = ed.weight + es[e.dest].weight; treeSet.add(es[ed.dest]); } } return es; } private static Edge[] kruskal(int v, Edge[] edges) { Edge[] res = new Edge[v-1]; int[] p = new int[v]; for(int i = 0; i < v; i++) p[i] = i; int[] rank = new int[v]; Arrays.fill(rank, 1); Arrays.sort(edges, (e1, e2) -> e1.weight - e2.weight); for(int i = 0, idx = 0; i < res.length;) { Edge e = edges[idx++]; if(union(p, rank, e.src, e.dest)) { res[i++] = e; } } return res; } private static boolean union(int[] root, int[] rank, int u, int v) { int rootA = find(root, u); int rootB = find(root, v); if(rootA == rootB) return false; if(rank[rootA] > rank[rootB]) { rank[rootA] += rank[rootB]; root[rootB] = rootA; } else { rank[rootB] += rank[rootA]; root[rootA] = rootB; } return true; } private static int find(int[] root, int node) { if(root[node] != node) { root[node] = find(root, root[node]); } return root[node]; } static class BIT { int n; int[] nums; int[] bit; public BIT(int[] nums) { this.nums = nums; this.n = nums.length; this.bit = new int[n + 1]; for(int i = 0; i < n; i++) init(i, nums[i]); } void init(int i, int val) { i++; while(i <= n) { bit[i] += val; i += (i & -i); // (i & (-i)): get moet least significate digit } } void update(int i, int val) { int diff = val - nums[i]; nums[i] = val; init(i, diff); } int getSum(int i) { int sum = 0; i++; while(i > 0) { sum += bit[i]; i -= (i & -i); // ex: 1100 -> 1000 -> 0000. subtract moet least significate digit } return sum; } int sumRange(int i, int j) { return getSum(j) - getSum(i - 1); } } }
Main.java:394: error: class, interface, enum, or record expected }import java.io.*; ^ Main.java:395: error: class, interface, enum, or record expected import java.util.*; ^ 2 errors
s020849782
p03752
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (int i = 0; i < (n); i++) #define all(v) begin(v),end(v) using ll = long long; int main() {
a.cc: In function 'int main()': a.cc:7:13: error: expected '}' at end of input 7 | int main() { | ~^
s396003396
p03752
C
#include<bits/stdc++.h> using namespace std; const long long INF = 1LL << 60; long long dp[100010]; template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;} template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;} #define rep(i,n) for(int i=0;i<n;i++) int main(){ long long n, k; cin >> n >> k; long long a[n]; rep(i,n) cin >> a[i]; long long ans = INF; rep(i,(1<<n)){ if(bitset<64>(i).count()==k){ int bit[30]; rep(j,n) bit[j] = (i/(1<<j))%2; bool flag = true; long long tmp=0, pre = 0; rep(j,n){ chmax(tmp, a[j]); if(bit[j]==1){ if(flag){ flag = false; } else{ if(a[j]<=tmp){ tmp++; pre += tmp-a[j]; } else { tmp = a[j]; } } } } chmin(ans,pre); } } cout << ans << endl; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s372253551
p03752
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9+7; int main() { ll n,k; cin >> n >> k; vector<ll>a(n); for(ll i=0;i<n;i++){ cin >> a[i]; } ll ans=1e15; for(ll i=0;i<(1<<n);i++){ ll cost=0; ll mh=0; ll num=0; vector<ll>b=a; for(ll j=0;j<n;j++){ if(i & (1<<j)){ cost+=max(0,mh+1-b[j]); b[j]=max(b[j],mh+1); if(b[j]>mh) num++; } mh=max(mh,b[j]); } if(num>=k) ans=min(ans,cost); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:20:26: error: no matching function for call to 'max(int, ll)' 20 | cost+=max(0,mh+1-b[j]); | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:20:26: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 20 | cost+=max(0,mh+1-b[j]); | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:20:26: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 20 | cost+=max(0,mh+1-b[j]); | ~~~^~~~~~~~~~~~~
s659502087
p03752
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll MOD = 1e9+7; int main() { ll n,k; cin >> n >> k; vector<ll>a(n); for(ll i=0;i<n;i++){ cin >> a[i]; } ll ans=1e15; for(ll i=0;i<(1<<n);i++){ ll cost=0; ll mh=0; ll num=0; vector<ll>b=a; for(ll i=0;i<n;i++){ if(b & (1<<i)){ cost+=max(0,mh+1-b[i]); b[i]=max(b[i],mh+1); if(b[i]>mh) num++; } mh=max(mh,b[i]); } if(num>=k) ans=min(ans,cost); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:19:18: error: no match for 'operator&' (operand types are 'std::vector<long long int>' and 'int') 19 | if(b & (1<<i)){ | ~ ^ ~~~~~~ | | | | | int | std::vector<long long int> In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bitset:1557:5: note: candidate: 'template<long unsigned int _Nb> std::bitset<_Nb> std::operator&(const bitset<_Nb>&, const bitset<_Nb>&)' 1557 | operator&(const bitset<_Nb>& __x, const bitset<_Nb>& __y) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/bitset:1557:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::vector<long long int>' is not derived from 'const std::bitset<_Nb>' 19 | if(b & (1<<i)){ | ^ 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:411:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::vector<long long int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/bits/valarray_after.h:411:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__bitwise_and, typename _Dom1::value_type>::result_type> std::operator&(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 411 | _DEFINE_EXPR_BINARY_OPERATOR(&, struct std::__bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:411:5: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/valarray:1202:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const valarray<_Tp>&, const valarray<_Tp>&)' 1202 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1202:1: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::vector<long long int>' is not derived from 'const std::valarray<_Tp>' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/valarray:1202:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1202 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1202:1: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::vector<long long int>' is not derived from 'const std::valarray<_Tp>' 19 | if(b & (1<<i)){ | ^ /usr/include/c++/14/valarray:1202:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__bitwise_and, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__bitwise_and, _Tp>::result_type> std::operator&(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1202 | _DEFINE_BINARY_OPERATOR(&, __bitwise_and) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1202:1: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'const std::valarray<_Tp>' and 'int' 19 | if(b & (1<<i)){ | ^ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/14/cstddef:141:3: note: candidate: 'constexpr std::byte std::operator&(byte, byte)' 141 | operator&(byte __l, byte __r) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:141:18: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::byte' 141 | operator&(byte __l, byte __r) noexcept | ~~~~~^~~ In file included 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/bits/ios_base.h:84:3: note: candidate: 'constexpr std::_Ios_Fmtflags std::operator&(_Ios_Fmtflags, _Ios_Fmtflags)' 84 | operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW | ^~~~~~~~ /usr/include/c++/14/bits/ios_base.h:84:27: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::_Ios_Fmtflags' 84 | operator&(_Ios_Fmtflags __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ios_base.h:134:3: note: candidate: 'constexpr std::_Ios_Openmode std::operator&(_Ios_Openmode, _Ios_Openmode)' 134 | operator&(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW | ^~~~~~~~ /usr/include/c++/14/bits/ios_base.h:134:27: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::_Ios_Openmode' 134 | operator&(_Ios_Openmode __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ios_base.h:181:3: note: candidate: 'constexpr std::_Ios_Iostate std::operator&(_Ios_Iostate, _Ios_Iostate)' 181 | operator&(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW | ^~~~~~~~ /usr/include/c++/14/bits/ios_base.h:181:26: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::_Ios_Iostate' 181 | operator&(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW | ~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/bits/shared_ptr_atomic.h:33, from /usr/include/c++/14/memory:81, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56: /usr/include/c++/14/bits/atomic_base.h:109:3: note: candidate: 'constexpr std::memory_order std::operator&(memory_order, __memory_order_modifier)' 109 | operator&(memory_order __m, __memory_order_modifier __mod) noexcept | ^~~~~~~~ /usr/include/c++/14/bits/atomic_base.h:109:26: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::memory_order' 109 | operator&(memory_order __m, __memory_order_modifier __mod) noexcept | ~~~~~~~~~~~~~^~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:176: /usr/include/c++/14/future:156:20: note: candidate: 'constexpr std::launch std::operator&(launch, launch)' 156 | constexpr launch operator&(launch __x, launch __y) noexcept | ^~~~~~~~ /usr/include/c++/14/future:156:37: note: no known conversion for argument 1 from 'std::vector<long long
s486078590
p03752
C++
#include <bits/stdc++.h> using namespace std; #define ll long long void chmin(ll& a, ll b) { if (a > b) a = b; } int main() { int N, K; cin >> N >> K; vector<ll> a(N); for (int i = 0; i < N; i++) { cin >> a[i]; } // i番目までで最も高いもの vector<ll> height(N); height[0] = 0; height[1] = a[0]; ll SUBMAX = a[0]; for (int i = 1; i < N; i++) { if (a[i] > SUBMAX) { height[i] = a[i-1]; } else { height[i] = SUBMAX; } } ll ans = 10000000000000; // bit 全探索 for (int bit = 0; bit < (1 << N); bit++) { ll color = 0; ll cost = 0; ll temp = 0; for (int i = 0; i < N; i++) { if (!(bit & (1 << 0)) continue; if (bit & (1 << i)) { color++; // 次の建物に必要な最低限の高さを temp で現す if (temp >= height[i]) { temp++; } else { temp = height[i]+1; } // cost の計算 if (i == 0) { temp = a[0]; continue; } if (a[i] > temp) { temp = a[i]; continue; } cost += temp -a[i]; } } if (color >= K) chmin(ans, cost); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:47:28: error: expected ';' before 'continue' 47 | if (!(bit & (1 << 0)) continue; | ^~~~~~~~~ | ; a.cc:49:7: error: expected primary-expression before 'if' 49 | if (bit & (1 << i)) { | ^~ a.cc:47:38: error: expected ')' before 'if' 47 | if (!(bit & (1 << 0)) continue; | ~ ^ | ) 48 | 49 | if (bit & (1 << i)) { | ~~ a.cc:70:5: error: expected primary-expression before '}' token 70 | } | ^
s694552120
p03752
C++
#include <iostream> #include <vector> #include <climits> using namespace std; typedef long long ll; vector<int> v; ll dfs(ll i, ll N, ll K, ll *a, ll m) { if (i == N) { if (v.size() < K) return 999999999999; return 0; } ll ans; if (a[i] <= m) { v.push_back(i); ans = m+1-a[i]+dfs(i+1, N, K, a, m+1); v.pop_back(); ans = min(ans, dfs(i+1, N, K, a, m)); return ans; } else { v.push_back(i); ans = dfs(i+1, N, K, a, a[i]); v.pop_back(i); return ans; } } int main() { ll N, K; cin >> N >> K; ll *a = new ll[N]; for (int i = 0; i < N; i++) cin >> a[i]; cout << dfs(0, N, K, a, 0) << endl; return 0; }
a.cc: In function 'll dfs(ll, ll, ll, ll*, ll)': a.cc:30:19: error: no matching function for call to 'std::vector<int>::pop_back(ll&)' 30 | v.pop_back(i); | ~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h:1324:7: note: candidate: 'void std::vector<_Tp, _Alloc>::pop_back() [with _Tp = int; _Alloc = std::allocator<int>]' 1324 | pop_back() _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:1324:7: note: candidate expects 0 arguments, 1 provided
s908297210
p03752
C++
include <iostream> #include <vector> using namespace std; using ll = long long; int main(){ int n,k; cin >> n >> k; vector<ll> a(n); for(int i=0; i<n; i++) cin >> a[i]; ll ans=1e18; for(int bit = 0; bit<(1<<n-1); bit++){ if(__builtin_popcount(bit) != k-1) continue; ll s=0; ll h=a[0]; bool flag = true; for(int i=1; i<n; i++){ if(((bit >> i-1) & 1)){ if(a[i]>h){ h=a[i]; } else { s += h+1-a[i]; h += 1; } } else { if (a[i]>h) { flag = false; break; } } } if(flag) ans = min(ans,s); } cout << ans << endl; }
a.cc:1:1: error: 'include' does not name a type 1 | include <iostream> | ^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
s997966211
p03752
C++
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<cmath> #include<cstdio> #include<queue> #include<deque> #include<map> #include<stack> #include<set> #include<tuple> using namespace std; typedef pair<int,int> ii; typedef long long ll; typedef pair<ll,ll> pll; const int INF=1e18; const ll MOD=1e9+7; int dy[]={1,0,-1,0}; int dx[]={0,1,0,-1}; int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b); } int dis2(int x1,int y1,int x2,int y2){ return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); } ll power(ll a,ll x){ ll res=1; while(x>0){ if(x&1) res=res*a%MOD; a=a*a%MOD; x>>=1; } return res; } string s; int main(){ int n,k;cin>>n>>k; vector<ll> a(n); for(int i=0;i<n;i++) cin>>a[i]; ll ans=INF; for(int bits=0;bits<(1<<(n-1));bits++){ int s=1,m=a[0]; bool flag=false; for(int i=0;i<n-1;i++){ if((bits>>i)&1) s++; if(m<a[i+1]&&!(bits>>1)){ flag=true; break; } m=max(m,a[i+1]); } if(flag||s!=k) continue; ll sum=0,mh=a[0]; for(int i=0;i<n-1;i++)if((bits>>i)&1){ if(mh>=a[i+1]){ sum+=(mh-a[i+1]+1); mh=a[i+1]+1; } } ans=min(ans,mh); } cout<<ans<<endl; return 0; }
a.cc:17:15: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow] 17 | const int INF=1e18; | ^~~~ a.cc: In function 'int main()': a.cc:55:18: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 55 | m=max(m,a[i+1]); | ~~~^~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:55:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 55 | m=max(m,a[i+1]); | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:55:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 55 | m=max(m,a[i+1]); | ~~~^~~~~~~~~~
s488688900
p03752
C++
#include <bits/stdc++.h> using namespace std; int main() { int N,K; cin >> N >> K; int A[N]; for (int i=0; i<N; i++) { cin >> A[i]; } cout << total << endl; for (int tmp=0; tmp<(1<<15); tmp++) { bitset<15> s(tmp); int B[K],C[N],count=0; if (!s.test(count)) continue; for (int i=0; i<N; i++) { if (s.test(i)) count++; } if (count!=K) continue; count=0; for (int i=0; i<N; i++) { if (s.test(i) && count!=K) { B[count]=i;count++; } else C[i]=A[i]; } C[0]=A[0]; int n=A[0]; count=0; for (int i=1; i<K; i++) { int a=B[i-1]; int b=B[i]; for (int j=a; j<b; j++) { if (n<C[j]) n=C[j]; if (j==b-1 && n<A[b]) C[b]=A[b]; else if (j==b-1) { C[b]=n+1; count+=n+1-A[b]; } } } if (total>count) total=count; } cout << total << endl; }
a.cc: In function 'int main()': a.cc:11:12: error: 'total' was not declared in this scope 11 | cout << total << endl; | ^~~~~
s600322014
p03752
C++
#include <bits/stdc++.h> #include <math.h> #include <cmath> using namespace std; using ll =long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; #define rep(i,n); for( int i =0; i < n ; i ++) #define all(a) a.begin(),a.end() #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define f(i,a,b) for(int i=a;i<b;i++) #define pri(a) printf("%.14lf\n",a); #define MOD 1000000007 typedef pair<int, int> P; bool is_int_lround(double x){ return std::lround(x)==x; } ll keta(ll x){ ll n=0; while(x>0){ x /=10 ; n ++; } return n; } ll conbi(int n,int m){ cin>>n>>m; vector<ll> a(100); a[0] =1; for(int i=0;i<14;i++){ a[i+1]=a[i]*(i+1); } return a[n] /(a[m] *a[n-m]); } long long modpow(long long a, long long n, long long mod) { long long res = 1;//繰り返し二乗法 while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } ll kaijo(ll x){ ll z=1; while(x>0){ z *=x; z %=MOD; x--; } return z; } ll yakusu_num(ll n){ vl yakusu(n+1,1); for(ll i=2;i*i<=n;i++){ while(n%i==0){ n /=i; yakusu[i]++; } } if(n!=1)yakusu[n]++; ll num=1; for(ll i=0;i <=n;i++){ num*=yakusu[i]; } return num; } //cout<<""<<endl; int main(){ ll N,K;cin>>N>>K;vl a(N); rep(i,N){ cin>>a[i]; } vl b(N); vl d(N);d[0]=a[0]; rep(i,N-1){ d[i+1]=max(d[i],a[i+1]); } ll ans=10000000000; for(int tmp ; tmp<(1<<N-1);tmp++){ bitset<14> s(tmp); ll cnt=0; b =d; if(s.count()>=K-1){ for(int i=0;i<N-1;i++){ b[i+1]=max(b[i],b[i+1]); if(s.test(i)){ if(b[i]>a[i+1]){ cnt+=b[i]-a[i+1]+1; b[i+1] =b[i]+1; } else if(b[i]<a[i+1]){ b[i+1]=a[i+1]; } else if(b[i]==a[i+1]){ cnt+=1; b[i+1]=b[i]+1; } } } ans =min(cnt,ans); } else continue; } cout<<ans<<endl; } #include <bits/stdc++.h> #include <math.h> #include <cmath> using namespace std; using ll =long long; using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>; using vs = vector<string>; using vvs = vector<vs>; using vc = vector<char>; using vvc = vector<vc>; using vb = vector<bool>; using vvb = vector<vb>; #define rep(i,n); for( int i =0; i < n ; i ++) #define all(a) a.begin(),a.end() #define pb(a) push_back(a) #define pd(a) printf("%.10f\n",a) #define mem(a) memset(a,0,sizeof(a)) #define f(i,a,b) for(int i=a;i<b;i++) #define pri(a) printf("%.14lf\n",a); #define MOD 1000000007 typedef pair<int, int> P; bool is_int_lround(double x){ return std::lround(x)==x; } ll keta(ll x){ ll n=0; while(x>0){ x /=10 ; n ++; } return n; } ll conbi(int n,int m){ cin>>n>>m; vector<ll> a(100); a[0] =1; for(int i=0;i<14;i++){ a[i+1]=a[i]*(i+1); } return a[n] /(a[m] *a[n-m]); } long long modpow(long long a, long long n, long long mod) { long long res = 1;//繰り返し二乗法 while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } ll kaijo(ll x){ ll z=1; while(x>0){ z *=x; z %=MOD; x--; } return z; } ll yakusu_num(ll n){ vl yakusu(n+1,1); for(ll i=2;i*i<=n;i++){ while(n%i==0){ n /=i; yakusu[i]++; } } if(n!=1)yakusu[n]++; ll num=1; for(ll i=0;i <=n;i++){ num*=yakusu[i]; } return num; } //cout<<""<<endl; int main(){ ll N,K;cin>>N>>K;vl a(N); rep(i,N){ cin>>a[i]; } vl b(N); vl d(N);d[0]=a[0]; rep(i,N-1){ d[i+1]=max(d[i],a[i+1]); } ll ans=100000000000; for(int tmp ; tmp<(1<<N-1);tmp++){ bitset<14> s(tmp); ll cnt=0; b =d; if(s.count()>=K-1){ for(int i=0;i<N-1;i++){ b[i+1]=max(b[i],b[i+1]); if(s.test(i)){ if(b[i]>a[i+1]){ cnt+=b[i]-a[i+1]+1; b[i+1] =b[i]+1; } else if(b[i]<a[i+1]){ b[i+1]=a[i+1]; } else if(b[i]==a[i+1]){ cnt+=1; b[i+1]=b[i]+1; } } } ans =min(cnt,ans); } else continue; } cout<<ans<<endl; }
a.cc:151:6: error: redefinition of 'bool is_int_lround(double)' 151 | bool is_int_lround(double x){ | ^~~~~~~~~~~~~ a.cc:27:6: note: 'bool is_int_lround(double)' previously defined here 27 | bool is_int_lround(double x){ | ^~~~~~~~~~~~~ a.cc:154:4: error: redefinition of 'll keta(ll)' 154 | ll keta(ll x){ | ^~~~ a.cc:30:4: note: 'll keta(ll)' previously defined here 30 | ll keta(ll x){ | ^~~~ a.cc:163:4: error: redefinition of 'll conbi(int, int)' 163 | ll conbi(int n,int m){ | ^~~~~ a.cc:39:4: note: 'll conbi(int, int)' previously defined here 39 | ll conbi(int n,int m){ | ^~~~~ a.cc:174:11: error: redefinition of 'long long int modpow(long long int, long long int, long long int)' 174 | long long modpow(long long a, long long n, long long mod) { | ^~~~~~ a.cc:50:11: note: 'long long int modpow(long long int, long long int, long long int)' previously defined here 50 | long long modpow(long long a, long long n, long long mod) { | ^~~~~~ a.cc:183:4: error: redefinition of 'll kaijo(ll)' 183 | ll kaijo(ll x){ | ^~~~~ a.cc:59:4: note: 'll kaijo(ll)' previously defined here 59 | ll kaijo(ll x){ | ^~~~~ a.cc:192:4: error: redefinition of 'll yakusu_num(ll)' 192 | ll yakusu_num(ll n){ | ^~~~~~~~~~ a.cc:68:4: note: 'll yakusu_num(ll)' previously defined here 68 | ll yakusu_num(ll n){ | ^~~~~~~~~~ a.cc:210:5: error: redefinition of 'int main()' 210 | int main(){ | ^~~~ a.cc:86:5: note: 'int main()' previously defined here 86 | int main(){ | ^~~~
s175502532
p03752
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; typedef long long ll; int N, K; vector<ll> A; void solve(){ ll m = 1e+10; ll height = A[0]; if(N == K){ ll cost = 0; for (int i = 1; i < N; i++){ ll dif = height - A[i]; if(dif >= 0){ cost += dif + 1; height += 1; continue; } height = A[i]; } m = cost; } else{ for (int b = 0; b < (1 << N); b++) { height = A[0]; ll cost = 0; bitset<> bs(b); int cnt = 0; vector<int> v; for (int i = 0; i < N; i++){ if(bs.test(i)){ cnt++; v.push_back(i); } } if(cnt == K && bs.test(0)){ for (int i = 1; i < (int)v.size(); i++){ ll dif = height - A[v[i]]; if(dif >= 0){ cost += dif + 1; height += 1; continue; } height = A[v[i]]; } m = min(m, cost); } } } cout << m << endl; } int main(){ cin >> N >> K; for (int i = 0; i < N; i++) { ll a; cin >> a; A.push_back(a); } solve(); return 0; }
a.cc: In function 'void solve()': a.cc:34:20: error: wrong number of template arguments (0, should be 1) 34 | bitset<> bs(b); | ^ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bitset:804:11: note: provided for 'template<long unsigned int _Nb> class std::bitset' 804 | class bitset | ^~~~~~ a.cc:39:23: error: request for member 'test' in 'bs', which is of non-class type 'int' 39 | if(bs.test(i)){ | ^~~~ a.cc:45:31: error: request for member 'test' in 'bs', which is of non-class type 'int' 45 | if(cnt == K && bs.test(0)){ | ^~~~
s933958887
p03752
C++
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #include<iomanip> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef pair<ll,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i,x) for(ll i=0;i<x;i++) #define repn(i,x) for(ll i=1;i<=x;i++) #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) const int MAX = 510000; const int MOD = 1000000007; int main(){ ll N, K; cin >> N >> K; vector<ll> a(N); rep(i,N) cin >> a[i]; ll ans = 1e16; rep(i, (1 << N)){ if(bitset<16>(i).count() != K or !bitset<16>(i).test(0) ) continue; ll cost = 0; ll h = a[0]; // hはなるべき高さ rep(j ,N){ if((i >> j) % 2 == 1){ cost += max(h - a[j] , (ll)0); h = max(++h, a[j] + 1); } } // cout << i << " " << cost << endl; ans = min(ans , cost); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:41:8: error: 'bitset' was not declared in this scope 41 | if(bitset<16>(i).count() != K or | ^~~~~~ a.cc:11:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>' 10 | #include<iomanip> +++ |+#include <bitset> 11 | using namespace std; a.cc:41:22: error: request for member 'count' in 'i', which is of non-class type 'll' {aka 'long long int'} 41 | if(bitset<16>(i).count() != K or | ^~~~~ a.cc:42:20: error: request for member 'test' in 'i', which is of non-class type 'll' {aka 'long long int'} 42 | !bitset<16>(i).test(0) ) continue; | ^~~~
s228305968
p03752
C++
#include<iostream> #include<cmath> #include<algorithm> #include<string> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #include<iomanip> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef pair<ll,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i,x) for(ll i=0;i<x;i++) #define repn(i,x) for(ll i=1;i<=x;i++) #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) const int MAX = 510000; const int MOD = 1000000007; int main(){ ll N, K; cin >> N >> K; vector<ll> a(N); rep(i,N) cin >> a[i]; ll ans = 1e16; rep(i, (1 << N)){ if(bitset<16>(i).count() != K or !bitset<16>(i).test(0) ) continue; ll cost = 0; ll h = a[0]; // hはなるべき高さ rep(j ,N){ if((i >> j) % 2 == 1){ cost += max(h - a[j] , (ll)0); h = max(++h, a[j] + 1); } } // cout << i << " " << cost << endl; ans = min(ans , cost); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:41:8: error: 'bitset' was not declared in this scope 41 | if(bitset<16>(i).count() != K or | ^~~~~~ a.cc:11:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>' 10 | #include<iomanip> +++ |+#include <bitset> 11 | using namespace std; a.cc:41:22: error: request for member 'count' in 'i', which is of non-class type 'll' {aka 'long long int'} 41 | if(bitset<16>(i).count() != K or | ^~~~~ a.cc:42:20: error: request for member 'test' in 'i', which is of non-class type 'll' {aka 'long long int'} 42 | !bitset<16>(i).test(0) ) continue; | ^~~~
s861198318
p03752
C++
#include<cmath> #include<algorithm> #include<string> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #include<iomanip> using namespace std; typedef long long ll; typedef pair<ll,ll> P; typedef pair<ll,P> P1; typedef pair<P,P> P2; #define pu push #define pb push_back #define mp make_pair #define eps 1e-7 #define INF 1000000000 #define fi first #define sc second #define rep(i,x) for(ll i=0;i<x;i++) #define repn(i,x) for(ll i=1;i<=x;i++) #define SORT(x) sort(x.begin(),x.end()) #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end()) #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) const int MAX = 510000; const int MOD = 1000000007; int main(){ ll N, K; cin >> N >> K; vector<ll> a(N); rep(i,N) cin >> a[i]; ll ans = 1e16; rep(i, (1 << N)){ if(bitset<16>(i).count() != K or !bitset<16>(i).test(0) ) continue; ll cost = 0; ll h = a[0]; // hはなるべき高さ rep(j ,N){ if((i >> j) % 2 == 1){ cost += max(h - a[j] , (ll)0); h = max(++h, a[j] + 1); } } // cout << i << " " << cost << endl; ans = min(ans , cost); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:34:12: error: 'cin' was not declared in this scope 34 | ll N, K; cin >> N >> K; | ^~~ a.cc:11:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 10 | #include<iomanip> +++ |+#include <iostream> 11 | using namespace std; a.cc:41:8: error: 'bitset' was not declared in this scope 41 | if(bitset<16>(i).count() != K or | ^~~~~~ a.cc:11:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>' 10 | #include<iomanip> +++ |+#include <bitset> 11 | using namespace std; a.cc:41:22: error: request for member 'count' in 'i', which is of non-class type 'll' {aka 'long long int'} 41 | if(bitset<16>(i).count() != K or | ^~~~~ a.cc:42:20: error: request for member 'test' in 'i', which is of non-class type 'll' {aka 'long long int'} 42 | !bitset<16>(i).test(0) ) continue; | ^~~~ a.cc:56:3: error: 'cout' was not declared in this scope 56 | cout << ans << endl; | ^~~~ a.cc:56:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s789298393
p03752
C++
#include<bits/stdc++.h> using namespace std; int64_t f(vector<int64_t>a,int64_t k){ int N=a.size(); if(N<k) return 200000000000; else if(k==1){ return 0; }else { if(a.at(0)<a.at(1)){ a.erase(a.begin()); return f(a,k-1); }else{ int t=a.at(0)+1-a.at(1); a.erase(a.begin()); a.erase(a.begin()); return min(t+f(a,k-2),f(a,k-1)); } } } int main(){ int64_t N,K; cin>>N>>K; vector<int>a(N); for(int i=0;i<N;i++) cin>>a.at(i); int64_t ans=f(a,K); cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:17: error: could not convert 'a' from 'vector<int>' to 'vector<long int>' 29 | int64_t ans=f(a,K); | ^ | | | vector<int>
s403710025
p03752
C++
#include<bits/stdc++.h> using namespace std; int64_t f(vector<int64_t>a,int64_t k){ int N=a.size(); if(N<k) return 200000000000; else if(k==1){ return 0; }else { if(a.at(0)<a.at(1)){ a.erase(a.begin()); return f(a,k-1); }else{ int t=a.at(0)+1-a.at(1); a.erase(a.begin()); a.erase(a.begin()); return min(t+f(a,k-2),f(a,k-1)); } } } int main(){ int N,K; cin>>N>>K; vector<int>a(N); for(int i=0;i<N;i++) cin>>a.at(i); int ans=f(a,K); cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:29:13: error: could not convert 'a' from 'vector<int>' to 'vector<long int>' 29 | int ans=f(a,K); | ^ | | | vector<int>
s774853047
p03752
C++
#include<bits/stdc++.h> using namespace std; int f(vector<int>a,int k){ int N=a.size(); if(N<k) return 20000000000; else if(k==1){ return 0; }else { if(a.at(0)<a.at(1){ a.erase(a.begin()); return f(a,k-1); }else{ int t=a.at(0)+1-a.at(0); a.erase(a.begin()); a.erase(a.begin()); return min(t+f(a,k-2),f(a,k-1)); } } } int main(){ int N,K; cin>>N>>K; vector<int>a(N); for(int i=0;i<N;i++) cin>>a.at(i); int ans=f(a,K); cout<<ans<<endl; return 0; }
a.cc: In function 'int f(std::vector<int>, int)': a.cc:6:10: warning: overflow in conversion from 'long int' to 'int' changes value from '20000000000' to '-1474836480' [-Woverflow] 6 | return 20000000000; | ^~~~~~~~~~~ a.cc:10:21: error: expected ')' before '{' token 10 | if(a.at(0)<a.at(1){ | ~ ^ | ) a.cc:20:3: error: expected primary-expression before '}' token 20 | } | ^ a.cc:22:1: warning: control reaches end of non-void function [-Wreturn-type] 22 | } | ^
s913264216
p03752
C++
#include<bits/stdc++.h> using namespace std; const long long int INF = 1000000000000000000; int main(){ int N, K; cin >> N >> K; long long int a[N]; for (int i = 0; i < N; i++) { cin >> a[i]; } long long int ans = INF; if(K <= 1) ans = 0; for (int bit = 0; bit < (1 << (N-1)); bit++) { int v = 0; long long int t = a[0]; long long int sum = 0; for (int i = 1; i < N; i++) { if(bit & (1 << (i-1))){ if( t - a[i] > -1ll){ sum += t - a[i] + 1ll; t++; v++; } else{ t = a[i]; v++; } } if(v >= K) ans = min(ans, sum); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:37:2: error: expected '}' at end of input 37 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s750239336
p03752
C++
int main() { int n,k; cin>>n>>k; ll a[n]; ll ok=0,temp1=0,temp1in=0; rep(i,n) cin>>a[i]; rep(i,n){ if(temp1<a[i]) ok++,temp1=a[i]; else break; } if(k<=ok){ cout<<0<<endl; return 0; } ll ans=1000000000000000; for(ll bit=0;bit<(1<<(n-ok));bit++){ ll cansee=0; for(int i=0;i<n-ok;i++){ if(bit&(1<<i)) cansee++; } if(cansee==k-ok){ ll temp2=temp1; ll yen=0; for(int i=0;i<n-ok;i++){ if(bit&(1<<i)){ if(temp2==a[i+ok]){ yen++; temp2++; } else if(temp2>a[i+ok]){ yen+=(temp2-a[i+ok]+1); temp2++; } else temp2=a[i+ok]; } } ans=min(ans,yen); } } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:3:3: error: 'cin' was not declared in this scope 3 | cin>>n>>k; | ^~~ a.cc:4:3: error: 'll' was not declared in this scope 4 | ll a[n]; | ^~ a.cc:5:5: error: expected ';' before 'ok' 5 | ll ok=0,temp1=0,temp1in=0; | ^~~ | ; a.cc:6:7: error: 'i' was not declared in this scope 6 | rep(i,n) cin>>a[i]; | ^ a.cc:6:3: error: 'rep' was not declared in this scope 6 | rep(i,n) cin>>a[i]; | ^~~ a.cc:11:9: error: 'ok' was not declared in this scope; did you mean 'k'? 11 | if(k<=ok){ | ^~ | k a.cc:12:7: error: 'cout' was not declared in this scope 12 | cout<<0<<endl; | ^~~~ a.cc:12:16: error: 'endl' was not declared in this scope 12 | cout<<0<<endl; | ^~~~ a.cc:15:5: error: expected ';' before 'ans' 15 | ll ans=1000000000000000; | ^~~~ | ; a.cc:16:9: error: expected ';' before 'bit' 16 | for(ll bit=0;bit<(1<<(n-ok));bit++){ | ^~~~ | ; a.cc:16:16: error: 'bit' was not declared in this scope 16 | for(ll bit=0;bit<(1<<(n-ok));bit++){ | ^~~ a.cc:16:27: error: 'ok' was not declared in this scope; did you mean 'k'? 16 | for(ll bit=0;bit<(1<<(n-ok));bit++){ | ^~ | k a.cc:18:9: error: expected ';' before 'cansee' 18 | ll cansee=0; | ^~~~~~~ | ; a.cc:20:26: error: 'cansee' was not declared in this scope 20 | if(bit&(1<<i)) cansee++; | ^~~~~~ a.cc:22:10: error: 'cansee' was not declared in this scope 22 | if(cansee==k-ok){ | ^~~~~~ a.cc:23:13: error: expected ';' before 'temp2' 23 | ll temp2=temp1; | ^~~~~~ | ; a.cc:24:13: error: expected ';' before 'yen' 24 | ll yen=0; | ^~~~ | ; a.cc:29:20: error: 'temp2' was not declared in this scope 29 | if(temp2==a[i+ok]){ | ^~~~~ a.cc:29:27: error: 'a' was not declared in this scope 29 | if(temp2==a[i+ok]){ | ^ a.cc:30:22: error: 'yen' was not declared in this scope 30 | yen++; | ^~~ a.cc:34:22: error: 'yen' was not declared in this scope 34 | yen+=(temp2-a[i+ok]+1); | ^~~ a.cc:40:11: error: 'ans' was not declared in this scope 40 | ans=min(ans,yen); | ^~~ a.cc:40:23: error: 'yen' was not declared in this scope 40 | ans=min(ans,yen); | ^~~ a.cc:40:15: error: 'min' was not declared in this scope; did you mean 'main'? 40 | ans=min(ans,yen); | ^~~ | main a.cc:46:3: error: 'cout' was not declared in this scope 46 | cout<<ans<<endl; | ^~~~ a.cc:46:9: error: 'ans' was not declared in this scope 46 | cout<<ans<<endl; | ^~~ a.cc:46:14: error: 'endl' was not declared in this scope 46 | cout<<ans<<endl; | ^~~~
s097782493
p03752
C++
#include <bits/stdc++.h> using namespace std; #define lli long long int #define REP(i,s,n) for(int i=s;i<n;i++) #define MOD 1000000007 #define NUM 2520 #define INF (1LL<<50) #define DEBUG 0 #define mp(a,b) make_pair(a,b) #define SORT(V) sort(V.begin(),V.end()) #define PI (3.141592653589794) lli bitCnt(lli now){ lli cnt=0; while(now>0){ cnt += (now%2); now/=2; } return cnt; } signed main(){ lli n,k; cin>>n>>k; vector<lli> a(n); REP(i,0,n)cin>>a[i]; vector<lli> amaxh(n+1); REP(i,0,n)amaxh[i+1] = max(a[i],amaxh[i]); lli ans = INF; for(lli b=0;b<(1LL<<(n));b++){ if(bitCnt(b)!=k)continue; lli nowh=0,tmp=0; REP(i,0,n){ if(bit&(1LL<<i)==0)continue; nowh=max(nowh,amaxh[i]); if(nowh>=a[i]){ tmp += nowh-a[i]+1; nowh++; } else{ nowh = a[i]; } } ans = min(ans,tmp); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:41:28: error: 'bit' was not declared in this scope 41 | if(bit&(1LL<<i)==0)continue; | ^~~
s982657645
p03752
C++
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (int)(n); i++) using namespace std; using ll = long long; using P = pair<int,int>; const ll inf = 1e18; int main() { int n, k; cin >> n >> k; vector<int> a(n); rep(i,n) cin >> a[i]; ll ans = inf; rep(i,1<<n) { ll t = 0; int flag = 0; if (i & 1 != 1) continue; if (__builtin_popcount(i) != k) continue; ll tmp = a[0]; for (int j = 1; j < n; j++) { if (i>>j & 1) { tmp = max(a[j],tmp+1); t += tmp-a[j]; } } ans = min(ans,t); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:22:22: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, ll)' 22 | tmp = max(a[j],tmp+1); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:22:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 22 | tmp = max(a[j],tmp+1); | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:22:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 22 | tmp = max(a[j],tmp+1); | ~~~^~~~~~~~~~~~
s032227643
p03752
C++
#include <bits/stdc++.h> #define ALL(a) (a).begin(),(a).end() #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) using namespace std; typedef long long ll; typedef pair<int, int> P; typedef pair<long long, long long> Pll; typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef vector<long long> vll; typedef vector<vector<long long>> vvll; template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long INF = 1LL << 60; int main(){ ll N, K; cin >> N >> K; vll a(N), aa(N); vll highest(N), highestt(N); for(int i = 0; i < N; i++){ cin >> a.at(i); if(i == 0) highest.at(0) = a.at(0); else if(a.at(i) > highest.at(i-1)) highest.at(i) = a.at(i); else highest.at(i) = highest.at(i-1); } aa = a; highestt = highest; ll result = INF; for(int tmp = 0; tmp < (1 << (N-1)); tmp++){ bitset<14> bit(tmp); if(bit.count() != K-1) continue; a = aa; highest = highestt; ll sum = 0; for(int i = 0; i < N-1; i++){ if(bit.test(i)){ //i+1番目がみえる if(a.at(i+1) <= highest.at(i)){ sum += (highest.at(i) + 1LL - a.at(i+1)); a.at(i+1) = highest.at(i) + 1LL; } highest.at(i+1) = max(a.at(i+1), highest.at(i)) } } chmin(result, sum); } cout << result << endl; }
a.cc: In function 'int main()': a.cc:42:56: error: expected ';' before '}' token 42 | highest.at(i+1) = max(a.at(i+1), highest.at(i)) | ^ | ; 43 | } | ~
s103295353
p03752
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int N, K; cin >> N >> K; vector<long long> a(N); for(int i = 0; i < N; i++){ cin >> a[i]; } long long ans = 1e18; for(int i = 0; i < 1 << (N - 1); i++){ int cnt = 0; for(int j=0;j < N-1;j++){ cnt += (i>>j)&1; } if(cnt != K-1)continue; long long tmp = 0; long now = a[0]; for(int j = 0; j < N - 1; j++){ if(i>>j&1){ if(now >= a[j + 1]){ tmp += now - a[j + 1] + 1; now = max(now + 1, a[j + 1]); } now = max(now, a[j + 1]); } } ans = min(ans, tmp); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:24:20: error: no matching function for call to 'max(long int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 24 | now = max(now + 1, a[j + 1]); | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:24:20: note: deduced conflicting types for parameter 'const _Tp' ('long int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 24 | now = max(now + 1, a[j + 1]); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:24:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 24 | now = max(now + 1, a[j + 1]); | ~~~^~~~~~~~~~~~~~~~~~~ a.cc:26:18: error: no matching function for call to 'max(long int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 26 | now = max(now, a[j + 1]); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 26 | now = max(now, a[j + 1]); | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 26 | now = max(now, a[j + 1]); | ~~~^~~~~~~~~~~~~~~
s901616929
p03752
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int N, K; cin >> N >> K; vector<int> a(N); for(int i = 0; i < N; i++){ cin >> a[i]; } ll ans = 1e11; for(int i = 0; i < (1 << (N - 1)); i++){ bitset<16> bit(i); if(bit.count() != K - 1) continue; ll ans1 = 0; ll bound = a[0]; for(int j = 0; j < N - 1; j++){ if(bit[j]){ if(bound >= a[j + 1]){ ans1 += bound - a[j + 1] + 1; bound++; } bound = max(bound, a[j + 1]); } } ans = min(ans, ans1); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:23:20: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 23 | bound = max(bound, a[j + 1]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:23:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 23 | bound = max(bound, a[j + 1]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:23:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 23 | bound = max(bound, a[j + 1]); | ~~~^~~~~~~~~~~~~~~~~
s563915444
p03752
C++
/* Problem 14 https://atcoder.jp/contests/s8pc-4/tasks/s8pc_4_b */ #include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <map> #include <numeric> #include <string> #include <cmath> #include <iomanip> #include <queue> #include <list> #include <set> #include <stack> #include <cctype> #include <cmath> #include <bitset> using namespace std; /* typedef */ typedef long long ll; /* constant */ const int MAX = 15; const ll INF = 1e18; /* global variables */ /* function */ /* main */ int main(){ int N, K, upper; ll ans, tmp, pre; cin >> N >> K; if (K == 1) { cout << 0 << '\n'; return 0; } vector<ll> building(N); for (int i = 0; i < N; i++) cin >> building[i]; upper = pow(2, N); ans = INF; for (int b = 0; b < upper; b++) { bitset<MAX> bs(b); vector<int> v(MAX, 0); if (bs.count() != K-1) continue; for (int i = 0; i < N; i++) if ((bs >> i)[0]) v[i] = 1; tmp = 0; pre = building[v[0]]; for (int i = 0; i < N-1; i++) { if (v[i]) { if (pre >= building[i+1]) { tmp += pre - building[i+1] + 1; pre++; } pre = max(pre, building[i]); } ans = min(ans, tmp); } cout << ans << '\n'; }
a.cc: In function 'int main()': a.cc:63:2: error: expected '}' at end of input 63 | } | ^ a.cc:31:11: note: to match this '{' 31 | int main(){ | ^
s261962767
p03752
C++
#include <bits/stdc++.h> using namespace std; #define INF 1000000000 int main() { int N, K; cin >> N >> K; vector<int> a(N); long long ans = INF; for (int i = 0; i < N; ++i) { cin >> a.at(i); } for (int i = 0; i < 1 << N; ++i) { if (__builtin_popcountll(i) != K) { continue; } long long ans_i = 0, max_hight = 0; for (int j = 0; j < N; ++j) { if (1 << (N - j - 1) & i) { if (max_hight >= a.at(j)) { ans_i += max_hight - a.at(j) + 1; max_hight += 1; } } max_hight = max(max_hight,a.at(j)); } bitset<15> bs(i); cout << bs << endl; cout << ans_i << endl; ans = min(ans, ans_i); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:32:22: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 32 | max_hight = max(max_hight,a.at(j)); | ~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 32 | max_hight = max(max_hight,a.at(j)); | ~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | max_hight = max(max_hight,a.at(j)); | ~~~^~~~~~~~~~~~~~~~~~~
s060853873
p03752
C++
//This template was last modified on 2/26/2020. //Define many functions and words. //The functions I have defined start with a capital letter. #include <bits/stdc++.h> using namespace std; //#define MOD 998244353 #define MOD 1000000007 typedef long long ll; typedef vector<ll> vl; typedef vector<double> vd; typedef vector<vl> matrix;//A(n, vl(m)); typedef vector<string> vs; typedef pair<ll,ll> pl; typedef vector<pl> vp; typedef pair<double,double> pd; typedef vector<pd> vpd; typedef vector<bool> vb; typedef map<ll,ll> mapl; typedef queue<ll> quell; typedef queue<pl> quepl; typedef priority_queue<ll> pq_ll; typedef priority_queue<pl> pq_pl; #define nl "\n"s #define rep(i,n) for(ll i=0LL; i<(n); i++) #define INF 1001001001001001001 #define PI 3.14159265358979323846 #define SP << " "s << #define PB push_back #define MP make_pair #define F first #define S second #define All(V) V.begin(),V.end() #define Sortup(V) sort(All(V)) #define Sortdown(V) sort(V.rbegin(), V.rend()) #define L_b(V, key) lower_bound(All(V), key) #define B_s(V, key) binary_search(All(V), key) #define endYes do{cout << "Yes" << nl; return 0;}while(0) #define endYES do{cout << "YES" << nl; return 0;}while(0) #define endNo do{cout << "No" << nl; return 0;}while(0) #define endNO do{cout << "NO" << nl; return 0;}while(0) #define endS(str) do{cout << str << nl; return 0;}while(0) //Mathmatical functions. template<class T>bool Chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;} template<class T>bool Chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;} template<class T>double Dist(T x,T y,T X,T Y){return sqrt( (x-X)*(x-X)+(y-Y)*(y-Y) );} ll Digit(ll N, ll base){ll res=0;while(N)res++, N/=base;return res;} bool Bit(ll subset, ll Rsift){ return ((subset)>>(Rsift))&1; } ll Gcd(ll a,ll b){ return b?Gcd(b,a%b):abs(a); } ll Lcm(ll A,ll B){ return A/Gcd(A,B)*B; } ll Pow(ll e,ll x){ll res=1LL;while(x){if(x&1)res*=e;e*=e;x/=2;}return res;} ll Pow_mod(ll e,ll x){ll res=1LL;while(x){if(x&1)res=(1LL*res*e)%MOD;e=(1LL*e*e)%MOD;x/=2;}return res;} void Mul(ll &a,ll b){ a=1LL*a*b%MOD; } void Eratos_prime(vb &is_prime){//1-indexed ll N=is_prime.size()-1; rep(i, N) is_prime.at(i) = true; is_prime.at(0) = is_prime.at(1) = false; for(ll i=2; i*i<=N; i++) if(is_prime.at(i)) { for(ll j=i+i; j<=N; j+=i) is_prime.at(j) = false; } } void Primefact(ll N, mapl &elem){ for(ll i=2; i*i<=N; i++) { while(N%i==0) { elem[i]++; N /= i; } } if(N>1) elem[N]++; } //any number of arguments. template<class... T> ll Sum(T... args){ ll res=0; for(ll i: initializer_list<ll>{args...}) res += i; return res; } //cumu is empty. void Cumu_sum(vl &cumu, vl a){ cumu.PB(0LL); rep(i, a.size()) cumu.PB( Sum(cumu[i], a[i]) ); } // auto MOD int (@sunuke pakutta) struct mint { ll x; mint(ll x=0):x((x%MOD+MOD)%MOD){} mint operator-() const { return mint(-x);} mint& operator+=(const mint a) { if ((x += a.x) >= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x += MOD-a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res+=a; } mint operator-(const mint a) const { mint res(*this); return res-=a; } mint operator*(const mint a) const { mint res(*this); return res*=a; } mint pow(ll t) const {//O(log(t)) if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } //for prime MOD //O(log(MOD-2)) mint inv() const { return pow(MOD-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; //2**n % MOD, O(log(n)) mint f(int n) { if (n == 0) return 1; mint x = f(n/2); x *= x; if (n%2 == 1) x *= 2; return x; } //O(a + log(MOD-2)), Independent of n mint choose(int n, int a) { mint x = 1, y = 1; rep(i,a) { x *= n-i; y *= i+1; } return x / y; } // https://youtu.be/L8grWxBlIZ4?t=9858 // https://youtu.be/ERZuLAxZffQ?t=4807 : optimize // https://youtu.be/8uowVvQ_-Mo?t=1329 : division /* //Topological sort O(|V|+|E|) vl g[100100]; vb used(100100); vl Sortedgraph; void dfs_Tsort(ll u) { if(used[u]) return; used[u] = true; for(auto x: g[u]) dfs_Tsort(x); Sortedgraph.push_back(u); } //N:=|V| void Topo_sort(ll N) { rep(i, N) dfs_Tsort(i); reverse(All(Sortedgraph)); } */ /* //Warshall floyd O(N**3) #define MAX_V 100 matrix d(MAX_V, vl(MAX_V)); void warshall_floyd(ll V){ rep(k, V) rep(i, V) rep(j, V){ Chmin(d[i][j], d[i][k] + d[k][j]); } } */ /* //Combination in MOD O(N) //Constraints 1<=k<=n<10^6 and MOD is prime and MOD>n const ll MAX=1001001; vl fac(MAX), finv(MAX), inv(MAX); void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (ll i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } //Combination ll COM(ll n, ll k){ if (n<k or n<0 or k<0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; }*/ ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// // solution comes here int main(){ ios::sync_with_stdio(0); cin.tie(0); ll N, K; cin >> N >> K; vl a(N); rep(i, N) cin >> a[i]; ll k=0, MM=0; rep(i, N) k += Chmax(MM, a[i]); if( K<=k ) endS("0"); auto cost = [&](ll sub){ ll view=0; rep(i, N-1) view += Bit(sub, i); if( view!=K-1 ) return INF; ll hei=a[0], res=0LL; rep(i, N-1){ if( Bit(sub, i) ){ if( Chmax(hei, a[i+1])==0 ){ res += hei+1-a[i+1]; hei++; } } else if( hei<a[i+1] ) return INF; } return res; }; ll ans=INF, ALL=1<<(N-1); rep(sub, ALL) Chmin(ans, cost(sub)); cout << ans << nl; }
a.cc: In lambda function: a.cc:241:16: error: inconsistent types 'long int' and 'long long int' deduced for lambda return type 241 | return res; | ^~~ a.cc: In function 'int main()': a.cc:245:24: error: no matching function for call to 'Chmin(ll&, long int)' 245 | rep(sub, ALL) Chmin(ans, cost(sub)); | ~~~~~^~~~~~~~~~~~~~~~ a.cc:48:23: note: candidate: 'template<class T> bool Chmin(T&, T)' 48 | template<class T>bool Chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;} | ^~~~~ a.cc:48:23: note: template argument deduction/substitution failed: a.cc:245:24: note: deduced conflicting types for parameter 'T' ('long long int' and 'long int') 245 | rep(sub, ALL) Chmin(ans, cost(sub)); | ~~~~~^~~~~~~~~~~~~~~~
s677863927
p03752
C++
#include <bits/stdc++.h> using namespace std; int main(){ long int N,K,m=0,M,w;bool x=true;cin>>N>>K;vector<int>a(N); for(int i=0;i<N;i++)cin>>a.at(i); for(long int i=0;i<(1<<16);i++){ bitset<16>p(i); if(p.test(N-1))break; w=a.at(0),M=0; if(p.count()==K-1){ for(int j=1;j<N;j++){ if(p.test(j-1)){ w=max(w+1,a.at(j)); M+=w-a.at(j); } } if(x)m=M; m=min(m,M); x=false; } } cout<<m<<endl; }
a.cc: In function 'int main()': a.cc:13:16: error: no matching function for call to 'max(long int, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 13 | w=max(w+1,a.at(j)); | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:13:16: note: deduced conflicting types for parameter 'const _Tp' ('long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 13 | w=max(w+1,a.at(j)); | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:13:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 13 | w=max(w+1,a.at(j)); | ~~~^~~~~~~~~~~~~
s571692505
p03752
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N,K,m,M,w;cin>>N>>K;vector<int>a(N); for(int i=0;i<N;i++)cin>>a.at(i); for(int i=0;i<(1<<15);i++){ bitset<16>p(i); if(p.test(N))break; w=a.at(0),M=0; if(p.count()==K){ if(int j=0;j<N;j++){ w=max(w+1,a.at(j)); if(p.test(j))M+=w-a.at(j); } } if(i==0)m=M; else m=min(m,M); } cout<<m<<endl; }
a.cc: In function 'int main()': a.cc:11:21: error: expected ')' before ';' token 11 | if(int j=0;j<N;j++){ | ~ ^ | ) a.cc:11:22: error: 'j' was not declared in this scope 11 | if(int j=0;j<N;j++){ | ^
s914932626
p03752
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N,K,m,M,w;cin>>N>>K;vector<int>a(N); for(int i=0;i<N;i++)cin>>a.at(i); for(int i=0;i<(1<<15);i++){ bitset<16>p(i); if(p.test(N))break; w=a.at(0),M=0; if(p.count()==K){ if(int j=0;j<N;j++){ w=max(w+1,a.at(j)); if(p.test(j))M+=w-a.at(j); } } } cout<<m<<endl; }
a.cc: In function 'int main()': a.cc:11:21: error: expected ')' before ';' token 11 | if(int j=0;j<N;j++){ | ~ ^ | ) a.cc:11:22: error: 'j' was not declared in this scope 11 | if(int j=0;j<N;j++){ | ^
s722545068
p03752
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i]; int tall = 0; int c = 0; int ans = 0; for(int i = 0; i < n; i++){ tall = max(tall, a[i]); }
a.cc: In function 'int main()': a.cc:18:2: error: expected '}' at end of input 18 | } | ^ a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s483171312
p03752
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n,k;cin>>n>>k; vector<long long> A(n);for(int i = 0; n > i; i++)cin>>A[i]; long long ans = 0; for(int bit = 0; (1<<(n-1)) > bit; bit++){ if(__builtin_popcount(bit)+1 != k)continue; long long he = A[0]; long long tmp = 0; for(int i = 0; n > i; i++){ if(bit & (1<<i)){ if(he < A[i+1]){ he = A[i+1]; }else{ he++; tmp =ht-A[i+1]; } } } ans = min(ans,tmp); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:18:16: error: 'ht' was not declared in this scope; did you mean 'he'? 18 | tmp =ht-A[i+1]; | ^~ | he
s216568970
p03752
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n,k;cin>>n>>k; for(int i = 0; n > i; i++){ vector<int> A(n); } int ans = -1; for(int bit = 0; (1<<n) > bit; bit++){ if(__builtin_popcount(bit) != k)continue; int nya = -1; int tmp = 0; for(int i = 0; n > i; i++){ if(bit & (1<<i)){ if(nya == -1){ nya = A[i]; }else{ if(nya < A[i]){ nya = A[i]; }else{ nya++; tmp += nya-A[i]; } } } } if(ans == -1)ans = tmp; else ans = min(ans,tmp); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:17:17: error: 'A' was not declared in this scope 17 | nya = A[i]; | ^ a.cc:19:20: error: 'A' was not declared in this scope 19 | if(nya < A[i]){ | ^
s685248724
p03752
C++
#include <bits/stdc++.h> using namespace std; #define int long long //TEMPLATE START---------------8<---------------8<---------------8<---------------8<---------------// typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<string> vst; typedef vector<bool> vb; typedef vector<ld> vld; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vector<int> > vvi; const int INF = (0x7FFFFFFFL); const ll INFF = (0x7FFFFFFFFFFFFFFFL); const string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int MOD = 1e9 + 7; const int MODD = 998244353; const string alphabet = "abcdefghijklmnopqrstuvwxyz"; const double PI = acos(-1.0); const double EPS = 1e-9; const string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; int dx[9] = { 1, 0, -1, 0, 1, -1, -1, 1, 0 }; int dy[9] = { 0, 1, 0, -1, -1, -1, 1, 1, 0 }; #define ln '\n' #define scnaf scanf #define sacnf scanf #define sancf scanf #define SS(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__); template<typename T> void MACRO_VAR_Scan(T& t){cin >> t;}template<typename First, typename...Rest> void MACRO_VAR_Scan(First& first, Rest&...rest){cin >> first;MACRO_VAR_Scan(rest...);} #define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i; #define SVV(type,c,n,m) vector<vector<type>> c(n,vector<type>(m));for(auto& r:c)for(auto& i:r)cin >> i; template<class T,class U>ostream &operator<<(ostream &o,const pair<T,U>&j){o<<"{"<<j.first<<", "<<j.second<<"}";return o;} template<class T,class U>ostream &operator<<(ostream &o,const map<T,U>&j){o<<"{";for(auto t=j.begin();t!=j.end();++t)o<<(t!=j.begin()?", ":"")<<*t;o<<"}";return o;} template<class T>ostream &operator<<(ostream &o,const set<T>&j){o<<"{";for(auto t=j.begin();t!=j.end();++t)o<<(t!=j.begin()?", ":"")<<*t;o<<"}";return o;} template<class T>ostream &operator<<(ostream &o,const multiset<T>&j){o<<"{";for(auto t=j.begin();t!=j.end();++t)o<<(t!=j.begin()?", ":"")<<*t;o<<"}";return o;} template<class T>ostream &operator<<(ostream &o,const vector<T>&j){o<<"{";for(int i=0;i<(int)j.size();++i)o<<(i>0?", ":"")<<j[i];o<<"}";return o;} inline int print(void){cout << endl; return 0;} template<class Head> int print(Head&& head){cout << head;print();return 0;} template<class Head,class... Tail> int print(Head&& head,Tail&&... tail){cout<<head<<" ";print(forward<Tail>(tail)...);return 0;} #ifdef LOCAL inline int dump(void){cerr << endl; return 0;} template<class Head> int dump(Head&& head){cerr << head;dump();return 0;} template<class Head,class... Tail> int dump(Head&& head,Tail&&... tail){cerr<<head<<" ";dump(forward<Tail>(tail)...);return 0;} #define debug(...) do{cerr<<__LINE__<<": "<<#__VA_ARGS__<<" = ";dump(__VA_ARGS__);}while(0) #define ER(x) cerr << #x << " = " << (x) << endl; #define ERV(v) {cerr << #v << " : ";for(const auto& xxx : v){cerr << xxx << " ";}cerr << "\n";} #else #define dump(...) #define debug(...) #define ER(x) #define ERV(v) #endif template<typename T> void PA(T &a){int ASIZE=sizeof(a)/sizeof(a[0]);for(int ii=0;ii<ASIZE;++ii){cout<<a[ii]<<" \n"[ii==ASIZE-1];}} template<typename T> void PV(T &v){int VSIZE=v.size();for(int ii=0;ii<VSIZE;++ii){cout<<v[ii]<<" \n"[ii==VSIZE-1];}} inline int YES(bool x){cout<<((x)?"YES":"NO")<<endl;return 0;} inline int Yes(bool x){cout<<((x)?"Yes":"No")<<endl;return 0;} inline int yes(bool x){cout<<((x)?"yes":"no")<<endl;return 0;} inline int yES(bool x){cout<<((x)?"yES":"nO")<<endl;return 0;} inline int Yay(bool x){cout<<((x)?"Yay!":":(")<<endl;return 0;} template<typename A,typename B> void sankou(bool x,A a,B b){cout<<((x)?(a):(b))<<endl;} #define _overload3(_1,_2,_3,name,...) name #define _REP(i,n) REPI(i,0,n) #define REPI(i,a,b) for(ll i=ll(a);i<ll(b);++i) #define REP(...) _overload3(__VA_ARGS__,REPI,_REP,)(__VA_ARGS__) #define _RREP(i,n) RREPI(i,n,0) #define RREPI(i,a,b) for(ll i=ll(a);i>=ll(b);--i) #define RREP(...) _overload3(__VA_ARGS__,RREPI,_RREP,)(__VA_ARGS__) #define EACH(e,v) for(auto& e : v) #define PERM(v) sort((v).begin(),(v).end());for(bool c##p=1;c##p;c##p=next_permutation((v).begin(),(v).end())) #define ADD(a,b) a=(a+ll(b))%MOD #define MUL(a,b) a=(a*ll(b))%MOD inline ll MOP(ll x,ll n,ll m=MOD){ll r=1;while(n>0){if(n&1)(r*=x)%=m;(x*=x)%=m;n>>=1;}return r;} inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}inline ll lcm(ll a,ll b){return a*b/gcd(a,b);}inline ll POW(ll a,ll b){ll c=1ll;do{if(b&1)c*=1ll*a;a*=1ll*a;}while(b>>=1);return c;} template<typename T,typename A,typename B> inline bool between(T x,A a,B b) {return ((a<=x)&&(x<b));}template<class T> inline T sqr(T x){return x*x;} template<typename A,typename B> inline bool chmax(A &a,const B &b){if(a<b){a=b;return 1;}return 0;} template<typename A,typename B> inline bool chmin(A &a,const B &b){if(a>b){a=b;return 1;}return 0;} #define tmax(x,y,z) max((x),max((y),(z))) #define tmin(x,y,z) min((x),min((y),(z))) #define PB emplace_back #define MP make_pair #define MT make_tuple #define all(v) (v).begin(),(v).end() #define rall(v) (v).rbegin(),(v).rend() #define SORT(v) sort((v).begin(),(v).end()) #define RSORT(v) sort((v).rbegin(),(v).rend()) #define EXIST(s,e) (find((s).begin(),(s).end(),(e))!=(s).end()) #define EXISTST(s,c) (((s).find(c))!=string::npos) #define POSL(x,val) (lower_bound(x.begin(),x.end(),val)-x.begin()) #define POSU(x,val) (upper_bound(x.begin(),x.end(),val)-x.begin()) #define GEQ(x,val) (int)(x).size() - POSL((x),(val)) #define GREATER(x,val) (int)(x).size() - POSU((x),(val)) #define LEQ(x,val) POSU((x),(val)) #define LESS(x,val) POSL((x),(val)) #define SZV(a) int((a).size()) #define SZA(a) sizeof(a)/sizeof(a[0]) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) #define MEMINF(a) memset(a,0x3f,sizeof(a)) #define FILL(a,b) memset(a,b,sizeof(a)) #define UNIQUE(v) sort((v).begin(),(v).end());(v).erase(unique((v).begin(),(v).end()),(v).end()) struct abracadabra{ abracadabra(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); cerr << fixed << setprecision(5); }; } ABRACADABRA; //TEMPLATE END---------------8<---------------8<---------------8<---------------8<---------------// map<int, int> dp[20][20]; signed main() { SS(int, N, K); SV(int, A, N); dp[0][0][0] = 0; auto update = [&](int a, int b, int c, int x) -> void { // debug(a, b, c, x); if (dp[a][b].count(c) == 0) dp[a][b][c] = x; else chmin(dp[a][b][c], x); }; vector<int> mx(N + 1, 0); REP(i, 1, N + 1) chmax(mx[i], max(mx[i - 1], A[i - 1])); REP(i, N) { REP(j, N) { EACH(p, dp[i][j]) { int hei, val; tie(hei, val) = p; { // i番目を採用 int need = max(0, (max(mx[i], hei) + 1) - A[i]); update(i + 1, j + 1, A[i] + need, val + need); } { // i番目を採用しない update(i + 1, j, hei, val); } } } } int res = INF; REP(i, K, N + 1) { EACH(e, dp[N][i]) { chmin(res, e.second); } } print(res); }
a.cc: In function 'int main()': a.cc:119:35: error: no matching function for call to 'max(int, long long int)' 119 | int need = max(0, (max(mx[i], hei) + 1) - A[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:119:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 119 | int need = max(0, (max(mx[i], hei) + 1) - A[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:119:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 119 | int need = max(0, (max(mx[i], hei) + 1) - A[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s898213254
p03752
C++
// #include <bits/stdc++.h> #include<climits> #include<cmath> #include<cstdio> #include<deque> #include<map> #include<set> #include<vector> #include<iostream> #include<sstream> #include<algorithm> #include<numeric> #include<string> #include<tuple> using namespace std; #include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; #define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define END return EXIT_SUCCESS #define rep(I,N) for(auto I=0;I<(N);++I) #define up(I,A,B) for(auto I=(A);I<=(B);++I) #define dw(I,A,B) for(auto I=(A);I>=(B);--I) #define all(C) (C).begin(),(C).end() #define rall(C) (C).rbegin(),(C).rend() #define ft first #define sd second #define mp make_pair #define mt make_tuple #define pf push_front #define pb push_back #define pt pop_front #define pk pop_back #define lb lower_bound #define ub upper_bound #define rs resize template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;} template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;} template<class T>inline void in(T &p){cin>>p;} template<class T1,class T2>inline void in(T1 &p1,T2 &p2){cin>>p1>>p2;} template<class T1,class T2,class T3>inline void in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;} template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;} template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;} template<class T>inline void out(T p){cout<<p<<endl;} template<class T1,class T2>inline void out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;} template<class T1,class T2,class T3>inline void out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;} template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;} inline void solve(void){ long N,K; in(N,K); vector<cpp_int>a(N); rep(i,N)in(a[i]); cpp_int ans=numeric_limits<mp::cpp_int>::max(); for(int i=0;i<1<<N;i++){ if(__builtin_popcount(i)<(int)K)continue; cpp_int now,cost=0; bool is_first=true; rep(j,N){ if(i>>j&1){ if(is_first){ if(a[0]>=a[j]&&j!=0){ now=a[0]+1; cost+=a[0]-a[j]+1; }else{ now=a[j]; } is_first=false; }else{ if(a[j]<=now){ cost+=now-a[j]+1; now++; }else now=a[j]; } } } chmin(ans,cost); } out(ans); } int main(int argc,char**argv){ BEGIN; solve(); END; }
a.cc:16:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 16 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s898065200
p03752
C++
// #include <bits/stdc++.h> #include<climits> #include<cmath> #include<cstdio> #include<deque> #include<map> #include<set> #include<vector> #include<iostream> #include<sstream> #include<algorithm> #include<numeric> #include<string> #include<tuple> using namespace std; #include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; #define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) #define END return EXIT_SUCCESS #define rep(I,N) for(auto I=0;I<(N);++I) #define up(I,A,B) for(auto I=(A);I<=(B);++I) #define dw(I,A,B) for(auto I=(A);I>=(B);--I) #define all(C) (C).begin(),(C).end() #define rall(C) (C).rbegin(),(C).rend() #define ft first #define sd second #define mp make_pair #define mt make_tuple #define pf push_front #define pb push_back #define pt pop_front #define pk pop_back #define lb lower_bound #define ub upper_bound #define rs resize template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;} template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;} template<class T>inline void in(T &p){cin>>p;} template<class T1,class T2>inline void in(T1 &p1,T2 &p2){cin>>p1>>p2;} template<class T1,class T2,class T3>inline void in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;} template<class T1,class T2,class T3,class T4>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;} template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;} template<class T>inline void out(T p){cout<<p<<endl;} template<class T1,class T2>inline void out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;} template<class T1,class T2,class T3>inline void out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;} template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;} inline void solve(void){ long N,K; in(N,K); vector<cpp_int>a(N); rep(i,N)in(a[i]); cpp_int ans=1e300; for(int i=0;i<1<<N;i++){ if(__builtin_popcount(i)<(int)K)continue; cpp_int now,cost=0; bool is_first=true; rep(j,N){ if(i>>j&1){ if(is_first){ if(a[0]>=a[j]&&j!=0){ now=a[0]+1; cost+=a[0]-a[j]+1; }else{ now=a[j]; } is_first=false; }else{ if(a[j]<=now){ cost+=now-a[j]+1; now++; }else now=a[j]; } } } chmin(ans,cost); } out(ans); } int main(int argc,char**argv){ BEGIN; solve(); END; }
a.cc:16:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 16 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s717907838
p03752
C++
#include <iostream> using namespace std; long h[20][20], dp[20][20]; int main() { int N, K, a[20]; cin >> N >> K; for(int i=0; i<N; ++i) cin >> a[i]; h[0][0]=h[0][1]=a[0]; for(int i=1; i<N; ++i){ h[i][0]=max(h[i-1][0], a[i]); for(int j=1; j<i+2; ++j){ if(a[i]>h[i-1][j-1]){ h[i][j]=a[i]; dp[i][j]=dp[i-1][j-1]; } else{ bool flag=false; if(j<=i){ if(dp[i-1][j]<dp[i-1][j-1]+h[i-1][j-1]-a[i]) flag=true; } if(flag){ h[i][j]=h[i-1][j]; dp[i][j]=dp[i-1][j]; } else{ h[i][j]=h[i-1][j-1]+1; dp[i][j]=dp[i-1][j-1]+h[i][j]-a[i]; } } } } cout << dp[N-1][K] << endl; return 0; }
a.cc: In function 'int main()': a.cc:10:24: error: no matching function for call to 'max(long int&, int&)' 10 | h[i][0]=max(h[i-1][0], a[i]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:10:24: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 10 | h[i][0]=max(h[i-1][0], a[i]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
s186399636
p03752
C++
#include "bits/stdc++.h" using namespace std; using namespace std::chrono; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> pll; #define _overload4(_1,_2,_3,_4,name,...) name #define _overload3(_1,_2,_3,name,...) name #define _overload2(_1,_2,name,...) name #define _re(n) _rep(i,n) #define _rep(i,n) _repi(i,0,n) #define _repi(i,a,b) for(ll i=a;i<b;++i) #define _repc(i,a,b,c) for(ll i=a;i<b;i+=c) #define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__) #define _rre(n) _rrep(i,n) #define _rrep(i,n) _rrepi(i,0,n) #define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--) #define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c) #define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__) #define rbr(i,a) for(auto&& i:a) #define sum(...) accumulate(range(__VA_ARGS__),0) #define _range(i) (i).begin(),(i).end() #define _rangek(i,k) (i).begin(),(i).begin()+k #define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__) #define LINF 0x3999999999999999LL #define MOD ll(1000000007) #define MODD ll(998244353) #define INF 0x39999999 #define Yes(i) out(i?"Yes":"No") #define YES(i) out(i?"YES":"NO") #define elif else if //#define START auto start=system_clock::now() //#define END auto end=system_clock::now();cerr<<duration_cast<milliseconds>(end-start).count()<<" ms\n" #define INT(...) int __VA_ARGS__;in(__VA_ARGS__) #define LL(...) ll __VA_ARGS__;in(__VA_ARGS__) #define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__) #define STR(...) string __VA_ARGS__;in(__VA_ARGS__) #define CHR(...) char __VA_ARGS__;in(__VA_ARGS__) #define DBL(...) double __VA_ARGS__;in(__VA_ARGS__) #define vec(type,name,size) vector<type> name(size); #define VEC(type,name,size) vector<type> name(size);in(name) #define v(name,size,value) vector<ll>name(size,value) #define vv(type,name,h,w,value) vector<vector<type>>name(h,vector<type>(w,value)) struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa; template<typename T> inline constexpr T gcd (T a,T b) {if(a==b)return a;else return gcd(b,(a-1)%b+1);} inline void in() {} template<typename T> istream& operator >> (istream& is, vector<T>& vec); template<typename T,size_t size> istream& operator >> (istream& is, array<T,size>& vec); template<typename T,typename L> istream& operator >> (istream& is, pair<T,L>& p); template<typename T> ostream& operator << (ostream& os, vector<T>& vec); template<typename T,typename L> ostream& operator << (ostream& os, pair<T,L>& p); template<typename T> istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;} template<typename T,typename L> istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;} template<typename T> ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;} template<typename T,typename L> ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;} template <class Head, class... Tail> inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);} template <typename T> inline void out(T t){cout<<t<<'\n';} inline void out(){cout<<'\n';} template <class Head, class... Tail> inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);} ll n; vec(ll,a,15); ll dp(ll k,ll at,ll height){ if(k==0)return 0; if(k==n-at){ return dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at]); } return min(dp(k,at+1,max(height,a[at])),dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at])); } int main(){ ll k; in(n,k); rep(n)in(a[i]); out(dp(k,0,0)); }
a.cc: In function 'll dp(ll, ll, ll)': a.cc:80:52: error: no matching function for call to 'max(int, ll)' 80 | return dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at]); | ~~~^~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:80:52: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 80 | return dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at]); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:80:52: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 80 | return dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at]); | ~~~^~~~~~~~~~~~~~~~~~ a.cc:82:81: error: no matching function for call to 'max(int, ll)' 82 | return min(dp(k,at+1,max(height,a[at])),dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at])); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:82:81: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 82 | return min(dp(k,at+1,max(height,a[at])),dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at])); | ~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:82:81: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 82 | return min(dp(k,at+1,max(height,a[at])),dp(k-1,at+1,max(height+1,a[at]))+max(0,height+1-a[at])); | ~~~^~~~~~~~~~~~~~~~~~
s023136740
p03752
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; long long N, K; vector<long long> buildings; long long build(long long now, long long back_building_height, long long increase_buildings){ if(increase_buildings == K){ return 0; }else if(N - now == K - increase_buildings){ return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); }else{ return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); } } int main(){ cin >> N >> K; buildings.resize(N); for(int i = 0; i < N; i++){ cin >> buildings[i]; } cout << build(1, buildings[0], 1) << endl; }
a.cc: In function 'long long int build(long long int, long long int, long long int)': a.cc:13:19: error: no matching function for call to 'max(long int, long long int)' 13 | return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:13:19: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 13 | return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:13:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 13 | return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:15:23: error: no matching function for call to 'max(long int, long long int)' 15 | return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:15:23: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 15 | return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:15:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 15 | return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s042037143
p03752
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; #define long long long int N, K; vector<long> buildings; long build(int now, long back_building_height, int increase_buildings){ if(increase_buildings == K){ return 0; }else if(N - now == K - increase_buildings){ return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); }else{ return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); } } int main(){ cin >> N >> K; buildings.resize(N); for(int i = 0; i < N; i++){ cin >> buildings[i]; } cout << build(1, buildings[0], 1) << endl; }
a.cc: In function 'long long int build(int, long long int, int)': a.cc:13:19: error: no matching function for call to 'max(long int, long long int)' 13 | return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:13:19: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 13 | return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:13:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 13 | return max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:15:23: error: no matching function for call to 'max(long int, long long int)' 15 | return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:15:23: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 15 | return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:15:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 15 | return min(max(0l, back_building_height + 1 - buildings[now]) + build(now + 1, max(back_building_height + 1, buildings[now]), increase_buildings + 1), build(now + 1, back_building_height, increase_buildings)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~