submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s714809592
p04006
C++
#include<bits/stdc++.h> using namespace std; int n,k,a[1010]; long long dp[2010][2010]; int main() { cin>>n>>k; for(int i=1;i<=n;++i)scanf("%d",a+i); for(int i=1;i<=n;++i){ dp[i][0]=a[i]; for(int j=1;j<n;++j){ int y=i-j;if(y<1)y+=n; dp[i][j]=min(dp[i][j-1],a[y]); } } long long mn=1e18; for(int i=0;i<n;++i){ long long ans=0; for(int j=1;j<=n;++j)ans+=dp[j][i]; mn=min(mn,i*k+ans); } cout<<mn<<endl; }
a.cc: In function 'int main()': a.cc:13:25: error: no matching function for call to 'min(long long int&, int&)' 13 | dp[i][j]=min(dp[i][j-1],a[y]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:13:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 13 | dp[i][j]=min(dp[i][j-1],a[y]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:13:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 13 | dp[i][j]=min(dp[i][j-1],a[y]); | ~~~^~~~~~~~~~~~~~~~~
s562249969
p04006
C++
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 2e3 + 5; LL a[maxn]; LL b[maxn][maxn];//b[i][k] : 当整个过程使用了【k】次魔法,获得【color i】时的最少花费的时间。(不包括【k * x】). int main(){ int n; LL x,sum = 1LL << 60LL; cin >> n >> x; for(int i = 1;i <= n;i++) cin >> a[i]; for(int i = 1;i <= n;i++){ b[i][0] = a[i]; for(int k = 1;k <= n - 1;k++){ int pos = i - k; if(pos <= 0) pos = n - abs(pos); b[i][k] = min(b[i][k - 1],a[pos]);//【b[i][k]】的转移方程. } } for(int k = 0;k <= n - 1;k++){ LL ans = 0; for(int i = 1;i <= n;i++){ ans += b[i][k]; } sum = min(sum,ans + x * k);//取最小值. } cout << sum << endl; }1
a.cc:30:2: error: expected unqualified-id before numeric constant 30 | }1 | ^
s166224571
p04006
C++
#include<stdio.h> int main(){ long n,i,j,a[2222],min[2222][2222],ans,x,p; scanf("%ld%ld",&n,&x); for(i=0;i<n;i++) scanf("%ld",&a[i]); for(i=0;i<n;i++) for(j=0;j<n;j++) min[i][j]=100000000000; for(i=0;i<n;i++){ for(j=0;j<n;j++){ if(a[(i-j)%n]<min[i][(i-j+1)%n]) min[i][(i-j)%n]=a[(i-j)%n]; else min[i][(i-j)%n]=min[i][(i-j+1)%n]; } ans=10000000000000; for(i=0;i<n;i++){ p=0; for(j=0;j<n;j++) p+=min[i][(i-j)%n]; p+=j*x; if(p<ans) ans=p; } printf("%ld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:28:2: error: expected '}' at end of input 28 | } | ^ a.cc:2:11: note: to match this '{' 2 | int main(){ | ^
s944926459
p04006
C++
#include "testlib.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const int MX = 2007; int a[MX]; int cost[MX]; int main() { #ifdef BZ freopen("input.txt", "r", stdin); #endif ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int n; cin >> n; int x; cin >> x; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cost[i] = a[i]; } ll ans = 1e18; for (int i = 0; i <= n + 1; i++) { ll cans = 0; for (int j = 0; j < n; j++) { cost[j] = min(cost[j], a[(i + j) % n]); cans += cost[j]; } ans = min(ans, cans + 1ll * x * i); } cout << ans << "\n"; }
a.cc:1:10: fatal error: testlib.h: No such file or directory 1 | #include "testlib.h" | ^~~~~~~~~~~ compilation terminated.
s448705412
p04006
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll ; long long gcd(long long aaa,long long bbb) { if(bbb==0) { return aaa; } return gcd(bbb,aaa%bbb); } int main (){ ll N,x; cin >> N >> x; ll a[N],s=0,cmp,tmp[2000]={},l=0,count=-1,o,countt=0,n[2000]={},tmpp=0; map<ll,ll>m; map<ll,ll>c; for(int i = 0; i < N; i++) { cin >> a[i]; s += a[i]; } for(int i = 0; i < N; i++) { tmp[i] = a[i]; for(int j = 0; j < N; j++) { cmp = i + 1; cmp += j; if(cmp >= N) { cmp -= N; } if(i == cmp) { break; } tmp[i] += min(a[cmp], a[i] + x); if(min(a[cmp],a[i] + x) == a[cmp]) { m[cmp] = 1; } } } for(int i = 0; i < N*2; i++) { if(i == N && countt == 0) { break; }else if(i == N) { countt++; } o = i % N; if(count == -1) { if(m[i] == 1) { l = i; count++; } }else { if(m[i] == 1) { n[count] = abs(o - l) * (a[l] + x); count++; l = o; if(countt == 1) { break; } } } } sort(n,n+2000); ll ans = s; countt = count+1; if(count >= 2) { if(m[i] == 1) { for(int j = 1; j <= count; j++) { tmpp += n[count-j]; } }else { break; } } for(int i = 0; i < N; i++) { ans = min(tmp[i],ans); } cout << min(ans,tmpp) << endl; return 0; }
a.cc: In function 'int main()': a.cc:73:14: error: 'i' was not declared in this scope 73 | if(m[i] == 1) { | ^ a.cc:78:13: error: break statement not within loop or switch 78 | break; | ^~~~~
s906683406
p04006
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll ; long long gcd(long long aaa,long long bbb) { if(bbb==0) { return aaa; } return gcd(bbb,aaa%bbb); } int main (){ ll N,x; cin >> N >> x; ll a[N],s=0,cmp,tmp[2000]={},l=0,count=-1,o,countt=0,n[2000]={},tmpp[2000]={}; map<ll,ll>m; map<ll,ll>c; for(int i = 0; i < N; i++) { tmpp[i] = 1e9; } for(int i = 0; i < N; i++) { cin >> a[i]; s += a[i]; } for(int i = 0; i < N; i++) { tmp[i] = a[i]; for(int j = 0; j < N; j++) { cmp = i + 1; cmp += j; if(cmp >= N) { cmp -= N; } if(i == cmp) { break; } tmp[i] += min(a[cmp], a[i] + x); if(min(a[cmp],a[i] + x) == a[cmp]) { m[cmp] = 1; } } } for(int i = 0; i < N*2; i++) { if(i == N && count == 0) { break; }else if(i == N) { countt++; } o = i % N; if(count == -1) { if(m[i] == 1) { l = i; count++; } }else { if(m[i] == 1) { n[count] = abs(o - l) * (a[l] + x); count++; l = o; if(countt == 1) { break; } } } } sort(n,n+2000); ll ans = s; countt = count+1; if(count >= 2) { for(int i = 0; i < N; i++) { if(m[i] == 1) { for(int j = 1; j <= count; j++) { tmpp[j] += n[count-j]; } tmpp[i] *= }else { break; } } } for(int i = 0; i < N; i++) { tmp[i] = min(tmp[i],tmpp[i]); } for(int i = 0; i < N; i++) { ans = min(tmp[i],ans); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:83:13: error: expected primary-expression before '}' token 83 | }else { | ^
s592349049
p04006
C++
#include <bits/stdc++.h> #define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(long long int i=(a);i<(b);i++) #define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--) #define all(v) (v).begin(), (v).end() #define pb(q) push_back(q) #define Abs(a,b) max(a,b)-min(a,b) #define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;} #define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;} #define Cout(x) cout<<(x)<<endl #define POSSIBLE(condition) if(condition){cout << "POSSIBLE" << endl;}else{cout << "IMPOSSIBLE" << endl;} #define Possible(condition) if(condition){cout << "Possible" << endl;}else{cout << "Impossible" << endl;} #define possible(condition) if(condition){cout << "possible" << endl;}else{cout << "impossible" << endl;} #define Size(n) (n).size() typedef long long ll; using namespace std; const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6; const ll LINF = 1e18; long long int n,cnt=0,ans=INF,a[ohara],b[ohara],c,d,cmp[ohara],cmpp,m,h,w,x,y,sum=0,pos,mi[2002][2002]; int dy[]={1,0,-1,0}; int dx[]={0,1,0,-1}; string alph("abcdefghijklmnopqrstuvwxyz"),s; bool fl; struct edge{int to,cost;}; //-------------------------↓↓↓↓↓↓------------------------ int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin>>n>>x; pos=0; rep(i,n){ cin>>a[i]; pos+=a[i] b[i]=INF; } rrep(i,n,2*n){ a[i]=a[i-n]; } rep(i,n){ cnt=n-1; rrrep(j,i+n,i+1){ mi[i][cnt--]=a[j]; } } rrep(genzaiti,n,2*n){ rrep(to,1,n){ mi[genzaiti-n][to]=min(mi[genzaiti-n][to],mi[genzaiti-n][to-1]); } } cnt=0; rep(mahou,n){ if(mahou==0)continue; rep(j,n){ cnt=min(a[j],a[2*n-j]); } cnt+=mahou*x; ans=min(ans,cnt); cnt=0; } Cout(min(ans,pos)); return 0; }
a.cc: In function 'int main()': a.cc:44:18: error: expected ';' before 'b' 44 | pos+=a[i] | ^ | ; 45 | b[i]=INF; | ~
s130777874
p04006
C++
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #define lp(n) for (int i = 0; i < n; i++) #define LP(n,i) for (int i = 0; i < n; i++) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define nya_n "(=^・ω・^=)" typedef long long ll; using namespace std; ll n, x, a[2000], mem, mx2[2000]; pair<ll, int>mx[2000]; ll cnt; int main() { cin >> n >> x; lp(n) { cin >> a[i]; mx[i] = make_pair(a[i], 0); } lp(n) { LP(n, j) { if (mx[j].first + x <= mx[(j + 1) % n].first) { mx[(j + 1) % n] = make_pair(mx[j].first + x, mx[j].second + 1); } } } mem = -1; lp(n) { mem = max(mem, mx[i].second); mx2[i] = a[i]; } lp(n) { LP(mem,j) { mx2[(i + mem) % n] = min(mx2[(i + mem) % n], a[(i + j) % n]); } } cnt = ll(mem)*ll(x); lp(n) { // cout << i << sp << mx2[i] << endl;; cnt += mx2[i]; } cout << cnt << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:26: error: no matching function for call to 'max(ll&, int&)' 42 | mem = max(mem, mx[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ 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:42:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 42 | mem = max(mem, mx[i].second); | ~~~^~~~~~~~~~~~~~~~~~~ /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:42:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 42 | mem = max(mem, mx[i].second); | ~~~^~~~~~~~~~~~~~~~~~~
s413089840
p04006
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.*; public class AGC004B{ public static void main(String[] args) throws IOException { MyScanner sc = new MyScanner(System.in); int n; long x; n = sc.nextInt(); x = sc.nextLong(); long[] a = new long[n]; for(int i=0; i<n; i++) a[i] = sc.nextLong(); long[] b = a.clone(); long ans=Long.MAX_VALUE; for(int k=0; k<n; k++) { long acc=0; long xk = ((long)x)*k; for(int i=0; i<n; i++) { b[i]=Math.min(b[i], a[(i-k+n)%n]); acc+=b[i]; } ans=Math.min(ans, acc+xk); } System.out.println(ans); } static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner(InputStream s) { br=new BufferedReader(new InputStreamReader(s)); } public String nextLine() throws IOException { return br.readLine(); } public String next() throws IOException { while(st==null || !st.hasMoreTokens()) st=new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public double nextDouble() throws IOException { return Double.parseDouble(next()); } public boolean ready() throws IOException { return br.ready(); } public long nextLong() throws IOException { return Long.parseLong(next()); } } }
Main.java:7: error: class AGC004B is public, should be declared in a file named AGC004B.java public class AGC004B{ ^ 1 error
s776932696
p04006
C++
#include <bits/stdc++.h> using namespace std; using ll = long long; using pii = pair<int, int>; int N, x; int a[2010]; ll dp[2010][2010], dp2[2010][2010]; int main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin >> N >> x; for (int i = 0; i < N; i++) { cin >> a[i]; dp[i][0] = a[i]; dp2[i][0] = 0; } for (int j = 1; j < N; j++) { for (int i = 0; i < N; i++) { if (dp[i][j - 1] < dp[(i - 1 + N) % N][j - 1] + x) { dp[i][j] = dp[i][j - 1]; dp2[i][j] = dp2[i][j - 1]; } else { dp[i][j] = dp[(i - 1 + N) % N][j - 1] + x; dp2[i][j] = dp2[(i - 1 + N) % N][j - 1] + 1; } } } int s = 0; for (int i = 0; i < N; i++) { s = max(s, dp2[i][N - 1]); } ll ans = s * x; for (int i = 0; i < N; i++) { ans += a[(i + (N - dp2[i][N - 1])) % N]; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:34:12: error: no matching function for call to 'max(int&, ll&)' 34 | s = max(s, dp2[i][N - 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:34:12: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 34 | s = max(s, dp2[i][N - 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:34:12: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 34 | s = max(s, dp2[i][N - 1]); | ~~~^~~~~~~~~~~~~~~~~~
s453456959
p04006
C++
#include <cstdio> #include <vector> #include <algorithm> #include <stdint.h> int64_t prev[100000]; int64_t next[100000]; int64_t as[100000]; int64_t bs[100000]; int64_t slope[100000]; int64_t total_slope; int64_t t; std::vector<int64_t> vanish[100001]; void calc_slope(int64_t x){ bs[x]+=t*slope[x]; total_slope-=slope[x]*as[x]; slope[x]=(as[next[x]]>as[x])-(as[x]>as[prev[x]]); bs[x]-=t*slope[x]; total_slope+=slope[x]*as[x]; if(slope[x]<0){ //printf("VVV %ld %ld\n",bs[x],x); vanish[bs[x]].push_back(x); } } int main(){ int64_t N,X; scanf("%ld %ld",&N,&X); for(int64_t i=0;i<N;i++){ scanf("%ld",&as[i]); } prev[0]=N-1; std::iota(prev+1,prev+N,0); next[N-1]=0; std::iota(next,next+N-1,1); int64_t sum=0; total_slope=X; std::fill(bs,bs+N,1); for(int64_t i=0;i<N;i++){ calc_slope(i); sum+=as[i]; //printf("as[%ld]=%ld\n",i,as[i]); } int64_t best=sum; //printf("SUM[0]=%ld\n",sum); for(t=1;t<=N;t++){ sum+=total_slope; //printf("SUM+=%ld\n",total_slope); //printf("SUM[%ld]=%ld\n",t,sum); for(int64_t a:vanish[t]){ //printf("VANISH %ld\n",a); total_slope-=slope[a]*as[a]; prev[next[a]]=prev[a]; next[prev[a]]=next[a]; calc_slope(prev[a]); calc_slope(next[a]); } best=std::min(best,sum); for(int64_t i=0;i<N;i++){ //printf("as[%ld]=%ld\n",i,as[i]); //printf("bs[%ld]=%ld\n",i,bs[i]); //printf("slope[%ld]=%ld\n",i,slope[i]); } } printf("%ld\n",best); return 0; }
a.cc: In function 'int main()': a.cc:35:8: error: 'iota' is not a member of 'std' 35 | std::iota(prev+1,prev+N,0); | ^~~~ a.cc:37:8: error: 'iota' is not a member of 'std' 37 | std::iota(next,next+N-1,1); | ^~~~
s127508208
p04006
C++
#include <algorithm> #include <iostream> #include <vector> #include <math.h> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <iomanip> #define _USE_MATH_DEFINES using namespace std; typedef long long ll; typedef pair<int, int> pii; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775808; ll m[2001][2001]; ll modminus(ll x, ll y) { return (x - y + mod) % mod; } int main() { ll N, x; cin >> N >> x; mod = N; for (int i = 0; i < N; i++) { cin >> m[0][i]; } for (int n = 1; n < N; n++) { for (int i = 0; i < N; i++) { m[n][i] = min(m[n - 1][i], m[n - 1][modminus(i , 1)]); } } ll ans = llmax; for (int n = 0; n < N; n++) { ll num = accumulate(m[n], m[n] + N, 0ll) + x * n; ans = min(ans, num); } cout << ans << endl; }
a.cc:20:13: warning: integer constant is so large that it is unsigned 20 | ll llmin = -9223372036854775808; | ^~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:42:18: error: 'accumulate' was not declared in this scope 42 | ll num = accumulate(m[n], m[n] + N, 0ll) + x * n; | ^~~~~~~~~~
s807571451
p04006
C++
#include <algorithm> #include <iostream> #include <vector> #include <math.h> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <iomanip> #include <functional> #define _USE_MATH_DEFINES using namespace std; typedef long long ll; typedef pair<int, int> pii; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775808; ll m[2001][2001]; ll modminus(ll x, ll y) { return (x - y + mod) % mod; } int main() { ll N, x; cin >> N >> x; mod = N; for (int i = 0; i < N; i++) { cin >> m[0][i]; } for (int n = 1; n < N; n++) { for (int i = 0; i < N; i++) { m[n][i] = min(m[n - 1][i], m[n - 1][modminus(i , 1)]); } } ll ans = llmax; for (int n = 0; n < N; n++) { ll num = accumulate(m[n], m[n] + N, 0) + x * n; ans = min(ans, num); } cout << ans << endl; }
a.cc:21:13: warning: integer constant is so large that it is unsigned 21 | ll llmin = -9223372036854775808; | ^~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:43:18: error: 'accumulate' was not declared in this scope 43 | ll num = accumulate(m[n], m[n] + N, 0) + x * n; | ^~~~~~~~~~
s259198751
p04006
C++
#include <algorithm> #include <iostream> #include <vector> #include <math.h> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <iomanip> #define _USE_MATH_DEFINES using namespace std; typedef long long ll; typedef pair<int, int> pii; double pi = 3.141592653589793; ll mod = 1000000007; int intmax = 2147483647; int intmin = -2147483648; ll llmax = 9223372036854775807; ll llmin = -9223372036854775808; ll m[2001][2001]; ll modminus(ll x, ll y) { return (x - y + mod) % mod; } int main() { ll N, x; cin >> N >> x; mod = N; for (int i = 0; i < N; i++) { cin >> m[0][i]; } for (int n = 1; n < N; n++) { for (int i = 0; i < N; i++) { m[n][i] = min(m[n - 1][i], m[n - 1][modminus(i , 1)]); } } ll ans = llmax; for (int n = 0; n < N; n++) { ll num = accumulate(m[n], m[n] + N, 0) + x * n; ans = min(ans, num); } cout << ans << endl; }
a.cc:20:13: warning: integer constant is so large that it is unsigned 20 | ll llmin = -9223372036854775808; | ^~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:42:18: error: 'accumulate' was not declared in this scope 42 | ll num = accumulate(m[n], m[n] + N, 0) + x * n; | ^~~~~~~~~~
s791958363
p04006
C++
#include <cstdio> #include <iostream> #include <bitset> #include <cmath> #include <vector> #include <algorithm> using namespace std; typedef long long ll; #define ALL(obj) (obj).begin(), (obj).end() #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) ll *buildRMQ(ll *a, ll n) { ll logn = 1; for (ll k = 1; k < n; k *= 2) ++logn; ll *r = new ll[n * logn]; ll *b = r; copy(a, a+n, b); for (ll k = 1; k < n; k *= 2) { copy(b, b+n, b+n); b += n; rep(i, n-k) b[i] = min(b[i], b[i+k]); } return r; } ll minimum(ll x, ll y, ll *rmq, ll n) { ll z = y - x, k = 0, e = 1, s; // y - x >= e = 2^k なる最大 k s = ( (z & 0xffff0000) != 0 ) << 4; z >>= s; e <<= s; k |= s; s = ( (z & 0x0000ff00) != 0 ) << 3; z >>= s; e <<= s; k |= s; s = ( (z & 0x000000f0) != 0 ) << 2; z >>= s; e <<= s; k |= s; s = ( (z & 0x0000000c) != 0 ) << 1; z >>= s; e <<= s; k |= s; s = ( (z & 0x00000002) != 0 ) << 0; z >>= s; e <<= s; k |= s; return min( rmq[x+n*k], rmq[y+n*k-e+1] ); } ll main(){ ll N,x; cin >> N >> x; ll aa[4010]; ll *a = aa + 2000; ll *b = a - N; rep(i,N) cin >> a[i]; rep(i,N) *(a - i - 1) = a[N-1-i]; // rep(i, 2 * N) cout << "b[" << i <<"] = " << b[i] << endl; ll *rmq = buildRMQ(b, 2 * N); ll ans = (ll)1000000000 *2000+1; rep(k,N){ ll cost=0; // k denote how many times one spell the magic. cost += x * k; rep(i,N){ cost += minimum(i+N-k,i+N,rmq,2*N); } ans = ans > cost ? cost : ans; } cout << ans << endl; return 0; }
a.cc:36:1: error: '::main' must return 'int' 36 | ll main(){ | ^~
s749032583
p04006
C++
#include <bits/stdc++.h> using namespace std; long long n, x, menor = LONG_MAX, answer = 0, val; long long colors[2010]; bool ready[2010]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); colors[0] = 0; cin >> n >> x; int inicial; for(int i = 0; i < n; ++i){ cin >> colors[i]; if(colors[i] < menor){ menor = colors[i]; inicial = i; } } long long real = 200000000000000; for(int l = 0; l < n; ++l){ menor = color[l]; answer = menor; int corrimientos = 0; menor += x; for(int i = (l + 1) % n, j = 1; j < n; ++i, ++j, i %= n){ if(colors[i] <= menor){ answer += colors[i]; val = colors[i]; for(int p = i + 1, k = j + 1, t = corrimientos; t && k < n; ++i, ++p, ++k, ++j, i %= n){ if(colors[p] <= val) break; else{ answer += val; --t; } } } else{ answer += menor; ++corrimientos; } } menor -= x; real = min(answer, real); } cout << real << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:17: error: 'color' was not declared in this scope; did you mean 'colors'? 28 | menor = color[l]; | ^~~~~ | colors
s756980316
p04006
C++
#include<iostream> #include<climits> #include<algorithm> using namespace std; typedef long long int ll; int main(){ ll n, k, a[2000]; int memo[2001][2000]; cin >> n >> k; for(ll i = 0; i < n; i++) cin >> a[i]; ll ans = LLONG_MAX; for(int i = 0; i <= n; i++){ ll cnt = 0; for(int j = 0; j < n; j++){ if(i == 0) memo[i][j] = a[j]; else if (i > j) memo[i][j] = min(memo[i - 1][j], a[j - i + n]); else memo[i][j] = min(memo[i - 1][j], a[j - i]); cnt += memo[i][j]; } cnt += i * k; if(cnt < ans) ans = cnt; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:57: error: no matching function for call to 'min(int&, ll&)' 16 | else if (i > j) memo[i][j] = min(memo[i - 1][j], a[j - i + n]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:16:57: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 16 | else if (i > j) memo[i][j] = min(memo[i - 1][j], a[j - i + n]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:16:57: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 16 | else if (i > j) memo[i][j] = min(memo[i - 1][j], a[j - i + n]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:17:46: error: no matching function for call to 'min(int&, ll&)' 17 | else memo[i][j] = min(memo[i - 1][j], a[j - i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:17:46: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 17 | else memo[i][j] = min(memo[i - 1][j], a[j - i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:17:46: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 17 | else memo[i][j] = min(memo[i - 1][j], a[j - i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
s183781891
p04006
C++
C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe 3 10 100 1 100 23 Process finished with exit code 0
a.cc:1:3: error: stray '\' in program 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ a.cc:1:9: error: stray '\' in program 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ a.cc:1:15: error: stray '\' in program 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ a.cc:1:29: error: stray '\' in program 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ a.cc:1:32: error: stray '\' in program 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ a.cc:1:50: error: stray '\' in program 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ a.cc:1:2: error: found ':' in nested-name-specifier, expected '::' 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^ | :: a.cc:1:1: error: 'C' does not name a type 1 | C:\Users\tassa\CLionProjects\CP\cmake-build-debug\CP.exe | ^
s499871466
p04006
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include <functional> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define inf INT_MAX/3 #define INF INT_MAX/3 #define PB push_back #define pb push_back #define MP make_pair #define mp make_pair #define ALL(a) (a).begin(),(a).end() #define all(a) (a).begin(),(a).end() #define SET(a,c) memset(a,c,sizeof a) #define CLR(a) memset(a,0,sizeof a) #define PII pair<int,int> #define pii pair<int,int> #define pcc pair<char,char> #define pic pair<int,char> #define pci pair<char,int> #define VS vector<string> #define VI vector<int> #define debug(x) cout<<#x<<": "<<x<<endl #define DEBUG(x) cout<<#x<<": "<<x<<endl #define MIN(a,b) (a>b?b:a) #define MAX(a,b) (a>b?a:b) #define pi 2*acos(0.0) #define INFILE() freopen("in0.txt","r",stdin) #define OUTFILE()freopen("out0.txt","w",stdout) #define in scanf #define out printf #define LL long long #define ll long long #define ULL unsigned long long #define ull unsigned long long #define eps 1e-14 #define FST first #define SEC second VI A; vector <vector <int> >dp; int N,x; int main(){ cin >> N >> x; A.resize(N); dp.resize(N); REP(i,N){ cin >> A[i]; dp[i].resize(N); } REP(i,N){ dp[i][0] = A[i]; FOR(j,1,N){ int jj = i - j; if (jj<0) { jj = N + jj; } if(dp[i][j-1] > A[jj]) dp[i][j] = A[jj]; else dp[i][j] = dp[i][j-1]; } } long long ans = INF; REP(i,N){ long long ans0 = x*i; REP(j,N){ ans0 += dp[j][i]; } if(ans > ans0) ans = ans0; } cout << ans; }
a.cc: In function 'int main()': a.cc:14:13: error: 'INT_MAX' was not declared in this scope 14 | #define INF INT_MAX/3 | ^~~~~~~ a.cc:76:25: note: in expansion of macro 'INF' 76 | long long ans = INF; | ^~~ a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include <functional> +++ |+#include <climits> 6 | using namespace std;
s433311308
p04006
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; const ll inf = 1e15; int main() { int N; cin>>N; ll x; cin>>x; ll a[N]; FOR(i,0,N) cin >> a[i]; int from[N]; // どこから来るか FOR(i,0,N) from[i] = i; ll mx = 0; FOR(i,0,N) { ll mnmn = inf; int cnt = 0; int j = i; while(cnt < N) { if(mnmn > a[j] + cnt * x) { mnmn = a[j] + cnt * x; mx = max(mx, cnt); from[i] = j; } j += N-1; j %= N; cnt++; } } ll ans = mx * x; FOR(i,0,N) { ans += a[from[i]]; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:40:17: error: no matching function for call to 'max(ll&, int&)' 40 | mx = max(mx, cnt); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, 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:40:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 40 | mx = max(mx, cnt); | ~~~^~~~~~~~~ /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:40:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 40 | mx = max(mx, cnt); | ~~~^~~~~~~~~
s610794938
p04006
C++
N, x = list(map(int, input().split())) n = N a = list(map(int, input().split())) b = [[1000000000000000000000 for i in range(n)] for j in range(n)] for i in range(n): b[i][0] = a[i] for j in range(1, n): b[i][j] = min(b[i][j-1], a[(i-j+n)%n]) s = [0 for i in range(n)] for i in range(n): for j in range(n): s[j] += b[i][j] ans = 1000000000000000000000 for i in range(n): for j in range(n): ans = min(ans, j*x+s[j]) print(ans)
a.cc:4:7: warning: integer constant is too large for its type 4 | b = [[1000000000000000000000 for i in range(n)] for j in range(n)] | ^~~~~~~~~~~~~~~~~~~~~~ a.cc:13:7: warning: integer constant is too large for its type 13 | ans = 1000000000000000000000 | ^~~~~~~~~~~~~~~~~~~~~~ a.cc:1:1: error: 'N' does not name a type 1 | N, x = list(map(int, input().split())) | ^
s966966144
p04006
C++
#include<iostream> #include<cstdio> #include<queue> #include<functional> #include<vector> #include<deque> #define int long long #define P pair<int,int> using namespace std; int c[4000]; signed main() { int a, b; scanf("%lld%lld", &a, &b); for (int d = 0; d < a; d++) { scanf("%lld", &c[d]); c[d + a] = c[d]; } int MIN = LLONG_MAX; for (int i = 0; i < a; i++) {//i回回す int sum = b*i; deque<P>Q;//番号 値 int k = LLONG_MAX; for (int j = 0; j <= i; j++) { while (Q.size() && Q.back().second >= c[j])Q.pop_back(); Q.push_back({j,c[j]}); k = min(k, c[j]); } sum += k; for (int j = 1; j < a; j++) { if(Q.front().first==j-1)Q.pop_front(); while (Q.size() && Q.back().second >= c[i + j])Q.pop_back(); Q.push_back({i+j,c[i+j]}); sum += Q.front().second; } MIN = min(MIN, sum); } printf("%lld\n", MIN); }
a.cc: In function 'int main()': a.cc:18:19: error: 'LLONG_MAX' was not declared in this scope 18 | int MIN = LLONG_MAX; | ^~~~~~~~~ a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include<functional> +++ |+#include <climits> 5 | #include<vector>
s010800558
p04006
C++
#include<bits/stdc++.h> #define range(i,a,b) for(int i = (a); i < (b); i++) #define rep(i,b) for(int i = 0; i < (b); i++) #define all(a) (a).begin(), (a).end() #define show(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; const long long INF = (1LL << 59); using namespace std; int main(){ int n, x; cin >> n >> x; long long dp[2000][2] = {0}; long long a[2000]; rep(i,n) cin >> a[i]; rep(i,n) dp[i][0] = INF; rep(i,n){ int parent; rep(j,n){ int diff; if(i <= j) diff = j - i; else if(i > j) diff = n - (i - j); if(dp[i][0] > diff * x + a[j]){ //show(diff*x+a[j]) dp[i][0] = diff * x + a[j]; parent = j; //show(parent) } } //cout << i << ' ' << parent << endl; assert(parent < 2000) assert(parent >= 0) dp[parent][1]++; } long long sum = 0; rep(i,n) sum+=dp[i][1] * a[i]; long long maxi = 0; rep(i,n) maxi = max(maxi, dp[i][1]); //rep(i,n) show(dp[i][1]) if(maxi) sum+=(maxi - 1) * x; cout << sum << endl; }
In file included from /usr/include/c++/14/cassert:44, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106, from a.cc:1: a.cc: In function 'int main()': a.cc:34:9: error: void value not ignored as it ought to be 34 | assert(parent < 2000) | ^~~~~~
s202032276
p04006
C++
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<map> #include<set> #include<utility> #include<cmath> #include<cstring> #include<queue> #include<stack> #include<cstdio> #include<sstream> #include<iomanip> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define pb push_back #define mp make_pair #define all(in) in.begin(),in.end() #define shosu(x) fixed<<setprecision(x) using namespace std; //kaewasuretyuui typedef long long ll; typedef pair<int,int> pii; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<pii> vp; typedef vector<vp> vvp; typedef vector<string> vs; typedef vector<double> vd; typedef pair<int,pii> pip; typedef vector<pip>vip; const double PI=acos(-1); const double EPS=1e-8; const double inf=1e8; int main(){ int n,x; cin>>n>>x; vi in(n); rep(i,n)cin>>in[i]; ll out=1e16LL; rep(q,n){ ll sum=x*q; rep(i,n){ ll mi=in[i]; loop(j,1,q+1){ int t=i-j; if(t<0)t+=n; mi=min(mi,in[t]); } sum+=mi; } cout<<sum<<endl; out=min(out,sum); } cout<<out<<endl; }
a.cc: In function 'int main()': a.cc:41:16: error: unable to find numeric literal operator 'operator""LL' 41 | ll out=1e16LL; | ^~~~~~
s141970191
p04006
C++
// 23:38~ #include <bits/stdc++.h> using namespace std; #define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl #define repi(i,a,b) for(int i=int(a);i<int(b);i++) #define peri(i,a,b) for(int i=int(b);i-->int(a);) #define rep(i,n) repi(i,0,n) #define per(i,n) peri(i,0,n) #define all(c) begin(c),end(c) #define mp make_pair #define mt make_tuple using uint=unsigned; using ll=long long; using ull=unsigned long long; using vi=vector<int>; using vvi=vector<vi>; using vl=vector<ll>; using vvl=vector<vl>; using vd=vector<double>; using vvd=vector<vd>; using vs=vector<string>; using pii=pair<int,int>; template<typename T1,typename T2> ostream& operator<<(ostream& os,const pair<T1,T2>& p){ return os<<'('<<p.first<<','<<p.second<<')'; } template<typename Tuple> void print_tuple(ostream&,const Tuple&){} template<typename Car,typename... Cdr,typename Tuple> void print_tuple(ostream& os,const Tuple& t){ print_tuple<Cdr...>(os,t); os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t); } template<typename... Args> ostream& operator<<(ostream& os,const tuple<Args...>& t){ print_tuple<Args...>(os<<'(',t); return os<<')'; } template<typename Ch,typename Tr,typename C> basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){ os<<'['; for(auto i=begin(c);i!=end(c);++i) os<<(i==begin(c)?"":" ")<<*i; return os<<']'; } constexpr int INF=1e9; constexpr int MOD=1e9+7; constexpr double EPS=1e-9; int main() { for(int n,x;cin>>n>>x && n|x;){ vi a(n); rep(i,n) cin>>a[i]; ll res=0; rep(i,n){ ll mn=INF; rep(j,n) mn=min(mn,a[j]+(i-j+n)%n*x); res+=mn; } cout<<res<<endl; } }
a.cc: In function 'int main()': a.cc:65:40: error: no matching function for call to 'min(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)' 65 | rep(j,n) mn=min(mn,a[j]+(i-j+n)%n*x); | ~~~^~~~~~~~~~~~~~~~~~~~~ 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:2: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:65:40: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 65 | rep(j,n) mn=min(mn,a[j]+(i-j+n)%n*x); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:65:40: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 65 | rep(j,n) mn=min(mn,a[j]+(i-j+n)%n*x); | ~~~^~~~~~~~~~~~~~~~~~~~~
s687841858
p04006
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; bool SortComp(pair<long long int, int> p1, pair<long long int, int> p2) { if(p1.first < p2.first) return true; else return false; } int main(void) { int num; long long int changet, catcht[2010]= {}, maxchange= 0, sum= 0; pair<long long int, int> timecheck[2010]; cin>>num>>changet; for(int i= 0; i < num; i++) cin>>catcht[i]; for(int i= 0; i < num; i++) { for(int j= 0; j < num; j++) { timecheck[j].second= j; if(i == j) timecheck[j].first= catcht[j]; else if(i > j) timecheck[j].first= catcht[j]+(i-j)*changet; else timecheck[j].first= catcht[j]+(num-j+i)*changet; } sort(timecheck, timecheck+num, SortComp); sum+= catcht[timecheck[0].second]; if(i > timecheck[0].second) maxchange= max(maxchange, (long long int)i-timecheck[0].second); else if(i < timecheck[0].second) maxchange= max(maxchange, (long long int)num-timecheck[0].second+i(long long int)); } sum+= changet*maxchange; cout<<sum<<endl; return 0; }
a.cc: In function 'int main()': a.cc:43:92: error: expected primary-expression before 'long' 43 | maxchange= max(maxchange, (long long int)num-timecheck[0].second+i(long long int)); | ^~~~ a.cc:43:105: error: 'i' cannot be used as a function 43 | maxchange= max(maxchange, (long long int)num-timecheck[0].second+i(long long int)); | ^
s858305787
p04006
C++
// #include <iostream> // #include <algorithm> #include <bits/stdc++.h> #define ll long long #define INF 1LL << 60 using namespace std; ll N, x; int a[2010]; ll b[2010]; int main(){ cin >> N >> x; for (int i = 0; i < N; ++i) { cin >> a[i]; b[i] = a[i]; } ll ans = INF; for (int k = 0; k < N; ++k) { ll tmp = k * x; for (int i = 0; i < N; ++i) { b[i] = min(b[i], a[(i - k + N) % N]); tmp += b[i]; } ans = min(ans, tmp); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: no matching function for call to 'min(long long int&, int&)' 27 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ 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:3: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:27:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 27 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:27:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
s887448900
p04006
C++
// #include <iostream> // #include <algorithm> #include <bits/stdc++.h> #define ll long long #define INF 1LL << 60 using namespace std; ll N, x; int a[2010]; ll b[2010]; int main(){ cin >> N >> x; for (int i = 0; i < N; ++i) { cin >> a[i]; b[i] = a[i]; } ll ans = INF; for (int k = 0; k < N; ++k) { ll tmp = k * x; for (int i = 0; i < N; ++i) { b[i] = min(b[i], a[(i - k + N) % N]); tmp += b[i]; } ans = min(ans, tmp); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:17: error: no matching function for call to 'min(long long int&, int&)' 27 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ 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:3: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:27:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 27 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:27:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 27 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
s720365072
p04006
C++
#include <iostream> #include <algorithm> #define ll long long #define INF 1LL << 60 using namespace std; ll N, x; int a[2010]; ll b[2010]; int main(){ cin >> N >> x; for (int i = 0; i < N; ++i) { cin >> a[i]; b[i] = a[i]; } ll ans = INF; for (int k = 0; k < N; ++k) { ll tmp = k * x; for (int i = 0; i < N; ++i) { b[i] = min(b[i], a[(i - k + N) % N]); tmp += b[i]; } ans = min(ans, tmp); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:17: error: no matching function for call to 'min(long long int&, int&)' 26 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:26:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 26 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:26:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 26 | b[i] = min(b[i], a[(i - k + N) % N]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
s016613314
p04006
C++
my ($N, $x) = <STDIN>; my $a = split(/ /,<STDIN>); calculate($N, $x, $a); sub calculate{ my $min_val_id = 0; my ($N, $x, $a) = @_; foreach my $i (0..$N-1){ $min_val_id = $i if($a->[$min_val_id] > $a->[$i]); } my $sum_time = 0; my $max_changed_count = 0; my $changed_count = 0; #I shuld be this program refactering foreach my $i (0..$N-1){ my $current_id = ($min_val_id + $i) % $N; my $prev_id = ($current_id) ? $current_id-1 : $N-1; my $current_time = 0; if ($a->[$current_id] <= $x || $a->[$current_id] <= $a->[$prev_id]+$x*($changed_count+1)){ $current_time = $a->[$current_id]; $changed_count = 0; }else{ $current_time = $a->[$current_id] = $a->[$prev_id]; ++$changed_count; } $sum_time += $current_time; $max_changed_count = $changed_count if $changed_count > $max_changed_count; } $sum_time += $x*$max_changed_count; print "$sum_time\n"; }
a.cc:8:21: error: stray '@' in program 8 | my ($N, $x, $a) = @_; | ^ a.cc:10:18: error: too many decimal points in number 10 | foreach my $i (0..$N-1){ | ^~~~~ a.cc:18:4: error: invalid preprocessing directive #I 18 | #I shuld be this program refactering | ^ a.cc:19:18: error: too many decimal points in number 19 | foreach my $i (0..$N-1){ | ^~~~~ a.cc:1:4: error: expected constructor, destructor, or type conversion before '(' token 1 | my ($N, $x) = <STDIN>; | ^ a.cc:2:1: error: 'my' does not name a type 2 | my $a = split(/ /,<STDIN>); | ^~ a.cc:3:10: error: expected constructor, destructor, or type conversion before '(' token 3 | calculate($N, $x, $a); | ^ a.cc:6:1: error: 'sub' does not name a type 6 | sub calculate{ | ^~~
s639371321
p04006
C++
#include <iostream> #include <cstdint> #include <vector> #include <algoirhtm> using namespace std; int main() { int64_t N, x; cin >> N >> x; vector<int64_t> times(N); for (int64_t &t : times) cin >> t; int64_t best=N*(int64_t)2000000000; int64_t dx = 0; for (int i=0 ; i<N ; i++, dx+=x) { int64_t sum=0; for (int j=0 ; j<N ; j++) { sum += times[j]; times[j] = min(times[j], times[(j+N-1)%N]); } // for j best = min(best, sum+dx); } // for i cout << best << "\n"; } // main
a.cc:4:10: fatal error: algoirhtm: No such file or directory 4 | #include <algoirhtm> | ^~~~~~~~~~~ compilation terminated.
s502823081
p04006
C++
/* *********************************************** Author :devil ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <string> #include <cmath> #include <stdlib.h> #define inf 0x3f3f3f3f #define LL long long #define rep(i,a,b) for(int i=a;i<=b;i++) #define dec(i,a,b) for(int i=a;i>=b;i--) #define ou(a) printf("%d\n",a) #define pb push_back #define mkp make_pair template<class T>inline void rd(T &x){char c=getchar();x=0;while(!isdigit(c))c=getchar();while(isdigit(c)){x=x*10+c-'0';c=getchar();}} #define IN freopen("in.txt","r",stdin); #define OUT freopen("out.txt","w",stdout); using namespace std; const int mod=1e9+7; const int N=2e3+10; int n,x,a[N],mi[N][N]; LL ans; int main() { rd(n),rd(x); rep(i,1,n) rd(a[i]),ans+=a[i]; rep(i,1,n) rep(j,i,n) mi[i][j]=(j==i)?a[i]:min(a[j],mi[i][j-1]); rep(l,1,n-1) { LL now=(LL)l*x; rep(1,n) now+=(i>l)?mi[i-l][i]:min(mi[1][i],mi[i+n-l][n]); ans=min(ans,now); } printf("%lld\n",ans); return 0; }
a.cc:38:16: error: macro "rep" requires 3 arguments, but only 2 given 38 | rep(1,n) now+=(i>l)?mi[i-l][i]:min(mi[1][i],mi[i+n-l][n]); | ^ a.cc:17:9: note: macro "rep" defined here 17 | #define rep(i,a,b) for(int i=a;i<=b;i++) | ^~~ a.cc: In function 'int main()': a.cc:38:9: error: 'rep' was not declared in this scope 38 | rep(1,n) now+=(i>l)?mi[i-l][i]:min(mi[1][i],mi[i+n-l][n]); | ^~~
s256506425
p04006
C++
#include <iostream> #include <sstream> #include <string> #include <cmath> #include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <functional> #include <numeric> #include <iomanip> using namespace std; typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; #define REP(i,n) for(int i = 0; i < (int)(n); ++i) #define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i) #define ALL(c) (c).begin(), (c).end() #define SIZE(v) ((int)v.size()) #define pb push_back #define mp make_pair #define mt make_tuple int main(void) { cin.sync_with_stdio(false); ll N, x; cin >> N >> x; vector<ll> As(N); REP(n,N) cin >> As[n]; // vector<ll> Bs; // auto itr = min_element(ALL(As)); // auto mn_idx = distance(begin(As), itr); // FOR(i,mn_idx,N) { // Bs.pb( As[i] ); // } // REP(i,mn_idx) { // Bs.pb( As[i] ); // } // // for(auto b: Bs) cout << b << ","; // // cout << endl; // As = Bs; vector<ll> costs = Bs; ll ans = 1e15; REP(k,N) { // 鬲疲ウ輔r蜚ア縺医k蝗樊焚 vector<ll> new_costs(N); REP(n,N) { new_costs[n] = min(costs[n], costs[(n - k + N) % N]); } costs = new_costs; ans = min(ans, accumulate(ALL(costs), 0LL) + k * x); } cout << ans << endl; // ll longest_streak = 0; // ll ans = As[0]; // FOR(n,1,N) { // ll cost = As[n]; // for(int n2 = n-1; n2 >= 0; --n2) { // ll diff = n - n2; // ll cost2 = diff * x; // if (cost2 < cost) { // longest_streak = max(longest_streak, diff); // cost = As[n2]; // } // } // ans += cost; // } // ans += longest_streak * x; // cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:53:24: error: 'Bs' was not declared in this scope; did you mean 'As'? 53 | vector<ll> costs = Bs; | ^~ | As
s501967631
p04006
C++
#include<bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f using namespace std; ll a[5000]; int main() { ll n,x,ans=0,MIN=inf; scanf("%lld%lld",&n,&x); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); MIN=min(a[i],MIN); } for(int i=1;i<=n;i++) ans+=min(a[i],MIN+x); printf("%lld",ans); return 0; }
a.cc: In function 'int main()': a.cc:17:1: error: 'printf\U0000ff08' was not declared in this scope; did you mean 'printf'? 17 | printf("%lld",ans); | ^~~~~~~~ | printf
s398311132
p04006
C++
#include <iostream> #define REP(i, a, n) for(int i = a; i < n; i++) using namespace std; long N, x, a[2001]; int main(void) { cin >> N >> x; REP(i, 1, N + 1) cin >> a[i]; long cost = 0; long cnt = 0; REP(i, 1, N + 1) { long m = a[i]; long p = a[i]; REP(j, 1, N) { int k = (i - j + N - 1) % N + 1; if(a[k] + j * x < m) { m = a[k] + j * x; p = a[k]; cnt = max(cnt, j); } } cost += p; } cost += cnt * x; cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:18: error: no matching function for call to 'max(long int&, int&)' 23 | cnt = max(cnt, j); | ~~~^~~~~~~~ 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:23:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int') 23 | cnt = max(cnt, 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
s049377361
p04006
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2005; const int M = 1000000007; int n; ll x; ll dp[N][N]; int main() { while (~scanf("%d%I64d", &n, &x)) { for (int i = 0; i < n; i++) { scanf("%I64d", &dp[i][0]); } for (int i = 0; i < n; i++) { for (int j = 1; j < n; j++) { dp[i][j] = min(dp[i][j - 1], a[(i - j + n) % n]); } } for (int j = 0; j < n; j++) { for (int i = n - 1; i >= 0; i--) { dp[i][j] += dp[i + 1][j]; } } ll ans = 0x3f3f3f3f3f3f3f3fll; for (int j = 0; j < n; j++) { ans = min(ans, j * x + dp[0][j]); } printf("%I64d\n", ans); } }
a.cc: In function 'int main()': a.cc:19:38: error: 'a' was not declared in this scope 19 | dp[i][j] = min(dp[i][j - 1], a[(i - j + n) % n]); | ^
s015463777
p04006
C++
#include <iostream> #include <string> #include <queue> #include <stack> #include <algorithm> #include <list> #include <vector> #include <complex> #include <utility> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <bitset> #include <ctime> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <cassert> #include <cstddef> #include <iomanip> #include <numeric> #include <tuple> #include <sstream> #include <fstream> #define REP(i, n) for (int (i) = 0; (i) < (n); (i)++) #define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++) #define RREP(i, a) for(int (i) = (a)-1; (i) >= 0; (i)--) #define FORR(i, a, b) for(int (i) = (a)-1; (i) >= (b); (i)--) #define PI acos(-1.0) #define DEBUG(C) cout<< C <<endl; #define VI vector <int> #define VII vector <VI> #define VL vector <LL> #define VLL vector <VL> #define VD vector <double> #define VDD vector <VD> #define PII pair <int, int> #define PDD pair <double, double> #define PLL pair <LL, LL> #define VPII vector <PII> #define ALL(a) (a).begin(), (a).end() #define SORT(a) sort(ALL(a)) #define REVERSE(a) reverse(ALL(a)) #define MP make_pair #define FORE(a,b) for(auto &&a:b) using namespace std; typedef long long LL; typedef unsigned long long ULL; const int INF = 1e9; const int MOD = INF+7; const LL LLINF = 1e18; int main(void) { int N, x; cin >> N >> x; VL a(N); REP (i, N) cin >> a[i]; copy_n(ALL(a), back_inserter(a)); LL ans = LLINF; VL b(N, LLINF); REP (k, N) { LL sum = k*x; REP (i, N) { int id = (i-k+N); b[i] = min<LL>(b[i], a[id]); sum += b[i]; } ans = min(ans, sum); } cout << ans << endl; }
In file included from /usr/include/c++/14/algorithm:61, from a.cc:5: /usr/include/c++/14/bits/stl_algo.h: In instantiation of '_OIter std::copy_n(_IIter, _Size, _OIter) [with _IIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Size = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _OIter = back_insert_iterator<vector<long long int> >]': a.cc:63:11: required from here 63 | copy_n(ALL(a), back_inserter(a)); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:708:47: error: no matching function for call to '__size_to_integer(__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >&)' 708 | const auto __n2 = std::__size_to_integer(__n); | ~~~~~~~~~~~~~~~~~~~~~~^~~~~ 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:1036:3: note: candidate: 'constexpr int std::__size_to_integer(int)' 1036 | __size_to_integer(int __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1036:25: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'int' 1036 | __size_to_integer(int __n) { return __n; } | ~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1038:3: note: candidate: 'constexpr unsigned int std::__size_to_integer(unsigned int)' 1038 | __size_to_integer(unsigned __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1038:30: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'unsigned int' 1038 | __size_to_integer(unsigned __n) { return __n; } | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1040:3: note: candidate: 'constexpr long int std::__size_to_integer(long int)' 1040 | __size_to_integer(long __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1040:26: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long int' 1040 | __size_to_integer(long __n) { return __n; } | ~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1042:3: note: candidate: 'constexpr long unsigned int std::__size_to_integer(long unsigned int)' 1042 | __size_to_integer(unsigned long __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1042:35: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long unsigned int' 1042 | __size_to_integer(unsigned long __n) { return __n; } | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1044:3: note: candidate: 'constexpr long long int std::__size_to_integer(long long int)' 1044 | __size_to_integer(long long __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1044:31: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long long int' 1044 | __size_to_integer(long long __n) { return __n; } | ~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1046:3: note: candidate: 'constexpr long long unsigned int std::__size_to_integer(long long unsigned int)' 1046 | __size_to_integer(unsigned long long __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1046:40: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long long unsigned int' 1046 | __size_to_integer(unsigned long long __n) { return __n; } | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1050:3: note: candidate: 'constexpr __int128 std::__size_to_integer(__int128)' 1050 | __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1050:44: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to '__int128' 1050 | __size_to_integer(__GLIBCXX_TYPE_INT_N_0 __n) { return __n; } | ^ /usr/include/c++/14/bits/stl_algobase.h:1052:3: note: candidate: 'constexpr __int128 unsigned std::__size_to_integer(__int128 unsigned)' 1052 | __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_0 __n) { return __n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1052:53: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to '__int128 unsigned' 1052 | __size_to_integer(unsigned __GLIBCXX_TYPE_INT_N_0 __n) { return __n; } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1074:3: note: candidate: 'constexpr long long int std::__size_to_integer(float)' 1074 | __size_to_integer(float __n) { return (long long)__n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1074:27: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'float' 1074 | __size_to_integer(float __n) { return (long long)__n; } | ~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1076:3: note: candidate: 'constexpr long long int std::__size_to_integer(double)' 1076 | __size_to_integer(double __n) { return (long long)__n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1076:28: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'double' 1076 | __size_to_integer(double __n) { return (long long)__n; } | ~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1078:3: note: candidate: 'constexpr long long int std::__size_to_integer(long double)' 1078 | __size_to_integer(long double __n) { return (long long)__n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1078:33: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to 'long double' 1078 | __size_to_integer(long double __n) { return (long long)__n; } | ~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_algobase.h:1081:3: note: candidate: 'constexpr long long int std::__size_to_integer(__float128)' 1081 | __size_to_integer(__float128 __n) { return (long long)__n; } | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1081:32: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to '__float128' 1081 | __size_to_integer(__float128 __n) { return (long long)__n; } | ~~~~~~~~~~~^~~
s545089990
p04006
C++
// include #include <algorithm> #include <iterator> #include <vector> #include <iomanip> #include <iostream> #include <stack> #include <queue> #include <list> #include <utility> #include <string> #include <cstring> #include <stdio.h> #include <cassert> // M_PI for pi #define _USE_MATH_DEFINES #include <math.h> #define MAX 100000005 using namespace std; int N; longlong x; long long A[2005]; long long B[2005]; void slove() { } int main(int argc, char* argv[]) { cin >> N >> x; for (int i = 0; i < N; ++i) { cin >> A[i]; } long long S = 1000000000000000000LL; long long s; for (int i = 0; i < N; ++i) { B[i] = A[i]; } for (int k = 0; k < N; ++k) { for (int i = 0; i < N; ++i) { B[i] = min(B[i], A[(N + i - k) % N]); } //for (int i = 0; i < N; ++i) { // cout << B[i] << " "; //} //cout << endl; s = 0; for (int i = 0; i < N; ++i) { s += B[i]; } s += k * x; //cout << s << endl; S = min(s, S); } cout << S << endl; return 0; }
a.cc:27:1: error: 'longlong' does not name a type 27 | longlong x; | ^~~~~~~~ a.cc: In function 'int main(int, char**)': a.cc:37:17: error: 'x' was not declared in this scope 37 | cin >> N >> x; | ^
s356748411
p04006
C++
int main(){ int N, x; cin >> N >> x; vector<int> a(N); for (int i = 0; i < N; ++i){ cin >> a[i]; } vector<int> minA = a; long long minTTTime = 9223372036854775807; for (int ms = 0; ms < N; ++ms){ for (int i = 0; i<N; ++i){ int mIndex = i - ms; if (mIndex<0) mIndex += N; if (minA[i]>a[mIndex]) minA[i] = a[mIndex]; } long long sum = 0; for (auto &el : minA){ sum += (long long)el; } sum += (long long)ms*x; if (sum < minTTTime) minTTTime = sum; } cout << minTTTime << endl; cin >> N; }
a.cc: In function 'int main()': a.cc:3:9: error: 'cin' was not declared in this scope 3 | cin >> N >> x; | ^~~ a.cc:4:9: error: 'vector' was not declared in this scope 4 | vector<int> a(N); | ^~~~~~ a.cc:4:16: error: expected primary-expression before 'int' 4 | vector<int> a(N); | ^~~ a.cc:6:24: error: 'a' was not declared in this scope 6 | cin >> a[i]; | ^ a.cc:9:16: error: expected primary-expression before 'int' 9 | vector<int> minA = a; | ^~~ a.cc:15:29: error: 'minA' was not declared in this scope 15 | if (minA[i]>a[mIndex]) minA[i] = a[mIndex]; | ^~~~ a.cc:15:37: error: 'a' was not declared in this scope 15 | if (minA[i]>a[mIndex]) minA[i] = a[mIndex]; | ^ a.cc:18:33: error: 'minA' was not declared in this scope 18 | for (auto &el : minA){ | ^~~~ a.cc:24:9: error: 'cout' was not declared in this scope 24 | cout << minTTTime << endl; | ^~~~ a.cc:24:30: error: 'endl' was not declared in this scope 24 | cout << minTTTime << endl; | ^~~~
s027389484
p04006
C++
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <sstream> #include <iostream> #include <algorithm> #include <cstdlib> #include <map> #include <queue> #include <utility> #include <vector> #include <set> #include <memory.h> #include <iomanip> #include <bitset> #include <list> #include <stack> using namespace std; #define pai 3.14159265359 #define mod 1000000007 long long int b[2001][2001]; int main() { long long int n, x; cin >> n >> x; long long int a[2001]; for(int i = 1; i <= n; i++){ cin >> a[i]; } for(int i = 1; i <= n; i++){ b[i][0] = a[i]; } for(int i = 1; i <= n; i++){ for(int j = 1; j < n; j++){ int moto = i - j; if(moto < 1) moto += n; b[i][j] = min(b[i][j - 1], a[moto]); } } // b[i][j]は魔法j回以下つかったときにスライムiを得るためのスライムを捕まえるのにかかる最短時間 long long int ans = (long long int)pow(mod, 2); for(int i = 0; i < n; i++){ // iは魔法を使う回数 long long int result = x * i; for(int j = 1; j <= n; j++){ result += b[j][i]; } ans = min(ans, result); } cout << ans << endl; return 0; }v
a.cc:57:2: error: 'v' does not name a type 57 | }v | ^
s061537542
p04006
C++
// include #include <algorithm> #include <iterator> #include <vector> #include <iomanip> #include <iostream> #include <stack> #include <queue> #include <list> #include <utility> #include <string> #include <cstring> #include <stdio.h> #include <cassert> // M_PI for pi #define _USE_MATH_DEFINES #include <math.h> #define MAX 10000000005 using namespace std; int N; int x; int A[MAX]; int B[MAX]; void slove() { } int main(int argc, char* argv[]) { cin >> N >> x; for (int i = 0; i < N; ++i) { cin >> A[i]; } int S = MAX; int s; for (int i = 0; i < N; ++i) { B[i] = A[i]; } for (int k = 0; k < N; ++k) { s = 0; for (int i = 0; i < N; ++i) { s += B[i]; //cout << B[i] << " "; } //cout << endl; s += k * x; //cout << k << " " << s << endl; S = min(s, S); //cout << endl; for (int i = 0; i < N; ++i) { if (i == 0) { B[i] = min(B[i], B[N-1]); } else { B[i] = min(B[i-1], B[i]); } } } cout << S << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:22:13: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000005' to '1410065413' [-Woverflow] 22 | #define MAX 10000000005 | ^~~~~~~~~~~ a.cc:44:13: note: in expansion of macro 'MAX' 44 | int S = MAX; | ^~~ /tmp/cco6oZeY.o: in function `main': a.cc:(.text+0xbd): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0x171): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0x188): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0x1ad): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0x1c6): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0x1e0): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `B' defined in .bss section in /tmp/cco6oZeY.o collect2: error: ld returned 1 exit status
s040583438
p04006
C++
#include<iostream> #include<vector> #include <algorithm> using namespace std; int main() { vector<long int> a; int b, p, flag = 0; long int count = 0, kiroku = 0, cowcow = 0, tiisai; long int c, d, hozon; long long int ans = 0; cin >> b >> d; for(int i = 0; i < b; i++) { cin >> c; a.push_back(c); } p = b; tiisai = a[0]; for(int i = 0; cowcow < p; i++) { cowcow++; if(i >= b) i = 0; cout << i << endl; if(a[i] < d) { if(!flag) { p += cowcow - 1; flag = 1; } hozon = a[i]; ans += a[i]; kiroku = max(kiroku, count); count = 0; }else { if(hozon) { count++; if(tiisai > a[i]) tiisai = a[i]; ans += hozon; } } } if(kiroku) { kiroku = max(kiroku, count); cout << ans + kiroku * d << endl; }else { cout << tiisai * d << endk; } }
a.cc: In function 'int main()': a.cc:44:27: error: 'endk' was not declared in this scope 44 | cout << tiisai * d << endk; | ^~~~
s107452148
p04006
C++
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;++i) #define rep(i,n) REP(i,0,n) using namespace std; #define MAX_N 2016 typedef long long ll; const bool debug = false; int N,x; ll a[MAX_N]; ll mini[MAX_N]; bool fin[MAX_N]; //bool check(ll cnt) { ll compute(ll cnt) { if( debug ) { puts(""); cout << "cnt == " << cnt << endl; } memset(fin,false,sizeof fin); rep(i,N) mini[i] = a[i]; rep(i,N) rep(j,N) if( i != j ) { if( i < j ) { if( j-i <= cnt ) { //mini[j] = min(mini[j],a[i]+(ll)(j-i)*(ll)x); mini[j] = min(mini[j],a[i]); } else { } } else { // i > j if( (j-i+N) <= cnt ) { //mini[j] = min(mini[j],a[i] + (ll)x * (ll)(j-i+N) ); mini[j] = min(mini[j],a[i]); } else { } } } ll answer = x * cnt; deque<int> sp; rep(i,N) { if( mini[i] == a[i] ) { fin[i] = true; answer += a[i]; sp.push_back(i); } } if( debug ) { rep(i,N) { cout << "mini[" << i << "] = " << mini[i] << endl; } cout << "current answer = " << answer << endl; } rep(i,(int)sp.size()) { ll step = 0; int cur = (sp[i]+1)%N; while( !fin[cur] ) { ( cur += 1 ) %= N; ++step; if( step > cnt ) { answer += a[cur]; } else { answer += a[sp[i]]; } } } return answer; } ll ternarySearch(){ int L = 1, R = N; int pL = L, pR = R; rep(_,120){ if( compute(((L+R*2)/3)) < compute(((L*2+R)/3)) ) { R = ( L + R * 2 ) / 3; } else { L = ( L * 2 + R ) / 3; } if( R == pR && L == pL ) break; pR = R, pL = L; } return compute((int)(((L+R)*0.5))); } int main() { /* cout << 2000 << " " << 1000000000LL << endl; rep(i,2000) { if( i ) printf(" "); cout << 1000000000; } puts(""); return 0; */ cin >> N >> x; rep(i,N) cin >> a[i]; /* ans = LLONG_MAX; ll L = 0, R = (ll)(N+1); while( L + 1 < R ){ ll M = ( L + R ) / 2; if( check(M) ) R = M; else L = M; } cout << ans << endl; */ ll mini = LLONG_MAX; rep(i,sqrt(N+1)) { mini = min(compute(i),mini); } cout << mini << endl; /.cout<< ternarySearch() << endl; return 0; }
a.cc: In function 'int main()': a.cc:117:3: error: expected primary-expression before '/' token 117 | /.cout<< ternarySearch() << endl; | ^ a.cc:117:4: error: expected primary-expression before '.' token 117 | /.cout<< ternarySearch() << endl; | ^
s188888120
p04006
C++
#include <iostream> using namespace std; int cost[2000]; bool own[2000]; int n, x ; long long decide() { long long costtt =INT_MAX; int minplace = 0; long long sum = 0, sumslide = 0 ; bool gotdemall = true; for(int i=0 ; i<n ; ++i) { if(!own[i]) { sum+=cost[i]; gotdemall = false; if(cost[i]< costtt) { minplace = i; costtt = cost[i] ; } } if(i) { if(!own[i-1]) { sumslide +=cost[i]; } } else if(!own[n - 1]) { sumslide += cost[0]; } } if(gotdemall) return 0 ; if( sumslide + x < sum ) { int tmp = own[n -1]; for(int i=n ; --i ; ) own[i] = own[i-1]; own[0]= tmp ; costtt = x ; } else own[minplace] = 1; return costtt + decide(); } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> x ; for(int i=0; i<n; ++i) cin >> cost[i]; cout << decide(); }
a.cc: In function 'long long int decide()': a.cc:8:23: error: 'INT_MAX' was not declared in this scope 8 | long long costtt =INT_MAX; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include <iostream> +++ |+#include <climits> 2 | using namespace std;
s612952648
p04006
C++
#include <iostream> using namespace std; int cost[2000]; bool own[2000]; int n , x ; long long decide(){ long long costtt =INT_MAX; int minplace = 0; long long sum = 0 , sumslide = 0 ; bool gotdemall = true; for(int i=0 ; i<n ;++i){ if(!own[i]){ sum+=cost[i]; gotdemall = false; if(cost[i]< costtt){ minplace = i; costtt = cost[i] ; } } if(i){ if(!own[i-1]) { sumslide +=cost[i]; }}else if(!own[n - 1]){ sumslide += cost[0]; } } if(gotdemall) return 0 ; if( sumslide + x < sum ){ int tmp = own[n -1]; for(int i=n ; --i ; ) own[i] = own[i-1]; own[0]= tmp ; costtt = x ; } else own[minplace] = 1; return costtt + decide(); } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n >> x ; for(int i=0;i<n;++i) cin >> cost[i]; cout << decide(); }
a.cc: In function 'long long int decide()': a.cc:6:19: error: 'INT_MAX' was not declared in this scope 6 | long long costtt =INT_MAX; int minplace = 0; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include <iostream> +++ |+#include <climits> 2 | using namespace std;
s344770524
p04006
Java
import java.util.*; public class B { public static void main(String[] args) { try (Scanner sc = new Scanner(System.in)) { int N = sc.nextInt(); int x = sc.nextInt(); sc.nextLine(); int[] as = new int[N]; for (int i = 0; i < N; i++) { as[i] = sc.nextInt(); } int min = Integer.MAX_VALUE; int minI = -1; for (int i = 0; i < N; i++) { if (as[i] < min) { min = as[i]; minI = i; } } int ans = min; int i = (minI + 1) % N; while (i != minI) { if (as[i] < min + x) { ans += as[i]; } else { ans += min + x; } i = (i + 1) % N; } System.out.println(ans); } } }
Main.java:3: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s793005205
p04006
C++
#include <bits/stdc++.h> using namespace std; __int64 a[2010]; __int64 maxDis[2010]; __int64 cnt[2010]; int main() { __int64 n, x; scanf("%I64d%I64d", &n, &x); for(__int64 i = 1; i <= n; ++i) scanf("%I64d", &a[i]); for(__int64 i = 1; i <= n; ++i) { __int64 min_j = i; __int64 min_v = a[i]; __int64 min_dis = 0; for(__int64 j = 1; j <= n; ++j) { if(j <= i) { if(a[j] + (i - j) * x < min_v) { min_v = a[j] + (i - j) * x; min_j = j; min_dis = i - j; } else if(a[j] + (i - j) * x == min_v && i - j < min_dis) { min_dis = i - j; min_j = j; } } else { if(a[j] + (n - j + i) * x < min_v) { min_v = a[j] + (n - j + i) * x; min_j = j; min_dis = n - j + i; } else if(a[j] + (n - j + i) * x == min_v && n - j + i < min_dis) { min_dis = n - j + i; min_j = j; } } } ++cnt[min_j]; maxDis[min_j] = max(maxDis[min_j], min_dis); } __int64 ans = 0; for(__int64 i = 1; i <= n; ++i) ans += a[i] * cnt[i] + x * maxDis[i]; printf("%I64d\n", ans); return 0; }
a.cc:4:1: error: '__int64' does not name a type; did you mean '__int64_t'? 4 | __int64 a[2010]; | ^~~~~~~ | __int64_t a.cc:5:1: error: '__int64' does not name a type; did you mean '__int64_t'? 5 | __int64 maxDis[2010]; | ^~~~~~~ | __int64_t a.cc:6:1: error: '__int64' does not name a type; did you mean '__int64_t'? 6 | __int64 cnt[2010]; | ^~~~~~~ | __int64_t a.cc: In function 'int main()': a.cc:9:5: error: '__int64' was not declared in this scope; did you mean '__ynf64'? 9 | __int64 n, x; | ^~~~~~~ | __ynf64 a.cc:10:26: error: 'n' was not declared in this scope; did you mean 'yn'? 10 | scanf("%I64d%I64d", &n, &x); | ^ | yn a.cc:10:30: error: 'x' was not declared in this scope 10 | scanf("%I64d%I64d", &n, &x); | ^ a.cc:11:16: error: expected ';' before 'i' 11 | for(__int64 i = 1; i <= n; ++i) | ^~ | ; a.cc:11:24: error: 'i' was not declared in this scope 11 | for(__int64 i = 1; i <= n; ++i) | ^ a.cc:12:25: error: 'a' was not declared in this scope 12 | scanf("%I64d", &a[i]); | ^ a.cc:13:16: error: expected ';' before 'i' 13 | for(__int64 i = 1; i <= n; ++i) | ^~ | ; a.cc:13:24: error: 'i' was not declared in this scope 13 | for(__int64 i = 1; i <= n; ++i) | ^ a.cc:15:16: error: expected ';' before 'min_j' 15 | __int64 min_j = i; | ^~~~~~ | ; a.cc:16:16: error: expected ';' before 'min_v' 16 | __int64 min_v = a[i]; | ^~~~~~ | ; a.cc:17:16: error: expected ';' before 'min_dis' 17 | __int64 min_dis = 0; | ^~~~~~~~ | ; a.cc:18:20: error: expected ';' before 'j' 18 | for(__int64 j = 1; j <= n; ++j) | ^~ | ; a.cc:18:28: error: 'j' was not declared in this scope; did you mean 'jn'? 18 | for(__int64 j = 1; j <= n; ++j) | ^ | jn a.cc:22:20: error: 'a' was not declared in this scope 22 | if(a[j] + (i - j) * x < min_v) | ^ a.cc:22:41: error: 'min_v' was not declared in this scope 22 | if(a[j] + (i - j) * x < min_v) | ^~~~~ a.cc:25:21: error: 'min_j' was not declared in this scope 25 | min_j = j; | ^~~~~ a.cc:26:21: error: 'min_dis' was not declared in this scope 26 | min_dis = i - j; | ^~~~~~~ a.cc:28:64: error: 'min_dis' was not declared in this scope 28 | else if(a[j] + (i - j) * x == min_v && i - j < min_dis) | ^~~~~~~ a.cc:31:21: error: 'min_j' was not declared in this scope 31 | min_j = j; | ^~~~~ a.cc:37:20: error: 'a' was not declared in this scope 37 | if(a[j] + (n - j + i) * x < min_v) | ^ a.cc:37:45: error: 'min_v' was not declared in this scope 37 | if(a[j] + (n - j + i) * x < min_v) | ^~~~~ a.cc:40:21: error: 'min_j' was not declared in this scope 40 | min_j = j; | ^~~~~ a.cc:41:21: error: 'min_dis' was not declared in this scope 41 | min_dis = n - j + i; | ^~~~~~~ a.cc:43:72: error: 'min_dis' was not declared in this scope 43 | else if(a[j] + (n - j + i) * x == min_v && n - j + i < min_dis) | ^~~~~~~ a.cc:46:21: error: 'min_j' was not declared in this scope 46 | min_j = j; | ^~~~~ a.cc:50:11: error: 'cnt' was not declared in this scope; did you mean 'int'? 50 | ++cnt[min_j]; | ^~~ | int a.cc:50:15: error: 'min_j' was not declared in this scope 50 | ++cnt[min_j]; | ^~~~~ a.cc:51:9: error: 'maxDis' was not declared in this scope 51 | maxDis[min_j] = max(maxDis[min_j], min_dis); | ^~~~~~ a.cc:51:44: error: 'min_dis' was not declared in this scope 51 | maxDis[min_j] = max(maxDis[min_j], min_dis); | ^~~~~~~ a.cc:53:12: error: expected ';' before 'ans' 53 | __int64 ans = 0; | ^~~~ | ; a.cc:54:16: error: expected ';' before 'i' 54 | for(__int64 i = 1; i <= n; ++i) | ^~ | ; a.cc:54:24: error: 'i' was not declared in this scope 54 | for(__int64 i = 1; i <= n; ++i) | ^ a.cc:55:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 55 | ans += a[i] * cnt[i] + x * maxDis[i]; | ^~~ | abs a.cc:55:16: error: 'a' was not declared in this scope 55 | ans += a[i] * cnt[i] + x * maxDis[i]; | ^ a.cc:55:23: error: 'cnt' was not declared in this scope; did you mean 'int'? 55 | ans += a[i] * cnt[i] + x * maxDis[i]; | ^~~ | int a.cc:55:36: error: 'maxDis' was not declared in this scope 55 | ans += a[i] * cnt[i] + x * maxDis[i]; | ^~~~~~ a.cc:56:23: error: 'ans' was not declared in this scope; did you mean 'abs'? 56 | printf("%I64d\n", ans); | ^~~ | abs
s331341106
p04006
C++
#include <iostream> #include <vector> #include<algorithm> using namespace std; long long secNeed(vector<int> &a, int ori, int moveStep,int N,int x){ int index = ori >= moveStep ? ori - moveStep : ori + N - moveStep; return a[index] + moveStep*x; } int main() { int N, x; int maxStep = 0; cin >> N >> x; vector<int> a(N); vector<vector<pair<int,int>>> minTime(N); for (int i = 0; i < N; ++i){ cin >> a[i]; } for (int i = 0; i < N; ++i){ minTime[i].push_back({ i, 0 }); for (int moveStep = 1; moveStep < N; ++moveStep){ long long pre = secNeed(a, minTime[i][moveStep - 1].first, minTime[i][moveStep - 1].second, N, x); long long cur = secNeed(a, i, moveStep, N, x); if (cur < pre){ minTime[i].push_back({ i, moveStep }); if (moveStep>maxStep) maxStep = moveStep; } else{ minTime[i].push_back(minTime[i][moveStep - 1]); } } } long long minTTTime = 9223372036854775807; for (long long i = 0; i <= maxStep; ++i){ long long sum=0; for (int j = 0; j < N; ++j){ int index = minTime[j][i].first - minTime[j][i].second; if (index<0)index += N; sum += a[index]; } sum += i*long long(x); if (sum < minTTTime) minTTTime = sum; } cout << minTTTime << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:26: error: expected primary-expression before 'long' 41 | sum += i*long long(x); | ^~~~
s751546360
p04006
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;i++) //#define int long long typedef long long ll; using namespace std; ll N, x; ll a[2000]; ll magic[2001]; pair<ll, ll> d[2010]; signed main() { cin >> N >> x; rep(i,N) { cin >> a[i]; d[i].first = a[i]; //コスト d[i].second = 0; //魔法の回数 } /* rep(i,N) { printf("%d cost = %d, magic = %d\n", i + 1, d[i].first, d[i].second); } */ bool change = true; while (change) { change = false; rep(i,N) { if (i == 0) { if (d[i].first > d[N-1].first + x) { d[i].first = d[N-1].first + x; d[i].second += d[N-1].second + 1; change = true; } } else { if (d[i].first > d[i-1].first + x) { d[i].first = d[i-1].first + x; d[i].second += d[i-1].second + 1; change = true; } } } } /* rep(i,N) { printf("%d cost = %d, magic = %d\n", i + 1, d[i].first, d[i].second); } */ rep(i,2001) magic[i] = 0; ll ans = 0; int magic_max_cnt = 0; rep(i,N) { ans += d[i].first - x * d[i].second; magic_max_cnt = max(magic_max_cnt, d[i].second); magic[d[i].second]++; } /* printf("magic_max_cnt = %d\n", magic_max_cnt); rep(i,10) { printf("magic[%d] = %d\n", i, magic[i]); }*/ /* for (int i=1; i<=magic_max_cnt; i++) { ans -= x * magic[i]; } */ ans += x * magic_max_cnt; cout << ans << endl; }
a.cc: In function 'int main()': a.cc:60:36: error: no matching function for call to 'max(int&, long long int&)' 60 | magic_max_cnt = max(magic_max_cnt, d[i].second); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:60:36: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 60 | magic_max_cnt = max(magic_max_cnt, d[i].second); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:60:36: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 60 | magic_max_cnt = max(magic_max_cnt, d[i].second); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
s493358144
p04006
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<string> #include<map> #include<cmath> #include<queue> #include<functional> #include<climits> #include<tuple> #include<utility> #include<cassert> using namespace std; //define #define ALL(a) a.begin(),a.end() #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define debug(x) if(1)cout<<#x<<":"<<x<<endl; #define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl; #define ll long long #define pb push_back #define PB push_back #define lb lower_bound #define LB lower_bound #define ub upper_bound #define UB upper_bound //constant const int MOD = 1000000007; const int INF = INT_MAX / 3 - 1; const double EPS = 1e-9; const int dx4[4] = { 1,0,-1,0 }; const int dy4[4] = { 0,1,0,-1 }; const int dx8[8] = { -1,0,1,-1,1,-1,0,1 }; const int dy8[8] = { -1,-1,-1,0,0,1,1,1 }; //typedef typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; int dat[2*2000]; int n; void segment_tree(int n_, int x) { n = 1; while (n < n_) n *= 2; REP(i, 2 * n - 1) dat[i] = x; } int F(int p, int q) {//function return min(p, q); } void update(int k, int a) { k += n - 1; dat[k] = a; while (k > 0) { k = (k - 1) / 2; dat[k] = F(dat[k * 2 + 2], dat[k * 2 + 1]); } } int query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return INF; if (a <= l&&r <= b) return dat[k]; else { int v1 = query(a, b, k * 2 + 1, l, (l + r) / 2); int v2 = query(a, b, k * 2 + 2, (l + r) / 2, r); return F(v1, v2); } } int main() { int n; int x; cin >> n >> x; vi a(n); REP(i, n) cin >> a[i]; segment_tree(n, INF); REP(i, n) update(i, a[i]); long long int res = 1e15; REP(i, n) { long long int sum = 0; REP(j, n) if (j - i < 0) sum += min(query(0, j + 1, 0, 0, n), query(n + j - i, n, 0, 0, n)); else sum += query(j - i, j + 1, 0, 0, n); res = min(res, sum + long long int(x)*i); } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:102:38: error: expected primary-expression before 'long' 102 | res = min(res, sum + long long int(x)*i); | ^~~~
s806224471
p04006
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<vector> #include<string> #include<map> #include<cmath> #include<queue> #include<functional> #include<climits> #include<tuple> #include<utility> #include<cassert> using namespace std; //define #define ALL(a) a.begin(),a.end() #define REP(i,n) for(int i=0;i<n;i++) #define RREP(i,n) for(int i=n-1;i>=0;i--) #define debug(x) if(1)cout<<#x<<":"<<x<<endl; #define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl; #define ll long long #define pb push_back #define PB push_back #define lb lower_bound #define LB lower_bound #define ub upper_bound #define UB upper_bound //constant const int MOD = 1000000007; const int INF = INT_MAX / 3 - 1; const double EPS = 1e-9; const int dx4[4] = { 1,0,-1,0 }; const int dy4[4] = { 0,1,0,-1 }; const int dx8[8] = { -1,0,1,-1,1,-1,0,1 }; const int dy8[8] = { -1,-1,-1,0,0,1,1,1 }; //typedef typedef vector<int> vi; typedef vector<vector<int>> vvi; typedef pair<int, int> pii; int dat[2*2000]; int x = 3e9; int n; void segment_tree(int n_, int x) { n = 1; while (n < n_) n *= 2; REP(i, 2 * n - 1) dat[i] = x; } int F(int p, int q) {//function return min(p, q); } void update(int k, int a) { k += n - 1; dat[k] = a; while (k > 0) { k = (k - 1) / 2; dat[k] = F(dat[k * 2 + 2], dat[k * 2 + 1]); } } int query(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return INF; if (a <= l&&r <= b) return dat[k]; else { int v1 = query(a, b, k * 2 + 1, l, (l + r) / 2); int v2 = query(a, b, k * 2 + 2, (l + r) / 2, r); return F(v1, v2); } } int main() { int n; int x; cin >> n >> x; vi a(n); REP(i, n) cin >> a[i]; segment_tree(n, INF); REP(i, n) update(i, a[i]); long long int res = 1e15; REP(i, n) { long long int sum = 0; REP(j, n) if (j - i < 0) sum += min(query(0, j + 1, 0, 0, n), query(n + j - i, n, 0, 0, n)); else sum += query(j - i, j + 1, 0, 0, n); res = min(res, sum + long long int(x)*i); } cout << res << endl; return 0; }
a.cc:48:9: warning: overflow in conversion from 'double' to 'int' changes value from '3.0e+9' to '2147483647' [-Woverflow] 48 | int x = 3e9; | ^~~ a.cc: In function 'int main()': a.cc:104:38: error: expected primary-expression before 'long' 104 | res = min(res, sum + long long int(x)*i); | ^~~~
s736098346
p04006
C++
#include <iostream> #include <algorithm> #include <climits> #define N 2010 #define LL long long using namespace std; LL a[N]; LL b[N][N]; int main(int argc, char* argv[]) { LL n, x; while(cin >> n >> x) { for(int i = 0; i < n ; ++i ) { cin >> a[i]; } for(int i = 0; i < n; ++i) { for(int j = 0; j < n; ++j) { if(j == 0) b[i][j] = a[i]; else b[i][j] = min(b[i][j-1], a[(i + n - j) % n]); } } LL re = LLONG_MAX; for(int i = 0; i < n; ++i) { LL ans = i * x; for(int j = 0; j < n; ++j) { ans += b[j][i]; } re = min(re, ans); } cout << re << endl; } return 0;
a.cc: In function 'int main(int, char**)': a.cc:33:14: error: expected '}' at end of input 33 | return 0; | ^ a.cc:11:1: note: to match this '{' 11 | { | ^
s020354450
p04006
C++
#include <iostream> #include <queue> #include <set> #include <cassert> #include <map> #include <reverse> #include <sstream> using namespace std; long long a[2010]; int mn[4010][4010]; int main(){ int N,x; cin >> N >> x; for(int i = 0 ; i < N ; i++) cin >> a[i]; reverse(a,a+N); for(int i = 0 ; i < 4010 ; i++) for(int j = 0 ; j < 4010 ; j++) mn[i][j] = 2e9; for(int i = 0 ;i < N ; i++) cin >> a[i], mn[i][i] = a[i], mn[i+N][i+N] = a[i]; for(int i = 0 ; i < 2*N ; i++){ for(int j = i+1 ; j < 2*N ; j++){ mn[i][j] = min(mn[i][j],min(mn[j][j],mn[i][j-1])); } } long long ans = 1e18; //cout << mn[0][0] << endl; for(int s = 0 ; s <= N ; s++){ long long sub = 0; for(int k = 0 ; k < N ; k++){ sub += mn[k][k+s]; } //cout << s << " " << sub << endl; ans = min(ans,sub+s*x); } cout << ans << endl; }
a.cc:6:10: fatal error: reverse: No such file or directory 6 | #include <reverse> | ^~~~~~~~~ compilation terminated.
s705188564
p04006
C++
#include <iostream> #include <queue> #include <set> #include <cassert> #include <map> #include <sstream> using namespace std; long long a[2010]; int mn[4010][4010]; int main(){ int N,x; cin >> N >> x; for(int i = 0 ; i < N ; i++) cin >> a[i]; reverse(a,a+N); for(int i = 0 ; i < 4010 ; i++) for(int j = 0 ; j < 4010 ; j++) mn[i][j] = 2e9; for(int i = 0 ;i < N ; i++) cin >> a[i], mn[i][i] = a[i], mn[i+N][i+N] = a[i]; for(int i = 0 ; i < 2*N ; i++){ for(int j = i+1 ; j < 2*N ; j++){ mn[i][j] = min(mn[i][j],min(mn[j][j],mn[i][j-1])); } } long long ans = 1e18; //cout << mn[0][0] << endl; for(int s = 0 ; s <= N ; s++){ long long sub = 0; for(int k = 0 ; k < N ; k++){ sub += mn[k][k+s]; } //cout << s << " " << sub << endl; ans = min(ans,sub+s*x); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:16:9: error: 'reverse' was not declared in this scope 16 | reverse(a,a+N); | ^~~~~~~
s348978824
p04006
C++
//ここからテンプレート //#define PLASMA_NO_BOOST #if 1 #include<iostream> #include<list> #include<algorithm> #include<utility> #include<type_traits> #include<tuple> #include<memory> #include<iterator> #include<string> #include<functional> #include<list> #include<array> #include<complex> #include<numeric> #include<iomanip> #include<vector> #include<queue> #include<random> #include<map> #include<chrono> #include<stack> #include<set> #ifndef PLASMA_NO_BOOST #include<boost/optional.hpp> #include<boost/optional/optional_io.hpp> #include<boost/variant.hpp> #include<boost/range/adaptor/transformed.hpp> #include<boost/range/adaptor/indexed.hpp> #include<boost/range/adaptor/filtered.hpp> #include<boost/range/algorithm.hpp> #include<boost/range/irange.hpp> #include<boost/multi_array.hpp> #include<boost/preprocessor.hpp> #endif typedef long long int int64; typedef unsigned long long uint64; typedef long double double64; #ifdef PLASMA_NO_BOOST struct none_t {}; constexpr none_t none{}; template<class T>class optional { union inside_t { T value; none_t ignore; constexpr inside_t(T const& v) :value(v) {} constexpr inside_t(T&& v) : value(std::move(v)) {} constexpr inside_t(none_t) : ignore(none) {} constexpr inside_t() : ignore(none) {} constexpr inside_t(inside_t const&) = default; inside_t(inside_t&&) = default; inside_t& operator=(inside_t const&) = default; inside_t& operator=(inside_t&&) = default; ~inside_t() = default; }; inside_t inside; bool flag; public: void swap(optional&& v) { std::swap(this->inside, v.inside); std::swap(this->flag, v.flag); } void reset() { if (flag) { inside.value.~T(); inside.ignore = none; flag = false; } } constexpr optional(T const& v) :inside(v), flag(true) {} constexpr optional(T&& v) : inside(std::move(v)), flag(true) {} constexpr optional(none_t) : inside(), flag(false) {} constexpr optional() : inside(), flag(false) {} constexpr optional(optional const& v) : inside(v.inside), flag(v.flag) {} optional(optional&& v) : optional() { swap(std::move(v)); } optional& operator=(optional const& v) { this->inside = v.inside; this->flag = v.flag; return *this; } optional& operator=(optional&& v) { swap(std::move(v)); v.reset(); return *this; } optional& operator=(T const& v) { reset(); inside.value = v; flag = true; return *this; } optional& operator=(T&& v) { reset(); inside.value = std::move(v); flag = true; return *this; } optional& operator=(none_t) { reset(); return *this; } constexpr operator bool()const { return flag; } constexpr T const& operator*()const { return flag ? inside.value : throw std::domain_error("optional error: dont have value"); } }; template<class T>constexpr optional<typename std::remove_reference<typename std::remove_const<T>::type>::type>make_optional(T&& v) { return optional<std::remove_reference_t<std::remove_const_t<T>>>(std::forward<T>(v)); } #else using boost::optional; using boost::none_t; using boost::none; #endif #ifndef PLASMA_NO_BOOST namespace adaptor { using namespace boost::adaptors; } namespace algorithm { using namespace boost::range; template<class SinglePassRange, class Pred>bool any_of(SinglePassRange const& range, Pred pred) { return std::any_of(std::begin(range), std::end(range), pred); } template<class SinglePassRange, class Pred>bool all_of(SinglePassRange const& range, Pred pred) { return std::all_of(std::begin(range), std::end(range), pred); } } #endif namespace math { template<class T>constexpr T pow(T p, int n) { return n == 0 ? T(1) : n == 1 ? p : n == 2 ? p*p : n % 2 == 0 ? pow(pow(p, n / 2), 2) : pow(pow(p, n / 2), 2)*p; } int log(long long int p, int n) { int64 t = n; for (int i = 0;;++i) { if (t > p) return i; t *= n; } } constexpr double pi = 3.141592653589793; namespace detail { int gcd(int larger, int less) { return less == 0 ? larger : gcd(less, larger%less); } } int gcd(int lhs, int rhs) { return lhs < rhs ? detail::gcd(rhs, lhs) : detail::gcd(lhs, rhs); } void fourier_transform( std::vector<std::complex<double>>& vec, std::size_t N) { std::vector<std::complex<double>> butterfly; vec.resize(N); butterfly.resize(N); std::complex<double> half(std::cos(pi), std::sin(pi)); for (uint64 i = 1, k = N / 2;i < N;[&]() {i *= 2;k /= 2;}())//i*k == N/4 { std::complex<double> circle(std::cos(pi / i), std::sin(pi / i)); std::complex<double> c(1.0, 0); for (auto count = 0ull; count < i;++count) { for (auto j = 0ull;j < k;++j) { butterfly[count*k + j] = vec[2 * count*k + j] + vec[2 * count*k + j + k] * c; butterfly[count*k + j + N / 2] = vec[2 * count*k + j] + vec[2 * count*k + j + k] * c*half; } c *= circle; } std::swap(vec, butterfly); } } class polynomial { std::vector<std::complex<double>> value; void swap(polynomial&& p) { std::swap(value, p.value); } public: polynomial() :value{ 0.0 } {} polynomial(polynomial const&) = default; polynomial(std::vector<std::complex<double>>&& vec) :value(std::move(vec)) {} polynomial(polynomial&& p) :polynomial() { swap(std::move(p)); } polynomial(std::initializer_list<std::complex<double>> lis) :value(lis) {} polynomial(std::complex<double> c) :polynomial({ c }) {} polynomial& operator=(polynomial const&) = default; polynomial& operator=(polynomial&& p) { value = std::vector<std::complex<double>>{ 0.0 }; swap(std::move(p)); return *this; } ~polynomial() = default; std::complex<double> operator[](std::size_t deg)const { return deg >= value.size() ? 0.0 : value[deg]; } std::size_t degree()const { return value.size() - 1; } void strict_degree_set() { std::size_t N = degree(); for (;N > 0;--N) { if (value[N] != 0.0) break; } value.resize(N + 1); } void integer_degree_set() { std::size_t N = degree(); for (;N > 0;--N) { std::cout << value[N] << " " << (std::norm(value[N]) > (1.0e-20)) << std::endl; if (std::norm(value[N]) > (1.0e-20)) break; } value.resize(N + 1); } friend polynomial operator*(polynomial const& lhs, polynomial const& rhs) { std::size_t N = 1; while (true) { N *= 2; if (N > (lhs.degree() + rhs.degree())) break; } auto lhs_ = lhs.value; auto rhs_ = rhs.value; fourier_transform(lhs_, N); fourier_transform(rhs_, N); std::vector<std::complex<double>> vec; vec.reserve(N); for (std::size_t i = 0;i < N;++i) { vec.push_back(lhs_[i] * rhs_[i]); } for (auto& v : vec) { v = 2 * v.real() - v; } fourier_transform(vec, N); for (auto& v : vec) { v = (2 * v.real() - v)*(1.0 / N); } std::size_t k = N; for (;k > 0;--k) { if (std::norm(vec[k]) > 1.0e-23) break; } vec.resize(k + 1); return polynomial(std::move(vec)); } }; int real_integer(std::complex<double> c) { int v = static_cast<int>(c.real()); double u = c.real() - v; return v + static_cast<int>(2 * u); } template<class T>polynomial make_poly(std::vector<T> const& vec) { auto range = vec | adaptor::transformed([](T const& v) {return static_cast<std::complex<double>>(v);}); std::vector<std::complex<double>> ret(std::begin(range), std::end(range)); return polynomial(std::move(ret)); } polynomial make_poly(std::initializer_list<double>init) { std::vector<std::complex<double>> vec; for (auto v : init) { vec.emplace_back(v); } return polynomial(std::move(vec)); } polynomial make_poly(std::initializer_list<int> init) { std::vector<std::complex<double>> vec; for (auto v : init) { vec.emplace_back(v); } return polynomial(std::move(vec)); } template<class T>class infinite_value { optional<T> val; public: infinite_value(T const& v) :val(v) {} infinite_value(T&& v) :val(std::move(v)) {} infinite_value(none_t = none) :val() {} infinite_value(infinite_value const&) = default; infinite_value(infinite_value&&) = default; ~infinite_value() = default; infinite_value& operator=(T const& v) { val = v; return *this; } infinite_value& operator=(T&& v) { val = std::move(v); return *this; } infinite_value& operator=(none_t) { val = boost::none; return *this; } infinite_value& operator=(infinite_value const&) = default; infinite_value& operator=(infinite_value&&) = default; operator bool()const { return static_cast<bool>(val); } T const& operator*()const { return *val; } friend infinite_value operator+(infinite_value const& lhs, infinite_value const& rhs) { return lhs&&rhs ? infinite_value<T>(*lhs + *rhs) : infinite_value<T>(none); } friend infinite_value operator+(infinite_value const& lhs, T const& rhs) { return lhs ? infinite_value<T>(*lhs + rhs) : infinite_value<T>(none); } friend infinite_value operator+(T const& lhs, infinite_value const& rhs) { return lhs&&rhs ? infinite_value<T>(*lhs + *rhs) : infinite_value<T>(none); } friend bool operator==(infinite_value const& lhs, infinite_value const& rhs) { return (!lhs && !rhs) || (lhs&&rhs && (*lhs == *rhs)); } friend bool operator==(infinite_value const& lhs, T const& rhs) { return lhs && (*lhs == rhs); } friend bool operator==(T const& lhs, infinite_value const& rhs) { return rhs && (lhs == *rhs); } friend bool operator<(infinite_value const& lhs, infinite_value const& rhs) { return !lhs ? false : !rhs ? true : *lhs < *rhs; } friend bool operator<(infinite_value const& lhs, T const& rhs) { return !lhs ? false : *lhs < rhs; } friend bool operator<(T const& lhs, infinite_value const& rhs) { return !rhs ? true : lhs < *rhs; } friend bool operator<=(infinite_value const& lhs, infinite_value const& rhs) { return (lhs < rhs) || (lhs == rhs); } friend bool operator<=(infinite_value const& lhs, T const& rhs) { return (lhs < rhs) || (lhs == rhs); } friend bool operator<=(T const& lhs, infinite_value const& rhs) { return (lhs < rhs) || (lhs == rhs); } friend bool operator>(infinite_value const& lhs, infinite_value const& rhs) { return !rhs ? false : !lhs ? true : *lhs > *rhs; } friend bool operator>(infinite_value const& lhs, T const& rhs) { return !lhs ? true : *lhs > rhs; } friend bool operator>(T const& lhs, infinite_value const& rhs) { return !rhs ? false : lhs > *rhs; } friend bool operator>=(infinite_value const& lhs, infinite_value const& rhs) { return (lhs > rhs) || (lhs == rhs); } friend bool operator>=(infinite_value const& lhs, T const& rhs) { return (lhs > rhs) || (lhs == rhs); } friend bool operator>=(T const& lhs, infinite_value const& rhs) { return (lhs > rhs) || (lhs == rhs); } }; template<std::size_t Mod>class modulo_number { uint64 val = {}; static constexpr uint64 abs(int64 n) { return n <= -1 ? n + Mod : n; } public: modulo_number(modulo_number const&) = default; modulo_number(modulo_number&&) = default; modulo_number& operator=(modulo_number const&) = default; modulo_number& operator=(modulo_number&&) = default; ~modulo_number() = default; constexpr modulo_number(uint64 num = {}) : val(num%Mod) {} constexpr modulo_number(unsigned int num) : val(num%Mod) {} constexpr modulo_number(int64 num) : val(abs(num%Mod)) {} constexpr modulo_number(int num) : val(abs(num%Mod)) {} modulo_number& operator=(uint64 num) { val = num%Mod; return *this; } modulo_number& operator=(int64 num) { val = abs(num%Mod); return *this; } modulo_number& operator=(unsigned int num) { val = num%Mod; return *this; } modulo_number& operator=(int num) { val = abs(num%Mod); return *this; } constexpr uint64 get()const { return val; } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>((lhs.val + rhs.val) % Mod); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, int const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs + modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator+(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator+(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator+(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator+(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) + rhs; } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>((lhs.val + Mod - rhs.val) % Mod); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, int const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs - modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator-(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator-(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator-(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator-(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) - rhs; } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>((lhs.val*rhs.val) % Mod); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, int const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs * modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator*(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator*(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator*(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator*(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) * rhs; } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, modulo_number<Mod>const& rhs) { return lhs*math::pow(rhs, Mod - 2); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, int const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, unsigned int const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, int64 const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(modulo_number<Mod>const& lhs, uint64 const& rhs) { return lhs / modulo_number<Mod>(rhs); } friend constexpr modulo_number<Mod> operator/(int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } friend constexpr modulo_number<Mod> operator/(unsigned int const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } friend constexpr modulo_number<Mod> operator/(int64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } friend constexpr modulo_number<Mod> operator/(uint64 const& lhs, modulo_number<Mod>const& rhs) { return modulo_number<Mod>(lhs) / rhs; } template<class Rhs>decltype(auto) operator+=(Rhs const& rhs) { return *this = *this + rhs; } template<class Rhs>decltype(auto) operator*=(Rhs const& rhs) { return *this = *this * rhs; } template<class Rhs>decltype(auto) operator-=(Rhs const& rhs) { return *this = *this - rhs; } template<class Rhs>decltype(auto) operator/=(Rhs const& rhs) { return *this = *this / rhs; } }; template<class T>constexpr T factorial(std::size_t n, std::size_t goal = 1) { return n == goal ? T(n) : n == 0 ? T(1) : factorial<T>(n, (n + goal) / 2 + 1)*factorial<T>((n + goal) / 2, goal); } namespace detail { constexpr uint64 integral_sqrt_i(uint64 v, uint64 start, uint64 end) { return start == end ? start : pow((start + end) / 2 + 1, 2) <= v ? integral_sqrt_i(v, (start + end) / 2 + 1, end) : integral_sqrt_i(v, start, (start + end) / 2); } } constexpr uint64 integral_sqrt(uint64 v) { return v == 0 ? 0 : v == 1 ? 1 : detail::integral_sqrt_i(v, 1, 0b100000000000000000000000000000000ull); } namespace detail { constexpr bool is_prime_i(uint64 v, uint64 start, uint64 end) { return start == end ? v%end != 0 : is_prime_i(v, start, (start + end) / 2) && is_prime_i(v, (start + end) / 2 + 1, end); } } constexpr bool is_prime(uint64 v) { return v == 0 ? false : v == 1 ? false : v == 2 ? true : v == 3 ? true : detail::is_prime_i(v, 2, integral_sqrt(v)); } class dynamic_modulo { uint64 value; uint64 mod; static constexpr uint64 abs(int64 v, uint64 mod) { return v <= -1 ? v + mod : v; } public: constexpr dynamic_modulo() :value(), mod(2) {} constexpr dynamic_modulo(uint64 v, uint64 m) : value(v), mod(m) {} dynamic_modulo(dynamic_modulo const&) = default; dynamic_modulo(dynamic_modulo&&) = default; dynamic_modulo& operator=(dynamic_modulo const&) = default; dynamic_modulo& operator=(dynamic_modulo&&) = default; ~dynamic_modulo() = default; constexpr uint64 get()const { return value; } constexpr friend auto operator+(dynamic_modulo const& lhs, dynamic_modulo const& rhs) { return lhs.mod != rhs.mod ? throw std::logic_error("math::dynamic_modulo mod number error") : dynamic_modulo((lhs.value + rhs.value) % lhs.mod, lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, uint64 const& rhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, int64 const& rhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, unsigned int const& rhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(dynamic_modulo const& lhs, int const& rhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator+(uint64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(int64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator+(unsigned int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value + rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator+(int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value + rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, dynamic_modulo const& rhs) { return lhs.mod != rhs.mod ? throw std::logic_error("math::dynamic_modulo mod number error") : dynamic_modulo((lhs.value * rhs.value) % lhs.mod, lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, uint64 const& rhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, int64 const& rhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, unsigned int const& rhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(dynamic_modulo const& lhs, int const& rhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(uint64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(int64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator*(unsigned int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo((lhs.value * rhs) % lhs.mod, lhs.mod); } constexpr friend auto operator*(int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value * rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, dynamic_modulo const& rhs) { return lhs.mod != rhs.mod ? throw std::logic_error("math::dynamic_modulo mod number error") : dynamic_modulo(abs((lhs.value - rhs.value) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, uint64 const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, int64 const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, unsigned int const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(dynamic_modulo const& lhs, int const& rhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(uint64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(int64 const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(unsigned int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } constexpr friend auto operator-(int const& rhs, dynamic_modulo const& lhs) { return dynamic_modulo(abs((lhs.value - rhs) % lhs.mod, lhs.mod), lhs.mod); } template<class Rhs>dynamic_modulo& operator+=(Rhs const& rhs) { return *this = *this + rhs; } template<class Rhs>dynamic_modulo& operator-=(Rhs const& rhs) { return *this = *this - rhs; } template<class Rhs>dynamic_modulo& operator*=(Rhs const& rhs) { return *this = *this * rhs; } }; } namespace geometry { template<class Type>struct point { Type x, y; }; template<class Type>auto make_point(Type x, Type y) { return point<Type>{x, y}; } template<class Type>auto operator+(point<Type>const& lhs, point<Type>const& rhs) { return make_point(lhs.x + rhs.x, lhs.y + rhs.y); } template<class Type>auto operator-(point<Type>const& lhs, point<Type>const& rhs) { return make_point(lhs.x - rhs.x, lhs.y - rhs.y); } template<class Point>struct box { Point small, large; }; template<class Point>auto make_box(Point a, Point b) { return box<Point>{ make_point(std::min(a.x, b.x), std::min(a.y, b.y)), make_point(std::max(a.x, b.x), std::max(a.y, b.y))}; } #ifndef PLASMA_NO_BOOST template<class Point>boost::optional<box<Point>> hit_check(box<Point> a, box<Point> b) { if (a.small.x > b.small.x) std::swap(a, b); if (a.large.x < b.small.x) return boost::none; auto small_x = b.small.x; auto large_x = std::min(b.large.x, a.large.x); if (a.small.y < b.small.y) { if (b.small.y < a.large.y) return make_box( make_point(small_x, b.small.y), make_point(large_x, std::min(a.large.y, b.large.y))); else return boost::none; } else { if (a.small.y < b.large.y) return make_box( make_point(small_x, a.small.y), make_point(large_x, std::min(a.large.y, b.large.y))); else return boost::none; } } #endif } namespace graph_traits { class graph { std::vector<int64> node_data; std::vector<std::vector<std::pair<int, int64>>> edge_data; public: graph() = default; graph(std::vector<int64>&& n) :node_data(std::move(n)), edge_data{} { edge_data.resize(node_data.size()); } graph(std::size_t size) :node_data(size), edge_data{} { } void resize(int size) { node_data.resize(size); edge_data.resize(size); } void edge_reserve(int size) { for (auto& v : edge_data) { v.reserve(size); } } void add_node(int64 data) { node_data.emplace_back(data); edge_data.emplace_back(); } void add_edge(int from, int to, int64 data) { edge_data[from].emplace_back(to, data); } std::vector<math::infinite_value<int64>> dijkstra(int from)const { struct compare { bool operator()( std::pair<int, math::infinite_value<int64>>const& lhs, std::pair<int, math::infinite_value<int64>>const& rhs)const { return lhs.second > rhs.second; } }; std::priority_queue< std::pair<int, math::infinite_value<int64>>, std::vector<std::pair<int, math::infinite_value<int64>>>, compare>nodes; std::vector<math::infinite_value<int64>> ret(node_data.size()); for (int i{};i < node_data.size();++i) { nodes.emplace(i, math::infinite_value<int64>()); } nodes.emplace(from, int()); while (nodes.size()) { auto p = nodes.top(); nodes.pop(); if (ret[p.first] <= p.second) continue; ret[p.first] = p.second; for (auto const& d : edge_data[p.first]) { nodes.emplace(d.first, std::min(ret[d.first], ret[p.first] + d.second)); } } return ret; } int64 operator[](int n)const { return node_data[n]; } }; } namespace container { template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<T>>; } void Main(std::integral_constant<int, 1>); void Main(std::integral_constant<int, 2>); void Main(std::integral_constant<int, 3>); void Main(std::integral_constant<int, 4>); void Main(std::integral_constant<int, 5>); #endif//テンプレートここまで //ここを書き換える constexpr int problem = 2; //ここは書き換えない int main() { std::cin.sync_with_stdio(false); std::cout << std::setprecision(std::numeric_limits<long double>::digits10 + 1); Main(std::integral_constant<int, problem>{}); } void Main(std::integral_constant<int, 1>) { int64 A, B, C; std::cin >> A >> B >> C; if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) { std::cout << 0 << std::endl; } else { std::cout << std::min({ A*B,B*C,C*A }) << std::endl; } } void Main(std::integral_constant<int, 2>) { int64 N, x; std::cin >> N >> x; std::vector<int64> a(N); for (auto& v : a) { std::cin >> v; } std::vector<std::vector<std::pair<int64, int>>> vec(N, std::vector<std::pair<int64, int>>(N)); for (int i{};i < N;++i) { vec[0][i] = std::make_pair(a[i], 0); } for (int i = 1;i < N;++i) { for (int j{};j < N;++j) { if (a[(j + i) % N] < vec[i - 1][j].first) { vec[i][j] = std::make_pair(a[(j + i) % N], i); } else { vec[i][j] = vec[i - 1][j]; } } } int min = std::numeric_limits<int>::max(); for (int i{};i < N;++i) { int count{}; int size{}; for (int j{};j < N;++j) { count = std::max(vec[i][j].second, count); size += vec[i][j].first; } min = std::min(min, count*x + size); } std::cout << min << std::endl; } void Main(std::integral_constant<int, 3>) { } int check(std::vector<std::vector<int>>const& map, int now, int recur, int K) { static boost::multi_array<optional<int>, 2> memo(boost::extents[map.size()][K + 1]); if (memo[now][recur]) { return *memo[now][recur]; } if (recur == 0) { int ret{}; for (auto v : map[now]) { ret += check(map, v, recur + 1, K); } memo[now][0] = ret; return ret; } if (recur == K) { int ret = 1; for (auto v : map[now]) { ret += check(map, v, 1, K); } memo[now][K] = ret; return ret; } int patternA{}; int patternB = 1; for (auto v : map[now]) { patternA += check(map, v, recur + 1, K); patternB += check(map, v, 1, K); } memo[now][recur] = std::min(patternA, patternB); return std::min(patternA, patternB); } void Main(std::integral_constant<int, 4>) { int N, K; std::cin >> N >> K; std::vector<std::vector<int>> map(N); int a; std::cin >> a; int count = a == 1 ? 0 : 1; for (int i = 1;i < N;++i) { int a; std::cin >> a; map[a - 1].emplace_back(i); } for (int v : map[0]) { count += check(map, v, 0, K); } std::cout << count << std::endl; } void Main(std::integral_constant<int, 5>) { }
a.cc:29:9: fatal error: boost/optional.hpp: No such file or directory 29 | #include<boost/optional.hpp> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated.
s017825861
p04006
C++
#include <bits/stdc++.h> using namespace std; int main() { long long n, x, mn = (1<<30); cin >> n >> x; long long a[n]; for(int i=0; i<n; i++) { cin >> a[i]; mn = min(a[i], mn); } long long ans = 0 for(int i=0; i<n; i++) ans += min(x + mn, a[i]); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: expected ',' or ';' before 'for' 14 | for(int i=0; i<n; i++) ans += min(x + mn, a[i]); | ^~~ a.cc:14:22: error: 'i' was not declared in this scope 14 | for(int i=0; i<n; i++) ans += min(x + mn, a[i]); | ^
s486226597
p04006
Java
import java.util.Scanner; public class B { public static void main (String args[]){ Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long x= sc.nextLong(); long[] a = new long[2*(int)n]; for (int i = 0; i<n; i++) { a[i]=sc.nextLong(); a[i+(int)n]=a[i]; } long[][] costs = new long[(int)n][(int)n]; for (int i = (int)n; i<2*n; i++) { long best=a[i]; for (int j=0; j<n; j++) { best=Math.min(best, a[i-j]); costs[i-(int)n][j]=best; } } long best = n*1000000000; for (int j = 0; j<n;j++) { long curr = j*x; for (int i = 0; i<n; i++) { curr+=costs[i][j]; } best=Math.min(best, curr); } System.out.println(best); } }
Main.java:3: error: class B is public, should be declared in a file named B.java public class B { ^ 1 error
s219031906
p04006
C++
//魔法をかける回数を固定(Kに)する。すると、色iのスライムは色i~i-Kのスライムから作れる。 //魔法によるコストは同じなので、この中から最小のものを選べばよい。 //愚直にやると、魔法回数O(N), 色O(N), 最小値O(N)だが、ナイーブに更新すると最小値クエリO(1)になって間に合う。 #include <iostream> #include <string> #include <algorithm> #include <functional> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #define int long long using namespace std; int n, x; int a[2000]; signed main() { int i, j, k; cin >> n >> x; for (i = 0; i < n; i++) cin >> a[i]; int ans = 11451419198100721; int mini[2000]; for (i = 0; i < n; i++) mini[i] = 1145141919; //魔法をi回かける for (i = 0; i < n; i++) { int cst = 0; //スライムjを得るためのコスト(魔法コストを除く) for (j = 0; j < n; j++) { mini[j] = min(a[(j - i + n) % n], mini[j]); cst += mini; } ans = min(ans, cst + i * x); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:40:29: error: invalid conversion from 'long long int*' to 'long long int' [-fpermissive] 40 | cst += mini; | ~~~~^~~~~~~ | | | long long int*
s781722760
p04006
C++
# define _CRT_SECURE_NO_WARNINGS 1 # define _USE_MATH_DEFINES # include <iostream> # include <numeric> # include <string> # include <bitset> # include <vector> # include <algorithm> # include <cstdlib> # include <cstdio> # include <cstring> # include <cstdlib> # include <iomanip> # include <queue> # include <sstream> # include <unordered_set> # include <unordered_map> # include <climits> # include <complex> # include <cmath> # include <list> # include <functional> # include <string> # include <ctime> # include <set> # include <forward_list> # include <map> # include <stack> using namespace std; # define INF ((int)(1<<25)) # define REP(i,n) for(int i=0;i<(int)n;i++) # define FOR(i,n) REP(i,n) # define FORI(i,k,n) for(int i=k;i<(int)n;i++) # define TORAD 2.0*M_PI/360.0 # define INT(x) int x;cin>>x; # define STRING(x) string x;cin>>x; # define STR(x) STRING(x); # define DOUBLE(x) double x;cin>>x; # define DBL(x) DOUBLE(x); # define ALL(x) begin(x),end(x) # define RALL(x) (x).rbegin(),(x).rend() # define DEBUG(x) cout<<#x<<":"<<x<<endl; # define EPS 1e-12 #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #endif typedef long long lint; typedef vector<bool> vb; typedef vector<char> vc; typedef vector<int> vi; typedef vector<lint> vl; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<int, pii> piii; const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 }; const int M = 1000000007; template<class T> void debug(T a) { for ( auto i : a )cout << i << endl; } #define int lint int main() { int n, x; cin >> n >> x; vi a, X; FOR(i, n) { INT(k); a.push_back(k); X.push_back(0); } lint ans = 0; int p = 0; auto prev = [n] (int i)->int { return (i == 0 ? n - 1 : i - 1); }; auto next = [n] (int i)->int { return (i == n - 1 ? 0 : i + 1); }; FOR(j, 2)FOR(i, n) { int pr = prev(i); if ( a[i] > a[pr] + x ) { a[i] = a[pr] + x; X[i] = X[pr] + 1; p = max(p, X[i]); } } ans += p*x; bool ok = false; FOR(i, n) { if ( ok )break; if ( X[i] == 0 ) { int c = 1, j= i; while ( 1 ) { if ( X[next(j)] == 0 )break; if ( next(j) == 0 )ok = true; j = next(j); c++; } ans += c*a[i]; i = j; } } cout << ans << endl; }
a.cc:60:13: error: '::main' must return 'int' 60 | #define int lint | ^~~~ a.cc:62:1: note: in expansion of macro 'int' 62 | int main() | ^~~ a.cc: In function 'int main()': a.cc:91:32: error: no matching function for call to 'max(lint&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 91 | p = max(p, X[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:3: /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:91:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 91 | p = max(p, X[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, from a.cc:8: /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:91:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 91 | p = max(p, X[i]); | ~~~^~~~~~~~~
s876332058
p04006
C++
#include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> #include <unordered_set> #include <unordered_map> using namespace std; #define all(c) ((c).begin()), ((c).end()) #define dump(c) cerr << "> " << #c << " = " << (c) << endl; #define iter(c) __typeof((c).begin()) #define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++) #define REP(i, a, b) for (int i = a; i < (int)(b); i++) #define rep(i, n) REP(i, 0, n) #define mp make_pair #define fst first #define snd second #define pb push_back #define debug( fmt, ... ) \ fprintf( stderr, \ fmt "\n", \ ##__VA_ARGS__ \ ) typedef unsigned int uint; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vll> vvll; typedef vector<vi> vvi; typedef vector<double> vd; typedef vector<vd> vvd; typedef vector<string> vs; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1 << 30; const double EPS = 1e-10; double zero(double d) { return d < EPS ? 0.0 : d; } template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; } #define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ); template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << '(' << p.first << ',' << p.second << ')'; } template<typename T> ostream &operator<<(ostream &os, const vector<T> &a) { os << '['; rep(i, a.size()) os << (i ? " " : "") << a[i]; return os << ']'; } string toString(int i) { stringstream ss; ss << i; return ss.str(); } const int MOD = 1000000007; // a^k ll fpow(ll a, ll k, int M) { ll res = 1ll; ll x = a; while (k != 0) { if ((k & 1) == 1) res = (res * x) % M; x = (x * x) % M; k >>= 1; } return res; } struct prepare { prepare() { cout.setf(ios::fixed, ios::floatfield); cout.precision(8); ios_base::sync_with_stdio(false); } } _prepare; int main() { ll N, x; cin >> N >> x; vll a(N); rep(i, N) cin >> a[i]; const ll INF = 1ll<<60; vector<pair<ll, int> > cost(N, mp(INF, 0)); rep(i, N) { cost[i] = mp(a[i], 0); REP(j, 1, N) { chmin(cost[i], mp(a[(i-j+N)%N] + (ll)x * j, j)); } } ll ans = 0; ll ma = 0; rep(i, N) { ans += cost[i].first - (ll)cost[i].second * x; chmax(ma, cost[i].second); } cout << ans + ma * x << endl; return 0; }
a.cc: In function 'int main()': a.cc:156:14: error: no matching function for call to 'chmax(ll&, int&)' 156 | chmax(ma, cost[i].second); | ~~~~~^~~~~~~~~~~~~~~~~~~~ a.cc:91:23: note: candidate: 'template<class T> bool chmax(T&, const T&)' 91 | template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; } | ^~~~~ a.cc:91:23: note: template argument deduction/substitution failed: a.cc:156:14: note: deduced conflicting types for parameter 'const T' ('long long int' and 'int') 156 | chmax(ma, cost[i].second); | ~~~~~^~~~~~~~~~~~~~~~~~~~
s723936460
p04006
C
#include <cstdio> #include <algorithm> using namespace std; typedef long long ll; int n; ll a[2222], x; int main(void) { scanf("%d%d", &n, &x); for (int i = 0; i < n; i++) scanf("%lld", a+i); ll res = 0; int ml = 0; for (int i = 0; i < n; i++) { ll m = a[i]; int idx = i; int l = 0; for (int j = 0; j < n-1; j++) { ll s = a[(i+j+1)%n]+x*(n-j-1); if (m > s) { m = s; idx = (i+j+1)%n; l = (n-j-1); } } res += a[idx]; ml = max(ml, l); } res += ml*x; printf("%lld\n", res); return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s521973643
p04006
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, x; cin >> n >> x; vector<int> a(n, 0); for(int i = 0; i < n; ++i) cin >> a[i]; int64_t ans = 1e9; ans = ans * ans; vector<vector<int>> partMin(n, vector<int> (n, 1e9 + 5)); for(int i = 0; i < n; ++i) { partMin[i][i] = a[i]; for(int j = i + 1; j < n; ++j) partMin[i][j] = min(a[j], partMin[i][j - 1]); } for(int slides = 0; slides < n; ++slides) { int64_t temp = 0; for(int i = 0; i < n; ++i) { int lf = i - slides; if(lf < 0) lf += n; int rt = i; if(lf <= rt) { temp += partMin[lf][rt]; } else { temp += min(partMin[0][rt], partMin[lf][n - 1]); } } ans = min(ans, 1LL * slides * x + temp); } cout << ans << "\n"; }
a.cc: In function 'int main()': a.cc:36:18: error: no matching function for call to 'min(int64_t&, long long int)' 36 | ans = min(ans, 1LL * slides * x + temp); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:36:18: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 36 | ans = min(ans, 1LL * slides * x + temp); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:36:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 36 | ans = min(ans, 1LL * slides * x + temp); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s657289177
p04006
C++
#include <iostream> #include <algorithm> #include <vector> #include <numeric> using namespace std; typedef long long ll; #define reps(i,f,n) for(int i=f; i<int(n); ++i) #define rep(i,n) reps(i,0,n) int main() { ll n, x; cin >> n >> x; vector<ll> a(n); rep(i, n){ cin >> a[i]; } vector<ll> sec(n, LLONG_MAX); vector<ll> b(n); vector<ll> p(n); rep(i, n){ rep(j, n){ ll tmp = a[(i-j+n)%n] + j*x; if(tmp < sec[i]){ sec[i] = tmp; b[i] = j; p[i] = a[(i-j+n)%n]; } } } ll m = *max_element(b.begin(), b.end()); ll sum = accumulate(p.begin(), p.end(), 0ll); cout << sum+m*x << endl; }
a.cc: In function 'int main()': a.cc:22:23: error: 'LLONG_MAX' was not declared in this scope 22 | vector<ll> sec(n, LLONG_MAX); | ^~~~~~~~~ a.cc:5:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <numeric> +++ |+#include <climits> 5 |
s850157770
p04007
C++
/** * author: nok0 * created: 2020.09.13 22:45:14 **/ #ifdef LOCAL #define _GLIBCXX_DEBUG #endif #include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; #pragma region Macros #define ll long long #define ld long double #define FOR(i,l,r) for(int i=(l);i<(r);++i) #define REP(i,n) FOR(i,0,n) #define REPS(i,n) FOR(i,1,n+1) #define RFOR(i,l,r) for(int i=(l);i>=(r);--i) #define RREP(i,n) RFOR(i,n-1,0) #define RREPS(i,n) RFOR(i,n,1) #define pb push_back #define eb emplace_back #define SZ(x) ((int)(x).size()) #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() template<class T = int> using V = vector<T>; template<class T = int> using VV = V<V<T>>; using pii = pair<int, int>; using pll = pair<ll, ll>; #define VEC(type, name, size)\ V<type> name(size);\ IN(name) #define VVEC(type, name, h, w)\ VV<type> name(h, V<type>(w));\ IN(name) #define INT(...)\ int __VA_ARGS__;\ IN(__VA_ARGS__) #define LL(...)\ ll __VA_ARGS__;\ IN(__VA_ARGS__) #define STR(...)\ string __VA_ARGS__;\ IN(__VA_ARGS__) #define CHAR(...)\ char __VA_ARGS__;\ IN(__VA_ARGS__) #define DOUBLE(...)\ DOUBLE __VA_ARGS__;\ IN(__VA_ARGS__) #define LD(...)\ LD __VA_ARGS__;\ IN(__VA_ARGS__) template <class T> void scan(T a) { cin >> a; } void scan(int &a) { cin >> a; } void scan(long long &a) { cin >> a; } void scan(char &a) { cin >> a; } void scan(double &a) { cin >> a; } void scan(long double &a) { cin >> a; } void scan(char a[]) { scanf("%s", a); } void scan(string &a) { cin >> a; } template <class T> void scan(V<T> &); template <class T, class L> void scan(pair<T, L> &); template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); } template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); } template <class T> void scan(T &a) { cin >> a; } void IN() {} template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); } template <class T> inline void print(T x){ cout << x << '\n';} template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p){ is >> p.first >> p.second; return is; } template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){ os << p.first << " " << p.second; return os; } template <class T> ostream &operator<<(ostream &os, const V<T> &v){ REP(i, SZ(v)){ if(i) os << " "; os << v[i]; } return os; } //debug template <typename T> void view(const V<T> &v){ cerr << "{ "; for(const auto &e : v){ cerr << e << ", "; } cerr << "\b\b }"; } template <typename T> void view(const VV<T> &vv){ cerr << "{\n"; for(const auto &v : vv){ cerr << "\t"; view(v); cerr << "\n"; } cerr << "}"; } template <typename T, typename U> void view(const V<pair<T, U>> &v){ cerr << "{\n"; for(const auto &c : v) cerr << "\t(" << c.first << ", " << c.second << ")\n"; cerr << "}"; } template <typename T, typename U> void view(const map<T, U> &m){ cerr << "{\n"; for(auto &t : m) cerr << "\t[" << t.first << "] : " << t.second << "\n"; cerr << "}"; } template <typename T, typename U> void view(const pair<T, U> &p){ cerr << "(" << p.first << ", " << p.second << ")";} template <typename T> void view(const set<T> &s) { cerr << "{ "; for(auto &t : s) { view(t); cerr << ", "; } cerr << "\b\b }"; } template <typename T> void view(T e) { cerr << e;} #ifdef LOCAL void debug_out() {} template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { view(H); cerr << ", "; debug_out(T...); } #define debug(...) \ do{ \ cerr << __LINE__ << " [" << #__VA_ARGS__ << "] : ["; \ debug_out(__VA_ARGS__); \ cerr << "\b\b]\n"; \ } while(0) #else #define debug(...) (void(0)) #endif template <class T> V<T> press(V<T> &x){ V<T> res = x; sort(all(res)); res.erase(unique(all(res)), res.end()); REP(i, SZ(x)){ x[i] = lower_bound(all(res), x[i]) - res.begin(); } return res; } template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; } template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true; }return false; } inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';} inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';} inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}} template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}} template<class T> T divup(T x, T y) {return (x+(y-1))/y;} template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; } const int inf = 1e9; const ll INF = 1e18; #pragma endregion int main(){ INT(h, w); VVEC(char, a, h, w); VV<char> b(h, V<char>(w, '.')), c(h, V<char>(w, '.')); REP(j, w) b[0][j] = '#'; for(int i = 1; i < h - 1; i++) b[i][0] = '#'; REP(j, w) c[h - 1][j] = '#'; for(int i = 1; i < h - 1; i++) c[i][w - 1] = '#'; for(int i = 1; i < h - 1; i++){ if(i % 2) REP(j, w - 1) b[i][j] = '#'; else REPS(j, w - 1) c[i][j] = '#'; } REP(i, h) REP(j, w) if(a[i][j] == '#') b[i][j] = c[i][j] = '#'; REP(i, h){ REP(j, w) cout<<b[i][j]; cout << endl; } cout << endl; REP(i, h){ REP(j, w) cout << c[i][j]; cout << endl; } }
a.cc:10:9: fatal error: atcoder/all: No such file or directory 10 | #include<atcoder/all> | ^~~~~~~~~~~~~ compilation terminated.
s774003425
p04007
C++
#include <bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f3f3f3f3f; long long n,m; char p[505][505] = {0},k; int r[505][505] = {0},b[505][505] = {0}; int main() { cin >> n >> m; for(int i = 1;i <= n;i ++){ for(int j = 1;j <= m;j ++){ cin >> k; if(k == '#') r[i][j] = b[i][j] = p[i][j] = 1; for(int i = 1;i <= n;i ++) r[i][1] = b[i][m] = 1; for(int i = 1;i <= n;i ++){ for(int j = 2;j < m;j ++){ if(i & 1) r[i][j] = 1; else b[i][j] = 1; for(int i = 1;i <= n;i ++){ for(int j = 1;j <= m;j ++) printf("%c",r[i][j] ? '#' : '.'); printf("\n"); } printf("\n"); for(int i = 1;i <= n;i ++){ for(int j = 1;j <= m;j ++) printf("%c",b[i][j] ? '#' : '.'); printf("\n"); } return 0; }
a.cc: In function 'int main()': a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:12:31: note: to match this '{' 12 | for(int i = 1;i <= n;i ++){ for(int j = 2;j < m;j ++){ if(i & 1) r[i][j] = 1; else b[i][j] = 1; | ^ a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:10:59: note: to match this '{' 10 | for(int i = 1;i <= n;i ++){ for(int j = 1;j <= m;j ++){ cin >> k; if(k == '#') r[i][j] = b[i][j] = p[i][j] = 1; | ^ a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:10:31: note: to match this '{' 10 | for(int i = 1;i <= n;i ++){ for(int j = 1;j <= m;j ++){ cin >> k; if(k == '#') r[i][j] = b[i][j] = p[i][j] = 1; | ^ a.cc:16:2: error: expected '}' at end of input 16 | } | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s489004003
p04007
C++
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define ALL(x) (x).begin(), (x).end() #define SZ(x) ((int)((x).size())) typedef pair<int, int> PII; typedef vector<int> VI; typedef long long int64; typedef unsigned int uint; typedef unsigned long long uint64; #define gi(x) ((x) = F()) #define gii(x, y) (gi(x), gi(y)) #define giii(x, y, z) (gii(x, y), gi(z)) int F() { char ch; int x, a; while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-'); if (ch == '-') ch = getchar(), a = -1; else a = 1; x = ch - '0'; while (ch = getchar(), ch >= '0' && ch <= '9') x = (x << 1) + (x << 3) + ch - '0'; return a * x; } int n, m; char str[510][510]; int main() { gii(n, m); for (int i = 1; i <= n; ++i) scanf("%s", str[i] + 1); for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (((j == 1 || (i & 1)) && j != m) || str[i][j] == '#') putchar('#'); else putchar('.'); } putchar('\n'); } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { if (((j == m || !(i & 1)) && j != 1) || str[i][j] == '#') putchar('#'); else putchar('.'); } putchar('\n'); } }   
a.cc:66:1: error: extended character   is not valid in an identifier 66 |    | ^ a.cc:66:1: error: extended character   is not valid in an identifier a.cc:66:1: error: '\U00003000\U00003000' does not name a type 66 |    | ^~~~
s405413451
p04007
C++
#include<bits/stdc++.h> using namespace std; long long n,m; char a[1001][1001],k; long long b[1001][1001],c[1001][1001]; int main(){ scanf("%lld%lld",&n,&m); for(register int i=0;i<n;++i){ for(register int j=0;j<m;++j){ k=getchar(); if(k=='#'){ a[i][j]=1; b[i][j]=1; c[i][j]=1; } } } for(register int i=0;i<n;++i){ r[i][1]=b[i][m]=1; } for(register int i=0;i<n;++i){ for(register int j=1;j<m-1;++j){ if(i&1){ c[i][j]=1; }else{ b[i][j]=1; } } } for(register int i=0;i<n;++i){ for(register int j=0;j<m;++j){ if(c[i][j])putchar('#'); else putchar('.'); } putchar('\n'); } putchar('\n'); for(register int i=0;i<n;i++){ for(register int j=0;j<m;++j){ if(b[i][j])putchar('#'); else putchar('.'); } putchar('\n'); } return 0; }
a.cc: In function 'int main()': a.cc:8:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 8 | for(register int i=0;i<n;++i){ | ^ a.cc:9:42: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 9 | for(register int j=0;j<m;++j){ | ^ a.cc:18:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 18 | for(register int i=0;i<n;++i){ | ^ a.cc:19:17: error: 'r' was not declared in this scope 19 | r[i][1]=b[i][m]=1; | ^ a.cc:21:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 21 | for(register int i=0;i<n;++i){ | ^ a.cc:22:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 22 | for(register int j=1;j<m-1;++j){ | ^ a.cc:30:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 30 | for(register int i=0;i<n;++i){ | ^ a.cc:31:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 31 | for(register int j=0;j<m;++j){ | ^ a.cc:38:22: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 38 | for(register int i=0;i<n;i++){ | ^ a.cc:39:34: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 39 | for(register int j=0;j<m;++j){ | ^
s729829567
p04007
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; class UnionFind{ public: //親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> parent; //-1で初期化。最初はすべてバラバラ UnionFind(int N){ parent = vector<int>(N,-1); } //Aがどのグループに属しているか(Aの根)を調べる int root(int A){ if(parent[A] < 0) return A; return parent[A]=root(parent[A]); } //自分のいるグループの頂点数を調べる int size(int A){ return -parent[root(A)]; } //AとBをくっつける bool unite(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); //既にくっついているからくっつけない if(A == B) return false; //大きいほう(A)に小さいほう(B)をくっつける //大小が逆ならひっくり返す if(size(A) < size(B)) swap(A,B); //Aのサイズを更新する parent[A] += parent[B]; //Bの親をAに変更する parent[B] = A; return true; } //AとBが同じグループならtrueを返す bool same(int A, int B){ return root(A)==root(B); } }; signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); int h,w; cin>>h>>w; string s[h]; for(int i=0;i<h;i++){ cin>>s[i]; } char a[h][w]={},b[h][w]={}; int cnt=0,num[h][w]={}; int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; UnionFind uni(h*w); for(int i=1;i<h-1;i++){ for(int j=1;j<w-1;j++){ num[i][j] = cnt; cnt++; for(int k=0;k<4;k++){ int nh = i+dy[k],nw = j+dx[k]; if(s[i][j]=='#' && s[nh][nw]=='#'){ uni.unite(i*w+j,nh*w+nw); } } } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ a[i][j]='.'; b[i][j]='.'; } } for(int i=0;i<w;i++){ a[0][j]='#'; uni.unite(0,i); } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(s[i][j]=='#' && !uni.same(0,i*w+j)){ for(int k=0;k<=i;k++){ a[k][j] = '#'; uni.unite(0,i*w+j); } } if(s[i][j]=='#') a[i][j]='#'; } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(s[i][j]=='#' || a[i][j]=='.'){ b[i][j] = '#'; } cout << a[i][j]; } cout << "\n"; } cout << "\n"; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout << b[i][j]; } cout << "\n"; } cout << "\n"; }
a.cc: In function 'int main()': a.cc:86:14: error: 'j' was not declared in this scope 86 | a[0][j]='#'; | ^
s554250611
p04007
C++
to be coded
a.cc:1:1: error: 'to' does not name a type; did you mean 'auto'? 1 | to be coded | ^~ | auto
s304289061
p04007
C++
#include <algorithm> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <limits.h> #include <map> #include <math.h> #include <queue> #include <set> #include <string> #include <string.h> #include <unordered_map> #include <unordered_set> #include <vector> #define rep(i,n) for(int i=0;i<n;i++) #define REP(i,n) for(int i=1;i<=n;i++) #define int long long #define ll long long #define eps LDBL_EPSILON #define moder 1000000007 #define double long double #define INF LLONG_MAX/10000 #define P pair<int,int> #define prique priority_queue using namespace std; int h,w; char a[510][510]; bool b[510][510],c[510][510]; signed main() { cin>>h>>w; rep(i,h){ rep(j,w)cin>>a[i][j]; } rep(i,h){ if(!i){ rep(j,w)b[i][j]=true; } else if(i%2==0){ for(int j=1;j<w;j++)b[i][j]=true; } else b[i][j-1]=true; } rep(i,h){ rep(j,w){ if(!b[i][j])c[i][j]=true; } } rep(i,h){ rep(j,w){ if(a[i][j]=='#'){ if(b[i][j])c[i][j]=true; else b[i][j]=true; } } } rep(i,h){ rep(j,w){ if(b[i][j])cout<<'#'; else cout<<'.'; } cout<<endl; } rep(i,h){ rep(j,w){ if(c[i][j])cout<<'#'; else cout<<'.'; } cout<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:42:27: error: 'j' was not declared in this scope 42 | else b[i][j-1]=true; | ^
s301616130
p04007
C++
#include <bist/stdc++.h> using namespace std; char a[505][505]; int main () { int n, m; cin >> n >> m; for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) cin >> a[i][j]; for(int i = 1; i <= n; i++, cout << endl) for(int j = 1; j <= m; j++) cout << a[i][j]; }
a.cc:1:10: fatal error: bist/stdc++.h: No such file or directory 1 | #include <bist/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s673718177
p04007
C++
7 13 ............. .###.###.###. .#.#.#...#... .###.#...#... .#.#.#.#.#... .#.#.###.###. .............
a.cc:3:2: error: stray '##' in program 3 | .###.###.###. | ^~ a.cc:3:4: error: stray '#' in program 3 | .###.###.###. | ^ a.cc:3:6: error: stray '##' in program 3 | .###.###.###. | ^~ a.cc:3:8: error: stray '#' in program 3 | .###.###.###. | ^ a.cc:3:10: error: stray '##' in program 3 | .###.###.###. | ^~ a.cc:3:12: error: stray '#' in program 3 | .###.###.###. | ^ a.cc:4:2: error: stray '#' in program 4 | .#.#.#...#... | ^ a.cc:4:4: error: stray '#' in program 4 | .#.#.#...#... | ^ a.cc:4:6: error: stray '#' in program 4 | .#.#.#...#... | ^ a.cc:4:10: error: stray '#' in program 4 | .#.#.#...#... | ^ a.cc:5:2: error: stray '##' in program 5 | .###.#...#... | ^~ a.cc:5:4: error: stray '#' in program 5 | .###.#...#... | ^ a.cc:5:6: error: stray '#' in program 5 | .###.#...#... | ^ a.cc:5:10: error: stray '#' in program 5 | .###.#...#... | ^ a.cc:6:2: error: stray '#' in program 6 | .#.#.#.#.#... | ^ a.cc:6:4: error: stray '#' in program 6 | .#.#.#.#.#... | ^ a.cc:6:6: error: stray '#' in program 6 | .#.#.#.#.#... | ^ a.cc:6:8: error: stray '#' in program 6 | .#.#.#.#.#... | ^ a.cc:6:10: error: stray '#' in program 6 | .#.#.#.#.#... | ^ a.cc:7:2: error: stray '#' in program 7 | .#.#.###.###. | ^ a.cc:7:4: error: stray '#' in program 7 | .#.#.###.###. | ^ a.cc:7:6: error: stray '##' in program 7 | .#.#.###.###. | ^~ a.cc:7:8: error: stray '#' in program 7 | .#.#.###.###. | ^ a.cc:7:10: error: stray '##' in program 7 | .#.#.###.###. | ^~ a.cc:7:12: error: stray '#' in program 7 | .#.#.###.###. | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 7 13 | ^
s177039859
p04007
C++
#include<iomanip> #include<limits> #include<thread> #include<utility> #include<iostream> #include<string> #include<algorithm> #include<set> #include<map> #include<vector> #include<stack> #include<queue> #include<cmath> #include<numeric> #include<cassert> #include<random> #include<chrono> #include<unordered_map> #include<fstream> #include<list> #include<functional> #include<bitset> using namespace std; typedef unsigned long long int ull; typedef long long int ll; typedef pair<ll,ll> pll; typedef pair<int,int> pi; typedef pair<double,double> pd; typedef pair<double,ll> pdl; #define F first #define S second const ll E=1e18+7; const ll MOD=1000000007; int main(){ ll h,w; cin>>h>>w; vector<string> a(h); for(int i=0;i<h;i++){ cin>>a[i]; } vector<string> ans(h,string(w,0)); for(int i=0;i<h;i++){ ans[i][0]=1;//blue ans[i][w-1]=2;//red } for(int i=0;i<h;i++){ for(int t=1;t+1<w;t++){ ans[i][t]=i&1?1:2; } } for(int i=0;i<h;i++){ for(int t=0;t<w;t++){ if(a[i][t]=='#'){ans[i][t]=3;} } } for(int i=0;i<h;i++){ for(int t=0;t<w;t++){ cout<<ans[i][t]&1?'#':'.'; } cout<<endl; } cout<<endl; for(int i=0;i<h;i++){ for(int t=0;t<w;t++){ cout<<ans[i][t]&2?'#':'.'; } cout<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:62:28: error: no match for 'operator&' (operand types are 'std::basic_ostream<char>' and 'int') 62 | cout<<ans[i][t]&1?'#':'.'; | ^~ | | | int a.cc:62:28: note: candidate: 'operator&(int, int)' (built-in) 62 | cout<<ans[i][t]&1?'#':'.'; | ~~~~~~~~~~~~~~~^~ a.cc:62:28: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int' In file included from a.cc:22: /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:62:29: note: 'std::basic_ostream<char>' is not derived from 'const std::bitset<_Nb>' 62 | cout<<ans[i][t]&1?'#':'.'; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68, 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/iomanip:42, from a.cc:1: /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::basic_ostream<char>' to 'std::byte' 141 | operator&(byte __l, byte __r) noexcept | ~~~~~^~~ /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::basic_ostream<char>' 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::basic_ostream<char>' 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::basic_ostream<char>' to 'std::_Ios_Iostate' 181 | operator&(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW | ~~~~~~~~~~~~~^~~ a.cc:69:28: error: no match for 'operator&' (operand types are 'std::basic_ostream<char>' and 'int') 69 | cout<<ans[i][t]&2?'#':'.'; | ^~ | | | int a.cc:69:28: note: candidate: 'operator&(int, int)' (built-in) 69 | cout<<ans[i][t]&2?'#':'.'; | ~~~~~~~~~~~~~~~^~ a.cc:69:28: note: no known conversion for argument 1 from 'std::basic_ostream<char>' to 'int' /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:69:29: note: 'std::basic_ostream<char>' is not derived from 'const std::bitset<_Nb>' 69 | cout<<ans[i][t]&2?'#':'.'; | ^ /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::basic_ostream<char>' to 'std::byte' 141 | operator&(byte __l, byte __r) noexcept | ~~~~~^~~ /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::basic_ostream<char>' 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::basic_ostream<char>' 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::basic_ostream<char>' to 'std::_Ios_Iostate' 181 | operator&(_Ios_Iostate __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW | ~~~~~~~~~~~~~^~~
s065986081
p04007
C++
#include <bits/stdc++.h> using namespace std; int main(){ int h,w; char c[500][500]; cin>>h>>w; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cin>>c[i][j]; } } char r[500][500]; char b[500][500]; for(int i=0;i<h;i++){ if(i%2){ for(int j=0;j<w-1;j++){ r[i][j]=‘#’; } b[i][w-1]=‘#’; }else{ for(int j=1;j<=w-1;j++){ b[i][j]=‘#’; } r[i][0]=‘#’; } } for (int i=0;i<h;i++){ for (int j=0;j<w;j++){ if(c[i][j]==‘#’){ r[i][j]=‘#’; b[i][j]=‘#’; } } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<r[i][j]; } cout<<endl; } cout<<endl; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ cout<<b[i][j]; } cout<<endl; } return 0; }
a.cc:17:17: error: extended character ‘ is not valid in an identifier 17 | r[i][j]=‘#’; | ^ a.cc:17:18: error: stray '#' in program 17 | r[i][j]=‘#’; | ^ a.cc:17:19: error: extended character ’ is not valid in an identifier 17 | r[i][j]=‘#’; | ^ a.cc:19:17: error: extended character ‘ is not valid in an identifier 19 | b[i][w-1]=‘#’; | ^ a.cc:19:18: error: stray '#' in program 19 | b[i][w-1]=‘#’; | ^ a.cc:19:19: error: extended character ’ is not valid in an identifier 19 | b[i][w-1]=‘#’; | ^ a.cc:22:17: error: extended character ‘ is not valid in an identifier 22 | b[i][j]=‘#’; | ^ a.cc:22:18: error: stray '#' in program 22 | b[i][j]=‘#’; | ^ a.cc:22:19: error: extended character ’ is not valid in an identifier 22 | b[i][j]=‘#’; | ^ a.cc:24:15: error: extended character ‘ is not valid in an identifier 24 | r[i][0]=‘#’; | ^ a.cc:24:16: error: stray '#' in program 24 | r[i][0]=‘#’; | ^ a.cc:24:17: error: extended character ’ is not valid in an identifier 24 | r[i][0]=‘#’; | ^ a.cc:29:19: error: extended character ‘ is not valid in an identifier 29 | if(c[i][j]==‘#’){ | ^ a.cc:29:20: error: stray '#' in program 29 | if(c[i][j]==‘#’){ | ^ a.cc:29:21: error: extended character ’ is not valid in an identifier 29 | if(c[i][j]==‘#’){ | ^ a.cc:30:17: error: extended character ‘ is not valid in an identifier 30 | r[i][j]=‘#’; | ^ a.cc:30:18: error: stray '#' in program 30 | r[i][j]=‘#’; | ^ a.cc:30:19: error: extended character ’ is not valid in an identifier 30 | r[i][j]=‘#’; | ^ a.cc:31:17: error: extended character ‘ is not valid in an identifier 31 | b[i][j]=‘#’; | ^ a.cc:31:18: error: stray '#' in program 31 | b[i][j]=‘#’; | ^ a.cc:31:19: error: extended character ’ is not valid in an identifier 31 | b[i][j]=‘#’; | ^ a.cc: In function 'int main()': a.cc:17:17: error: '\U00002018' was not declared in this scope 17 | r[i][j]=‘#’; | ^ a.cc:19:17: error: '\U00002018' was not declared in this scope 19 | b[i][w-1]=‘#’; | ^ a.cc:22:17: error: '\U00002018' was not declared in this scope 22 | b[i][j]=‘#’; | ^ a.cc:24:15: error: '\U00002018' was not declared in this scope 24 | r[i][0]=‘#’; | ^ a.cc:29:19: error: '\U00002018' was not declared in this scope 29 | if(c[i][j]==‘#’){ | ^ a.cc:29:20: error: expected ')' before '\U00002019' 29 | if(c[i][j]==‘#’){ | ~ ^~ | )
s619329348
p04007
C++
def recover(purple): h = len(purple) w = len(purple[0]) red = [] blue = [] for i in xrange(h): if (i&1)==0: red.append(['#' for j in xrange(w-1)]+['.']) blue.append(['.' for j in xrange(w-1)]+['#']) else: red.append(['#']+['.' for j in xrange(w-1)]) blue.append(['.']+['#' for j in xrange(w-1)]) for j in xrange(w): if purple[i][j]=='#': red[i][j] = '#' blue[i][j] = '#' return red, blue def main(): h, w = [int(i) for i in raw_input().strip().split()] purple = [] for i in xrange(h): purple.append(raw_input().strip()) r, b = recover(purple) for line in r: print line print '' for line in b: print line if __name__=='__main__': main()
a.cc:27:11: error: empty character constant 27 | print '' | ^~ a.cc:31:14: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 31 | if __name__=='__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'def' does not name a type 1 | def recover(purple): | ^~~
s317998244
p04007
C++
#include<iostream> #include<cstring> #include<cstdio> #include<vector> #define MN 100000 #define ll long long using namespace std; inline int read() { int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar(); return x*f; } char st[MN+5][MN+5]; int n,m; bool Check(int x) { if(n&1) return x&1; else return ((x<=n-2&&(x&1))||x==n); } int main() { n=read();m=read(); for(int i=1;i<=n;++i) scanf("%s",st[i]+1); for(int i=1;i<=n;++i) { for(int j=1;j<=m;++j) if((Check(i)&&j<m)||j==1||st[i][j]=='#') putchar('#'); else putchar('.'); puts(""); } puts(""); for(int i=1;i<=n;++i) { for(int j=1;j<=m;++j) if((!Check(i)&&j>1)||j==m||st[i][j]=='#') putchar('#'); else putchar('.'); puts(""); } return 0; }
/tmp/ccc0MQkm.o: in function `Check(int)': a.cc:(.text+0x9): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x3b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccc0MQkm.o /tmp/ccc0MQkm.o: in function `main': a.cc:(.text+0x62): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0xb1): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0xdf): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x15e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x1a8): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccc0MQkm.o a.cc:(.text+0x203): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s659398036
p04007
C++
#include <bits/stdc++.h> typedef long long int ll; #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define EREP(i, n) for (int i = (n)-1; i >= 0; --i) #define mod 1000000007 #define pb(a) push_back((a)) #define INF 93193111451418101 #define MIN -93193111451418101 #define EPS 1e-11 //#define INF 931931114518101 using namespace std; typedef pair<ll, ll> P; template <typename T> void fill_all(T &arr, const T &v) { arr = v; } template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) { for (auto &i : arr) { fill_all(i, v); } } //------------------変数-----------------------// ll h,w; char grid[501][501]; ll 4x[]={0,1,0,-1,0}; bool blue[501][501],red[501][501],vis[501][501]; P road[501][501]; //-------------------関数----------------------// bool in(ll y,ll x){ if(y<0||x<0||y==h||x==w){ return false; } return true; } int main() { cin>>h>>w; ll fx,fy,db=0; REP(i,h){ REP(j,w){ cin>>grid[i][j]; fy=i;fx=j; if(grid[i][j]=='#'){db++;} } } std::queue<P>q ; q.push_back(P(i,j)); ll dbledcnt=0; while(!q.empty()){ ll y=q.front.first; ll x=q.front.second; if(grid[y][x]=='#'){ ll ky=road[y][x].first,kx=road[y][x].second; while(grid[ky][kx]!='#'){ ky=road[y][x].first,kx=road[y][x].second; } } REP(i,4){ if(in(y+4x[i],x+4x[i+1]&&!vis[y+4x[i]][x+4x[i+1]])){ vis[y+4x[i]][x+4x[i+1]]=1; q.pb(P(y+4x[i],x+4x[i+1])); road[y+4x[i]][x+4x[i+1]]=P(y,x); } } } }
a.cc:23:4: error: expected unqualified-id before numeric constant 23 | ll 4x[]={0,1,0,-1,0}; | ^~ a.cc: In function 'int main()': a.cc:45:7: error: 'class std::queue<std::pair<long long int, long long int> >' has no member named 'push_back' 45 | q.push_back(P(i,j)); | ^~~~~~~~~ a.cc:45:19: error: 'i' was not declared in this scope 45 | q.push_back(P(i,j)); | ^ a.cc:45:21: error: 'j' was not declared in this scope 45 | q.push_back(P(i,j)); | ^ a.cc:48:13: error: invalid use of member function 'std::queue<std::pair<long long int, long long int> >::front' (did you forget the '()' ?) 48 | ll y=q.front.first; | ~~^~~~~ a.cc:49:13: error: invalid use of member function 'std::queue<std::pair<long long int, long long int> >::front' (did you forget the '()' ?) 49 | ll x=q.front.second; | ~~^~~~~ a.cc:57:18: error: unable to find numeric literal operator 'operator""x' 57 | if(in(y+4x[i],x+4x[i+1]&&!vis[y+4x[i]][x+4x[i+1]])){ | ^~ a.cc:57:26: error: unable to find numeric literal operator 'operator""x' 57 | if(in(y+4x[i],x+4x[i+1]&&!vis[y+4x[i]][x+4x[i+1]])){ | ^~ a.cc:57:42: error: unable to find numeric literal operator 'operator""x' 57 | if(in(y+4x[i],x+4x[i+1]&&!vis[y+4x[i]][x+4x[i+1]])){ | ^~ a.cc:57:51: error: unable to find numeric literal operator 'operator""x' 57 | if(in(y+4x[i],x+4x[i+1]&&!vis[y+4x[i]][x+4x[i+1]])){ | ^~ a.cc:58:20: error: unable to find numeric literal operator 'operator""x' 58 | vis[y+4x[i]][x+4x[i+1]]=1; | ^~ a.cc:58:29: error: unable to find numeric literal operator 'operator""x' 58 | vis[y+4x[i]][x+4x[i+1]]=1; | ^~ a.cc:7:15: error: 'class std::queue<std::pair<long long int, long long int> >' has no member named 'push_back' 7 | #define pb(a) push_back((a)) | ^~~~~~~~~ a.cc:59:16: note: in expansion of macro 'pb' 59 | q.pb(P(y+4x[i],x+4x[i+1])); | ^~ a.cc:59:23: error: unable to find numeric literal operator 'operator""x' 59 | q.pb(P(y+4x[i],x+4x[i+1])); | ^~ a.cc:7:26: note: in definition of macro 'pb' 7 | #define pb(a) push_back((a)) | ^ a.cc:59:31: error: unable to find numeric literal operator 'operator""x' 59 | q.pb(P(y+4x[i],x+4x[i+1])); | ^~ a.cc:7:26: note: in definition of macro 'pb' 7 | #define pb(a) push_back((a)) | ^ a.cc:60:21: error: unable to find numeric literal operator 'operator""x' 60 | road[y+4x[i]][x+4x[i+1]]=P(y,x); | ^~ a.cc:60:30: error: unable to find numeric literal operator 'operator""x' 60 | road[y+4x[i]][x+4x[i+1]]=P(y,x); | ^~
s869375614
p04007
C++
include <bits/stdc++.h> typedef long long int ll; #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) #define REP(i, n) FOR(i, 0, n) #define EREP(i, n) for (int i = (n)-1; i >= 0; --i) #define mod 1000000007 #define pb(a) push_back((a)) #define INF 93193111451418101 #define MIN -93193111451418101 #define EPS 1e-11 //#define INF 931931114518101 using namespace std; typedef pair<ll, ll> P; template <typename T> void fill_all(T &arr, const T &v) { arr = v; } template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) { for (auto &i : arr) { fill_all(i, v); } } //------------------変数-----------------------// ll h,w; char grid[250001]; //-------------------関数----------------------// int main() { cin>>h>>w; REP(i,h){ } }
a.cc:1:1: error: 'include' does not name a type 1 | include <bits/stdc++.h> | ^~~~~~~ a.cc:13:9: error: 'pair' does not name a type 13 | typedef pair<ll, ll> P; | ^~~~ a.cc:21:1: error: 'll' does not name a type 21 | ll h,w; | ^~ a.cc: In function 'int main()': a.cc:25:5: error: 'cin' was not declared in this scope 25 | cin>>h>>w; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | include <bits/stdc++.h> a.cc:25:10: error: 'h' was not declared in this scope 25 | cin>>h>>w; | ^ a.cc:25:13: error: 'w' was not declared in this scope 25 | cin>>h>>w; | ^ a.cc:3:27: error: 'll' was not declared in this scope 3 | #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) | ^~ a.cc:4:19: note: in expansion of macro 'FOR' 4 | #define REP(i, n) FOR(i, 0, n) | ^~~ a.cc:26:5: note: in expansion of macro 'REP' 26 | REP(i,h){ | ^~~ a.cc:26:9: error: 'i' was not declared in this scope 26 | REP(i,h){ | ^ a.cc:3:39: note: in definition of macro 'FOR' 3 | #define FOR(i, a, b) for (ll i = (a); i < (b); ++i) | ^ a.cc:26:5: note: in expansion of macro 'REP' 26 | REP(i,h){ | ^~~
s812355610
p04007
C++
#include <bits/stdc++.h> #define rep(i, a, n) for(int i = a; i < n; i++) #define REP(i, n) rep(i, 0, n) #define repb(i, a, b) for(int i = a; i >= b; i--) #define all(a) a.begin(), a.end() #define int long long #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; typedef pair<int, int> P; const int mod = 1000000007; const int INF = 1e12; signed main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; char c[510][510]; rep(i, 0, h) rep(j, 0, w) cin >> c[i][j]; char r[510][510], b[510][510]; rep(i, 0, h){ rep(j, 0, w - 1){ if(j == 0 || i % 2 == 0 || c[i][j] == '#') r[i][j] = '#'; else r[i][j] = '.'; } rep(j, 1, w) if(j == w - 1 || i % 2 || c[i][j] == '#') b[i][j] = '#'; else b[i][j] = '.'; } } rep(i, 0, h){ rep(j, 0, w){ cout << r[i][j]; } cout << endl; } cout << endl; rep(i, 0, h){ rep(j, 0, w){ cout << b[i][j]; } cout << endl; } }
a.cc:2:22: error: expected unqualified-id before 'for' 2 | #define rep(i, a, n) for(int i = a; i < n; i++) | ^~~ a.cc:32:5: note: in expansion of macro 'rep' 32 | rep(i, 0, h){ | ^~~ a.cc:32:9: error: 'i' does not name a type 32 | rep(i, 0, h){ | ^ a.cc:2:37: note: in definition of macro 'rep' 2 | #define rep(i, a, n) for(int i = a; i < n; i++) | ^ a.cc:32:9: error: 'i' does not name a type 32 | rep(i, 0, h){ | ^ a.cc:2:44: note: in definition of macro 'rep' 2 | #define rep(i, a, n) for(int i = a; i < n; i++) | ^ a.cc:38:5: error: 'cout' does not name a type 38 | cout << endl; | ^~~~ a.cc:2:22: error: expected unqualified-id before 'for' 2 | #define rep(i, a, n) for(int i = a; i < n; i++) | ^~~ a.cc:39:5: note: in expansion of macro 'rep' 39 | rep(i, 0, h){ | ^~~ a.cc:39:9: error: 'i' does not name a type 39 | rep(i, 0, h){ | ^ a.cc:2:37: note: in definition of macro 'rep' 2 | #define rep(i, a, n) for(int i = a; i < n; i++) | ^ a.cc:39:9: error: 'i' does not name a type 39 | rep(i, 0, h){ | ^ a.cc:2:44: note: in definition of macro 'rep' 2 | #define rep(i, a, n) for(int i = a; i < n; i++) | ^ a.cc:45:1: error: expected declaration before '}' token 45 | } | ^
s290158801
p04007
C++
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #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; void solve(){ int H,W; cin >> H >> W; vector< string > org(H),fldA(H),fldB(H); UnionFind uf(H*W); vector< bool > used(H*W,false);//代表値のみuf.find() for(int h=0;h<H;++h){ cin >> org[h]; fldA[h] = org[h]; fldB[h] = org[h]; for(int w=0;w<W;++w){ if( org[h][w] != '#' ) continue; if( org[h-1][w] == '#' ){ uf.add((h-1)*W + w,h*W + w); } if( org[h][w-1] == '#' ){ uf.add(h*W + (w-1),h*W + w ); } } } for(int w=1;w<W-1;++w){//端でない一番上を塗る。 fldA[1][w] = '#'; if( w > 1 ){//左と繋ぐ uf.add(W + w-1,W + w); int num = uf.find(W+w); used[num] = true; } if( 2 < H ){ if( fldA[2][w] == '#' ){//下 uf.add(1*W + w, 2*W + w); int num = uf.find(1*W+w); used[num] = true; } } } for(int h=0;h<H;++h){//全面塗る。 for(int w=0;w<W;++w){ fldB[h][w] = '#'; } if( h==1 ){ for(int w=1;w<W-1;++w){ if( org[h][w] != '#' ){ fldB[h][w] = '.';//fldAで塗っている } } } } for(int h=2;h<H-1;++h){ for(int w=1;w<W-1;++w){ if( org[h][w] != '#' ) continue; int num = h*W + w; num = uf.find( num ); if( used[num] ) continue; used[num] = true; for(int hh = h-1; hh>=1;--hh){ if( org[hh][w] == '#' ) break; fldA[hh][w] = '#'; fldB[hh][w] = '.'; } } } for(int h=0;h<H;++h){ cout << fldA[h] << endl; } cout << endl; for(int h=0;h<H;++h){ cout << fldB[h] << 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: In function 'void solve()': a.cc:51:9: error: 'UnionFind' was not declared in this scope 51 | UnionFind uf(H*W); | ^~~~~~~~~ a.cc:60:33: error: 'uf' was not declared in this scope 60 | uf.add((h-1)*W + w,h*W + w); | ^~ a.cc:63:33: error: 'uf' was not declared in this scope 63 | uf.add(h*W + (w-1),h*W + w ); | ^~ a.cc:72:25: error: 'uf' was not declared in this scope 72 | uf.add(W + w-1,W + w); | ^~ a.cc:78:33: error: 'uf' was not declared in this scope 78 | uf.add(1*W + w, 2*W + w); | ^~ a.cc:102:31: error: 'uf' was not declared in this scope 102 | num = uf.find( num ); | ^~
s796183194
p04007
C++
a
a.cc:1:1: error: 'a' does not name a type 1 | a | ^
s475268195
p04007
C++
#include<bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);i++) #define per(i,a,b) for(int i=(a);i>=(b);i--) #define forE(i,x) for(int i=head[x];i!=-1;i=ne[i]) using namespace std; typedef long long i64; typedef unsigned long long u64; typedef unsigned u32; typedef pair<int,int> pin; #define mk(a,b) make_pair(a,b) #define lowbit(x) ((x)&(-(x))) #define sqr(a) ((a)*(a)) #define clr(a) (memset((a),0,sizeof(a))) #define ls ((x)<<1) #define rs (((x)<<1)|1) #define mid (((l)+(r))>>1) #define pb push_back #define w1 first #define w2 second inline void read(int &x){ x=0;int f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} x*=f; } inline void judge(){ freopen("in.txt","r",stdin); freopen("out.txt","w",stdout); } /******************************head*******************************/ const int maxn=505; char s[maxn][maxn]; char s1[maxn][maxn],s2[maxn][maxn]: int n,m; int main(){ read(n);read(m); rep(i,1,n)scanf("%s",s[i]+1); rep(i,1,n)rep(j,1,m) s1[i][j]=s2[i][j]=s[i][j]; rep(i,1,n){ if(i&1) rep(j,1,m-1) s1[i][j]='#'; else rep(j,2,m)s2[i][j]='#'; s1[i][1]='#'; s2[i][m]='#'; } return 0; }
a.cc:33:35: error: expected initializer before '\U0000ff1a' 33 | char s1[maxn][maxn],s2[maxn][maxn]: | ^~ a.cc: In function 'int main()': a.cc:36:14: error: 'n' was not declared in this scope; did you mean 'yn'? 36 | read(n);read(m); | ^ | yn a.cc:36:22: error: 'm' was not declared in this scope; did you mean 'tm'? 36 | read(n);read(m); | ^ | tm a.cc:39:26: error: 's2' was not declared in this scope; did you mean 's1'? 39 | s1[i][j]=s2[i][j]=s[i][j]; | ^~ | s1 a.cc:45:35: error: 's2' was not declared in this scope; did you mean 's1'? 45 | rep(j,2,m)s2[i][j]='#'; | ^~ | s1 a.cc:47:17: error: 's2' was not declared in this scope; did you mean 's1'? 47 | s2[i][m]='#'; | ^~ | s1
s416425044
p04007
C++
#include<bits/stdc++.h> using namespace std; int N, M; char sir[509][509]; bool A[509][509], B[509][509]; int main () { //freopen ("input", "r", stdin); //freopen ("output", "w", stdout); scanf ("%d %d\n", &N, &M); for (int i=1; i<=N; i++) gets (sir[i] + 1); for (int i=1; i<=N; i++) for (int j=1; j<=M; j++) { if (j & 1) A[i][j] = (i < N); else B[i][j] = (i > 1); if (sir[i][j] == '#') A[i][j] = B[i][j] = 1; } for (int i=1; i<=N; i++, printf ("\n")) for (int j=1; j<=M; j++) if (A[i][j]) printf ("#"); else printf ("."); printf ("\n"); for (int i=1; i<=N; i++, printf ("\n")) for (int j=1; j<=M; j++) if (B[i][j]) printf ("#"); else printf ("."); return 0; }
a.cc: In function 'int main()': a.cc:16:5: error: 'gets' was not declared in this scope; did you mean 'getw'? 16 | gets (sir[i] + 1); | ^~~~ | getw
s677170271
p04008
C++
#include<iostream> #include<iomanip> #include<cmath> #include<string> #include<cstring> #include<vector> #include<list> #include<algorithm> #include<map> #include<set> #include<queue> #include<stack> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair #define mt make_tuple #define pqueue priority_queue const int inf=1e9+7; const ll mod=1e9+7; const ll mod1=998244353; const ll big=1e18; const double PI=2*asin(1); int N, K; int parent[100005]; int depth[100005]; vector<vector<int> > edge(100005); void getdepth(ll u, ll dist) { depth[u] = dist; for(ll i=0;i<edge[u].size();++i) { getdepth(edge[u][i], dist+1); } return; } int main() { cin>>N>>K; ll tmp; ll ans = 0; for(ll i=0;i<N;++i) { cin>>tmp; tmp--; if(i==0 && tmp!=0) ans++; if(i!=0) { parent[i] = tmp; edge[tmp].push_back(i); } } prepare(); getdepth(0, 0); vector<pair<ll, ll> > arr(N); for(ll i=0;i<N;++i) arr[i] = mp(depth[i], i); sort(arr.begin(), arr.end(), greater<pair<ll, ll> >()); ll cut; ll now; bool can; for(ll i=0;i<N;++i) { if(ok[arr[i].se]) continue; if(arr[i].fi<=K) continue; now = arr[i].se; can = false; for(ll j=0;j<K;++j) { if(ok[now]) { can = true; break; } ok[now] = true; now = parent[now]; } if(!can) ans++; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:52:3: error: 'prepare' was not declared in this scope 52 | prepare(); | ^~~~~~~ a.cc:61:8: error: 'ok' was not declared in this scope 61 | if(ok[arr[i].se]) continue; | ^~ a.cc:66:10: error: 'ok' was not declared in this scope 66 | if(ok[now]) { | ^~ a.cc:70:7: error: 'ok' was not declared in this scope 70 | ok[now] = true; | ^~
s832278668
p04008
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 100100; int n, k, ans, par[N]; vector<int> g[N]; int dfs(int v, int p = -1) { int res = 0; for (int to: g[v]) { if (to == p) continue; res = max(res, dfs(to, v)); } if (res == k - 1 && par[v] != 1) { ans++; return 0; } return res + 1; } int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> par[i]; if (i != 1) g[par[i]].pb(i); else ans += x != 1; } dfs(1); cout << ans; }
a.cc: In function 'int main()': a.cc:29:29: error: 'x' was not declared in this scope 29 | else ans += x != 1; | ^
s512195024
p04008
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 100100; int n, k, ans; vector<int> g[N]; bool used[N]; void dfs(int v, int d = 0) { used[v] = true; if (d - mns == k + 1) { ans++; d = 0; } for (int to: g[v]) if (!used[to]) dfs(to, d + 1); } int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { int x; cin >> x; if (i != 1) g[x].pb(i); else ans += x != 1; } dfs(1); cout << ans; }
a.cc: In function 'void dfs(int, int)': a.cc:14:17: error: 'mns' was not declared in this scope; did you mean 'ans'? 14 | if (d - mns == k + 1) { | ^~~ | ans
s282779080
p04008
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back const int N = 100100; int n, k, ans; vector<int> g[N]; bool used[N]; void dfs(int v, int d = 0) { used[v] = true; if (d - mns == k + 1) { ans++; d = 0; } for (int to: g[v]) if (!used[to]) dfs(to, d + 1, mns); } int main() { cin >> n >> k; for (int i = 1; i <= n; i++) { int x; cin >> x; if (i != 1) g[x].pb(i); else ans += x != 1; } dfs(1); cout << ans; }
a.cc: In function 'void dfs(int, int)': a.cc:14:17: error: 'mns' was not declared in this scope; did you mean 'ans'? 14 | if (d - mns == k + 1) { | ^~~ | ans a.cc:19:47: error: 'mns' was not declared in this scope; did you mean 'ans'? 19 | if (!used[to]) dfs(to, d + 1, mns); | ^~~ | ans
s109100532
p04008
C++
#include <iostream> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <cassert> #include <bitset> #include <fstream> #include <cstring> #include <stack> using namespace std; #define fst first #define snd second #define pb push_back #define mp make_pair #define ll long long #define ull unsigned long long #define ld long double const ld pi = acos(-1); template<typename T> T abs(T x) { return x > 0 ? x : -x; } template<typename T> T sqr(T x) { return x * x; } template<typename T> ostream& operator << (ostream &s, const vector<T> &x) { s << "["; for (auto it : x) { s << it << ", "; } s << "]"; return s; } template<typename T> ostream& operator << (ostream &s, const set<T> &x) { s << "{"; for (auto it : x) { s << it << ", "; } s << "}"; return s; } template<typename U, typename V> ostream& operator << (ostream &s, const pair<U, V> &x) { s << "(" << x.fst << ", " << x.snd << ")"; return s; } template<typename T> bool chmax(T &x, const T &y) { if (x < y) { x = y; return true; } return false; } template<typename T> bool chmin(T &x, const T &y) { if (x > y) { x = y; return true; } return false; } //--------------------------------------------------------------------- const int maxn = 1e5 + 5; vector<int> g[maxn]; int ans = 0; int k; int dfs(int v) { int depth = 0; for (int to : g[v]) { int r = 1 + dfs(to); if (r == k && v != 1) { ans++; } else { chmax(depth, r); } } //cout << v << " " << depth << endl; return depth; } int main() { srand(time(NULL)); retry: #ifdef LOCAL freopen("a.in", "r", stdin); //freopen("a.out", "w", stdout); #else //freopen("sum.in", "r", stdin); //freopen("sum.out", "w", stdout); #endif int n; scanf("%d", &n); cin >> k; vector<int> a(n + 1); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); } if (a[1] != 1) { a[1] = 1; ans++; } for (int i = 2; i <= n; i++) { g[a[i]].pb(i); } dfs(1); cout << ans << endl; return 0; }
a.cc:23:15: error: 'acos' was not declared in this scope 23 | const ld pi = acos(-1); | ^~~~
s058966407
p04008
C++
#include <bits/stdc++.h> using namespace std; typedef long long llo; #define mp make_pair #define pb push_back #define a first #define b second //#define endl '\n' int n,k; int it[100001]; vector<int> adj[100001]; int co=0; int ss[100001]; int endd[100001]; vector<pair<int,int>> ss3; int par[100001]; set<int> cur2; int ss2[100001]; int vis[100001]; void dfs(int no,int parr=-1,int levv=0){ ss[no]=co; ss2[co]=no; par[no]=parr; co++; //cout<<no<<":"<<endl; ss3.pb({levv,no}); for(auto j:adj[no]){ if(j!=parr){ dfs(j,no,levv+1); } } endd[no]=co-1; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int ans=0; cin>>n>>k; for(int i=0;i<n;i++){ cin>>it[i]; it[i]--; if(i==0){ if(it[i]!=0){ ans+=1; it[i]=0; } } else{ adj[it[i]].pb(i); } } dfs(0); sort(ss3.begin(),ss3.end()); for(int i=0;i<n;i++){ cur2.insert(i); } reverse(ss3.begin(),ss3.end()); for(auto j:ss3){ if(j.a<=k){ continue; } if(vis[j.b]){ continue; } int cur=j.b; for(int i=0;i<k-1;i++){ cur=par[cur]; } for(int i=ss[cur];i<=endd[cur];i++){ assert(vis[ss2[i]]==0) vis[ss2[i]]=1; } /*auto jj=cur2.lower_bound(ss[cur]); while(true){ if(jj==cur2.end()){ break; } if(*jj>endd[cur]){ break; } vis[ss2[*jj]]=1; jj++; }*/ ans+=1; /// cout<<j.a<<":"<<j.b<<":"<<cur<<endl; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:72:25: error: expected ';' before 'vis' 72 | vis[ss2[i]]=1; | ^~~
s695720512
p04008
C++
#include <iostream> #include <vector> using namespace std; const int maxSize=44000; vector<int> graph[maxSize]; bool visited[maxSize][maxSize]; int distances[maxSize][maxSize], amount, required; vector<int> exceeded; void fillingGraph() { cin>>amount>>required; int vertex0; for(int i=1; i<=amount; ++i) { cin>>vertex0; graph[i].push_back(vertex0); } return; } void dfs(int root, int current, int distance) { visited[root][current]=true; for(int next : graph[current]) { if(!visited[root][next]) { dfs(root, next, distance+1); } } distances[root][current]=distance; return; } void usingDfs() { for(int point=1; point<=amount; ++point) { dfs(point, point, 0); } for(int i=1; i<=amount; ++i) { for(int j=1; j<=amount; ++j) { if(distances[i][1]>required) { exceeded.push_back(distances[i][1]); } } } int minimum; if(!exceeded.empty()) { minimum=exceeded[0]; for(int item : exceeded) { minimum=min(minimum, item); } } else { minimum=0; } cout<<minimum; return; } int main() { fillingGraph(); usingDfs(); return 0; }
/tmp/ccBA9oq2.o: in function `fillingGraph()': a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `required' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccBA9oq2.o /tmp/ccBA9oq2.o: in function `usingDfs()': a.cc:(.text+0x1d3): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `required' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x240): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x25b): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x27a): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/ccBA9oq2.o a.cc:(.text+0x28e): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s714697224
p04008
C++
#include <iostream> #include <vector> using namespace std; const int maxSize=44000; vector<int> graph[maxSize]; bool visited[maxSize][maxSize]; int distances[maxSize][maxSize], amount, required; vector<int> exceeded; void fillingGraph() { cin>>amount>>required; int vertex0; for(int i=1; i<=amount; ++i) { cin>>vertex0; graph[i].push_back(vertex0); } return; } void dfs(int root, int current, int distance) { visited[root][current]=true; for(int next : graph[current]) { if(!visited[root][next]) { dfs(root, next, distance+1); } } distances[root][current]=distance; return; } void usingDfs() { for(int point=1; point<=amount; ++point) { dfs(point, point, 0); } for(int i=1; i<=amount; ++i) { for(int j=1; j<=amount; ++j) { if(distances[i][1]>required) { exceeded.push_back(distances[i][1]); } } } int minimum; if(!exceeded.empty()) { minimum=exceeded[0]; for(int item : exceeded) { minimum=min(minimum, item); } } else { minimum=0; } cout<<minimum; return; } int main() { fillingGraph(); usingDfs(); return 0; }
/tmp/cczQfPx4.o: in function `fillingGraph()': a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `required' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/cczQfPx4.o /tmp/cczQfPx4.o: in function `usingDfs()': a.cc:(.text+0x1d3): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `required' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x240): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x25b): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x27a): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/cczQfPx4.o a.cc:(.text+0x28e): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s013178622
p04008
C++
#include <iostream> #include <vector> using namespace std; const int maxSize=400000; vector<int> graph[maxSize]; bool visited[maxSize][maxSize]; int distances[maxSize][maxSize], amount, required; vector<int> exceeded; void fillingGraph() { cin>>amount>>required; int vertex0; for(int i=1; i<=amount; ++i) { cin>>vertex0; graph[i].push_back(vertex0); } return; } void dfs(int root, int current, int distance) { visited[root][current]=true; for(int next : graph[current]) { if(!visited[root][next]) { dfs(root, next, distance+1); } } distances[root][current]=distance; return; } void usingDfs() { for(int point=1; point<=amount; ++point) { dfs(point, point, 0); } for(int i=1; i<=amount; ++i) { for(int j=1; j<=amount; ++j) { if(distances[i][1]>required) { exceeded.push_back(distances[i][1]); } } } int minimum; if(!exceeded.empty()) { minimum=exceeded[0]; for(int item : exceeded) { minimum=min(minimum, item); } } else { minimum=0; } cout<<minimum; return; } int main() { fillingGraph(); usingDfs(); return 0; }
/tmp/ccrv7OdW.o: in function `fillingGraph()': a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `required' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccrv7OdW.o /tmp/ccrv7OdW.o: in function `dfs(int, int, int)': a.cc:(.text+0x19b): relocation truncated to fit: R_X86_64_PC32 against symbol `distances' defined in .bss section in /tmp/ccrv7OdW.o /tmp/ccrv7OdW.o: in function `usingDfs()': a.cc:(.text+0x1d3): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x1fd): relocation truncated to fit: R_X86_64_PC32 against symbol `distances' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `required' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x221): relocation truncated to fit: R_X86_64_PC32 against symbol `distances' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x22e): relocation truncated to fit: R_X86_64_PC32 against symbol `exceeded' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x240): relocation truncated to fit: R_X86_64_PC32 against symbol `amount' defined in .bss section in /tmp/ccrv7OdW.o a.cc:(.text+0x24f): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s512665529
p04008
C++
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> #include<queue> #include<vector> #include<stack> #include<map> #include<deque> #include<set> #define inf 1e9 #define eps 1e-6 #define N 200010 using namespace std; typedef long long ll; typedef unsigned long long ull; inline ll read() { char ch=getchar(); ll s=0,w=1; while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();} while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();} return s*w; } struct edge { int next,to; }e[N<<1]; int head[N],cnt; int n,k,ans,maxn[N]; inline void add_edge(int from,int to){e[++cnt]=(edge){head[from],to};head[from]=cnt;} void dfs(int now) { for(register int i=head[now];i;i=e[i].next) { dfs(e[i].to);maxn[now]=max(maxn[e[i].to]+1,maxn[now]); } if(maxn[now]==k){ans++;maxn[now]=-1;} } int main() { //freopen(".in","r",stdin); //freopen(".out","w",stdout); n=read(),k=read(); for(register int i=1;i<=n;i++) { int x=read(); if(i==1)ans+=(x!=1); else add_edge(x,i); } dfs(1,0); printf("%d\n",ans); return 0; }
a.cc: In function 'void dfs(int)': a.cc:35:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 35 | for(register int i=head[now];i;i=e[i].next) | ^ a.cc: In function 'int main()': a.cc:46:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 46 | for(register int i=1;i<=n;i++) | ^ a.cc:52:12: error: too many arguments to function 'void dfs(int)' 52 | dfs(1,0); | ~~~^~~~~ a.cc:33:6: note: declared here 33 | void dfs(int now) | ^~~
s379444523
p04008
C++
#include<bits/stdc++.h> #define ll long long #define N 100010 using namespace std; int n,a[N],k,ans; int dfn[N],size[N],tot,fk[N],sonk[N],f[N],dep[N]; int s[N],cnt; int t[N<<2]; struct member { int x; }; bool operator <(const member &x,const member &y) { return dep[x.x]<dep[y.x]; } priority_queue<member> qx[N]; struct node { int num,next; }mp[N]; void init(int x,int y) { mp[++cnt].next=s[x]; mp[cnt].num=y; s[x]=cnt; } void dfs(int x,int fa,int d) { f[x]=fa; size[x]=1; dep[x]=d; dfn[x]=++tot; if(d==k)fk[x]=sonk[1]; if(d>k)fk[x]=sonk[fk[fa]]; int tx=0; for(int i=s[x];i;i=mp[i].next) { tx=1; int y=mp[i].num; sonk[x]=y; dfs(y,x,d+1); size[x]+=size[y]; } if(!tx&&d>k) { member z; z.x=x; qx.push(z); } } void change(int x,int lx,int rx,int l,int r) { if(l<=lx&&rx<=r) { t[x]=1; return; } int mid=(lx+rx)>>1; if(l<=mid)change(x<<1,lx,mid,l,r); if(mid<r)change(x<<1|1,mid+1,rx,l,r); } int ask(int x,int lx,int rx,int p) { if(t[x]||lx==rx)return t[x]; int mid=(lx+rx)>>1; if(p<=mid)return ask(x<<1,lx,mid,p); else return ask(x<<1|1,mid+1,rx,p); } int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); if(i>1)init(a[i],i); } if(a[1]!=1)++ans,a[1]=1; dfs(1,1,0); while(qx.size()) { member z=qx.top(); qx.pop(); int x=z.x; if(!ask(1,1,n,dfn[x])) { x=fk[x]; ++ans; change(1,1,n,dfn[x],dfn[x]+size[x]-1); x=f[x]; if(dep[x]>k) { z.x=x; qx.push(z); } } } printf("%d",ans); }
a.cc: In function 'void dfs(int, int, int)': a.cc:31:9: error: reference to 'size' is ambiguous 31 | size[x]=1; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:12: note: 'int size [100010]' 6 | int dfn[N],size[N],tot,fk[N],sonk[N],f[N],dep[N]; | ^~~~ a.cc:43:17: error: reference to 'size' is ambiguous 43 | size[x]+=size[y]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:12: note: 'int size [100010]' 6 | int dfn[N],size[N],tot,fk[N],sonk[N],f[N],dep[N]; | ^~~~ a.cc:43:26: error: reference to 'size' is ambiguous 43 | size[x]+=size[y]; | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:12: note: 'int size [100010]' 6 | int dfn[N],size[N],tot,fk[N],sonk[N],f[N],dep[N]; | ^~~~ a.cc:49:20: error: request for member 'push' in 'qx', which is of non-class type 'std::priority_queue<member> [100010]' 49 | qx.push(z); | ^~~~ a.cc: In function 'int main()': a.cc:80:18: error: request for member 'size' in 'qx', which is of non-class type 'std::priority_queue<member> [100010]' 80 | while(qx.size()) | ^~~~ a.cc:82:29: error: request for member 'top' in 'qx', which is of non-class type 'std::priority_queue<member> [100010]' 82 | member z=qx.top(); | ^~~ a.cc:83:20: error: request for member 'pop' in 'qx', which is of non-class type 'std::priority_queue<member> [100010]' 83 | qx.pop(); | ^~~ a.cc:89:52: error: reference to 'size' is ambiguous 89 | change(1,1,n,dfn[x],dfn[x]+size[x]-1); | ^~~~ /usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])' 272 | size(const _Tp (&)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)' 262 | size(const _Container& __cont) noexcept(noexcept(__cont.size())) | ^~~~ a.cc:6:12: note: 'int size [100010]' 6 | int dfn[N],size[N],tot,fk[N],sonk[N],f[N],dep[N]; | ^~~~ a.cc:94:36: error: request for member 'push' in 'qx', which is of non-class type 'std::priority_queue<member> [100010]' 94 | qx.push(z); | ^~~~
s364529949
p04008
C++
#include<cstdio> using namespace std; typedef const int& cint; const int MAXN = 100010; int N, K, ans; struct Edge{ int to, nxt; Edge(){} Edge(cint to_, cint nxt_){to = to_, nxt = nxt_;} }ed[MAXN << 1]; int head[MAXN], tot; int par[MAXN], dep[MAXN], mx[MAXN]; inline void add(cint u, cint v){ ed[++tot] = Edge(v, head[u]), head[u] = tot; ed[++tot] = Edge(u, head[v]), head[v] = tot; } inline chkmax(int& a, int b){if (b > a) a = b;} void dfs(int u){ mx[u] = dep[u]; int tmp, v; for (tmp = head[u]; tmp; tmp = ed[tmp].nxt){ v = ed[tmp].to; if (v != par[u]) dep[v] = dep[u] + 1, dfs(v), chkmax(mx[u], mx[v]); } if (mx[u] - dep[u] == K - 1 && par[u] != 1) ++ans, mx[u] = 0; } int main(){ scanf("%d %d", &N, &K); for (int i = 1; i <= N; ++i) scanf("%d", &par[i]); if (par[1] != 1) ++ans, par[1] = 1; for (int i = 2; i <= N; ++i) add(i, par[i]); dfs(1); printf("%d", ans); return 0; }
a.cc:24:8: error: ISO C++ forbids declaration of 'chkmax' with no type [-fpermissive] 24 | inline chkmax(int& a, int b){if (b > a) a = b;} | ^~~~~~ a.cc: In function 'int chkmax(int&, int)': a.cc:24:47: warning: no return statement in function returning non-void [-Wreturn-type] 24 | inline chkmax(int& a, int b){if (b > a) a = b;} | ^
s364457382
p04008
C++
#include <iostream> #include <vector> #include <queue> using namespace std; typedef pair<int, int> P; struct Graph { int n; vector<vector<int>> g; Graph(int n) : n(n){ g.resize(n); } void init(int n_){ n = n_; g.resize(n_); } void add_edge(int from, int to){ g[from].push_back(to); } }; struct Tree //create tree(directed) from graph(undirected) { int n; int root; vector<vector<int>> t; vector<int> par; vector<int> dpt; void init(Graph &g, int root_){ n = g.n; root = root_; t.resize(n); par.resize(n); dpt.resize(n); fill(dpt.begin(), dpt.end(), -1); queue<int> que; par[root] = -1; dpt[root] = 0; que.push(root); while(que.size()){ int pa = que.front(); que.pop(); for(int ch : g.g[pa]){ if(dpt[ch] == -1){ t[pa].push_back(ch); par[ch] = pa; dpt[ch] = dpt[pa] + 1; que.push(ch); } } } } Tree(){} Tree(Graph &g, int root_){ init(g, root_); } }; int main() { int n, k; cin >> n >> k; int ans = 0; Graph g(n); for(int i = 0; i < n; i++){ int a; cin >> a; a--; if(i == 0){ if(a != 0) ans++; } else{ g.add_edge(i, a); g.add_edge(a, i); } } Tree t(g, 0); P p[100005]; bool b[100005]{0}; for(int i = 0; i < n; i++) p[i] = P(t.dpt[i], i); sort(p, p + n, greater<P>()); for(int i = 0; i < n; i++){ int u = p[i].second; if(b[u]) continue; for(int i = 0; i < k - 1; i++){ if(u == 0) break; u = t.par[u]; } if(u != 0 && t.par[u] != 0) ans++; queue<int> que; que.push(u); b[u] = true; while(que.size()){ int v = que.front(); que.pop(); for(int w : t.t[v]){ if(!b[w]){ b[w] = true; que.push(w); } } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:88:5: error: 'sort' was not declared in this scope; did you mean 'short'? 88 | sort(p, p + n, greater<P>()); | ^~~~ | short
s170025943
p04008
C++
//#include<bits/stdc++.h> #include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <set> #include <queue> #include <deque> #include <map> #include <stack> #include<bitset> #include<list> #include<cassert> #include<numeric> using namespace std; const int N = 1e5 + 5; vector<int> rgraph[N]; vector<int> rnk[N]; int dp[N]; int a[N]; int h[N]; int g[N]; int p; bool mark[N]; bool ok[N]; int n, k; int ans; void bfs(int v) { queue<int> q; q.push(v); while (q.size()) { int x = q.front(); q.pop(); for (int i = 0; i < rgraph[x].size(); i++) { int u = rgraph[x][i]; if (!mark[u]) { if (u != x) { h[u] = h[x] + 1; } rnk[h[u]].push_back(u); mark[u] = true; q.push(u); } } } } void dfs(int v) { mark[v] = true; dp[v] = h[v]; for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { dfs(u); dp[v] = max(dp[v], dp[u]); } } } void solver(int v, int par) { mark[v] = true; for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { if (dp[u] - h[u] == k - 1 && v != 0) { ok[u] = true; ans++; } else { g[v] = max(g[v], dp[u]); } solver(u, v); } } if (g[v] - h[v] == k - 1 && !ok[v] && par != 0) { ans++; } } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { int v; cin >> v; a[i] = v; v--; rgraph[v].push_back(i); } if (a[0] != 1) { ans++; rgraph[0].push_back(0); a[0] = 1; } bfs(0); memset(mark, 0, sizeof mark); dfs(0); memset(mark, 0, sizeof mark); solver(0, 0); cout << ans << endl; }
a.cc: In function 'int main()': a.cc:115:9: error: 'memset' was not declared in this scope 115 | memset(mark, 0, sizeof mark); | ^~~~~~ a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 14 | #include<numeric> +++ |+#include <cstring> 15 |
s281113254
p04008
C++
//#include<bits/stdc++.h> #include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <set> #include <queue> #include <deque> #include <map> #include <stack> #include<bitset> #include<list> #include<cassert> #include<numeric> using namespace std; const int N = 1e5 + 5; vector<int> rgraph[N]; vector<int> rnk[N]; int dp[N]; int a[N]; int h[N]; int p; bool mark[N]; int n, k; int ans; void bfs(int v) { queue<int> q; q.push(v); while (q.size()) { int x = q.front(); q.pop(); for (int i = 0; i < rgraph[x].size(); i++) { int u = rgraph[x][i]; if (!mark[u]) { if (u != x) { h[u] = h[x] + 1; } rnk[h[u]].push_back(u); mark[u] = true; q.push(u); } } } } void dfs(int v) { mark[v] = true; dp[v] = h[v]; for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { dfs(u); dp[v] = max(dp[v], dp[u]); } } } void calc(int v) { mark[v] = true; for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { calc(u); } } } void solver(int v, int l) { h[v] = h[v] - l; mark[v] = true; int less = 0; less += h[v] - 1; int cnt = 0; for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { if (dp[u] - l > k && dp[u] - l - less <= k) { cnt++; } } } if (cnt > 1 || h[v] > k) { if (a[0] == v + 1) { h[0] = 0; ans++; } ans++; //cout << v << " " << less << " " << l << " " << h[v] << endl;; for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { if (dp[u] - l - less > k) { solver(u, l + h[v] - p); } else { calc(u); } } } } else { for (int i = 0; i < rgraph[v].size(); i++) { int u = rgraph[v][i]; if (!mark[u]) { solver(u, l); } } } } int main() { cin >> n >> k; for (int i = 0; i < n; i++) { int v; cin >> v; a[i] = v; v--; rgraph[v].push_back(i); } bfs(0); memset(mark, 0, sizeof mark); for (int i = 0; i < n; i++) { for (auto u: rnk[i]) { if (!mark[u]) { dfs(u); } } } memset(mark, 0, sizeof mark); for (int i = 0; i < n; i++) { for (int j = 0; j < rnk[i].size(); i++) { int u = rnk[i][j]; if (!mark[u]) { p = i + 1; solver(u, 0); } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:150:9: error: 'memset' was not declared in this scope 150 | memset(mark, 0, sizeof mark); | ^~~~~~ a.cc:15:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 14 | #include<numeric> +++ |+#include <cstring> 15 |
s521399888
p04008
C++
#include<vector> #include<algorithm> #include<string> using namespace std; #define int long long int ans, K, X; int dfs(vector<vector<int>> & tree, int depth, int now, int per){ int maximum = depth; for(int next : tree[now]){ maximum = max(maximum, dfs(tree, depth+1, next, now)); // cout<<now<<" -> "<<next<<endl; } // cout<<endl; //cout<<"K = "<<K<<" per "<<per<<endl; //cout<<"now "<<now<<" depth "<<depth<<" maximum "<<maximum<<" <> "<<maximum-depth<<" ans "<<ans<<endl; if(now == 0){ } else if(per == 0){ if(maximum - depth >= K){ ans++; maximum = depth-1; } }else{ if(maximum - depth >= K-1){ ans++; maximum = depth-1; } } // cout<<"now "<<now<<" depth "<<depth<<" maximum "<<maximum<<" <> "<<maximum-depth<<" ans "<<ans<<endl; return maximum; } signed main(){ int N; vector<int> a; vector<vector<int>> tree; cin>>N>>K; a.resize(N); tree.resize(N); for(int i = 0; i < N; i++){ cin>>a[i]; a[i]--; if(!i) { if(a[i] != 0) ans++; continue; } tree[a[i]].push_back(i); //tree[i].push_back(a[i]); } dfs(tree, 0, 0, -1); cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:46:3: error: 'cin' was not declared in this scope 46 | cin>>N>>K; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include<string> +++ |+#include <iostream> 4 | using namespace std; a.cc:68:3: error: 'cout' was not declared in this scope 68 | cout<<ans<<endl; | ^~~~ a.cc:68:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:68:14: error: 'endl' was not declared in this scope 68 | cout<<ans<<endl; | ^~~~ a.cc:4:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 3 | #include<string> +++ |+#include <ostream> 4 | using namespace std;
s834485378
p04008
C++
int LongestIncreasingSubsequenceLength(std::vector<int>& v) { if (v.size() == 0) return 0; std::vector<int> tail(v.size(), 0); int length = 1; // always points empty slot in tail tail[0] = v[0]; for (int i = 1; i < v.size(); i++) { // Do binary search for the element in // the range from begin to begin + length auto b = tail.begin(), e = tail.begin() + length; auto it = lower_bound(b, e, v[i]); // If not present change the tail element to v[i] if (it == tail.begin() + length) tail[length++] = v[i]; else *it = v[i]; } return length; }
a.cc:1:45: error: 'vector' is not a member of 'std' 1 | int LongestIncreasingSubsequenceLength(std::vector<int>& v) | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | int LongestIncreasingSubsequenceLength(std::vector<int>& v) a.cc:1:52: error: expected primary-expression before 'int' 1 | int LongestIncreasingSubsequenceLength(std::vector<int>& v) | ^~~