submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s823241489
p03806
C++
const int nmax=40,abmax=10,inf = 1000000; int a[nmax],b[nmax],c[nmax]; int dp[nmax+1][nmax*abmax+1][nmax*abmax+1]; int main(void){ int n,ma,mb; cin >> n >> ma >> mb; for(int i=0;i<n;++i){ cin >> a[i] >> b[i] >> c[i]; } for(int i = 0; i <= n; ++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ dp[i][ca][cb]=inf; } } } dp[0][0][0]=0; for(int i = 0; i < n; ++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ if(dp[i][ca][cb]==inf) continue; dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]); } } } int ans=inf; for(int ca = 1; ca <= nmax*abmax; ++ca){ for(int cb = 1; cb <= nmax*abmax; ++cb){ if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:1: error: 'cin' was not declared in this scope 7 | cin >> n >> ma >> mb; | ^~~ a.cc:28:18: error: 'min' was not declared in this scope; did you mean 'main'? 28 | dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); | ^~~ | main a.cc:37:23: error: 'min' was not declared in this scope; did you mean 'main'? 37 | if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); | ^~~ | main a.cc:42:2: error: 'cout' was not declared in this scope 42 | cout << ans << endl; | ^~~~ a.cc:42:17: error: 'endl' was not declared in this scope 42 | cout << ans << endl; | ^~~~
s999723890
p03806
C++
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include<iostream> #include<cstdint> #include<cstddef> #include<vector> #include<algorithm> using namespace std; using i32 = int_fast32_t; using i64 = int_fast64_t; using usize = uint_fast64_t; #define rep(i, n) for (usize i = 0; i < (usize)(n); i++) #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() using P = pair<i64,i64>; i64 dp[404][404][4004];//aの値,bの値,料金 int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); i32 n,m_a,m_b; cin >> n >> m_a >> m_b; vector<i32> a(n),b(n),c(n); rep(i,n)cin >> a[i] >> b[i] >> c[i]; dp[0][0][0] = 1; rep(i,n){ for(i32 j = 400; 0 <= j; j--){ for(i32 k = 400; 0 <= k; k--){ for(i32 l = 4000; 0 <= l; l--){ if(dp[j][k][l] != 0){ dp[j + a[i]][k + b[i]][l + c[i]] = 1; } } } } } i64 ans = 1e18; for(i32 i = 1; i * max(m_a,m_b) <= 400; i++){ for(i32 j = 0; j <= 4000; j++){ if(dp[i * m_a][i * m_b][j])ans = min(ans,j); } } cout << (ans == 1e18 ? -1 : ans) << endl; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:4: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<long int, std::allocator<long int> >::_Vector_impl::~_Vector_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = long int]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:7: /usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here 132 | struct _Vector_impl | ^~~~~~~~~~~~
s248523375
p03806
C++
#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;} template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;} #define itn int #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--) #define rrep1(i,n) for(int i=(int)(n);i>=1;i--) #define all(vec) vec.begin(),vec.end() #define sortt(vec) sort((vec).begin(),(vec).end()) #define rsort(vec) sort((vec).rbegin(), (vec).rend()) typedef long long ll; typedef long double ld; typedef pair<ll,ll> pll; typedef pair<int,int> pii; typedef tuple<ll,ll,ll> tlll; typedef tuple<int,int,int> tiii; const ll mod=1e9+7; const int inf=2e9; const ll lnf=9e18; ll gcd(ll a,ll b){ if(a%b==0) return b; return gcd(b,a%b); } ll dp[41][410][410]; int main(){ int n,ma,mb; cin >> n >> ma >> mb; rep(z,41)rep(i,410)rep(j,410) dp]z][i][j]=inf; dp[0][0][0]=0; rep(z,n){ int a,b,c; cin >> a >> b >> c; rep(i,410)rep(j,410){ if(i+a<410&&j+b<410) chmin(dp[z+1][i+a][j+b],dp[z][i][j]+c); } } ll ans=inf; rep(i,410)rep(j,410){ if(i==0||j==0) continue; ll GCD=gcd(i,j); if(i/GCD==ma&&j/GCD==mb) chmin(ans,dp[n][i][j]); } if(ans==inf) cout << -1 << endl; else cout << ans << endl; }
a.cc: In function 'int main()': a.cc:36:35: error: expected ';' before ']' token 36 | rep(z,41)rep(i,410)rep(j,410) dp]z][i][j]=inf; | ^ | ;
s851276751
p03806
C++
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int ma=sc.nextInt(); int mb=sc.nextInt(); int a[]=new int[n]; int b[]=new int[n]; int c[]=new int[n]; for(int i=0;i<n;i++) { int x=sc.nextInt(); int y=sc.nextInt(); int z=sc.nextInt(); a[i]=x; b[i]=y; c[i]=z; } int dp[][][]=new int[n+1][601][601]; for(int i=0;i<=n;i++) { for(int j=0;j<=500;j++) { for(int k=0;k<=500;k++) { dp[i][j][k]=Integer.MAX_VALUE; } } } dp[0][0][0]=0; for(int i=1;i<=n;i++) { for(int j=0;j<=500;j++) { for(int k=0;k<=500;k++) { dp[i][j][k]=dp[i-1][j][k]; if(j-a[i-1]>=0 && k-b[i-1]>=0 && dp[i-1][j-a[i-1]][k-b[i-1]]!=Integer.MAX_VALUE) dp[i][j][k]=Math.min( dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1],dp[i][j][k]); } } } int ans=Integer.MAX_VALUE; for(int j=1;j<=500;j++) { for(int k=1;k<=500;k++) { if(dp[n][j][k] !=Integer.MAX_VALUE) { if((j*mb)==(k*ma)) { ans=Math.min(ans,dp[n][j][k]); } } } } if(ans==Integer.MAX_VALUE) { System.out.println(-1); }else { System.out.println(ans); } } static boolean isValid(int i,int j,int r,int c ) { return i>=0&&j>=0&&i<r&&j<c; } static int[] arr(int n,Scanner sc) { int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } return a; } } class let{ int x,y,z; let(int x,int y,int z){ this.x=x; this.y=y; this.z=z; } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: expected unqualified-id before 'public' 3 | public class Main { | ^~~~~~ a.cc:86:2: error: expected ';' after class definition 86 | } | ^ | ; a.cc: In constructor 'let::let(int, int, int)': a.cc:82:22: error: request for member 'x' in '(let*)this', which is of pointer type 'let*' (maybe you meant to use '->' ?) 82 | this.x=x; | ^ a.cc:83:22: error: request for member 'y' in '(let*)this', which is of pointer type 'let*' (maybe you meant to use '->' ?) 83 | this.y=y; | ^ a.cc:84:22: error: request for member 'z' in '(let*)this', which is of pointer type 'let*' (maybe you meant to use '->' ?) 84 | this.z=z; | ^
s872955582
p03806
C++
#include <bits/stdc++.h> using namespace std; #define all(n) begin(n), end(n) typedef long long ll; template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } int main() { int N, Ma, Mb; cin >> N >> Ma >> Mb; int ans = 1e9; vector<tuple<int, int, int>> t1(N / 2), t2(N - N / 2); //前半と後半 for (size_t i = 0; i < N; i++) { int a, b, c; cin >> a >> b >> c; if (i < N / 2) t1[i] = {a, b, c}; else { t2[i - N / 2] = {a, b, c}; } } vector<pair<int, int>> T2; //探す値を持っておく配列 後半の配列をbit全探索して入れていく for (int bit = 0; bit < (1 << t2.size()); bit++) { int a = 0, b = 0, c = 0; for (int i = 0; i < t2.size(); i++) { auto [A, B, C] = t2[i]; if (bit & (1 << i)) { a += A; b += B; c += C; } } T2.push_back({b * Ma - a * Mb, c}); int d=b*Na-a*Nb; if(d==0 && c>0){ chmin(ans,c); } } sort(all(T2)); //普通のpair<int,int>の順序で昇順ソート for (int bit = 0; bit < (1LL << t1.size()); bit++) { int a = 0, b = 0, c = 0; for (size_t i = 0; i < t1.size(); i++) { auto [A, B, C] = t1[i]; if (bit & (1LL << i)) { a += A; b += B; c += C; } } int d = a * Mb - b * Ma; //このdの値がT2に入ってるか二分探索で調べる ll ok = T2.size() - 1, ng = -1; while (abs(ok - ng) > 1) { ll mid = (ok + ng) / 2; if (T2[mid].first >= d) ok = mid; else ng = mid; } //この時点でokは 「T2[i].second >= dを満たすようなiの集合」 の最小値になっているはず(あるいはその集合は空) if (T2[ok].first == d and c + T2[ok].second > 0) { chmin(ans, c + T2[ok].second); } if(d==0 && c>0){ chmin(ans,c); } } if (ans != 1e9) cout << ans << endl; else cout << -1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:51:17: error: 'Na' was not declared in this scope; did you mean 'a'? 51 | int d=b*Na-a*Nb; | ^~ | a a.cc:51:22: error: 'Nb' was not declared in this scope; did you mean 'b'? 51 | int d=b*Na-a*Nb; | ^~ | b
s266400119
p03806
C++
#include<bits/stdc++.h> using namespace std; ///Welcome to Nasif's Code #define bug printf("bug\n"); #define bug2(var) cout<<#var<<" "<<var<<endl; #define co(q) cout<<q<<endl; #define all(q) (q).begin(),(q).end() typedef long long int ll; typedef unsigned long long int ull; const int MOD = (int)1e9+7; const int MAX = 1e6; #define pi acos(-1) #define inf 1000000000000000LL #define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll dp[500][500],a[100],b[100],c[100]; int main() { FastRead //freopen("output.txt", "w", stdout); for(int i=0; i<=400; i++) for(int j=0; j<=400; j++) dp[i][j]=1e12; int n,p,q; cin>>n>>p>>q; for(int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i]; dp[0][0]=0; for(int k=0; k<n; k++) { for(int i=a[k]; i<=400; i++) { for(int j=b[k]; j<=400; j++) { dp[i][j]=min(dp[i][j],dp[i-a[k]][j-b[k]]+c[k]); } } } int ans=1e12; for(int i=1; i<=400; i++) { if(((p*i)>400) || ((q*i)>400)) break; ans=min(ans,dp[i*p][i*q]); } if(ans==1e12) cout<<"-1"<<endl; else cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:38:13: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+12' to '2147483647' [-Woverflow] 38 | int ans=1e12; | ^~~~ a.cc:43:16: error: no matching function for call to 'min(int&, ll&)' 43 | ans=min(ans,dp[i*p][i*q]); | ~~~^~~~~~~~~~~~~~~~~~ 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:43:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 43 | ans=min(ans,dp[i*p][i*q]); | ~~~^~~~~~~~~~~~~~~~~~ /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:43:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 43 | ans=min(ans,dp[i*p][i*q]); | ~~~^~~~~~~~~~~~~~~~~~
s168366227
p03806
C++
#include<bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ll long long ll gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; } //最大公約数 ll lcm(ll x, ll y) { return x / gcd(x, y) * y; } //最小公倍数 using Graph = vector<vector<ll>>; ll inf=300000000000000000; const double PI = 3.14159265358979323846; int main(){ int n,a,b; cin >> n >> a >> b; int x[n]; int y[n]; int z[n]; rep(i,n)cin >> x[i] >> y[i] >> z[i]; int dp[n+1][401][401]; rep(i,n+1)rep(j,40i)rep(o,401)dp[i][j][o]=1000000000; dp[0][0][0]=[0]; rep(i,n){ rep(j,401)rep(o,401)dp[i+1][j][o]=dp[i][j][o]; rep(j,401){ rep(o,401){ if(j-x[i]<0||o-y[i]<0)continue; dp[i+1][j][o]=min(dp[i+1][j][o],dp[i][j-x[i]][o-y[i]]+z[i]); } } } int ans=1000000000; rep(i,400){ rep(j,400){ if((i+1)/(gcd(i+1,j+1))==a&&(j+1)/(gcd(i+1,j+1)))ans=min(ans,dp[n][i+1][j+1]) } } if(ans==1000000000){ cout << -1 << endl; } else cout << ans << endl; }
a.cc: In function 'int main()': a.cc:3:39: error: invalid cast from type 'std::complex<double>' to type 'int' 3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++) | ^~~~~~~~ a.cc:18:13: note: in expansion of macro 'rep' 18 | rep(i,n+1)rep(j,40i)rep(o,401)dp[i][j][o]=1000000000; | ^~~ a.cc:19:16: error: expected identifier before numeric constant 19 | dp[0][0][0]=[0]; | ^ a.cc: In lambda function: a.cc:19:18: error: expected '{' before ';' token 19 | dp[0][0][0]=[0]; | ^ a.cc: In function 'int main()': a.cc:19:15: error: invalid user-defined conversion from 'main()::<lambda()>' to 'int' [-fpermissive] 19 | dp[0][0][0]=[0]; | ^~~ a.cc:19:15: note: candidate is: 'constexpr main()::<lambda()>::operator void (*)()() const' (near match) 19 | dp[0][0][0]=[0]; | ^ a.cc:19:15: note: no known conversion from 'void (*)()' to 'int' a.cc:32:84: error: expected ';' before '}' token 32 | if((i+1)/(gcd(i+1,j+1))==a&&(j+1)/(gcd(i+1,j+1)))ans=min(ans,dp[n][i+1][j+1]) | ^ | ; 33 | } | ~
s761621299
p03806
C++
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define x() real() #define y() imag() typedef complex<double> point; // 2D point only typedef long long ll; typedef unsigned long long ull; typedef long double ldob; typedef pair<ll, ll> ii; typedef pair<ll, ii> iii; typedef pair<ii, ll> ii_i; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<ii> vii; typedef vector<iii> viii; // OST template <typename T> using ordered_set = __gnu_pbds::tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; // from: https://codeforces.com/blog/entry/62393 struct custom_hash { static uint64_t splitmix64(uint64_t x) { // http://xorshift.di.unimi.it/splitmix64.c x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM); } }; const int INF = ~(1<<31); const ll LINF = (1LL << 60); const long double EPS = 1e-9; const long double PI = acos(-1); const int N = 41; const int NN = 1001; const int MOD = 1e9+7; const int IMAX = 1e9+7; const int dx[4] = {0,0,-1,1}; const int dy[4] = {-1,1,0,0}; ll n, Ma, Mb, ai[N], bi[N], ci[N], dp[N][N*21][N*21]; int main () { ios_base::sync_with_stdio(false); cin.tie(0); // cout.precision(3); cout << fixed; // memset(dp, -1, sizeof dp); cin >> n >> Ma >> Mb; for (int i = 1; i <= n; ++i) cin >> ai[i] >> bi[i] >> ci[i]; for (int i = 0; i <= n; ++i) for (int a = 0; a < N*11; ++a) for (int b = 0; b < N*11; ++b) dp[i][a][b] = IMAX; dp[0][0][0] = 0; for (int i = 0; i < n; ++i) { for (int a = 0; a < N*21; ++a) { for (int b = 0; b < N*21; ++b) { if (dp[i][a][b] == IMAX) continue; dp[i+1][a][b] = min(dp[i+1][a][b], dp[i][a][b]); dp[i+1][a+ai[i]][b+bi[i]] = min(dp[i+1][a+ai[i]][b+bi[i]], dp[i][a][b]+ci[i]); } } } int ans = IMAX; for (int a = 1; a < N*21; ++a) { for (int b = 1; b < N*21; ++b) { int g = __gcd(a,b); if (a/g == Ma and b/g == Mb) ans = min(ans, dp[n][a][b]); } } cout << (ans == IMAX ? -1 : ans) << endl; return 0; }
a.cc: In function 'int main()': a.cc:85:42: error: no matching function for call to 'min(int&, ll&)' 85 | ans = min(ans, dp[n][a][b]); | ~~~^~~~~~~~~~~~~~~~~~ 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:85:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 85 | ans = min(ans, dp[n][a][b]); | ~~~^~~~~~~~~~~~~~~~~~ /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:85:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 85 | ans = min(ans, dp[n][a][b]); | ~~~^~~~~~~~~~~~~~~~~~
s098531802
p03806
C++
#include <bits/stdc++.h> #include <boost/rational.hpp> using namespace std; using i64 = long long; using u64 = unsigned long long; #define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i) const int INF = 1 << 30; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N, ma, mb; cin >> N >> ma >> mb; int mincost = INF; vector<tuple<int, int>> x_minus, x_plus; REP(i, N) { int a, b, c; cin >> a >> b >> c; int x = a * mb - ma * b; if (x == 0) { if (mincost > c) { mincost = c; // cerr << "x = 0, cost = " << c << endl; } } else if (x < 0) { x_minus.emplace_back(c, -x); } else { x_plus.emplace_back(c, x); } } // dp_*[i] := mincost of total weight i. const int XMAX = 1000; vector<int> dp_plus(XMAX + 1, INF), dp_minus(XMAX + 1, INF); dp_plus[0] = dp_minus[0] = 0; REP(i, x_plus.size()) { auto [ci, xi] = x_plus[i]; for (int w = XMAX - xi; w >= 0; --w) { dp_plus[w + xi] = min(dp_plus[w + xi], dp_plus[w] + ci); } } REP(i, x_minus.size()) { auto [ci, xi] = x_minus[i]; for (int w = XMAX - xi; w >= 0; --w) { dp_minus[w + xi] = min(dp_minus[w + xi], dp_minus[w] + ci); } } REP(w, XMAX) { int wp = dp_plus[w + 1], wm = dp_minus[w + 1]; if (wp != INF && wm != INF && mincost > wp + wm) { // cerr << "Found: weight = " << (wp + wm) << " (" << wp << " + " << wm // << ")\n"; mincost = wp + wm; } } cout << (mincost == INF ? -1 : mincost) << endl; }
a.cc:3:10: fatal error: boost/rational.hpp: No such file or directory 3 | #include <boost/rational.hpp> | ^~~~~~~~~~~~~~~~~~~~ compilation terminated.
s730086912
p03806
C++
#include <bits/stdc++.h> using namespace std; int main() { int N,A,B; cin>>N>>A>>B; vector<vector<vector<int>>> dp(N,vector<vector<int>>(401,vector<int>(401,5000))); int a,b,c; cin>>a>>b>>c; dp.at(0).at(0).at(0)=0,dp.at(0).at(a).at(b)=c; for(int i=1;i<N;i++){ cin>>a>>b>>c; for(int j=0;j<401;j++){ for(int k=0;k<401;k++){ if(j>=a&&k>=b){ dp.at(i).at(j).at(k)=min(dp.at(i-1).at(j).at(k),dp.at(i-1).at(j-a).at(k-b)+c); } else{ dp.at(i).at(j).at(K)=dp.at(i-1).at(j).at(k); } } } } int X=A,Y=B,Z=5000; while(X<=400&&Y<=400){ Z=min(Z,dp.at(N-1).at(X).at(Y)); X+=A,Y+=B; } if(Z==5000){ cout<<"-1"<<endl; } else{ cout<<Z<<endl; } }
a.cc: In function 'int main()': a.cc:19:29: error: 'K' was not declared in this scope 19 | dp.at(i).at(j).at(K)=dp.at(i-1).at(j).at(k); | ^
s587185607
p03806
C++
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author zjsdut */ #ifndef ALGO_UTILS #define ALGO_UTILS #include <algorithm> #include <vector> template<typename A, typename B> bool chkmin(A &a, const B &b) { if (b < a) { a = b; return true; } return false; } template<typename A, typename B> bool chkmax(A &a, const B &b) { if (b > a) { a = b; return true; } return false; } using ll = long long; using ull = unsigned long long; using vl = std::vector<ll>; using vb = std::vector<bool>; using vi = std::vector<int>; using pii = std::pair<int, int>; using pli = std::pair<ll, int>; using pll = std::pair<ll, ll>; template<typename T> using vv = std::vector<std::vector<T>>; #define rng(i, a, b) for (std::common_type<decltype(a),decltype(b)>::type i = a; i < b; ++i) #define up(i, a, b) for (std::common_type<decltype(a),decltype(b)>::type i = a; i <= b; ++i) #define down(i, b, a) for (std::common_type<decltype(a),decltype(b)>::type i = b; i >= a; i--) #define TOKENPASTE(x, y) x##y #define TOKENPASTE2(x, y) TOKENPASTE(x, y) #define rep(n) \ for (int TOKENPASTE2(_iter_, __LINE__) = 0, \ TOKENPASTE2(_num_, __LINE__) = n; \ TOKENPASTE2(_iter_, __LINE__) < TOKENPASTE2(_num_, __LINE__); \ ++TOKENPASTE2(_iter_, __LINE__)) #define FOR(x, cont) for (const auto &x : cont) #define For(x, cont) for (auto &x : cont) #define all(x) begin(x), end(x) #define pb push_back #define mp make_pair #define eb emplace_back #define ep emplace #define SZ(x) (int)(x).size() #define UNIQ(vec) (vec).erase(std::unique(all(vec)), std::end(vec)) #define LB(cont, x) int(std::lower_bound(all(cont), x) - std::begin(cont)) #define UB(cont, x) int(std::upper_bound(all(cont), x) - std::begin(cont)) #endif #ifndef JHELPER_EXAMPLE_PROJECT_LIBRARY_IO_HPP_ #define JHELPER_EXAMPLE_PROJECT_LIBRARY_IO_HPP_ #include <iostream> #include <iomanip> struct fast_ios { fast_ios() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(10); }; } fast_ios_; template<typename T> std::istream &operator>>(std::istream &stream, std::vector<T> &vec) { for (auto &x : vec) stream >> x; return stream; } template<typename T, typename U> std::istream &operator>>(std::istream &in, std::pair<T, U> &p) { in >> p.first >> p.second; return in; } void scan() {} template<class T, class... Args> void scan(T &a, Args &... rest) { std::cin >> a; scan(rest...); } template<typename T> std::ostream &operator<<(std::ostream &stream, const std::vector<T> &vec) { bool first = true; for (const T &t : vec) { if (first) first = false; else std::cout << ' '; std::cout << t; } return stream; } template<typename T> void print(const std::vector<T> &t) { std::cout << t << '\n'; } template<typename T> void print(const std::vector<std::vector<T>> &t) { for (const auto &row : t) { print(row); } } template<typename T> void print(const T &t) { std::cout << t << ' '; } template<typename T, typename... Args> void print(const T &t, const Args &... rest) { print(t); print(rest...); } template<typename T> void println(const T &t) { std::cout << t << '\n'; } template<typename T, typename... Args> void println(const T &t, const Args &... rest) { print(t); println(rest...); } #endif //JHELPER_EXAMPLE_PROJECT_LIBRARY_IO_HPP_ #include <bitset> using std::to_string; std::string to_string(const std::string &s) { return '"' + s + '"'; } std::string to_string(const char *s) { return to_string((std::string) s); } std::string to_string(bool b) { return (b ? "true" : "false"); } template<typename A, typename B> std::string to_string(const std::pair<A, B> &p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } template<size_t N> std::string to_string(const std::bitset<N> &bs) { return bs.to_string(); } template<typename A> std::string to_string(const A &v) { bool first = true; std::string res = "{"; for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); } res += "}"; return res; } void debug_out() { std::cerr << std::endl; } template<typename Head, typename... Tail> void debug_out(const Head &H, const Tail &... T) { std::cerr << " " << to_string(H); debug_out(T...); } #if defined LOCAL #define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) 42 #endif using namespace std; class DMixingExperiment { static void SOLVE() { int n, ma, mb; scan(n, ma, mb); vi a(n), b(n), c(n); rng (i, 0, n) scan(a[i], b[i], c[i]); const int MAX = INT_MAX / 2; vv<int> dp(401, vi(401, MAX)); dp[0][0] = 0; rng (i, 0, n) { down (x, 400, 1) { down (y, 400, 1) { if (x >= a[i] && y >= b[i]) chkmin(dp[x][y], c[i] + dp[x - a[i]][y - b[i]]); } } } int ans = MAX; up (i, 1, 400) up (j, 1, 400) { if (i * mb == j * ma) chkmin(ans, dp[i][j]); } if (ans == MAX) println(-1); else println(ans); } public: static void solve(std::istream &in, std::ostream &out) { auto cin_buff = std::cin.rdbuf(in.rdbuf()); auto cerr_buff = std::cerr.rdbuf(std::cout.rdbuf(out.rdbuf())); SOLVE(); std::cout.rdbuf(std::cerr.rdbuf(cerr_buff)); std::cin.rdbuf(cin_buff); } }; int main() { DMixingExperiment solver; std::istream& in(std::cin); std::ostream& out(std::cout); solver.solve(in, out); return 0; }
a.cc: In static member function 'static void DMixingExperiment::SOLVE()': a.cc:189:21: error: 'INT_MAX' was not declared in this scope 189 | const int MAX = INT_MAX / 2; | ^~~~~~~ a.cc:137:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 136 | #include <bitset> +++ |+#include <climits> 137 | using std::to_string;
s180813125
p03806
C++
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define MAX 510000 #define Rep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep(i, n) for(ll i = 1; i <= (ll)(n); i++) using namespace std; typedef long long int ll; typedef pair<int, int> P; //cout << fixed << setprecision(10);// //最小公倍数// ll gcd(ll x, ll y) { if (x == 0) return y; return gcd(y%x, x); } ll lcm(ll x, ll y) { return x * y / gcd(x, y); } //べき// ll squ(ll n, ll p, ll m){ if(p==0) return 1; if(p%2==0){ ll t=squ(n, p/2, m); return t*t%m; } return n*squ(n,p-1,m); } //逆元mod(mを法とするaの逆元)// long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } //Cmonp// ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //nが大 ll com(ll n,ll m){ if(n<m || n<=0 ||m<0){ return 0; } if( m==0 || n==m){ return 1; } ll k=1; for(ll i=1;i<=m;i++){ k*=(n-i+1); k%=MOD; k*=modinv(i,MOD); k%=MOD; } return k; } //////////////////////////////////////////////////////////////////// int main() { ll n; ll ma,mb; cin>>n; cin>>ma>>mb; ll med[n+1][3]; for(ll i=0;i<=n;i++){ for(int j=0;j<=2;j++){ if(i==0){med[i][j]=0; continue;} cin>>med[i][j]; } } ll ans=1000000; ll dp[401][401][n+1]; for(int k=0;k<=n;k++){ ll p=med[k][0]; ll q=med[k][1]; ll val=med[k][2]; for(ll i=0;i<=400;i++){ for(ll j=0;j<=400;j++){ if(i==0 && j==0 ){dp[i][j][k]=0; continue;} if(k==0){dp[i][j][k]=1000000; continue;} if(i>=p && j>=q){ dp[i][j][k]=min(dp[i-p][j-q][k-1]+val,dp[i][j][k-1]); continue; } dp[i][j][k]=dp[i][j][k-1]; } } } for(ll i=1;i<=400;i++){ for(ll j=1;j<=400;j++){ if(i/ma==j/mb && i%ma==0 && j%mb==0){ ans=min(ans,dp[i][j][n]); } } } if(ans==1000000){cout<<-1<<endl;} else {cout<<ans<<endl;} return 0; }
a.cc:137:12: error: extended character   is not valid in an identifier 137 | if(i/ma==j/mb && i%ma==0 && j%mb==0){ | ^ a.cc: In function 'int main()': a.cc:137:12: error: 'mb\U00003000' was not declared in this scope 137 | if(i/ma==j/mb && i%ma==0 && j%mb==0){ | ^~~~
s360929853
p03806
C++
#include <bits/stdc++.h> #define ALL(v) v.begin(), v.end() #define MOD 1000000007 #define MAX 510000 #define Rep(i, n) for(ll i = 0; i < (ll)(n); i++) #define rep(i, n) for(ll i = 1; i <= (ll)(n); i++) using namespace std; typedef long long int ll; typedef pair<int, int> P; //cout << fixed << setprecision(10);// //最小公倍数// ll gcd(ll x, ll y) { if (x == 0) return y; return gcd(y%x, x); } ll lcm(ll x, ll y) { return x * y / gcd(x, y); } //べき// ll squ(ll n, ll p, ll m){ if(p==0) return 1; if(p%2==0){ ll t=squ(n, p/2, m); return t*t%m; } return n*squ(n,p-1,m); } //逆元mod(mを法とするaの逆元)// long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } //Cmonp// ll fac[MAX], finv[MAX], inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 ll COM(ll n, ll k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } //nが大 ll com(ll n,ll m){ if(n<m || n<=0 ||m<0){ return 0; } if( m==0 || n==m){ return 1; } ll k=1; for(ll i=1;i<=m;i++){ k*=(n-i+1); k%=MOD; k*=modinv(i,MOD); k%=MOD; } return k; } //////////////////////////////////////////////////////////////////// int main() { ll n; ll ma,mb; cin>>n; cin>>ma>>mb; ll med[n+1][3]; for(ll i=0;i<=n;i++){ for(int j=0;j<=2;j++){ if(i==0){med[i][j]=0; continue;} cin>>med[i][j]; } } ll ans=1000000; ll dp[401][401][n+1]; for(int k=0;k<=n;k++){ ll p=med[k][0]; ll q=med[k][1]; ll val=med[k][2]; for(ll i=0;i<=400;i++){ for(ll j=0;j<=400;j++){ if(i==0 && j==0 ){dp[i][j][k]=0; continue;} if(k==0){dp[i][j][k]=1000000; continue;} if(i>=p && j>=q){ dp[i][j][k]=min(dp[i-p][j-q][k-1]+val,dp[i][j][k-1]); continue; } dp[i][j][k]=dp[i][j][k-1]; } } } for(int i=1;i<=400;i++){ for(int j=1;j<=400;j++){ if(i/ma==j/mb && i%ma==0 && j%mb==0){ ans=min(ans,dp[i][j][n]); } } } if(ans==1000000){cout<<-1<<endl;} else {cout<<ans<<endl;} return 0; }
a.cc:137:12: error: extended character   is not valid in an identifier 137 | if(i/ma==j/mb && i%ma==0 && j%mb==0){ | ^ a.cc: In function 'int main()': a.cc:137:12: error: 'mb\U00003000' was not declared in this scope 137 | if(i/ma==j/mb && i%ma==0 && j%mb==0){ | ^~~~
s683094033
p03806
C++
+a#include <bits/stdc++.h> using namespace std; #define fr(i,n) _back #define pb push_back #define eb emplace_back #define mk make_pair #define fi first #define se second #define endl '\n' typedef long long ll; typedef pair<int,int> ii; typedef vector<ii> vii; const int INF = 0x3f3f3f3f; const double PI = acos(-1.0); const int Z = 4e2 + 10; int n, ma,mb; int dp[Z][Z]; int main() { ios_base::sync_with_stdio(false); cin >> n >> ma >> mb; memset(dp, INF, sizeof dp); dp[0][0] = 0; while(n--) { int a,b,c; cin >> a >> b >> c; for(int j = 0; j+a < Z; j++) for(int k = 0; k+b < Z; k++) { int &r = dp[j+a][k+b]; r = min(r, dp[j][k]+c); } } int ans = INF; for(int i = 1; i*ma < Z and i*mb < Z; i++) ans = min(ans,dp[i*ma][i*mb]); cout << (ans == INF? -1 : ans) << endl; return 0; }
a.cc:1:3: error: stray '#' in program 1 | +a#include <bits/stdc++.h> | ^ a.cc:1:1: error: expected unqualified-id before '+' token 1 | +a#include <bits/stdc++.h> | ^ a.cc:13:9: error: 'pair' does not name a type 13 | typedef pair<int,int> ii; | ^~~~ a.cc:14:9: error: 'vector' does not name a type 14 | typedef vector<ii> vii; | ^~~~~~ a.cc:16:19: error: 'acos' was not declared in this scope 16 | const double PI = acos(-1.0); | ^~~~ a.cc: In function 'int main()': a.cc:22:5: error: 'ios_base' has not been declared 22 | ios_base::sync_with_stdio(false); | ^~~~~~~~ a.cc:23:5: error: 'cin' was not declared in this scope 23 | cin >> n >> ma >> mb; | ^~~ a.cc:25:5: error: 'memset' was not declared in this scope 25 | memset(dp, INF, sizeof dp); | ^~~~~~ a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' +++ |+#include <cstring> 1 | +a#include <bits/stdc++.h> a.cc:32:21: error: 'min' was not declared in this scope; did you mean 'main'? 32 | r = min(r, dp[j][k]+c); | ^~~ | main a.cc:37:54: error: 'min' was not declared in this scope; did you mean 'main'? 37 | for(int i = 1; i*ma < Z and i*mb < Z; i++) ans = min(ans,dp[i*ma][i*mb]); | ^~~ | main a.cc:38:5: error: 'cout' was not declared in this scope 38 | cout << (ans == INF? -1 : ans) << endl; | ^~~~
s872979636
p03806
C++
N, Ma, Mb = map(int,input().split()) rate = Ma / Mb a = [0] * N b = [0] * N c = [0] * N MA = 0 MB = 0 MC = 0 for i in range(N): a[i], b[i], c[i] = map(int, input().split()) MA += a[i] MB += b[i] MC += c[i] dp = [[[MC for i in range(MB+1)] for j in range(MA+1)] for k in range(N+1)] dp[0][0][0] = 0 for it_N in range(N): for it_MA in range(MA+1): for it_MB in range(MB+1): if it_MA >= a[it_N] and it_MB >= b[it_N]: if dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] != MC: dp[it_N+1][it_MA][it_MB] = min(dp[it_N][it_MA-a[it_N]][it_MB-b[it_N]] + c[it_N], dp[it_N][it_MA][it_MB]) else: dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB] else: dp[it_N+1][it_MA][it_MB]=dp[it_N][it_MA][it_MB] ans = -1 for a in range(1, MA+1): for b in range(1, MB+1): if a/b == rate and dp[N][a][b] != MC: if ans == -1: ans = dp[N][a][b] else: ans = min(dp[N][a][b], ans) print(ans)
a.cc:2:1: error: 'N' does not name a type 2 | N, Ma, Mb = map(int,input().split()) | ^
s582874332
p03806
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <cctype> #include <cassert> #include <climits> #include <string> #include <bitset> #include <cfloat> #include <unordered_set> #include <iomanip> using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typedef vector<pair<int,int> > vpii; typedef vector<vector<int> > vvi; typedef vector<vector<char> > vvc; typedef vector<vector<string> > vvs; typedef vector<vector<ll> > vvll; #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++) #define drep(i,n) for(int i = (n) - 1; i >= 0; --i) #define fin(ans) cout << (ans) << endl #define mp(p,q) make_pair(p, q) #define pb(n) push_back(n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) #define MATHPI acos(-1) int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dx4[4] = {1, 0, -1, 0}; int dy4[4] = {0, 1, 0, -1}; template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;} template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;} template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); } struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}}; const int INF = INT_MAX; const ll LLINF = 1LL<<60; const ll MOD = 1000000007; const double EPS = 1e-9; //状態の立て方はok、あとは細部 int main(){ int N,MA,MB; cin >> N >> MA >> MB; int dp[51][510][510];//[今まで見た個数][aの合計][bの合計]=最低金額 vll a(N),b(N),c(N); Fill(dp,INF); rep(i,N){ cin >> a[i] >> b[i] >> c[i]; } dp[0][0][0] = 0; rep(i,N){ rep(j,510){ rep(k,510){ if(dp[i][j][k] >= INF) continue; chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]); chmin(dp[i+1][j][k],dp[i][j][k]); } } } int ans=INF; rep(j,510){ rep(k,510){ //MA:MB = j:kであってほしいのでMA*J == MB*kがほしい if(MA*j != MB*k)continue; chmin(ans,dp[N][j][k]); } } if(ans < INF)fin(ans); else fin(-1); }
a.cc: In function 'int main()': a.cc:81:24: error: no matching function for call to 'chmin(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 81 | chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:52:32: note: candidate: 'template<class T> bool chmin(T&, T)' 52 | template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;} | ^~~~~ a.cc:52:32: note: template argument deduction/substitution failed: a.cc:81:24: note: deduced conflicting types for parameter 'T' ('int' and 'long long int') 81 | chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s321737349
p03806
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <vector> #include <list> #include <set> #include <map> #include <queue> #include <stack> #include <cctype> #include <cassert> #include <climits> #include <string> #include <bitset> #include <cfloat> #include <unordered_set> #include <iomanip> using namespace std; typedef long double ld; typedef long long int ll; typedef unsigned long long int ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<char> vc; typedef vector<bool> vb; typedef vector<double> vd; typedef vector<string> vs; typedef vector<ll> vll; typedef vector<pair<int,int> > vpii; typedef vector<vector<int> > vvi; typedef vector<vector<char> > vvc; typedef vector<vector<string> > vvs; typedef vector<vector<ll> > vvll; #define rep(i,n) for(int i = 0; i < (n); ++i) #define rrep(i,n) for(int i = 1; i <= (n); ++i) #define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++) #define drep(i,n) for(int i = (n) - 1; i >= 0; --i) #define fin(ans) cout << (ans) << endl #define mp(p,q) make_pair(p, q) #define pb(n) push_back(n) #define all(a) a.begin(), a.end() #define rall(a) a.rbegin(), a.rend() #define Sort(a) sort(a.begin(), a.end()) #define Rort(a) sort(a.rbegin(), a.rend()) #define MATHPI acos(-1) int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1}; int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int dx4[4] = {1, 0, -1, 0}; int dy4[4] = {0, 1, 0, -1}; template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;} template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;} template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); } struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}}; const int INF = INT_MAX; const ll LLINF = 1LL<<60; const ll MOD = 1000000007; const double EPS = 1e-9; //状態の立て方はok、あとは細部 int main(){ int N,MA,MB; cin >> N >> MA >> MB; int dp[51][510][510];//[今まで見た個数][aの合計][bの合計]=最低金額 vll a(N),b(N),c(N); Fill(dp,INF); rep(i,N){ cin >> a[i] >> b[i] >> c[i]; } d[0][0][0] = 0; rep(i,N){ rep(j,510){ rep(k,510){ if(dp[i][j][k] >= INF) continue; chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]); chmin(dp[i+1][j][k],dp[i][j][k]); } } } int ans=INF; rep(j,510){ rep(k,510){ //MA:MB = j:kであってほしいのでMA*J == MB*kがほしい if(MA*j != MB*k)continue; chmin(ans,dp[N][j][k]); } } if(ans < INF)fin(ans); else fin(-1) }
a.cc: In function 'int main()': a.cc:76:5: error: 'd' was not declared in this scope 76 | d[0][0][0] = 0; | ^ a.cc:81:24: error: no matching function for call to 'chmin(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)' 81 | chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:52:32: note: candidate: 'template<class T> bool chmin(T&, T)' 52 | template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;} | ^~~~~ a.cc:52:32: note: template argument deduction/substitution failed: a.cc:81:24: note: deduced conflicting types for parameter 'T' ('int' and 'long long int') 81 | chmin(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k] + c[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:97:1: error: expected ';' before '}' token 97 | } | ^
s592818342
p03806
C++
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; #define rep(i, n) REP(i, 0, n) #define repr(i, n) for (int i = (n); i >= 0; i--) #define ALL(v) v.begin(), v.end() #define MSG(a) cout << #a << " " << a << endl; #define REP(i, x, n) for (int i = x; i < n; i++) #define OP(m) cout << m << endl typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> pii; const int inf = 1000000; int dp[41][401][401]; int main() { int n, ma, mb; cin >> n >> ma >> mb; int a[n], b[n], c[n]; rep(i, n) cin >> a[i] >> b[i] >> c[i]; rep(i, n + 1) rep(j, ) rep(k, ) dp[i][j][k] = inf; dp[0][0][0] = 0; rep(i, n) { rep(j, ) { rep(k, ) { if (j - a[i] >= 0 && k - b[i] >= 0) dp[i + 1][j][k] = min(dp[i][j - a[i]][k - b[i]] + c[i], dp[i + 1][j][k]); dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]); } } } int ans = 1e7; rep(j, 401) { rep(k, 401) { if (j * k == 0) continue; if (j * mb == k * ma) ans = min(ans, dp[n][j][k]); } } OP((ans == inf ? -1 : ans)); return 0; }
a.cc: In function 'int main()': a.cc:9:43: error: expected primary-expression before ';' token 9 | #define REP(i, x, n) for (int i = x; i < n; i++) | ^ a.cc:5:19: note: in expansion of macro 'REP' 5 | #define rep(i, n) REP(i, 0, n) | ^~~ a.cc:28:19: note: in expansion of macro 'rep' 28 | rep(i, n + 1) rep(j, ) rep(k, ) dp[i][j][k] = inf; | ^~~ a.cc:9:43: error: expected primary-expression before ';' token 9 | #define REP(i, x, n) for (int i = x; i < n; i++) | ^ a.cc:5:19: note: in expansion of macro 'REP' 5 | #define rep(i, n) REP(i, 0, n) | ^~~ a.cc:28:28: note: in expansion of macro 'rep' 28 | rep(i, n + 1) rep(j, ) rep(k, ) dp[i][j][k] = inf; | ^~~ a.cc:9:43: error: expected primary-expression before ';' token 9 | #define REP(i, x, n) for (int i = x; i < n; i++) | ^ a.cc:5:19: note: in expansion of macro 'REP' 5 | #define rep(i, n) REP(i, 0, n) | ^~~ a.cc:34:9: note: in expansion of macro 'rep' 34 | rep(j, ) | ^~~ a.cc:9:43: error: expected primary-expression before ';' token 9 | #define REP(i, x, n) for (int i = x; i < n; i++) | ^ a.cc:5:19: note: in expansion of macro 'REP' 5 | #define rep(i, n) REP(i, 0, n) | ^~~ a.cc:36:13: note: in expansion of macro 'rep' 36 | rep(k, ) | ^~~
s302322870
p03806
C++
#include "iostream" #include "vector" #include "iomanip" #include "algorithm" #include "vector" typedef struct { int a; int b; int c; int exist; }Drag; bool next_choice(std::vector<Drag> *d, long int *n, int *keta) { for(int i = 0; i < (*d).size(); ++i) if ((*d)[i].exist) (*d)[i].exist = false; else { (*d)[i].exist = true; (*n)++; *keta = log2(*n) + 1; return true; } return false; } Drag drag_mix(std::vector<Drag> d, int min, int keta) { Drag price = {0, 0, 0, 1}; for (int i = 0; i < keta; ++i) if (d[i].exist) { price.a += d[i].a; price.b += d[i].b; price.c += d[i].c; if (price.c >= min && min != -1) { price.exist = 0; return price; } } return price; } int main() { int n; double ma, mb; std::cin >> n; std::cin >> ma; std::cin >> mb; std::vector<Drag> drag(n); for (int i = 0; i < n; ++i) { std::cin >> drag[i].a; std::cin >> drag[i].b; std::cin >> drag[i].c; } long int num = 0; int keta; double m = ma / mb; Drag mix; int min = -1; while(next_choice(&drag, &num, &keta)){ mix = drag_mix(drag, min, keta); if (mix.exist && (double)mix.a / mix.b == m) if(min == -1 || mix.c < min) min = mix.c; }; std::cout << min; }
a.cc: In function 'bool next_choice(std::vector<Drag>*, long int*, int*)': a.cc:21:33: error: 'log2' was not declared in this scope 21 | *keta = log2(*n) + 1; | ^~~~
s758346670
p03806
C++
#include <stdio.h> #include <iostream> #include <string> #include <vector> #include <utility> #include <algorithm> #include <queue> #include <list> #include <stack> using namespace std; struct drag { int m, val; }; int n; int ma, mb; int result; vector<drag> v; void calc(int cost, int i, int m) { if (i == n) { if (m != 0) return; if (cost == 0) return; if (cost < result) result = cost; } else { if (cost >= result) return; // 次の製品がm = 0でもcostは高くなるのでx if (m == 0 && cost > 0) { result = cost; return; } if (m + v[i].m <= 0) { calc(cost + v[i].val, i + 1, m + v[i].m); calc(cost, i + 1, m); } } } int main() { result = INT_MAX; cin >> n >> ma >> mb; v.resize(n); for (int i = 0; i < n; i++) { int a, b; cin >> a >> b >> v[i].val; v[i].m = a * mb - b * ma; } sort(v.begin(), v.end(), [](drag &l, drag &r) {return l.m < r.m; }); stable_sort(v.begin(), v.end(), [](drag &l, drag &r) {return l.val < r.val; }); int plus = 0; int minus = -1; for (int i = 0; i < n; i++) if (v[i].m >= 0) { if (minus == -1) minus = i - 1; plus += v[i].m; } if (minus >= 0 && plus + v[minus].m < 0) { printf("-1"); return; } calc(0, 0, 0); if (result == INT_MAX) result = -1; printf("%d", result); return 0; }
a.cc: In function 'int main()': a.cc:56:18: error: 'INT_MAX' was not declared in this scope 56 | result = INT_MAX; | ^~~~~~~ a.cc:10:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 9 | #include <stack> +++ |+#include <climits> 10 | a.cc:80:17: error: return-statement with no value, in function returning 'int' [-fpermissive] 80 | return; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, 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:2: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<drag*, std::vector<drag> >; _Value = const drag; _Compare = main()::<lambda(drag&, drag&)>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Tp = drag; _Compare = __gnu_cxx::__ops::_Iter_comp_val<main()::<lambda(drag&, drag&)> >]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2460:26: required from 'void std::__merge_without_buffer(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Compare) [with _BidirectionalIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Distance = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(drag&, drag&)> >]' 2460 | = std::__lower_bound(__middle, __last, *__first_cut, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2461 | __gnu_cxx::__ops::__iter_comp_val(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2754:34: required from 'void std::__inplace_stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(drag&, drag&)> >]' 2754 | std::__merge_without_buffer(__first, __middle, __last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 2755 | __middle - __first, | ~~~~~~~~~~~~~~~~~~~ 2756 | __last - __middle, | ~~~~~~~~~~~~~~~~~~ 2757 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4956:28: required from 'void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(drag&, drag&)> >]' 4956 | std::__inplace_stable_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5030:36: required from 'void std::stable_sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Compare = main()::<lambda(drag&, drag&)>]' 5030 | _GLIBCXX_STD_A::__stable_sort(__first, __last, | ^ a.cc:66:13: required from here 66 | stable_sort(v.begin(), v.end(), [](drag &l, drag &r) {return l.val < r.val; }); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:196:30: error: no match for call to '(main()::<lambda(drag&, drag&)>) (drag&, const drag&)' 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:196:30: note: candidate: 'bool (*)(drag&, drag&)' (conversion) /usr/include/c++/14/bits/predefined_ops.h:196:30: note: conversion of argument 3 would be ill-formed: /usr/include/c++/14/bits/predefined_ops.h:196:30: error: binding reference of type 'drag&' to 'const drag' discards qualifiers a.cc:66:41: note: candidate: 'main()::<lambda(drag&, drag&)>' (near match) 66 | stable_sort(v.begin(), v.end(), [](drag &l, drag &r) {return l.val < r.val; }); | ^ a.cc:66:41: note: conversion of argument 2 would be ill-formed: a.cc:66:41: error: binding reference of type 'drag&' to 'const drag' discards qualifiers /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = const drag; _Iterator = __gnu_cxx::__normal_iterator<drag*, std::vector<drag> >; _Compare = main()::<lambda(drag&, drag&)>]': /usr/include/c++/14/bits/stl_algo.h:1993:14: required from '_ForwardIterator std::__upper_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Tp = drag; _Compare = __gnu_cxx::__ops::_Val_comp_iter<main()::<lambda(drag&, drag&)> >]' 1993 | if (__comp(__val, __middle)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2469:26: required from 'void std::__merge_without_buffer(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Distance, _Distance, _Compare) [with _BidirectionalIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Distance = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(drag&, drag&)> >]' 2469 | = std::__upper_bound(__first, __middle, *__second_cut, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2470 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:2754:34: required from 'void std::__inplace_stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(drag&, drag&)> >]' 2754 | std::__merge_without_buffer(__first, __middle, __last, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 2755 | __middle - __first, | ~~~~~~~~~~~~~~~~~~~ 2756 | __last - __middle, | ~~~~~~~~~~~~~~~~~~ 2757 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4956:28: required from 'void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<main()::<lambda(drag&, drag&)> >]' 4956 | std::__inplace_stable_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:5030:36: required from 'void std::stable_sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<drag*, vector<drag> >; _Compare = main()::<lambda(drag&, drag&)>]' 5030 | _GLIBCXX_STD_A::__stable_sort(__first, __last, | ^ a.cc:66:13: required from here 66 | stable_sort(v.begin(), v.end(), [](drag &l, drag &r) {return l.val < r.val; }); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(main()::<lambda(drag&, drag&)>) (const drag&, drag&)' 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: note: candidate: 'bool (*)(drag&, drag&)' (conversion) /usr/include/c++/14/bits/predefined_ops.h:240:30: note: conversion of argument 2 would be ill-formed: /usr/include/c++/14/bits/predefined_ops.h:240:30: error: binding reference of type 'drag&' to 'const drag' discards qualifiers a.cc:66:41: note: candidate: 'main()::<lambda(drag&, drag&)>' (near match) 66 | stable_sort(v.begin(), v.end(), [](drag &l, drag &r) {return l.val < r.val; }); | ^ a.cc:66:41: note: conversion of argument 1 would be ill-formed: a.cc:66:41: error: binding reference of type 'drag&' to 'const drag' discards qualifiers
s179646479
p03806
C++
#include <bits/stdc++.h> using namespace std; const int MAXN = 40; const int abmax = 10; const int inf = 1000000; int a[MAXN], b[MAXN],c[MAXN]; int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1]; int main(){ int N, Ma, Mb; cin >> N >> Ma >> Mb; for(int i=0;i<N;i++){ cin >> a[i] >> b[i] >> c[i]; } for(int i=0;i<=MAXN;i++){ for(int j=0;j<=MAXN*abmax;j++){ for(int k=0;k<=MAXN*abmax;k++){ dp[i][j][k]=inf; } } } dp[0][0][0] = 0; for(int i=0;i<N;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax){ if(dp[i][j][k]==inf) continue; dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]); dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]); } } } int ans=inf; for(int i=1;i<=MAXN*abmax; ++i){ for(int j = 1;j<=MAXN*abmax;++j){ if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:34: error: expected ';' before ')' token 26 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:27:38: error: expected ';' before ')' token 27 | for(int k=0;k<=MAXN*abmax){ | ^ | ;
s174027193
p03806
C++
#include <bits/stdc++.h> using namespace std; const int MAXN = 40; const int abmax = 10; const int inf = 1000000; int a[MAXN], b[MAXN],c[MAXN]; int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1]; int main(){ int N, Ma, Mb; cin >> N >> Ma >> Mb; for(int i=0;i<N;i++){ cin >> a[i] >> b[i] >> c[i]; } for(int i=0;i<=MAXN;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax){ dp[i][j][k]=inf; } } } dp[0][0][0] = 0; for(int i=0;i<N;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax){ if(dp[i][j][k]==inf) continue; dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]); dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]); } } } int ans=inf; for(int i=1;i<=MAXN*abmax; ++i){ for(int j = 1;j<=MAXN*abmax;++j){ if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:34: error: expected ';' before ')' token 17 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:18:38: error: expected ';' before ')' token 18 | for(int k=0;k<=MAXN*abmax){ | ^ | ; a.cc:26:34: error: expected ';' before ')' token 26 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:27:38: error: expected ';' before ')' token 27 | for(int k=0;k<=MAXN*abmax){ | ^ | ;
s494772420
p03806
C++
#include <bits/stdc++.h> using namespace std; const int MAXN = 40; const int abmax = 10; const int inf = 1000000; int a[MAXN], b[MAXN],c[MAXN]; int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1]; int main(){ int N, Ma, Mb; cin >> N >> Ma >> Mb; for(int i=0;i<N;i++){ cin >> a[i] >> b[i] >> c[i]; } for(int i=0;i<=MAXN;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax){ dp[i][j][k]=inf; } } } dp[0][0][0] = 0; for(int i=0;i<N;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax){ if(dp[i][j][k]==inf) continue; dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]); dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]); } } } int ans=inf; for(int i=1;i<=MAXN*abmax; ++i){ for(int j = 1;j<=MAXN*abmax;++j){ if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:34: error: expected ';' before ')' token 17 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:18:38: error: expected ';' before ')' token 18 | for(int k=0;k<=MAXN*abmax){ | ^ | ; a.cc:26:34: error: expected ';' before ')' token 26 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:27:38: error: expected ';' before ')' token 27 | for(int k=0;k<=MAXN*abmax){ | ^ | ;
s699429911
p03806
C++
#include <bits/stdc++.h> using namespace std; const int MAXN = 40; const int abmax = 10; const int inf = 1000000; int a[MAXN], b[MAXN],c[MAXN]; int dp[MAXN+1][MAXN*abmax+1][MAXN*abmax+1]; int main(){ int N, Ma, Mb; cin >> N >> Ma >> Mb; for(int i=0;i<N;i++){ cin >> a[i] >> b[i] >> c[i]; } for(int i=0;i<=MAXN;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax) dp[i][j][k]=inf; } } dp[0][0][0] = 0; for(int i=0;i<N;i++){ for(int j=0;j<=MAXN*abmax){ for(int k=0;k<=MAXN*abmax){ if(dp[i][j][k]==inf) continue; dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]); dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j][k],dp[i][j][k]+c[i]); } } } int ans=inf; for(int i=1;i<=MAXN*abmax; ++i){ for(int j = 1;j<=MAXN*abmax;++j){ if(i*Mb==j*Ma) ans = min(ans,dp[N][i][j]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:34: error: expected ';' before ')' token 17 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:18:38: error: expected ';' before ')' token 18 | for(int k=0;k<=MAXN*abmax) | ^ | ; a.cc:25:34: error: expected ';' before ')' token 25 | for(int j=0;j<=MAXN*abmax){ | ^ | ; a.cc:26:38: error: expected ';' before ')' token 26 | for(int k=0;k<=MAXN*abmax){ | ^ | ;
s169033687
p03806
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define co(a) cout<<a<<endl #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define V2(a,b,c) V<V<int>> a(b,V<int>(c)) #define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d)) #define incin(a) int a; cin>>a #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(),a.end()),a.end()) #define pri priority_queue #define Pri priority_queue<int,vector<int>,greater<int>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(),(a).end() #define Pi P<int,int> #define elif else if int low(V<int> a,int b){ decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } int upp(V<int> a,int b){ decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int gcm(int a,int b){ if(a%b==0) return b; return gcm(b,a%b); } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; double b=sqrt(a); for(int i=3;i<=b;i+=2){ if(a%i==0){ return false; } } return true; } struct Union{ vector<int> par; Union(int a){ par=vector<int>(a,-1); } int find(int a){ if(par[a]<0) return a; else return par[a]=find(par[a]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } int lcm(int a,int b){ return a/gcm(a,b)*b; } bool fe(int a,int b){ a%=10; b%=10; if(a==0) a=10; if(b==0) b=10; if(a>b) return true; else return false; } int INF=1000000007; struct edge{int s,t,d; }; V<int> mojisyu(string a){ V<int> b(26,0); fo(i,a.sz){ b[a[i]-'a']++; } return b; } int wa2(int a){ if(a%2==1) return a/2; return a/2-1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n,int r){ int a=1; r=min(r,n-r); for(int i=n;i>n-r;i--){ a*=i; a/=n-i+1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a){ int b=1; fo(i,a) b*=i+1; return b; } int nPr(int a,int b){ int c=1; for(int i=a;i>=b;i--) c*=i; return c; } int MOD=INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 //先にCOMinit()で前処理をする //ABC145D void COMinit() { fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i<1000010;i++){ fac[i]=fac[i-1]*i%MOD; inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; finv[i]=finv[i-1]*inv[i]%MOD; } } // 二項係数計算 int COM(int n,int k){ if(n<k) return 0; if(n<0||k<0) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } signed main(){ int a,b,c; cin>>a>>b>>c; V<P<P<int,int>,int>> d(a); fo(i,a) cin>>d[i].ff>>d[i].fs>>d[i].se; int e=a*10+5; int dp[a+1][e][e]; fo(i,a+1){ fo(j,e){ fo(k,e){ dp[i][j][k]=INF; } } } dp[0][0][0]=0; fo(i,a){ fo(j,e){ fo(k,e){ dp[i+1][j+d[i].ff][k+d[i].fs]=min(dp[i+1][j+d[i].ff][k+d[i].fs],dp[i][j][k]+d[i].se); } } } int f=-1; for(int i=1;i*max(b,c)<e){ fo(j,a+1){ if(dp[j][i*b][i*c]!=INF) f=dp[j][i*b][i*c]; } } cout<<f<<endl; }
a.cc: In function 'int main()': a.cc:269:27: error: expected ';' before ')' token 269 | for(int i=1;i*max(b,c)<e){ | ^ | ;
s268765368
p03806
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define co(a) cout<<a<<endl #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define V2(a,b,c) V<V<int>> a(b,V<int>(c)) #define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d)) #define incin(a) int a; cin>>a #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(),a.end()),a.end()) #define pri priority_queue #define Pri priority_queue<int,vector<int>,greater<int>> #define ff first.first #define fs first.second #define sf second.first #define ss second.second #define all(a) (a).begin(),(a).end() #define Pi P<int,int> #define elif else if int low(V<int> a,int b){ decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } int upp(V<int> a,int b){ decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int gcm(int a,int b){ if(a%b==0) return b; return gcm(b,a%b); } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; double b=sqrt(a); for(int i=3;i<=b;i+=2){ if(a%i==0){ return false; } } return true; } struct Union{ vector<int> par; Union(int a){ par=vector<int>(a,-1); } int find(int a){ if(par[a]<0) return a; else return par[a]=find(par[a]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } int lcm(int a,int b){ return a/gcm(a,b)*b; } bool fe(int a,int b){ a%=10; b%=10; if(a==0) a=10; if(b==0) b=10; if(a>b) return true; else return false; } int INF=1000000007; struct edge{int s,t,d; }; V<int> mojisyu(string a){ V<int> b(26,0); fo(i,a.sz){ b[a[i]-'a']++; } return b; } int wa2(int a){ if(a%2==1) return a/2; return a/2-1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n,int r){ int a=1; r=min(r,n-r); for(int i=n;i>n-r;i--){ a*=i; a/=n-i+1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a){ int b=1; fo(i,a) b*=i+1; return b; } int nPr(int a,int b){ int c=1; for(int i=a;i>=b;i--) c*=i; return c; } int MOD=INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 //先にCOMinit()で前処理をする //ABC145D void COMinit() { fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i<1000010;i++){ fac[i]=fac[i-1]*i%MOD; inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; finv[i]=finv[i-1]*inv[i]%MOD; } } // 二項係数計算 int COM(int n,int k){ if(n<k) return 0; if(n<0||k<0) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } signed main(){ int a,b,c; cin>>a>>b>>c; V<P<P<int,int>,int>> d(a); fo(i,a) cin>>d[i].ff>>d[i].fs>>d[i].se; int e=a*10+5; int dp[a+1][e][e]; fo(i,a+1){ fo(j,e){ fo(k,e){ dp[i][j][k]=INF; } } } dp[0][0][0]=0; fo(i,a){ fo(j,e){ fo(k,e){ dp[i+1][j+d[i].ff][k+d[i].fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d[i].se); } } } int f=-1; for(int i=1;i*max(b,c)<e){ fo(j,a+1){ if(dp[j][i*b][i*c]!=INF) f=dp[j][i*b][i*c]; } } cout<<f<<endl; }
a.cc: In function 'int main()': a.cc:25:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 25 | #define ff first.first | ^~~~~ a.cc:264:55: note: in expansion of macro 'ff' 264 | dp[i+1][j+d[i].ff][k+d[i].fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d[i].se); | ^~ a.cc:26:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 26 | #define fs first.second | ^~~~~ a.cc:264:63: note: in expansion of macro 'fs' 264 | dp[i+1][j+d[i].ff][k+d[i].fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d[i].se); | ^~ a.cc:269:27: error: expected ';' before ')' token 269 | for(int i=1;i*max(b,c)<e){ | ^ | ;
s935031278
p03806
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define double long double #define fo(a,b) for(int a=0;a<b;a++) #define Sort(a) sort(a.begin(),a.end()) #define rev(a) reverse(a.begin(),a.end()) #define fi first #define se second #define co(a) cout<<a<<endl #define sz size() #define bgn begin() #define en end() #define pb push_back #define pp() pop_back() #define V vector #define P pair #define V2(a,b,c) V<V<int>> a(b,V<int>(c)) #define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d)) #define incin(a) int a; cin>>a #define yuko(a) setprecision(a) #define uni(a) a.erase(unique(a.begin(),a.end()),a.end()) #define pri priority_queue #define Pri priority_queue<int,vector<int>,greater<int>> #define ff fi.fi #define fs fi.se #define sf se.fi #define ss se.se #define all(a) (a).begin(),(a).end() #define Pi P<int,int> #define elif else if int low(V<int> a,int b){ decltype(a)::iterator c=lower_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } int upp(V<int> a,int b){ decltype(a)::iterator c=upper_bound(a.begin(),a.end(),b); int d=c-a.bgn; return d; } template<class T> void cou(vector<vector<T>> a){ int b=a.size(); int c=a[0].size(); fo(i,b){ fo(j,c){ cout<<a[i][j]; if(j==c-1) cout<<endl; else cout<<' '; } } } int wari(int a,int b) { if(a%b==0) return a/b; else return a/b+1; } int keta(int a){ double b=a; b=log10(b); int c=b; return c+1; } int souwa(int a){ return a*(a+1)/2; } int gcm(int a,int b){ if(a%b==0) return b; return gcm(b,a%b); } bool prime(int a){ if(a<2) return false; else if(a==2) return true; else if(a%2==0) return false; double b=sqrt(a); for(int i=3;i<=b;i+=2){ if(a%i==0){ return false; } } return true; } struct Union{ vector<int> par; Union(int a){ par=vector<int>(a,-1); } int find(int a){ if(par[a]<0) return a; else return par[a]=find(par[a]); } bool same(int a,int b){ return find(a)==find(b); } int Size(int a){ return -par[find(a)]; } void unite(int a,int b){ a=find(a); b=find(b); if(a==b) return; if(Size(b)>Size(a)) swap<int>(a,b); par[a]+=par[b]; par[b]=a; } }; int ketas(int a){ string b=to_string(a); int c=0; fo(i,keta(a)){ c+=b[i]-'0'; } return c; } int lcm(int a,int b){ return a/gcm(a,b)*b; } bool fe(int a,int b){ a%=10; b%=10; if(a==0) a=10; if(b==0) b=10; if(a>b) return true; else return false; } int INF=1000000007; struct edge{int s,t,d; }; V<int> mojisyu(string a){ V<int> b(26,0); fo(i,a.sz){ b[a[i]-'a']++; } return b; } int wa2(int a){ if(a%2==1) return a/2; return a/2-1; } /*signed main(){ int a,b,c; cin>>a>>b>>c; V<V<edge>> d(a); fo(i,b){ edge e; cin>>e.s>>e.t>>e.d; d[e.s].pb(e); } V<int> e(a,INF); e[c]=0; priority_queue<P<int,int>,V<P<int,int>>,greater<P<int,int>>> f; f.push({0,c}); int h=INF; while(!f.empty()){ P<int,int> g; g=f.top(); f.pop(); int v = g.second, i = g.first; for(edge l : d[v]){ if(e[l.t] > i + l.d){ e[l.t] = i + l.d; f.push({i+l.d , l.t}); } } } fo(i,a){ if(e[i]==INF) cout<<"INF"<<endl; else cout<<e[i]<<endl; } } ?*/ int nCr(int n,int r){ int a=1; r=min(r,n-r); for(int i=n;i>n-r;i--){ a*=i; a/=n-i+1; } return a; } /*void sea(int x,int y){ if(x<0||a<=x||y<0||b<=y||c[x][y]=='#') return; if(d[x][y]) return; d[x][y]++; sea(x+1,y); sea(x-1,y); sea(x,y+1); sea(x,y-1); }*/ int kaijou(int a){ int b=1; fo(i,a) b*=i+1; return b; } int nPr(int a,int b){ int c=1; for(int i=a;i>=b;i--) c*=i; return c; } int MOD=INF; int fac[1000010], finv[1000010], inv[1000010]; // テーブルを作る前処理 //先にCOMinit()で前処理をする //ABC145D void COMinit() { fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for(int i=2;i<1000010;i++){ fac[i]=fac[i-1]*i%MOD; inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD; finv[i]=finv[i-1]*inv[i]%MOD; } } // 二項係数計算 int COM(int n,int k){ if(n<k) return 0; if(n<0||k<0) return 0; return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD; } signed main(){ int a,b,c; cin>>a>>b>>c; V<P<P<int,int>,int>> d(a); fo(i,a) cin>>d.ff>>d.fs>>d.se; int e=a*10+5; int dp[a+1][e][e]; fo(i,a+1){ fo(j,e){ fo(k,e){ dp[i][j][k]=INF; } } } dp[0][0][0]=0; fo(i,a){ fo(j,e){ fo(k,e){ dp[i+1][j+d.ff][k+d.fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d.se); } } } int f=-1; for(int i=1;i*max(b,c)<e){ fo(j,a+1){ if(dp[j][i*b][i*c]!=INF) f=dp[j][i*b][i*c]; } } cout<<f<<endl; }
a.cc: In function 'int main()': a.cc:8:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 8 | #define fi first | ^~~~~ a.cc:25:12: note: in expansion of macro 'fi' 25 | #define ff fi.fi | ^~ a.cc:250:10: note: in expansion of macro 'ff' 250 | cin>>d.ff>>d.fs>>d.se; | ^~ a.cc:8:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 8 | #define fi first | ^~~~~ a.cc:26:12: note: in expansion of macro 'fi' 26 | #define fs fi.se | ^~ a.cc:250:16: note: in expansion of macro 'fs' 250 | cin>>d.ff>>d.fs>>d.se; | ^~ a.cc:9:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'second' 9 | #define se second | ^~~~~~ a.cc:250:22: note: in expansion of macro 'se' 250 | cin>>d.ff>>d.fs>>d.se; | ^~ a.cc:8:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 8 | #define fi first | ^~~~~ a.cc:25:12: note: in expansion of macro 'fi' 25 | #define ff fi.fi | ^~ a.cc:264:21: note: in expansion of macro 'ff' 264 | dp[i+1][j+d.ff][k+d.fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d.se); | ^~ a.cc:8:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 8 | #define fi first | ^~~~~ a.cc:26:12: note: in expansion of macro 'fi' 26 | #define fs fi.se | ^~ a.cc:264:29: note: in expansion of macro 'fs' 264 | dp[i+1][j+d.ff][k+d.fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d.se); | ^~ a.cc:8:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 8 | #define fi first | ^~~~~ a.cc:25:12: note: in expansion of macro 'fi' 25 | #define ff fi.fi | ^~ a.cc:264:49: note: in expansion of macro 'ff' 264 | dp[i+1][j+d.ff][k+d.fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d.se); | ^~ a.cc:8:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'first' 8 | #define fi first | ^~~~~ a.cc:26:12: note: in expansion of macro 'fi' 26 | #define fs fi.se | ^~ a.cc:264:57: note: in expansion of macro 'fs' 264 | dp[i+1][j+d.ff][k+d.fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d.se); | ^~ a.cc:9:12: error: 'class std::vector<std::pair<std::pair<long long int, long long int>, long long int> >' has no member named 'second' 9 | #define se second | ^~~~~~ a.cc:264:75: note: in expansion of macro 'se' 264 | dp[i+1][j+d.ff][k+d.fs]=min(dp[i+1][j+d.ff][k+d.fs],dp[i][j][k]+d.se); | ^~ a.cc:269:27: error: expected ';' before ')' token 269 | for(int i=1;i*max(b,c)<e){ | ^ | ;
s261938609
p03806
C++
#include <bits/stdc++.h> #include <iostream> #include <algorithm> using namespace std; int main(){ int n,m,l,a[45],b[45],c[45],dp[45][410][410]={1e9},ans =1e9; cin >> n >> m >> l; for(int i=0;i<n;i++){ cin >> a[i] >> b[i] >> c[i]; } dp[0][0][0] =0; for(int i=0;i<n;i++){ for(int j=0;j<410;j++){ for(int k=0;k<410;k++){ if(dp[i][j][k] == 1e9){ continue; } dp[i+1][j][k] = min(dp[i][j][k],dp[i+1][j][k]); dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]); } } } for(int j=0;j<410;j++){ for(int k=0;k<410;k++){ if(k*m ==j*l){ ans = min(dp[n][j][k],ans); } } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:8:49: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing] 8 | int n,m,l,a[45],b[45],c[45],dp[45][410][410]={1e9},ans =1e9; | ^~~
s243850281
p03806
Java
import java.util.*; public class ABC054{ static int[] a, b, c; static int n, ma, mb; static int opt=Integer.MAX_VALUE; public static void main(String[] args){ Scanner sc=new Scanner(System.in); n=Integer.parseInt(sc.next()); ma=Integer.parseInt(sc.next()); mb=Integer.parseInt(sc.next()); a=new int[n]; b=new int[n]; c=new int[n]; for(int i=0;i<n;i++){ a[i]=Integer.parseInt(sc.next()); b[i]=Integer.parseInt(sc.next()); c[i]=Integer.parseInt(sc.next()); } sc.close(); int ans=search(0, 0, 0, 0); if(ans==Integer.MAX_VALUE) ans=-1; System.out.println(ans); } public static int search(int sumA, int sumB, int sumC, int st){ if(sumC>=opt) return opt; if((sumA+a[st])*mb==(sumB+b[st])*ma){ opt=Math.min(opt,sumC+c[st]); if(st==n-1) return opt; return Math.min(opt, search(sumA, sumB, sumC, st+1)); } if(st==n-1) return opt; return Math.min(Math.min(opt,search(sumA, sumB, sumC, st+1)), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1)); } }
Main.java:3: error: class ABC054 is public, should be declared in a file named ABC054.java public class ABC054{ ^ 1 error
s315309400
p03806
C++
#include <iostream> #define MAX 5000 using namespace std ; int a[40],b[40],c[40],n,ma,mb,opt; int search(int sumA, int sumB, int sumC, int st){ if(sumC>=opt) return opt; if((sumA+a[st])*mb==(sumB+b[st])*ma){ opt=min(opt,sumC+c[st]); if(st==n-1) return opt; return min(opt, search(sumA, sumB, sumC, st+1)); } if(st==n-1) return opt; return min(opt, search(sumA, sumB, sumC, st+1), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1)); } int main(void){ opt=MAX; cin>>n>>ma>>mb; for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]; opt=search(0,0,0,0); if(opt>=MAX) opt=-1; cout<<opt<<endl; }
In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]': a.cc:14:15: required from here 14 | return min(opt, search(sumA, sumB, sumC, st+1), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1)); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function 284 | if (__comp(__b, __a)) | ~~~~~~^~~~~~~~~~
s427631298
p03806
C++
#include <iostream> using namespace std ; int a[50], b[50], c[50], n, ma, mb, opt; int search(int sumA, int sumB, int sumC, int st){ if(sumC>=opt) return 5000; if((sumA+a[st])*mb==(sumB+b[st])*ma){ if(sumC+c[st]<opt) opt=sumC+c[st]; return sumC+c[st]; } else{ if(st==n-1) return 5000; else{ int a=search(sumA, sumB, sumC, st+1); int b=search(sumA+a[st], sumB+b[st], sumC+c[st], st+1); return min(a,b); } } } int main(void){ opt=5000; cin>>n>>ma>>mb; for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]; search(0,0,0,0); if(opt>=5000||opt==0) opt=-1; cout<<opt<<endl; }
a.cc: In function 'int search(int, int, int, int)': a.cc:15:32: error: invalid types 'int[int]' for array subscript 15 | int b=search(sumA+a[st], sumB+b[st], sumC+c[st], st+1); | ^ a.cc:15:44: error: invalid types 'int[int]' for array subscript 15 | int b=search(sumA+a[st], sumB+b[st], sumC+c[st], st+1); | ^
s855926737
p03806
C++
#include <iostream> #include <string> using namespace std ; int a[50], b[50], c[50], n, ma, mb, opt; int search(int sumA, int sumB, int sumC, int st){ if(sumC>=opt){ string s=(sumA+" "+sumB+" "+sumC+" "+st+" "+" opt:"+opt); return 5000; } if((sumA+a[st])*mb==(sumB+b[st])*ma){ if(sumC+c[st]<opt) opt=sumC+c[st]; return sumC+c[st]; } else{ if(st==n-1) return 5000; else return min(search(sumA, sumB, sumC, st+1), search(sumA+a[st], sumB+b[st], sumC+c[st], st+1)); } } int main(void){ opt=5000; cin>>n>>ma>>mb; for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i]; search(0, 0, 0, 0); int ans=opt; if(ans>=5000||ans==0) ans=-1; cout<<ans<<endl; }
a.cc: In function 'int search(int, int, int, int)': a.cc:8:32: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+' 8 | string s=(sumA+" "+sumB+" "+sumC+" "+st+" "+" opt:"+opt); | ~~~~~~~~~~~~~^~~~ | | | | | const char [2] | const char*
s577334451
p03806
C++
#include<iostream> #include<stdio.h> #include<vector> #include<algorithm> #include<set> #include<string> #include<map> #include<string.h> #include<complex> #include<math.h> #include<queue> #include<time.h> using namespace std; typedef long long int llint; typedef pair<int, int> pint; typedef vector<bool> vbool; typedef vector<int> vint; typedef vector<vint> vvint; typedef vector<llint> vllint; typedef vector<vllint> vvllint; typedef vector<pair<int, int>> vpint; typedef vector<pair<llint, llint>> vpllint; #define rep(i,n) for(int i=0;i<n;i++) #define drep(i,n) for(int i=n-1;0<=i;i--) #define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl; #define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl; #define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl; #define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl; #define Pi 3.1415926535897932384626 #define coutans rep(i, ans.size())cout << ans[i] << endl; class UnionFind { public: //親の番号を格納する。親だった場合は-(その集合のサイズ) vector<int> Parent; //作るときはParentの値を全て-1にする //こうすると全てバラバラになる UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//親をとってきたい } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらひっくり返しちゃう。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; //aとbの最大公約数を求めるよ long long GCD(long long a, long long b) { if (b == 0) return a; else return GCD(b, a % b); } // 返り値: a と b の最大公約数 // ax + by = gcd(a, b) を満たす (x, y) が格納される long long extGCD(long long a, long long b, long long& x, long long& y) { if (b == 0) { x = 1; y = 0; return a; } long long d = extGCD(b, a % b, y, x); y -= a / b * x; return d; } bool check(int a, int b) { return a > b; } // mod. m での a の逆元 a^{-1} を計算する long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } //aCbを1000000007で割った余りを求める llint convination(llint a, llint b) { llint ans = 1; for (llint i = 0; i < b; i++) { ans *= a - i; ans %= 1000000007; } for (llint i = 1; i <= b; i++) { ans *= modinv(i, 1000000007); ans %= 1000000007; } return ans; } int dp[50][500][500]; int main() { rep(i, 50)rep(j, 500)rep(k, 500)dp[i][j][k] = INT_MAX; int n, ma, mb; cin >> n >> ma >> mb; vvint a(n, vint(3)); rep(i, n)rep(j, 3)cin >> a[i][j]; //dp[i][j][k]…i番目の薬品までで、Aがjグラム、Bがkグラムの時の最小コスト dp[0][0][0] = 0; rep(i, n) { rep(j, 500) { rep(k, 500) { if (dp[i][j][k] != INT_MAX) { dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]); dp[i + 1][j + a[i][0]][k + a[i][1]] = min(dp[i + 1][j + a[i][0]][k + a[i][1]], dp[i][j][k] + a[i][2]); } } } } int ans = INT_MAX; int x = ma, y = mb; while (x < 500 && y < 500) { ans = min(ans, dp[n][x][y]); x += ma; y += mb; } if (ans == INT_MAX)cout << -1 << endl; else cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:130:55: error: 'INT_MAX' was not declared in this scope 130 | rep(i, 50)rep(j, 500)rep(k, 500)dp[i][j][k] = INT_MAX; | ^~~~~~~ a.cc:12:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 11 | #include<queue> +++ |+#include <climits> 12 | #include<time.h> a.cc:140:52: error: 'INT_MAX' was not declared in this scope 140 | if (dp[i][j][k] != INT_MAX) { | ^~~~~~~ a.cc:140:52: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' a.cc:149:19: error: 'INT_MAX' was not declared in this scope 149 | int ans = INT_MAX; | ^~~~~~~ a.cc:149:19: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s740800245
p03806
C++
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll LLINF = 1LL<<60; const int INTINF = 1<<30; const int MOD = 1000000007; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N; ll ma,mb; vector<ll> a,b,c; ll dp[51][510][510]; int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> ma >> mb; a.resize(N); b.resize(N); c.resize(N); rep(i,N) cin >> a[i] >> b[i] >> c[i]; for (int i = 0; i < 51; ++i) for (int j = 0; j < 510; ++j) for (int k = 0; k < 510; ++k) dp[i][j][k] = LLINF; dp[0][0][0] = 0; rep(i,N){ rep(wa,500){ rep(wb,500){ if(dp[i][wa][wb] >= LLINF) continue; chmin(dp[i+1][wa][wb], dp[i][wa][wb]); chmin(dp[i+1][wa][wb], dp[i][wa][wb] + c[i]); } } } ll ans = LLINF; REP(wa,1,500){ REP(wb,1,500){ if (wa * mb != wb * ma) continue; chmin(ans, dp[N][wa][wb]); } } if (ans < INF) cout << ans << endl; else cout << -1 << endl; }
a.cc: In function 'int main()': a.cc:54:15: error: 'INF' was not declared in this scope 54 | if (ans < INF) cout << ans << endl; | ^~~
s515272537
p03806
C++
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll LLINF = 1LL<<60; const int INTINF = 1<<30; const int MOD = 1000000007; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N; ll ma,mb; vector<ll> a,b,c; ll dp[51][510][510]; int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> ma >> mb; a.resize(N); b.resize(N); c.resize(N); rep(i,N) cin >> a[i] >> b[i] >> c[i]; for (int i = 0; i < 51; ++i) for (int j = 0; j < 510; ++j) for (int k = 0; k < 510; ++k) dp[i][j][k] = LLINF; dp[0][0][0] = 0; rep(i,N){ rep(wa,500){ rep(wb,500){
a.cc: In function 'int main()': a.cc:39:21: error: expected '}' at end of input 39 | rep(wb,500){ | ~^ a.cc:39:21: error: expected '}' at end of input a.cc:38:18: note: to match this '{' 38 | rep(wa,500){ | ^ a.cc:39:21: error: expected '}' at end of input 39 | rep(wb,500){ | ^ a.cc:37:13: note: to match this '{' 37 | rep(i,N){ | ^ a.cc:39:21: error: expected '}' at end of input 39 | rep(wb,500){ | ^ a.cc:29:15: note: to match this '{' 29 | int main(void){ | ^
s502345886
p03806
C++
#include<bits/stdc++.h> using namespace std; #define all(x) (x).begin(),(x).end() typedef long long ll; #define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i) #define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} const ll LLINF = 1LL<<60; const int INTINF = 1<<30; const int MOD = 1000000007; void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; } const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1}; int N; ll ma,mb; vector<ll> a,b,c; ll dp[51][510][510]; int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> ma >> mb; a.resize(N); b.resize(N); c.resize(N); rep(i,N) cin >> a[i] >> b[i] >> c[i]; for (int i = 0; i < 51; ++i) for (int j = 0; j < 510; ++j) for (int k = 0; k < 510; ++k) dp[i][j][k] = LLINF; dp[0][0][0] = 0; rep(i,N){ rep(wa,500){ rep(wb,500){ chmin(dp[i+1][wa][wb], dp[i][wa][wb]); chmin(dp[i+1][wa][wb], dp[i][wa][wb] + c[i]); } } } ll ans = LLINF; REP(wa,1,500){ REP(wb,1,500){ if (wa * mb != wb * ma) continue; chmin(res, dp[N][wa][wb]); } } }
a.cc: In function 'int main()': a.cc:51:15: error: 'res' was not declared in this scope; did you mean 'rep'? 51 | chmin(res, dp[N][wa][wb]); | ^~~ | rep
s525859234
p03806
C++
/** OJ : Program Code : Md. Mujahedul Azad (Turin) Hajee Mohammad Danesh Science & Technology University **/ #include<bits/stdc++.h> using namespace std; #define pi 2*acos(0.0) #define all(v) v.begin(),v.end() #define ff first #define se second #define pb push_back #define mp make_pair #define Sort(a) sort(all(a)) #define RSort(a) Sort(a), reverse(all(a)) #define sz(x) (int)x.size() #define max3(a,b,c) max(a, max(b, c)) #define min3(a,b,c) min(a, min(b, c)) #define maxall(v) *max_element(all(v)) #define minall(v) *min_element(all(v)) #define sq(a) ((a) * (a)) #define abs(x) (((x)<0)?-(x):(x)) #define precision(x) cout << setprecision(x) << fixed #define mem(a,v) memset(a, v, sizeof(a)) #define fillAra(a,n,v) fill(a, a+n, v) #define fillVec(a, v) fill(all(a), v) #define countOne(a) __builtin_popcount(a) #define parity(a) __builtin_parity(a) #define btz(a) __builtin_ctz(a) #define gf << ' ' << #define nl << '\n' #define cinIg cin.sync(); cin.get() #define FasterIO ios_base::sync_with_stdio(false);cin.tie(NULL) #define TestCases int cases, tc; sfi(tc); for(cases=1; cases<=tc; cases++) #define TestCasespp int cases, tc; cin>>tc; for(cases=1; cases<=tc; cases++) #define un(a) Sort(a), (a).erase(unique(all(a)),a.end()) #define common(a,b) Sort(a), Sort(b), a.erase(set_intersection(all(a), all(b), a.begin()), a.end()) #define uncommon(a,b) Sort(a), Sort(b), a.erase(set_symmetric_difference(all(a), all(b), a.begin()), a.end()) /**------- ShortCuts----------*/ typedef long long ll; typedef unsigned long long ull; typedef double db; typedef long double ldb; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<int, pii> iii; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<pii> vii; typedef vector<iii> viii; typedef vector<vi> vvi; typedef map<int, int> mapii; typedef map<int, bool> mapib; typedef map<int, string> mapis; typedef set<int> seti; /**------- Char Chk----------*/ inline bool isLow(char ch){if(ch>='a' && ch<='z') return true; return false;} inline bool isUpp(char ch){if(ch>='A' && ch<='Z') return true; return false;} inline bool isDig(char ch){if(ch>='0' && ch<='9') return true; return false;} /**------- Double Chk----------*/ inline bool are_equal(db a, db b){return fabs(a-b)<numeric_limits<db>::epsilon();} inline bool greater_than(db a, db b){return (a-b) > ((fabs(a)<fabs(b)?fabs(b):fabs(a)) * numeric_limits<db>::epsilon());} inline bool less_than(db a, db b){return (b-a) > ((fabs(a)<fabs(b)?fabs(b):fabs(a)) * numeric_limits<db>::epsilon());} /**------- Functions ---------*/ template<typename T> string toString(T x){stringstream ss; ss<<x; return ss.str();} template<typename T> T SOD(T n){__typeof(n) sum=0, i=1; for(; i*i<=n; i++) sum += (n%i)?0:((sq(i)==n)?i:i+n/i); return sum;} template<typename T> T stringToT(string s, T a){T p; istringstream ss(s); ss>>p; return p;} template<typename T>ostream& operator << (ostream& os, const vector<T> &v){os << "["; for(int i=0; i<v.size(); i++){ os << v[i]; if(i != sz(v)-1) os << ", ";} os << "]"; return os;} template<typename T>ostream& operator << (ostream& os, const set<T> &v){ os << "["; for(auto it : v){os << it;if(it != *v.rbegin())os << ", ";}os << "]";return os;} template<typename T, typename S> ostream& operator << (ostream& os, const map<T, S> &v){for(auto it : v) os << it.ff << " : " << it.se nl; return os;} template<typename T, typename S> ostream& operator << (ostream& os, const pair<T, S> &v){os << "(" << v.ff << ", " << v.se << ")";return os;} ll power(ll a, ll b){ll res = 1; while(b){if(b & 1) res *= a; a = sq(a); b >>= 1;} return res;} ll bigmod(ll a, ll b, ll m) {ll res = 1; while(b) { if(b & 1) { res = ( (res % m) * (a % m) ) %m ; } a= ((a%m) * (a%m)) %m; b >>= 1; } return res; } ll modInverse(ll a, ll m) {return bigmod(a,m-2,m);} /**------- Scanf----------*/ #define sf scanf #define sfi(a) scanf("%d", &a) #define sfc(a) scanf("%c", &a) #define sfl(a) scanf("%lld", &a) #define sfu(a) scanf("%llu", &a) #define sfs(a) scanf("%s", a) #define sfd(a) scanf("%lf", &a) #define sfii(a, b) scanf("%d %d", &a, &b) #define sfll(a, b) scanf("%lld %lld", &a, &b) #define sfuu(a, b) scanf("%llu %llu", &a, &b) #define sfdd(a, b) scanf("%lf %lf", &a, &b) #define sfiii(a, b, c) scanf("%d %d %d", &a, &b, &c) #define sflll(a, b, c) scanf("%lld %lld %lld", &a, &b, &c) #define sfuuu(a, b, c) scanf("%llu %llu %llu", &a, &b, &c) #define sfddd(a, b, c) scanf("%lf %lf %lf", &a, &b, &c) /**------- Printf----------*/ #define pf printf #define pfig(a) pf("%d ", a) #define pfgap pf(" ") #define pfi(a) printf("%d\n", a) #define pfc(a) printf("%c\n", a) #define pfl(a) printf("%lld\n", a) #define pfu(a) printf("%llu\n", a) #define pfs(a) printf("%s\n", a) #define pfd(a) printf("%.2lf\n", a) #define pfii(a, b) printf("%d %d\n", a, b) #define pfll(a, b) printf("%lld %lld\n", a, b) #define pfuu(a, b) printf("%llu %llu\n", a, b) #define pfdd(a, b) printf("%.2lf %.2lf\n", a, b) #define pfiii(a, b, c) printf("%d %d %d\n", a, b, c) #define pflll(a, b, c) printf("%lld %lld %lld\n", a, b, c) #define pfuuu(a, b, c) printf("%llu %llu %llu\n", a, b, c) #define pfddd(a, b, c) printf("%.2lf %.2lf %.2lf\n", a, b, c) #define pnl printf("\n") /**--------File------------*/ #define output freopen("output.txt","w",stdout) #define input freopen("input.txt","r",stdin) #define inOut input, output #define Case printf("Case %d: ", cases) #define Casepp cout << "Case " << cases << ": " /**--------Constant------------*/ #define mx2 101 #define mx3 1001 #define mx4 10001 #define mx5 100001 #define mx6 1000001 #define INF 0x3f3f3f3f #define eps 1e-8 /**--------Loops--------------*/ #define frab(i, a, b) for(__typeof(b) i=(a); i<=(b); i++) #define fr0(i, n) frab(i, 0, n-1) #define fr1(i, n) frab(i, 1, n) #define rfrab(i, a, b) for(__typeof(b) i=(b); i>=a; i--) #define rfr0(i, n) rfrab(i, (n)-1, 0) #define rfr1(i, n) rfrab(i, n, 1) #define frabv(i, a, b, v) for(__typeof(b) i=(a); i<=(b); i+=v) #define rfrabv(i, a, b, v) for(__typeof(b) i=(b); i>=a; i-=v) #define frstl(i, s) for(__typeof((s).end()) i=(s).begin(); i != (s).end(); i++) /**-------Upper & Lower Bound-------*/ #define LB(a, v) (lower_bound(all(a), v)) #define UB(a, v) (upper_bound(all(a), v)) /**--------DeBug------------*/ #define watch(x) cout<<(#x)<<" is "<<x<<"\n" #define chk cout<<"Wtf"<<"\n" const int mod = 1e9 + 7; const int mx = 2*mx5; int n, ma, mb; struct info{ int a, b, c; }; vector<info> va, vb; vector<info> sa, sb; void generateFun(){ int tot = (1 << va.size()); for(int i=1; i<tot; i++){ int aa = 0, bb = 0, cc = 0; for(int j=0; j<va.size(); j++) if(i & (1<<j)) aa += va[j].a, bb += va[j].b, cc += va[j].c; sa.pb({aa, bb, cc}); } tot = (1 << vb.size()); for(int i=1; i<tot; i++){ int aa = 0, bb = 0, cc = 0; for(int j=0; j<vb.size(); j++) if(i & (1<<j)) aa += vb[j].a, bb += vb[j].b, cc += vb[j].c; sb.pb({aa, bb, cc}); } sort(all(sb)); } int main(){ sfiii(n, ma, mb); for(int i=0; i<n; i++){ int a, b, c; sfiii(a,b,c); if(i&1) va.pb({a, b, c}); else vb.pb({a, b, c}); } generateFun(); int ans = INF; for(int i=0; i<sa.size(); i++){ info u = sa[i]; for(int k=1; k<401; k++){ int na = ma*k, nb = mb*k; if(na<u.a || nb<u.b) continue; int ra = na-u.a, rb = nb-u.b; int lw = 0, hh = sb.size()-1, res = -1; while(lw<=hh){ int mid = (lw+hh)/2; if(sb[mid].a<ra) lw = mid+1; else if(sb[mid].a>ra) hh = mid-1; else{ if(sb[mid].b<rb) lw = mid+1; else if(sb[mid].b>rb) hh = mid-1; else {res=mid; break;} } } if(res != -1) ans = min(ans, u.c+sb[res].c); } } if(ans == INF) ans = -1; pfi(ans); return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:8: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<info*, std::vector<info> >; _Iterator2 = __gnu_cxx::__normal_iterator<info*, std::vector<info> >]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<info*, vector<info> >]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:189:9: required from here 189 | sort(all(sb)); | ~~~~^~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'info' and 'info') 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:45:23: note: 'info' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:45:23: note: 'info' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = info; _Iterator = __gnu_cxx::__normal_iterator<info*, std::vector<info> >]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Val_less_iter]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<info*, vector<info> >]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:189:9: required from here 189 | sort(all(sb)); | ~~~~^~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:98:22: error: no match for 'operator<' (operand types are 'info' and 'info') 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:98:22: note: 'info' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:98:22: note: 'info' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<info*, std::vector<info> >; _Value = info]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Distance = long int; _Tp = info; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Distance = long int; _Tp = info; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1593 | std::__make_heap(__first, __middle, __comp); | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<info*, vector<info> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1868 |
s767546417
p03806
C
#include<bits/stdc++.h> using namespace std; #define int long long const int INF=1e18; int dp[50][1010][1010]; signed main() { int N,X,Y; cin>>N>>X>>Y; vector<int> a(N),b(N),c(N); for(int i=0;i<N;i++){ cin>>a[i]>>b[i]>>c[i]; } for(int i=0;i<=N;i++){ for(int j=0;j<=1000;j++){ for(int k=0;k<=1000;k++){ dp[i][j][k]=INF; } } } dp[0][0][0]=0; for(int i=0;i<N;i++){ for(int j=0;j<=1000;j++){ for(int k=0;k<=1000;k++){ if(dp[i][j][k]==INF) continue; dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]); if(j+a[i]<=1000 and k+b[i]<=1000){ dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]); } } } } int ans=INF; for(int r=1;;r++){ int x=r*X; int y=r*Y; if(x<=1000 and y<=1000){ ans=min(ans,dp[N][x][y]); }else break; } cout<<(ans==INF? -1:ans)<<endl; return 0; }
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory 1 | #include<bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s509122591
p03806
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) //typedef pair<long long,long long> P; const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; int main(){ int n,ma,mb; cin>>n>>ma>>mb; int a[n],b[n],c[n]; REP(i,n){ cin>>a[i]>>b[i]>>c[i]; } vector<vector<vector<int>>> dp(n,vector<vector<int>>(401,vector<int>(401,-1))); REP(k,n){ dp[k][0][0]=0; } REP(k,n){ if(k==0){ dp[k][a[k]][b[k]]=c[k]; continue; } for(int i=0;i<a[k];i++){ for(int j=0;j<b[k];j++){ dp[k][i][j] = dp[k-1][i][j]; } } for(int i=a[k];i<=400;i++){ for(int j=b[k];j<=400;j++){ if(dp[k-1][i][j]==-1 && dp[k-1][i-a[k]][j-b[k]]!=-1){ dp[k][i][j] = dp[k-1][i-a[k]][j-b[k]]+c[k]; }else if(dp[k-1][i][j]!=-1 && dp[k-1][i-a[k]][j-b[k]]!=-1){ dp[k][i][j] = min(dp[k-1][i][j],dp[k-1][i-a[k]][j-b[k]]+c[k]); }else if(dp[k-1][i][j]!=-1 && dp[k-1][i-a[k]][j-b[k]]==-1){ dp[k][i][j] = dp[k-1][i][j]; }else{ continue; } } } } int x = min(400/ma,400/mb); int res=-1; REPP(i,x){ if(dp[n-1][ma*i][mb*i]==-1){ continue; }else if(res==-1){ res = dp[n-1][ma*i][mb*j]; }else{ res = min(res,dp[n-1][ma*i][mb*j]); } } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:132:30: error: 'j' was not declared in this scope 132 | res = dp[n-1][ma*i][mb*j]; | ^ a.cc:134:38: error: 'j' was not declared in this scope 134 | res = min(res,dp[n-1][ma*i][mb*j]); | ^
s059152047
p03806
C++
#include<iostream> #include<vector> #include<sstream> #include<string> #include<numeric> #include <algorithm> #include<math.h> #include<cstdio> #include<string.h> #include<unistd.h> #include <array> #include <map> #include<stdio.h> #include<queue> #include<set> #include<tuple> #include <iomanip> #define ALL(a) (a).begin(),(a).end() const long long MOD = 1000000007; //いろんなstlの使い方 https://qiita.com/tukejonny/items/f4013547df761a0b3523 //http://y-mazun.hatenablog.com/entry/20111202/1322840281 using namespace std; struct point{ int x; int y; }; long long gcd(long long a, long long b) { if(a>b){ return gcd(b,a); } return a == 0 ? b : gcd(b % a, a); } long long lcm( long long m, long long n ) { // 引数に0がある場合は0を返す if ( ( 0 == m ) || ( 0 == n ) ) return 0; return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n) }//lcm int input(){ int x; cin>>x; return x; } int moji(char in) { int ans = (int)in-(int)'a'; if((ans < 0) || (ans > 25)){ ans = 26; } return ans; } const int VV=1;//場合に応じてVVの値のみ変更する必要あり //dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能 int cost[VV][VV]; int d[VV]; bool used[VV]; void dijkstra(int s){ fill(d,d+VV,100000); fill(used,used+VV,false); d[s]=0; while(true){ cout<<"Hello"<<endl; int v=-1; for(int u=0;u<VV;u++){ if(!used[u]&&(v==-1||d[u]<d[v]))v=u; } if(v==-1)break; used[v]=true; for(int u=0;u<VV;u++){ d[u]=min(d[u],d[v]+cost[v][u]); } } } int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用) { return *(int*)a - *(int*)b; } int binary_searchh(long long x,long long k[],int n){ int l=0; int r=n; while(r-l>=1){ int i=(l+r)/2; if(k[i]==x)return i; else if(k[i]<x)l=i+1; else r=i; } return -1; } struct File { int aa; int bb; File(const int& aa, const int& bb) : aa(aa), bb(bb) {} }; /*bool operator<(const File& a, const File& b) { // ファイル種別、ファイル名の順番で優先順位を付けて比較 return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb); }*/ long long kaijo(long long x){ long long l=10*10*10*10*10*10*10*10*10+7; long long sum=1; for(int i=x;i>0;i--){ sum*=i; if(sum>l){ sum%=l; } } return sum; } template<class T>void chmin(T &a,T b){ if(a>b){ a=b; } } //formerは前方のindex(自分自身を含んで良い) template<class T>int former(const vector<T>&v,T x){ return upper_bound(v.begin(),v.end(),x)-v.begin()-1; } //latterは後方のindex(自分自身を含んで良い) template<class T>int latter(const vector<T>&v,T x){ return lower_bound(v.begin(),v.end(),x)-v.begin(); } struct UnionFind{ //par[i]データiの属する木の親の番号。i==par[i]のときデータiは木の根ノードである vector<int>par; //sizes[i]:根ノードiの木に含まれるデータ数、iが根ノードでないときは無意味な値になる vector<int>sizes; UnionFind(int n):par(n),sizes(n,1){ //最初は全てのデータiがグループiに存在するものとして初期化 for(int i=0;i<n;i++){ par[i]=i; } } //データxが属する木の根を得る int find(int x){ if(x==par[x]){ return x; } return par[x]=find(par[x]); } //2つのデータx,yが属する木をマージする void unite(int x,int y){ //データの根ノードを得る x=find(x); y=find(y); //もしすでに同じ木に属しているならマージの必要はない if(x==y){ return; } //xの木がyの木よりも大きくなるようにする if(sizes[x]<sizes[y]){ swap(x,y); } //xがyの親になるように連結する par[y]=x; sizes[x]+=sizes[y]; } //2つのデータx,yが属する木が同じならtrueを返す bool same(int x,int y){ return find(x)==find(y); } //データxが含まれる木の大きさを返す int size(int x){ return sizes[find(x)]; } }; //クラスカル法 //頂点a,bをつなぐコストcostの(無向)辺 struct Edge{ int a,b,cost; //コストの大小で順序定義 bool operator<(const Edge& o)const{ return cost<o.cost; } }; //頂点数と辺集合の組として定義したグラフ struct Graph{ int n;//頂点数 vector<Edge>es;//辺集合 //クラスカル法で無向最小全域木のコストの和を計算する //グラフが非連結の時は最小全域森のコストの和になる //使い方http://dai1741.github.io/maximum-algo-2012/docs/minimum-spanning-tree/ int kruskal(){ //コストが小さい順にソーと sort(es.begin(),es.end()); UnionFind uf(n); int min_cost=0; for(int ei=0;ei<es.size();ei++){ Edge& e=es[ei]; if(!uf.same(e.a,e.b)){ //その辺によって2つの木が連結される min_cost+=e.cost; uf.unite(e.a,e.b); } } return min_cost; } }; //標準入力からグラフを読み込む Graph input_graph(){ Graph g; int m; cin>>g.n>>m; for(int i=0;i<m;i++){ Edge e; cin>>e.a>>e.b>>e.cost; g.es.push_back(e); } return g; } long long labs(long long x){ if(x<0){ return -x; } return x; } // a^n mod を計算する long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } //indexを用いてvectorから要素削除 template<typename T> void remove(std::vector<T>& vector, unsigned int index) { vector.erase(vector.begin() + index); } void modadd(long long &a,long long b){ a+=b; if(a>=MOD){ a-=MOD; } } int main(){ int dp[45][405][405] int N,Ma,Mb; cin>>N>>Ma>>Mb; int a[N],b[N],c[N]; for(int i=0;i<N;i++){ cin>>a[i]>>b[i]>>c[i]; } for(int i=0;i<405;i++){ for(int j=0;j<405;j++){ for(int k=0;k<45;k++){ dp[k][i][j]=1000000;} } } dp[0][0][0]=0; for(int i=0;i<N;i++){ for(int j=0;j<405;j++){ for(int k=0;k<405;k++){ if(dp[i][j][k]>=1000000){ continue; } dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]); if(j+a[i]<405&&k+b[i]<405){ dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);} } } } int ans=1000000; for(int i=1;i*max(Ma,Mb)<405;i++){ ans=min(ans,dp[N][i*Ma][i*Mb]); } if(ans>=1000000){ ans=-1; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:273:4: error: expected initializer before 'int' 273 | int N,Ma,Mb; | ^~~ a.cc:274:9: error: 'N' was not declared in this scope 274 | cin>>N>>Ma>>Mb; | ^ a.cc:274:12: error: 'Ma' was not declared in this scope 274 | cin>>N>>Ma>>Mb; | ^~ a.cc:274:16: error: 'Mb' was not declared in this scope 274 | cin>>N>>Ma>>Mb; | ^~ a.cc:277:13: error: 'a' was not declared in this scope 277 | cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:277:19: error: 'b' was not declared in this scope 277 | cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:277:25: error: 'c' was not declared in this scope 277 | cin>>a[i]>>b[i]>>c[i]; | ^ a.cc:283:12: error: 'dp' was not declared in this scope; did you mean 'dup'? 283 | dp[k][i][j]=1000000;} | ^~ | dup a.cc:288:4: error: 'dp' was not declared in this scope; did you mean 'dup'? 288 | dp[0][0][0]=0; | ^~ | dup a.cc:297:25: error: 'a' was not declared in this scope 297 | if(j+a[i]<405&&k+b[i]<405){ | ^ a.cc:297:37: error: 'b' was not declared in this scope 297 | if(j+a[i]<405&&k+b[i]<405){ | ^ a.cc:298:84: error: 'c' was not declared in this scope 298 | dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);} | ^
s005871953
p03806
C++
#include<iostream> #include<sstream> #include<fstream> #include<cstring>/*The header <string> and <string.h> does not contain the useful function 'memset' and 'memcpy'.*/ #include<vector> #include<stack> #include<map> #include<set> #include<queue> #include<deque> #include<bitset> #include<utility> #include<algorithm> #include<functional> #include<ctime> #include<cmath> #include<cstdlib> #include<cstdio> using namespace std; vector<pair<pair<int,int>,int> > X; int init=1000000000,ans=1000000000,dp[50],N,A,B; void dfs(int pos,int a,int b,int c) { if(pos==X.size()) { if(a==A&&b==B) ans=min(ans,c); return ; } dfs(pos+1,a,b,c); if(a+X[pos].first.first<=A&&b+X[pos].first.second<=B) dfs(pos+1,a+X[pos].first.first,b+X[pos].first.second,c+X[pos].second); return ; } int main() { cin.tie(); cout.tie(); ios_base::sync_with_stdio(false); cin>>N>>A>>B; for(int i=0;i<N;i++) { int x,y,z; cin>>x>>y>>z; if(x*B==y*A) init=min(init,z); else X.push_back(make_pair(make_pair(x,y),z)); } sort(X.begin(),X.end()); int Ai=A,Bi=B; while(A<=10&&B<=10) { vector<pair<pair<int,int>,int> > V; for(int i=0;i<X.size();i++) if(X[i].first.first<=A&&X[i].first.second<=B) V.push_back(X[i]); swap(V,X); dfs(0,0,0,0); A+=Ai; B+=Bi; swap(V,X); } cout<<(init==INT_MAX&&ans==INT_MAX?-1:min(init,ans))<<endl; return 0; }
a.cc: In function 'int main()': a.cc:65:22: error: 'INT_MAX' was not declared in this scope 65 | cout<<(init==INT_MAX&&ans==INT_MAX?-1:min(init,ans))<<endl; | ^~~~~~~ a.cc:21:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 20 | #include<cstdio> +++ |+#include <climits> 21 | using namespace std;
s179481334
p03806
C++
#include<iostream> #include<sstream> #include<fstream> #include<cstring>/*The header <string> and <string.h> does not contain the useful function 'memset' and 'memcpy'.*/ #include<vector> #include<stack> #include<map> #include<set> #include<queue> #include<deque> #include<bitset> #include<utility> #include<algorithm> #include<functional> #include<ctime> #include<cmath> #include<cstdlib> #include<cstdio> using namespace std; vector<pair<pair<int,int>,int> > X; int init=INT_MAX,ans=INT_MAX,dp[50],N,A,B; void dfs(int pos,int a,int b,int c) { if(pos==X.size()) { if(a==A&&b==B) ans=min(ans,c); return ; } dfs(pos+1,a,b,c); if(a+X[pos].first.first<=A&&b+X[pos].first.second<=B) dfs(pos+1,a+X[pos].first.first,b+X[pos].first.second,c+X[pos].second); return ; } int main() { cin.tie(); cout.tie(); ios_base::sync_with_stdio(false); cin>>N>>A>>B; for(int i=0;i<N;i++) { int x,y,z; cin>>x>>y>>z; if(x*B==y*A) init=min(init,z); else X.push_back(make_pair(make_pair(x,y),z)); } sort(X.begin(),X.end()); int Ai=A,Bi=B; while(A<=10&&B<=10) { vector<pair<pair<int,int>,int> > V; for(int i=0;i<X.size();i++) if(X[i].first.first<=A&&X[i].first.second<=B) V.push_back(X[i]); swap(V,X); dfs(0,0,0,0); A+=Ai; B+=Bi; swap(V,X); } cout<<(init==INT_MAX&&ans==INT_MAX?-1:min(init,ans))<<endl; return 0; }
a.cc:23:10: error: 'INT_MAX' was not declared in this scope 23 | int init=INT_MAX,ans=INT_MAX,dp[50],N,A,B; | ^~~~~~~ a.cc:21:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 20 | #include<cstdio> +++ |+#include <climits> 21 | using namespace std; a.cc: In function 'void dfs(int, int, int, int)': a.cc:28:23: error: 'A' was not declared in this scope 28 | if(a==A&&b==B) | ^ a.cc:28:29: error: 'B' was not declared in this scope 28 | if(a==A&&b==B) | ^ a.cc:29:25: error: 'ans' was not declared in this scope; did you mean 'abs'? 29 | ans=min(ans,c); | ^~~ | abs a.cc:33:34: error: 'A' was not declared in this scope 33 | if(a+X[pos].first.first<=A&&b+X[pos].first.second<=B) | ^ a.cc:33:60: error: 'B' was not declared in this scope 33 | if(a+X[pos].first.first<=A&&b+X[pos].first.second<=B) | ^ a.cc: In function 'int main()': a.cc:42:14: error: 'N' was not declared in this scope 42 | cin>>N>>A>>B; | ^ a.cc:42:17: error: 'A' was not declared in this scope 42 | cin>>N>>A>>B; | ^ a.cc:42:20: error: 'B' was not declared in this scope 42 | cin>>N>>A>>B; | ^ a.cc:65:22: error: 'INT_MAX' was not declared in this scope 65 | cout<<(init==INT_MAX&&ans==INT_MAX?-1:min(init,ans))<<endl; | ^~~~~~~ a.cc:65:22: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' a.cc:65:31: error: 'ans' was not declared in this scope; did you mean 'abs'? 65 | cout<<(init==INT_MAX&&ans==INT_MAX?-1:min(init,ans))<<endl; | ^~~ | abs
s346696386
p03806
C++
#include<bits/stdc++.h> using namespace std; int INF = 1'000'000'000; int main(){ int n, ma, mb; cin >> n >> ma >> mb; vector<vector<int>> med(401, vector<int>(401, INF)); queue<tuple<int, int, int>> que; int a, b, c; for (int i = 0; i < n; i++){ cin >> a >> b >> c; que.push(tie(a, b, c)); for (int x = 0; x < 401; x++){ for (int y = 0; y < 401; y++){ if (med[x][y] != INF) que.push(tie(x + a, y + b, med[x][y] + c)); } } while (que.size() > 0){ a = get<0>(que.front()); b = get<1>(que.front()); c = get<2>(que.front()); que.pop(); med[a][b] = min(med[a][b], c); } } int ans = INF; int x = 0; int y = 0; while (1){ x += ma; y += mb; if (x > 400 || y > 400) break; ans = min(ans, med[x][y]); } if (ans == INF) cout << -1 << endl; else cout << ans << endl; }
a.cc: In function 'int main()': a.cc:17:54: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' 17 | if (med[x][y] != INF) que.push(tie(x + a, y + b, med[x][y] + c)); | ~~^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68, 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/tuple:2791:19: note: initializing argument 1 of 'constexpr std::tuple<_Elements& ...> std::tie(_Elements& ...) [with _Elements = {int, int, int}]' 2791 | tie(_Elements&... __args) noexcept | ~~~~~~~~~~^~~~~~~~~~
s067309909
p03806
C++
#include <iostream> #include <cstdio> #include <map> #include <algorithm> #include <vector> #include <string> #include <utility> #include <queue> #define INF 1e9+7 #define rep(i,n) for(int i=0;i<n;i++) #define NO cout<<"NO"<<endl; #define YES cout << "YES"<<endl; #define No cout << "No"<<endl; #define Yes cout << "Yes"<<endl; #define all(a) a.begin(),a.end() #define P pair<int,int> using namespace std; typedef long long int ll; typedef unsigned long long int ull; //(int)'a'は97 (int)'A'は65 (int)'1'は49 //おまじない //UnionFind const int nmax=40,abmax=10,inf = 1000000; int a[nmax],b[nmax],c[nmax]; int dp[nmax+1][nmax*abmax+1][nmax*abmax+1]; int main(void){ int n,ma,mb; cin >> n >> ma >> mb; for(int i=0;i<n;++i){ cin >> a[i] >> b[i] >> c[i]; } for(int i = 0; i <= n; ++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ dp[i][ca][cb]=inf; } } } dp[0][0][0]=0; for(inti=0;i<n;++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ if(dp[i][ca][cb]==inf) continue; dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]); } } } int ans=inf; for(int ca = 1; ca <= nmax*abmax; ++ca){ for(int cb = 1; cb <= nmax*abmax; ++cb){ if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:43:5: error: 'inti' was not declared in this scope; did you mean 'int'? 43 | for(inti=0;i<n;++i){ | ^~~~ | int a.cc:43:12: error: 'i' was not declared in this scope 43 | for(inti=0;i<n;++i){ | ^
s353036962
p03806
C++
/*#include <iostream> #include <cmath> #include <vector> #include <algorithm> #include <array> #include <vector> #include <deque> #include <set> #include <map> #include <string> #include <stack> #include <queue> #include <unordered_map> #include <unordered_set> */ #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back #define mp make_pair #define F first #define S second #define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++) #define REP(i,n) FOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define SORT(c) sort((c).begin(),(c).end()) #define REVERSE(a) reverse((c).begin(),(c).end()) typedef long long ll; const ll INF = 1LL<<60; const ll mod = 1e9 + 7; const int MAX_N = 5e5 + 5; int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 }; vector<ll> prime; ll inv[MAX_N], fac[MAX_N]; template <class T = ll> T in() { T x; cin >> x; return (x); } inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; } inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); } inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; } inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } } inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; } inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } } typedef pair<int, pair<int, int>> edge; int dp[500][500]; signed main() { int n,Ma,Mb; cin >> n >> Ma >> Mb; pair<int,pair<int,int>> C[n]; REP (i,n) { cin >> C[i].F >> C[i].S.F >> C[i].S.S; } REP (i,500) REP (j,500) dp[i][j] = INF; sort(C,C+n); dp[0][0] = 0; REP (i,n) { int x = C[i].S.F,y = C[i].S.S; int cost = C[i].F; REP (j,410) { REP (k,410) { if (dp[i][j] != INF) { dp[i+x][j+y] = min(dp[i+x][j+y],dp[i][j] + cost); } } } } int ans = INF; FOR (i,1,410) { FOR (j,1,410) { if (i * mb == j * ma) ans = min(ans,dp[i][j]); } } if (ans == INF) cout << -1 << endl; else cout << ans << endl; }
a.cc: In function 'int main()': a.cc:77:33: error: 'mb' was not declared in this scope; did you mean 'Mb'? 77 | if (i * mb == j * ma) ans = min(ans,dp[i][j]); | ^~ | Mb a.cc:77:43: error: 'ma' was not declared in this scope; did you mean 'Ma'? 77 | if (i * mb == j * ma) ans = min(ans,dp[i][j]); | ^~ | Ma
s922977689
p03806
C
#pragma comment (linker, "/STACK:256000000") #include "bits/stdc++.h" #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i) #define BUGAVOID(x) x #define rep(...) BUGAVOID(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__)) #define sz(c) (int)(c.size()) #define all(c) c.begin(),c.end() #define mp make_pair #define write(x) cout<<(x)<<"\n" using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll; template<class T, class U>using vp = vector<pair<T, U>>; template<class T>using vv = vector<vector<T>>; template<class T, class U>using vvp = vv<pair<T, U>>; template<class T>vv<T> vvec(const size_t n, const size_t m, const T v) { return vv<T>(n, vector<T>(m, v)); } template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; }return 0; } template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; }return 0; } constexpr ll pow2(const int n) { return 1ll << n; } constexpr int INF = 1 << 28; constexpr ll LINF = 1ll << 60; constexpr int MAX = 1e5 + 5; constexpr int MOD = 1e9 + 7; constexpr double EPS = 1e-6; constexpr int dy[4] = { 0,1,0,-1 }; constexpr int dx[4] = { 1,0,-1,0 }; struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa; int N, Ma, Mb; vi A, B, C; vv<int> dp; int main() { cin >> N >> Ma >> Mb; A.resize(N); B.resize(N); C.resize(N); rep(i, N) { cin >> A[i] >> B[i] >> C[i]; } dp = vvec(N + 1, 401 * 401, INF); dp[0][0] = 0; rep(i, 1, N + 1) { rep(j, 401 * 401) { const int a = j % 401; const int b = j / 401; if (a + A[i - 1] > 400 || b + B[i - 1] > 400) continue; const int k = a + A[i - 1] + 401 * (b + B[i - 1]); chmin(dp[i][j], dp[i - 1][j]); chmin(dp[i][k], dp[i - 1][j] + C[i - 1]); } } int ans = INF; rep(j, 401 * 401) { const int a = j % 401; const int b = j / 401; if (a * Mb == b * Ma && a != 0 && b != 0) { chmin(ans, dp[N][j]); } } if (ans == INF) { write(-1); } else { write(ans); } }
main.c:2:10: fatal error: bits/stdc++.h: No such file or directory 2 | #include "bits/stdc++.h" | ^~~~~~~~~~~~~~~ compilation terminated.
s700592634
p03806
C++
#include <stdio.h> #include <stdlib.h> #include<math.h> #include<algorithm> #include<vector> #include<queue> #include<string> #include<set> #include<cstring> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define INF 1001001001 #define LLINF 1001001001001001001 #define mp make_pair #define pb push_back #define LLIandI pair<long long int , int> #define ll long long //DPバージョン int main(void){ int N,Ma,Mb; scanf("%d %d %d",&N,&Ma,&Mb); int A[50],B[50],C[50]; int dp[41][41*11*11*2]; //dp[i][j]=m i番までの薬品を使ってM_a*b-M_b*a(絶対値N(=40)*Ma,Mb(=10)*max(a),max(b)(=10)=4000以下)=Jにしたときの最低のコストがmということを表す //Jについては、添字jについてJ=k-N*10*10とする。(kは0以上2*N*10*10以下 ) rep(i,N)rep(j,N*10*10*2+1)dp[i][j]=INF; rep(i,N){ scanf("%d %d %d",&A[i],&B[i],&C[i]); if(i==0){ dp[i][N*100]=0; dp[i][N*100+Ma*B[i]-Mb*A[i]]=C[i]; } } rep(i,N){ rep(k,2*100*N+1){ //i-1番めまでは一切使わない時の例外処理 dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min (C[i], dp[i][ N*100+Ma*B[i]-Mb*A[i] ] ); if(i<N-1){ if(dp[i][k]==0)continue;//i番目までは全く使っていないものについては上で処理するので継承しない int newJ=Ma*B[i+1]-Mb*A[i+1]; //i+1を使う時 dp[i+1][k+newJ]=min(dp[i][k]+C[i+1], dp[i+1][k+newJ] ); //i+1を使わない時 dp[i+1][k]=min(dp[i][k],dp[i+1][k]); } } } if(dp[N-1][N*100]>=INF||dp[N-1][N*100]<=0)printf("%d\n",-1); else printf("%d\n",dp[N-1][N*100]); }
a.cc:39:19: error: extended character   is not valid in an identifier 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min (C[i], dp[i][ N*100+Ma*B[i]-Mb*A[i] ] ); | ^ a.cc:39:42: error: extended character   is not valid in an identifier 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min (C[i], dp[i][ N*100+Ma*B[i]-Mb*A[i] ] ); | ^ a.cc: In function 'int main()': a.cc:39:19: error: '\U00003000N' was not declared in this scope 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min (C[i], dp[i][ N*100+Ma*B[i]-Mb*A[i] ] ); | ^~~ a.cc:39:42: error: expected ']' before '\U00003000' 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min (C[i], dp[i][ N*100+Ma*B[i]-Mb*A[i] ] ); | ^~ | ]
s387008958
p03806
C++
#include <stdio.h> #include <stdlib.h> #include<math.h> #include<algorithm> #include<vector> #include<queue> #include<string> #include<set> #include<cstring> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define INF 1001001001 #define LLINF 1001001001001001001 #define mp make_pair #define pb push_back #define LLIandI pair<long long int , int> #define ll long long //DPバージョン int main(void){ int N,Ma,Mb; scanf("%d %d %d",&N,&Ma,&Mb); int A[50],B[50],C[50]; int dp[41][41*11*11*2]; //dp[i][j]=m i番までの薬品を使ってM_a*b-M_b*a(絶対値N(=40)*Ma,Mb(=10)*max(a),max(b)(=10)=4000以下)=Jにしたときの最低のコストがmということを表す //Jについては、添字jについてJ=k-N*10*10とする。(kは0以上2*N*10*10以下 ) rep(i,N)rep(j,N*10*10*2+1)dp[i][j]=INF; rep(i,N){ scanf("%d %d %d",&A[i],&B[i],&C[i]); if(i==0){ dp[i][N*100]=0; dp[i][N*100+Ma*B[i]-Mb*A[i]]=C[i]; } } rep(i,N){ rep(k,2*100*N+1){ //i-1番めまでは一切使わない時の例外処理 dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min(C[i],dp[i][N*100+Ma*B[i]-Mb*A[i]] ); if(i<N-1){ if(dp[i][k]==0)continue;//i番目までは全く使っていないものについては上で処理するので継承しない int newJ=Ma*B[i+1]-Mb*A[i+1]; //i+1を使う時 dp[i+1][k+newJ]=min(dp[i][k]+C[i+1], dp[i+1][k+newJ] ); //i+1を使わない時 dp[i+1][k]=min(dp[i][k],dp[i+1][k]); } } } if(dp[N-1][N*100]>=INF||dp[N-1][N*100]<=0)printf("%d\n",-1); else printf("%d\n",dp[N-1][N*100]); }
a.cc:39:19: error: extended character   is not valid in an identifier 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min(C[i],dp[i][N*100+Ma*B[i]-Mb*A[i]] ); | ^ a.cc:39:42: error: extended character   is not valid in an identifier 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min(C[i],dp[i][N*100+Ma*B[i]-Mb*A[i]] ); | ^ a.cc: In function 'int main()': a.cc:39:19: error: '\U00003000N' was not declared in this scope 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min(C[i],dp[i][N*100+Ma*B[i]-Mb*A[i]] ); | ^~~ a.cc:39:42: error: expected ']' before '\U00003000' 39 | dp[i][ N*100+Ma*B[i]-Mb*A[i] ]=min(C[i],dp[i][N*100+Ma*B[i]-Mb*A[i]] ); | ^~ | ]
s998808272
p03806
Java
import java.util.Scanner; class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int N=sc.nextInt(); int Ma=sc.nextInt(); int Mb=sc.nextInt(); int[][][] dp=new int[41][401][401]; int INF=1000000007; for(int i=0; i<=40; i++) { for(int j=0; j<=400; j++) { Arrays.fill(dp[i][j],INF); } } dp[0][0][0]=0; int[][] kusuri=new int[N][3]; for(int i=0; i<N; i++) { kusuri[i][0]=sc.nextInt(); kusuri[i][1]=sc.nextInt(); kusuri[i][2]=sc.nextInt(); } for(int i=0; i<N; i++) { for(int j=0; j<=400; j++) { for(int k=0; k<=400; k++) { if(dp[i][j][k]<INF) { dp[i+1][j][k]=Math.min(dp[i+1][j][k],dp[i][j][k]); dp[i+1][j+kusuri[i][0]][k+kusuri[i][1]]=Math.min(dp[i+1][j+kusuri[i][0]][k+kusuri[i][1]],dp[i][j][k]+kusuri[i][2]); } } } } int min=114514810; int counter=1; while(Ma*counter<=400 && Mb*counter<=400) { min=Math.min(dp[N][Ma*counter][Mb*counter],min); counter++; } System.out.println(min); } }
Main.java:13: error: cannot find symbol Arrays.fill(dp[i][j],INF); ^ symbol: variable Arrays location: class Main 1 error
s986886452
p03806
C++
#include <bits/stdc++.h> using namespace std; int N,Ma,Mb; vector<int> a(50),b(50),c(50); int dp(int n,int x,int y,int z,int m){ if(n==1){ if(Ma*(y+b[1])==Mb*(x+a[1])){ if(z+c[1]<m){return z+c[1];} else{return m;} } else{return m;} } else{ if(Ma*(y+b[n])!=Mb*(x+a[n])){ return dp( int main(){ cin >> N >> Ma >> Mb; for(int i=1;i<=N;i++){cin >> a[i] >> b[i] >> c[i];}
a.cc: In function 'int dp(int, int, int, int, int)': a.cc:19:1: error: expected primary-expression before 'int' 19 | int main(){ | ^~~ a.cc:21:54: error: expected ';' at end of input 21 | for(int i=1;i<=N;i++){cin >> a[i] >> b[i] >> c[i];} | ^ | ; a.cc:21:54: error: expected '}' at end of input a.cc:16:33: note: to match this '{' 16 | if(Ma*(y+b[n])!=Mb*(x+a[n])){ | ^ a.cc:21:54: error: expected '}' at end of input 21 | for(int i=1;i<=N;i++){cin >> a[i] >> b[i] >> c[i];} | ^ a.cc:15:7: note: to match this '{' 15 | else{ | ^ a.cc:21:54: error: expected '}' at end of input 21 | for(int i=1;i<=N;i++){cin >> a[i] >> b[i] >> c[i];} | ^ a.cc:7:38: note: to match this '{' 7 | int dp(int n,int x,int y,int z,int m){ | ^
s886515112
p03806
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int Ma = sc.nextInt(); int Mb = sc.nextInt(); int[] a = new int[N]; int[] b = new int[N]; int[] c = new int[N]; for(int i = 0; i < N; i++) { a[i] = sc.nextInt(); b[i] = sc.nextInt(); c[i] = sc.nextInt(); } sc.close(); int n = 401; int[][][] dp = new int[N + 1][n][n]; int INF = 100000000; for(int i = 0; i <= N; i++) { for(int j = 0; j < n; j++) { for(int k = 0; k < n; k++) { dp[i][j][k] = INF; } } } dp[0][0][0] = 0; for(int i = 0; i < N; i++) { for(int j = 0; j < n; j++) { for(int k = 0; k < n; k++) { if(dp[i][j][k] != INF) { int A = j + a[i]; int B = k + b[i]; dp[i + 1][j][k] = Math.min(dp[i + 1][j][k], dp[i][j][k]); dp[i + 1][A][B] = Math.min(dp[i + 1][A][B], dp[i][A][B] + c[i]); } } } } int min = INF; for(int j = 1; j < n; j++) { for(int k = 0; k < n; k++) { if(Ma * j == Mb * k) { min = Math.min(min, dp[N][j][k]); } } } if(min == INF) min = -1; System.out.println(min); }
Main.java:52: error: reached end of file while parsing } ^ 1 error
s488594214
p03806
C
#include<stdio.h> #define INF 999999 int dp[41][160801]; int min(int x,int y){ if(x<y)return x; return y; } int max(int x,int y){ if(x>y)return x; return y; } int main(){ int N,A,B,i,m=INF; scanf("%d%d%d",&N,&A,&B); int a[N],b[N],c[N],s[N]; for(i=0;i<N;i++){ scanf("%d%d%d",&a[i],&b[i],&c[i]); s[i]=a[i]*401+b[i]; } for(i=0;i<41;i++)for(int j=0;j<160801;j++)dp[i][j]=INF; dp[0][0]=0; for(i=0;i<N;i++){ for(int j=0;j<160801;j++){ dp[i+1][j] = min(dp[i+1][j], dp[i][j]); if(j>=s[i])dp[i+1][j]=min(dp[i+1][j],dp[i][j-s[i]]+c[i]); } for(i=1;i<=400/max(A,B);i++){ if(dp[N][A*i*401+B*i]<m){ m=dp[N][A*i*401+B*i]; } } if(m<INF)printf("%d\n",m); else printf("-1\n"); return 0; }
main.c: In function 'main': main.c:40:1: error: expected declaration or statement at end of input 40 | } | ^
s517567718
p03806
C++
#include <bits/stdc++.h> using namespace std; struct initon { initon() { cin.tie(0); ios::sync_with_stdio(false); }; } hoee; //別名 #define int long long using ll = long long; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using vl = vector<ll>; using vvl = vector<vl>; using P = pair<int, int>; using T = tuple<int, int, int>; using vp = vector<P>; using dou = double; using itn = int; using str = string; #define F first #define S second //定数 const int INF = (int) 1e9 + 100; const int MINF = (int) -1e9 - 100; const ll LINF = (ll) 1e18 + 100; const ll MLINF = (ll) 1e18 - 100; const double EPS = 1e-9; const int y4[] = {-1, 1, 0, 0}; const int x4[] = {0, 0, -1, 1}; const int y8[] = {0, 1, 0, -1, -1, 1, 1, -1}; const int x8[] = {1, 0, -1, 0, 1, -1, 1, -1}; //配列 #define sz(a) (sizeof(a)/sizeof(a[0])) //コンテナ #define mp make_pair #define pb push_back #define eb emplace_back #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sort(v) sort(v.begin(),v.end()) //繰り返し #define _overloadrep(_1, _2, _3, name, ...) name #define _rep(i, n) for(int i = 0,RLN = (n); i < RLN ; i++) #define repi(i, m, n) for(int i = m,RLN = (n); i < RLN ; i++) #define rep(...) _overloadrep(__VA_ARGS__,repi,_rep,)(__VA_ARGS__) #define _rer(i, n) for(int RLN = (n) ,i = RLN; i >= 0 ; i--) #define reri(i, m, n) for(int RLN = (n) ,i = m-1; i >= n ; i--) #define rer(...) _overloadrep(__VA_ARGS__,reri,_rer,)(__VA_ARGS__) // 多次元配列の初期化。第2引数の型のサイズごとに初期化していく。 template<typename A, size_t N, typename T> void fill(A (&array)[N], const T &val) { std::fill((T *) array, (T *) (array + N), val); } #define arcpy(a, b) memcpy(a,b,sizeof(b)) //入力 template<typename T = int> T in() { T x; cin >> x; return (x); } string sin() { return in<string>(); } double din() { return in<double>(); } ll lin() { return in<ll>(); } #define na(a, n) rep(i,n) cin >> a[i]; #define nad(a, n) rep(i,n) cin >> a[i]; a[i]--; #define nt(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi]; #define ntd(a, h, w) rep(hi,h)rep(wi,w) cin >> a[hi][wi]; a[hi][wi]--; #define nctp(a, c) fill(a,c); rep(hi,1,sz(a)+1)rep(wi,1,sz(a[0])+1) cin >> a[hi][wi]; #define add(a, n) rep(i,n) a.pb(in()); //出力 template<class T> void out(T x) { if (typeid(x) == typeid(double))cout << fixed << setprecision(10) << x << endl; else cout << x << endl; } //デバッグ #define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n'; //便利関数 #define bit(n) (1LL<<(n)) 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; } inline bool inside(int y, int x, int H, int W) { return y >= 0 && x >= 0 && y < H && x < W; } //mod関連 ll MOD = (int) 1e9 + 7; class mint { private: ll v; public: static ll mod(ll a) { return (a % MOD + MOD) % MOD; } mint(ll a = 0) { this->v = mod(a); }; mint(const mint &a) { v = a.v; } mint operator+(const mint &a) { return mint(v + a.v); } mint operator+(const ll a) { return mint(v + a % MOD); } mint operator+(const signed a) { return mint(v + a % MOD); } friend mint operator+(const ll a, const mint &b) { return mint(a % MOD + b.v); } void operator+=(const mint &a) { v = (v + a.v) % MOD; } void operator+=(const ll a) { v = mod(v + a % MOD); } void operator+=(const signed a) { v = mod(v + a % MOD); } friend void operator+=(ll &a, const mint &b) { a = mod(a % MOD + b.v); } mint operator-(const mint &a) { return mint(v - a.v); } mint operator-(const ll a) { return mint(v - a % MOD); } mint operator-(const signed a) { return mint(v - a % MOD); } friend mint operator-(const ll a, const mint &b) { return mint(a % MOD - b.v); } void operator-=(const mint &a) { v = mod(v - a.v); } void operator-=(const ll a) { v = mod(v - a % MOD); } void operator-=(const signed a) { v = mod(v - a % MOD); } friend void operator-=(ll &a, const mint &b) { a = mod(a % MOD - b.v); } mint operator*(const mint &a) { return mint(v * a.v); } mint operator*(const ll a) { return mint(v * (a % MOD)); } mint operator*(const signed a) { return mint(v * (a % MOD)); } friend mint operator*(const ll a, const mint &b) { return mint(a % MOD * b.v); } void operator*=(const mint &a) { v = (v * a.v) % MOD; } void operator*=(const ll a) { v = mod(v * (a % MOD)); } void operator*=(const signed a) { v = mod(v * (a % MOD)); } friend void operator*=(ll &a, const mint &b) { a = mod(a % MOD * b.v); } mint operator/(const mint &a); mint operator/(const ll a); mint operator/(const signed a); friend mint operator/(const ll a, const mint &b); void operator/=(const mint &a); void operator/=(const ll a); void operator/=(const signed a); friend void operator/=(ll &a, const mint &b); //単項演算子 mint operator+() { return *this; } mint operator++() { v++; return *this; } mint operator++(signed d) { mint res = *this; v++; return res; } mint operator-() { return operator*(-1); } mint operator--() { v++; return *this; } void operator--(signed d) { mint res = *this; v++; } bool operator==(mint &a) { return v == a.v; } bool operator==(signed a) { return v == a; } friend bool operator==(signed a, mint &b) { return a == b.v; } bool operator!=(mint &a) { return v != a.v; } bool operator!=(signed a) { return v != a; } friend bool operator!=(signed a, mint &b) { return a != b.v; } operator int() { return v; } }; const int setModMax = 510000; mint fac[setModMax], finv[setModMax], inv[setModMax]; void setMod() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < setModMax; i++) { fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } mint minv(ll a) { if (a < setModMax) return inv[a]; a %= MOD; ll b = MOD, x = 1, y = 0; while (b) { ll t = a / b; a -= t * b; swap(a, b); x -= t * y; swap(x, y); } return (x % MOD + MOD) % MOD; } mint mpow(mint &v, ll a) { ll x = v, n = a, res = 1; while (n) { if (n & 1)res = (res * x) % MOD; x = (x * x) % MOD; n >>= 1; } return res; } mint mint::operator/(const mint &a) { return mint(v * minv(a.v)); } mint mint::operator/(const ll a) { return mint(v * minv(a)); } mint mint::operator/(const signed a) { return mint(v * minv(a)); } mint operator/(const ll a, const mint &b) { return mint(a % MOD * minv(b.v)); } void mint::operator/=(const mint &a) { v = (v * minv(a.v)) % MOD; } void mint::operator/=(const ll a) { v = mod(v * minv(a)); } void mint::operator/=(const signed a) { v = mod(v * minv(a)); } void operator/=(ll &a, const mint &b) { a = mint::mod(a % MOD * minv(b.v)); } mint com(ll n, ll r) { if (n < r || n < 0 || r < 0)return 0; if (fac[0] == 0)setMod(); return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD; } ll u(ll a) { return a < 0 ? 0 : a; } #define ans(a) cout<<a<<endl;continue; int N, M, H, W, cou, A[101010], B[101010], C[101010]; signed dp[50][1010][1010]; signed main() { int a, b; cin >> N >> a >> b; for (int i = 0; i < N; i++) { cin >> A[i] >> B[i] >> C[i]; } fill(dp, INF); dp[0][0][0] = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j < 1010; ++j) { for (int k = 0; k < 1010; ++k) { if (dp[i][j][k] == INF)continue; chmin(dp[i + 1][j + A[i]][k + B[i]], dp[i][j][k] + C[i]); } } } int res = INF; for (int i = 1; i < N + 1; ++i) { for (int j = 0; j < 1010; ++j) { for (int k = 0; k < 1010; ++k) { if (j * b == a * k) chmin(res, dp[i][j][k]); } } } cout << (res == INF ? -1 : res) << endl; return 0; }
a.cc: In function 'int main()': a.cc:345:22: error: no matching function for call to 'chmin(int&, long long int)' 345 | chmin(dp[i + 1][j + A[i]][k + B[i]], dp[i][j][k] + C[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:116:6: note: candidate: 'template<class T> bool chmin(T&, const T&)' 116 | bool chmin(T &a, const T &b) { | ^~~~~ a.cc:116:6: note: template argument deduction/substitution failed: a.cc:345:22: note: deduced conflicting types for parameter 'const T' ('int' and 'long long int') 345 | chmin(dp[i + 1][j + A[i]][k + B[i]], dp[i][j][k] + C[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:354:26: error: no matching function for call to 'chmin(long long int&, int&)' 354 | chmin(res, dp[i][j][k]); | ~~~~~^~~~~~~~~~~~~~~~~~ a.cc:116:6: note: candidate: 'template<class T> bool chmin(T&, const T&)' 116 | bool chmin(T &a, const T &b) { | ^~~~~ a.cc:116:6: note: template argument deduction/substitution failed: a.cc:354:26: note: deduced conflicting types for parameter 'const T' ('long long int' and 'int') 354 | chmin(res, dp[i][j][k]); | ~~~~~^~~~~~~~~~~~~~~~~~
s250550964
p03806
C++
#include<bits/stdc++.h> typedef long long ll; using namespace std; int main(){ int n,x,y; cin>>n>>x>>y; int a[n+1],b[n+1],c[n+1]; ll dp[50][501][501]; ll INF=10000000; for(int i=0; i<n; i++){ cin>>a[i]>>b[i]>>c[i]; } for(int i=0; i<=50; i++){ for(int j=0; j<=500; j++){ for(int k=0; k<=500; k++){ dp[i][j][k]=INF; } } } dp[0][0][0]=0; for(int i=0; i<n; i++){ for(int j=0; j<500; j++){ for(int k=0; k<500; k++){ if(dp[i][j][k]==INF){continue;} dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]); dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]); } } } ll ans=10000000; for(int j=0; j<500; j++){ for(int k=0; k<500; k++){ if(dp[i][j][k]){ if(j*y==k*x){ ans=min(ans,dp[n][j][k]); } } } } if(ans==10000000){ cout<<-1; } else{ cout<<ans; } }
a.cc: In function 'int main()': a.cc:33:39: error: 'i' was not declared in this scope 33 | if(dp[i][j][k]){ | ^
s183952599
p03806
C++
// ==UserScript== // @name AtCoderScoreHider // @namespace https://github.com/task4233 // @version 1.0.6 // @description AtCoder(beta.atcoder.jp)の日本語、英語版の配点を全て隠します。 // @author Mister task4233 // @grant none // @license MIT // @include /^https?://beta\.atcoder\.jp\/contests\/* // ==/UserScript== // --------------------------------------------------------------------------------------------- // 変更したい場合はここをいじってください var display_score = '???';// 点数の代わりに置換される文字列 var problem_page = true;// 問題ページで表示するか否か var top_page = true;// トップページで表示するか否か var source_code_page = true;// ソースコードページで表示するか否か var submit_list_page = true;// 提出コード一覧ページで表示するか否か // --------------------------------------------------------------------------------------------- var i; // 点数表示取得(問題ページ) var problem_page_scores=document.querySelectorAll('#task-statement > span > span > p > var'); // 点数表示取得(トップページ) var top_page_scores=document.querySelectorAll('.span4 > .table > tbody > tr > td'); // 点数表示取得(ソースコードページ) var submit_page_scores=document.querySelectorAll('.panel > table > tbody > tr > td'); // 点数表示取得(提出コード一覧ページ) var submit_list_page_scores=document.querySelectorAll('.table-responsive > table > tbody > tr > td'); if (problem_page && problem_page_scores.length>0){ for(i=0;i<2;++i){ problem_page_scores[i].innerText=display_score; } } if (top_page && top_page_scores.length > 0){ for(i=1;i<top_page_scores.length;i+=2){ top_page_scores[i].innerText = display_score; } } if (source_code_page && submit_page_scores.length > 0){ submit_page_scores[4].innerText = display_score; } // エラー配列 var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; // contains関数 let contains = (str) => { return (errors.indexOf(str) >= 0); } if (submit_list_page && submit_list_page_scores.length > 0){ for(i=4;i<submit_list_page_scores.length; i+=10) { submit_list_page_scores[i].innerText = display_score; if(contains(submit_list_page_scores[i + 2].innerText)) { i -= 2; } } }
a.cc:14:23: warning: trigraph ??' ignored, use -trigraphs to enable [-Wtrigraphs] 14 | var display_score = '???';// 点数の代わりに置換される文字列 a.cc:14:21: warning: multi-character character constant [-Wmultichar] 14 | var display_score = '???';// 点数の代わりに置換される文字列 | ^~~~~ a.cc:24:51: warning: multi-character literal with 39 characters exceeds 'int' size of 4 bytes 24 | var problem_page_scores=document.querySelectorAll('#task-statement > span > span > p > var'); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:26:47: warning: multi-character literal with 33 characters exceeds 'int' size of 4 bytes 26 | var top_page_scores=document.querySelectorAll('.span4 > .table > tbody > tr > td'); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:28:50: warning: multi-character literal with 32 characters exceeds 'int' size of 4 bytes 28 | var submit_page_scores=document.querySelectorAll('.panel > table > tbody > tr > td'); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:30:55: warning: multi-character literal with 43 characters exceeds 'int' size of 4 bytes 30 | var submit_list_page_scores=document.querySelectorAll('.table-responsive > table > tbody > tr > td'); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:15: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~ a.cc:47:21: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~ a.cc:47:27: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~~ a.cc:47:34: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~~ a.cc:47:41: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~ a.cc:47:47: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~~ a.cc:47:54: warning: multi-character character constant [-Wmultichar] 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~~~ a.cc:14:1: error: 'var' does not name a type 14 | var display_score = '???';// 点数の代わりに置換される文字列 | ^~~ a.cc:15:1: error: 'var' does not name a type 15 | var problem_page = true;// 問題ページで表示するか否か | ^~~ a.cc:16:1: error: 'var' does not name a type 16 | var top_page = true;// トップページで表示するか否か | ^~~ a.cc:17:1: error: 'var' does not name a type 17 | var source_code_page = true;// ソースコードページで表示するか否か | ^~~ a.cc:18:1: error: 'var' does not name a type 18 | var submit_list_page = true;// 提出コード一覧ページで表示するか否か | ^~~ a.cc:21:1: error: 'var' does not name a type 21 | var i; | ^~~ a.cc:24:1: error: 'var' does not name a type 24 | var problem_page_scores=document.querySelectorAll('#task-statement > span > span > p > var'); | ^~~ a.cc:26:1: error: 'var' does not name a type 26 | var top_page_scores=document.querySelectorAll('.span4 > .table > tbody > tr > td'); | ^~~ a.cc:28:1: error: 'var' does not name a type 28 | var submit_page_scores=document.querySelectorAll('.panel > table > tbody > tr > td'); | ^~~ a.cc:30:1: error: 'var' does not name a type 30 | var submit_list_page_scores=document.querySelectorAll('.table-responsive > table > tbody > tr > td'); | ^~~ a.cc:32:1: error: expected unqualified-id before 'if' 32 | if (problem_page && problem_page_scores.length>0){ | ^~ a.cc:37:1: error: expected unqualified-id before 'if' 37 | if (top_page && top_page_scores.length > 0){ | ^~ a.cc:42:1: error: expected unqualified-id before 'if' 42 | if (source_code_page && submit_page_scores.length > 0){ | ^~ a.cc:47:1: error: 'var' does not name a type 47 | var errors = ['WJ', 'RE', 'TLE', 'MLE', 'CE', 'OLE', 'QLE']; | ^~~ a.cc:49:1: error: 'let' does not name a type 49 | let contains = (str) => { | ^~~ a.cc:53:1: error: expected unqualified-id before 'if' 53 | if (submit_list_page && submit_list_page_scores.length > 0){ | ^~
s019336139
p03806
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int, int> P; const ll LLINF = LLONG_MAX; #define REP(i, n) for (int i = 0; i < n; i++) int n, ma, mb, a[45], b[45], c[45]; void build(int bg, int en, map<P, int> &mp) { int _n = en - bg; REP(i, (1 << _n)) { int at = 0, bt = 0, ct = 0; REP(j, _n) { if ((i >> j) & 1) { at += a[j + bg]; bt += b[j + bg]; ct += c[j + bg]; } } if (!mp.count({at, bt}) || mp[{at, bt}] > ct) { mp[{at, bt}] = ct; } } } int main() { map<P, int> mp1, mp2; cin >> n >> ma >> mb; REP(i, n) cin >> a[i] >> b[i] >> c[i]; build(0, n / 2, mp1); build(n / 2, n, mp2); int ans = IINF; for (auto it1 : mp1) { for (auto it2 : mp2) { int as, bs; as = it1.first.first + it2.first.first; bs = it1.first.second + it2.first.second; if (as * bs > 0 && as * mb == bs * ma) { ans = min(ans, it1.second + it2.second); } } } cout << (ans != IINF ? ans : -1) << endl; return 0; }
a.cc:5:7: error: 'll' does not name a type 5 | const ll LLINF = LLONG_MAX; | ^~ a.cc: In function 'int main()': a.cc:33:15: error: 'IINF' was not declared in this scope 33 | int ans = IINF; | ^~~~
s651012562
p03806
C++
#include <bits/stdc++.h> using namespace std; #define int long long #define INF (1<<29) #define rep(i,n) for(int i=0;i<(n);i++) int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } int lcm(int a,int b){ return a/gcd(a,b)*b; } int dp[50][500][500],a[50],b[50],c[50],n,ma,mb,ans=INF; signed main(){ cin>>n>>ma>>mb; rep(i,n)cin>>a[i]>>b[i]>c[i]; rep(i,50)rep(j,500)rep(k,500)dp[i][j][k]=INF; dp[0][0][0]=0; for(int i=1;i<=n;i++){ rep(j,500){ rep(k,500){ if(j<a[i-1]||k<b[i-1])dp[i][j][k]=dp[i-1][j][k]; else dp[i][j][k]=min(dp[i-1][j][k],dp[i-1][j-a[i-1]][k-b[i-1]]+c[i-1]); } } } for(int i=1;ma*i<500&&mb*i<1000;i++)ans=min(ans,dp[n][ma*i][mb*i]); if(ans==INF)cout<<-1<<endl; else cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:32: error: no match for 'operator>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'long long int') 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ~~~~~~~~~~~~~~~^~~~~ | | | | | long long int | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} a.cc:16:32: note: candidate: 'operator>(int, long long int)' (built-in) 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ~~~~~~~~~~~~~~~^~~~~ a.cc:16:32: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1176:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1176 | operator>(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1176:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/regex.h:1236:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1236 | operator>(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1236:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/regex.h:1329:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1329 | operator>(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1329:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/regex.h:1403:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1403 | operator>(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1403:5: note: template argument deduction/substitution failed: a.cc:16:36: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/regex.h:1497:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1497 | operator>(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1497:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/regex.h:1573:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1573 | operator>(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1573:5: note: template argument deduction/substitution failed: a.cc:16:36: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/regex.h:1673:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1673 | operator>(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1673:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::pair<_T1, _T2>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:16:36: note: 'std::basic_istream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 16 | rep(i,n)cin>>a[i]>>b[i]>c[i]; | ^ /usr/include/c++/14/string_view:710:5: n
s362313410
p03806
C++
#include<string> #include<vector> #include<algorithm> #include<queue> #include<functional> #include<vector> #include<math.h> using namespace std; typedef long long ll; typedef pair<int, int> P; #define rep(i, n) for(int i=0;i<(n);i++) int inf = 1000000000; ll INF = 1000000000000000000; int n, ma, mb, a[50], b[50], c[50]; int dp[50][1000][1000]; int main() { cin >> n >> ma >> mb; rep(i, 50) { rep(j, 1000) { rep(k, 1000)dp[i][j][k] = inf; } } rep(i, n)cin >> a[i] >> b[i] >> c[i]; dp[0][0][0] = 0; for (int i = 1; i <= n; i++) { rep(j, 1000) { rep(k, 1000) { if (j < a[i - 1] || k < b[i - 1])dp[i][j][k] = dp[i - 1][j][k]; else dp[i][j][k] = min(dp[i - 1][j][k], dp[i - 1][j - a[i - 1]][k - b[i - 1]] + c[i - 1]); } } } int ans = inf; for (int i = 1; ma*i < 1000 && mb*i < 1000; i++) { int z = ans; ans = min(ans, dp[n][ma * i][mb * i]); } if (ans == inf)cout << -1 << endl; else cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:9: error: 'cin' was not declared in this scope 17 | cin >> n >> ma >> mb; | ^~~ a.cc:8:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 7 | #include<math.h> +++ |+#include <iostream> 8 | using namespace std; a.cc:38:24: error: 'cout' was not declared in this scope 38 | if (ans == inf)cout << -1 << endl; | ^~~~ a.cc:38:24: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:38:38: error: 'endl' was not declared in this scope 38 | if (ans == inf)cout << -1 << endl; | ^~~~ a.cc:8:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 7 | #include<math.h> +++ |+#include <ostream> 8 | using namespace std; a.cc:39:14: error: 'cout' was not declared in this scope 39 | else cout << ans << endl; | ^~~~ a.cc:39:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:39:29: error: 'endl' was not declared in this scope 39 | else cout << ans << endl; | ^~~~ a.cc:39:29: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s222721563
p03806
C++
#include <iostream> #include <string> #include <vector> #include <cstdlib> #include <cstdio> #include <cmath> #include <algorithm> #include <map> #include <stack> #include <queue> #include <set> #include <cstring> using namespace std; // ascending order #define vsort(v) sort(v.begin(), v.end()) // descending order #define vsort_r(v) sort(v.begin(), v.end(), greater<int>()) #define vunique(v) unique(v.begin(), v.end()) #define mp make_pair #define ts(x) to_string(x) #define rep(i, a, b) for(int i = (int)a; i < (int)b; i++) #define repm(i, a, b) for(int i = (int)a; i > (int)b; i--) #define bit(a) bitset<8>(a) typedef long long ll; typedef pair<int, int> P; const ll INF = 1e18; int main(){ cin.tie(0); ios::sync_with_stdio(false); int N, Ma, Mb; cin >> N >> Ma >> Mb; int a[N], b[N], c[N]; rep(i, 0, N) cin >> a[i] >> b[i] >> c[i]; if((Ma * i) % Mb != 0) { cout << -1 << endl; return 0; } int dp[N + 1][N * Ma + 1][N * Mb + 1]; rep(i, 0, N + 1) rep(j, 0, N * Ma + 1) rep(k, 0, N * Mb + 1) dp[i][j][k] = 1e9; dp[0][0][0] = 0; rep(i, 0, N) { rep(j, 0, N * Ma + 1) { rep(k, 0, N * Mb + 1) { if(k - b[i] >= 0 && j - a[i] >= 0) { dp[i + 1][j][k] = min(dp[i][j][k], dp[i][j - a[i]][k - b[i]] + c[i]); } else dp[i + 1][j][k] = dp[i][j][k]; } } } int i = 1; int ans = 1e9; while(true) { if(i >= N * Ma + 1 || ((Ma * i) / Mb) >= N * Mb + 1) break; ans = min(ans, dp[N][i][(Ma * i) / Mb]); i++; } if(ans == 0 || ans == 1e9) cout << -1 << endl; else cout << ans << endl; }
a.cc: In function 'int main()': a.cc:37:18: error: 'i' was not declared in this scope 37 | if((Ma * i) % Mb != 0) { | ^
s647989589
p03806
C
#define T 999 D[T][T],i,j,x,y,a,b,c,R;main(k){scanf("%*d%d%d",&x,&y);for(D[0][0]=9999;~scanf("%d%d%d",&a,&b,&c);)for(i=T;i-->a;)for(j=T;j-->b;)k=D[i-a][j-b]-c,D[i][j]<k?D[i][j]=k:0;for(i=x,j=y;i<T&&j<T;i+=x,j+=y)D[i][j]>R?R=D[i][j]:0;printf("%d\n",R>0?9999-R:-1);}
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s060607287
p03806
C
#define T 999 D[T][T], i, j, x, y, a, b, c, r = 9999; main(k) { for (i = -1; ++i < T;) for (j = -1; ++j < T;) D[i][j] = r; scanf("%*d%d%d", &x, &y); for (D[0][0] = 0; ~scanf("%d%d%d", &a, &b, &c);) for (i = T; i-- > a;) for (j = T; j-- > b;) k = D[i - a][j - b] + c, D[i][j] > k ? D[i][j] = k : 0; for (i = x, j = y; i += x < T &&j += y < T;) D[i][j] < r ? r = D[i][j] : 0; printf("%d\n", r < 9999 ? r : -1); }
main.c:2:1: warning: data definition has no type or storage class 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:1: error: type defaults to 'int' in declaration of 'D' [-Wimplicit-int] main.c:2:10: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:13: error: type defaults to 'int' in declaration of 'j' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:16: error: type defaults to 'int' in declaration of 'x' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:19: error: type defaults to 'int' in declaration of 'y' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:22: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:25: error: type defaults to 'int' in declaration of 'b' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:28: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:2:31: error: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] 2 | D[T][T], i, j, x, y, a, b, c, r = 9999; | ^ main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int] 3 | main(k) { | ^~~~ main.c: In function 'main': main.c:3:1: error: type of 'k' defaults to 'int' [-Wimplicit-int] main.c:7:3: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 7 | scanf("%*d%d%d", &x, &y); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | #define T 999 main.c:7:3: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 7 | scanf("%*d%d%d", &x, &y); | ^~~~~ main.c:7:3: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:12:37: error: lvalue required as left operand of assignment 12 | for (i = x, j = y; i += x < T &&j += y < T;) | ^~ main.c:14:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 14 | printf("%d\n", r < 9999 ? r : -1); | ^~~~~~ main.c:14:3: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:14:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:14:3: note: include '<stdio.h>' or provide a declaration of 'printf'
s631362914
p03806
C++
#include <iostream> #include <string> #include <algorithm> #include <cstdio> #include <vector> #include <queue> #include <set> #include <numeric> #include <cmath> using namespace std; typedef long long int ll; #define all(x) x.begin(),x.end() const ll mod = 1e9+7; const int INF = 1e9; const ll MAXN = 1e9; int main() { int n,m_a,m_b; cin >> n >> m_a >> m_b; vector<int> a(n+1),b(n+1),c(n+1); for(int i = 1; i <= n; i++){ cin >> a[i] >> b[i] >> c[i]; } int dp[41][401][401] = {0}; for(int i = 0; i <= 40; i++){ for(int j = 0; j <=400; j++){ for(int k = 0; k <= 400; k++){ dp[i][j][k] = INF; } } } dp[0][0][0] = 0; for(int i = 1; i <= 40; i++){ for(int j = 400; j >= 0; j--){ for(int k = 400; k >= 0; k--){ if(j-a[i]>=0 && k-b[i]>=0){ dp[i][j][k] = min(dp[i-1][j-a[i]][k-b[i]]+c[i],dp[i-1][j][k]); }else{ dp[i][j][k] = min(dp[i][j][k],dp[i-1][j][k]); } } } } int ans = INF; for(int j = 1; j <= 400; j++){ for(int k = 1; k <= 400; k++){ if(k*m_a == j*m_b && dp[n][j][k] < ans) ans = dp[i][j][k]; } } if(ans == INF) cout << -1 << endl; else cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:56:82: error: 'i' was not declared in this scope 56 | if(k*m_a == j*m_b && dp[n][j][k] < ans) ans = dp[i][j][k]; | ^
s025724711
p03806
C
#include<iostream> using namespace std; int a[100], b[100], c[100]; int N, Ma, Mb; int min_cost = 9999; void comb(int current_chemical, int sum_a, int sum_b, int sum_c){ sum_a += a[current_chemical]; sum_b += b[current_chemical]; sum_c += c[current_chemical]; if(sum_c < min_cost){ if(Ma*sum_b != Mb*sum_a){ for(int i=current_chemical+1;i<N;++i){ comb(i, sum_a, sum_b, sum_c); } } else{ min_cost = sum_c; } } } int main(void){ int sum_a=0, sum_b=0, sum_c=0; cin >> N >> Ma >> Mb; for(int i=0;i<N;++i){ cin >> a[i] >> b[i] >> c[i]; } comb(0, sum_a, sum_b, sum_c); cout << ((min_cost == 9999) ? -1 : min_cost) << endl; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s274410535
p03806
C++
#include <iostream> #include <vector> #include <algorithm> #include <list> #include <map> int main(){ int N , Ma , Mb; cin >> N >> Ma >> Mb; int a[50] , b[50] , c[50]; for(int i = 0 ; i < N ; i++){ cin >> a[i] >> b[i] >> c[i]; } for(int ii = 0 ; ii < 50 ; ii ++){ for(int ai = 0 ; ai < nmax*abmax ; ai ++) { for (int bi = 0; bi < nmax*abmax ; bi++) { dp[ii][ai][bi] = INF; } } } dp[0][0][0] = 0; for(int ii = 0 ; ii < N ; ii ++){ for(int ai = 0 ; ai < nmax*abmax ; ai ++) { for (int bi = 0; bi < nmax*abmax ; bi++) { if(dp[ii][ai][bi] == INF) continue; dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]); dp[ii+1][ai+a[ii]][bi+b[ii]] = min(dp[ii+1][ai+a[ii]][bi+b[ii]] , dp[ii][ai][bi]+c[ii]); } } } int res = INF; for(int ma = 1 ; ma <= nmax*abmax ; ma ++) { for (int mb = 1; mb <= nmax*abmax; mb++) { if(ma*Mb == Ma*mb){ res = min(res , dp[N-1][ma][mb]); } } } if(res == INF) cout << -1 << endl; else cout << res << endl; }
a.cc: In function 'int main()': a.cc:10:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 10 | cin >> N >> Ma >> Mb; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:20:31: error: 'nmax' was not declared in this scope 20 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~ a.cc:20:36: error: 'abmax' was not declared in this scope 20 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~~ a.cc:23:17: error: 'dp' was not declared in this scope 23 | dp[ii][ai][bi] = INF; | ^~ a.cc:23:34: error: 'INF' was not declared in this scope 23 | dp[ii][ai][bi] = INF; | ^~~ a.cc:28:5: error: 'dp' was not declared in this scope 28 | dp[0][0][0] = 0; | ^~ a.cc:32:31: error: 'nmax' was not declared in this scope 32 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~ a.cc:32:36: error: 'abmax' was not declared in this scope 32 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~~ a.cc:34:38: error: 'INF' was not declared in this scope 34 | if(dp[ii][ai][bi] == INF) continue; | ^~~ a.cc:35:36: error: 'min' was not declared in this scope; did you mean 'std::min'? 35 | dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]); | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:42:15: error: 'INF' was not declared in this scope 42 | int res = INF; | ^~~ a.cc:43:28: error: 'nmax' was not declared in this scope; did you mean 'ma'? 43 | for(int ma = 1 ; ma <= nmax*abmax ; ma ++) { | ^~~~ | ma a.cc:43:33: error: 'abmax' was not declared in this scope 43 | for(int ma = 1 ; ma <= nmax*abmax ; ma ++) { | ^~~~~ a.cc:46:23: error: 'min' was not declared in this scope; did you mean 'std::min'? 46 | res = min(res , dp[N-1][ma][mb]); | ^~~ | std::min /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:51:20: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 51 | if(res == INF) cout << -1 << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:51:34: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 51 | if(res == INF) cout << -1 << endl; | ^~~~ | std::endl In file included from /usr/include/c++/14/iostream:41: /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~ a.cc:52:10: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 52 | else cout << res << endl; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:52:25: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 52 | else cout << res << endl; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s155960538
p03806
C++
int main(){ int N , Ma , Mb; cin >> N >> Ma >> Mb; int a[50] , b[50] , c[50]; for(int i = 0 ; i < N ; i++){ cin >> a[i] >> b[i] >> c[i]; } for(int ii = 0 ; ii < 50 ; ii ++){ for(int ai = 0 ; ai < nmax*abmax ; ai ++) { for (int bi = 0; bi < nmax*abmax ; bi++) { dp[ii][ai][bi] = INF; } } } dp[0][0][0] = 0; for(int ii = 0 ; ii < N ; ii ++){ for(int ai = 0 ; ai < nmax*abmax ; ai ++) { for (int bi = 0; bi < nmax*abmax ; bi++) { if(dp[ii][ai][bi] == INF) continue; dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]); dp[ii+1][ai+a[ii]][bi+b[ii]] = min(dp[ii+1][ai+a[ii]][bi+b[ii]] , dp[ii][ai][bi]+c[ii]); } } } int res = INF; for(int ma = 1 ; ma <= nmax*abmax ; ma ++) { for (int mb = 1; mb <= nmax*abmax; mb++) { if(ma*Mb == Ma*mb){ res = min(res , dp[N-1][ma][mb]); } } } if(res == INF) cout << -1 << endl; else cout << res << endl; }
a.cc: In function 'int main()': a.cc:5:5: error: 'cin' was not declared in this scope 5 | cin >> N >> Ma >> Mb; | ^~~ a.cc:15:31: error: 'nmax' was not declared in this scope 15 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~ a.cc:15:36: error: 'abmax' was not declared in this scope 15 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~~ a.cc:18:17: error: 'dp' was not declared in this scope 18 | dp[ii][ai][bi] = INF; | ^~ a.cc:18:34: error: 'INF' was not declared in this scope 18 | dp[ii][ai][bi] = INF; | ^~~ a.cc:23:5: error: 'dp' was not declared in this scope 23 | dp[0][0][0] = 0; | ^~ a.cc:27:31: error: 'nmax' was not declared in this scope 27 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~ a.cc:27:36: error: 'abmax' was not declared in this scope 27 | for(int ai = 0 ; ai < nmax*abmax ; ai ++) { | ^~~~~ a.cc:29:38: error: 'INF' was not declared in this scope 29 | if(dp[ii][ai][bi] == INF) continue; | ^~~ a.cc:30:36: error: 'min' was not declared in this scope; did you mean 'main'? 30 | dp[ii+1][ai][bi] = min(dp[ii][ai][bi] , dp[ii+1][ai][bi]); | ^~~ | main a.cc:37:15: error: 'INF' was not declared in this scope 37 | int res = INF; | ^~~ a.cc:38:28: error: 'nmax' was not declared in this scope; did you mean 'ma'? 38 | for(int ma = 1 ; ma <= nmax*abmax ; ma ++) { | ^~~~ | ma a.cc:38:33: error: 'abmax' was not declared in this scope 38 | for(int ma = 1 ; ma <= nmax*abmax ; ma ++) { | ^~~~~ a.cc:41:23: error: 'min' was not declared in this scope; did you mean 'main'? 41 | res = min(res , dp[N-1][ma][mb]); | ^~~ | main a.cc:46:20: error: 'cout' was not declared in this scope 46 | if(res == INF) cout << -1 << endl; | ^~~~ a.cc:46:34: error: 'endl' was not declared in this scope 46 | if(res == INF) cout << -1 << endl; | ^~~~ a.cc:47:10: error: 'cout' was not declared in this scope 47 | else cout << res << endl; | ^~~~ a.cc:47:25: error: 'endl' was not declared in this scope 47 | else cout << res << endl; | ^~~~
s163457882
p03806
C++
#include<bits/stdc++.h> typedef short ll; typedef unsigned long long ull; using namespace std; #define pb push_back int dy[]={0, 0, 1, -1, 1, 1, -1, -1}; int dx[]={1, -1, 0, 0, 1, -1, -1, 1}; #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 mp make_pair #define fi first #define sc second #define INF (30000) ll gcd (ll a,ll b) { if(b == 0) { return a; } return gcd(b,a % b); } ll n,ma,mb,a[100],b[100],c[100]; ll dp[41][2500][2500]; int main(){ cin >> n; cin >> ma >> mb; REP(i,n) { cin >> a[i] >> b[i] >> c[i]; } REP(k,n + 1){ REP(i,1001) { REP(j,1001) { dp[k][i][j] = INF; } } } dp[0][0][0] = 0; REP(i,n) { REP(k,1001) { REP(l,1001) { dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]); dp[i + 1][k][l] = min(dp[i + 1][k][l],dp[i][k][l]); } } } ll ans = INF; FOR(i,1,1001) { FOR(j,1,1001) { ll g = gcd(i,j); if(i / g == ma && j / g == mb) { ans = min(ans,dp[n][i][j]); } } } if(ans < INF) { cout << ans << endl; }else { cout << -1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:49:68: error: no matching function for call to 'min(ll&, int)' 49 | dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: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:49:68: note: deduced conflicting types for parameter 'const _Tp' ('short int' and 'int') 49 | dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:49:68: note: mismatched types 'std::initializer_list<_Tp>' and 'short int' 49 | dp[i + 1][k + a[i]][l + b[i]] = min(dp[i + 1][k + a[i]][l + b[i]],dp[i][k][l] + c[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s420761172
p03806
C++
object Main extends App { val scan = new java.util.Scanner(System.in) val n = scan.next().toInt val ma = scan.next().toInt val mb = scan.next().toInt val ns = for ( _ <- (1 to n).toArray ) yield (scan.next().toInt, scan.next().toInt, scan.next().toInt) val dp: Array[Array[Array[Option[Int]]]] = Array.fill(n+1, 400, 400)(None) dp(0)(0)(0) = Some(0) for ( i <- 1 to n ) { val (a, b, value) = ns(i-1) for ( j <- 0 until n ) { for ( k <- 0 until n ) { dp(i)(j)(k) = (dp(i-1)(j)(k), dp(i)(j)(k)) match { case (Some(n), Some(m)) => Some(math.min(n,m)) case (Some(n), _) => Some(n) case (_, Some(m)) => Some(m) case _ => None } if (a+j<400 && b+k<400) { dp(i)(a+j)(b+k) = (dp(i-1)(j)(k), dp(i-1)(a+j)(b+k)) match { case (Some(n), Some(m)) => Some(math.min(n+value,m)) case (Some(n), _) => Some(n+value) case (_, Some(m)) => Some(m) case _ => None } } } } } val costs = for (i <- 1 until 400; j <- 1 until 400; if ma*j == mb*i; if dp(n)(i)(j) != None) yield { dp(n)(i)(j).get } println(if (costs.nonEmpty) { costs.min } else { -1 }) }
a.cc:1:1: error: 'object' does not name a type 1 | object Main extends App { | ^~~~~~
s629300255
p03806
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define pb push_back #define rep(i, a, n) for(int i = (a); i < (n); i++) #define dep(i, a, n) for(int i = (a); i >= (n); i--) #define mod (ll)(1e9+7) #define int ll __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } struct Y { int a, b, c; }; Y v[50]; map<P, int> y; signed main() { int n, m1, m2; int ans = 1145141919; cin >> n >> m1 >> m2; rep(i, 0, n) cin >> v[i].a >> v[i].b >> v[i].c; rep(i, 0, 1 << n / 2) { Y p; rep(j, 0, n / 2) { if(1 & i >> j) { p.a += v[j].a; p.b += v[j].b; p.c += v[j].c; } } int n1 = p.a, n2 = p.b; while(n1 != n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } if(n1) p.a /= n1; if(n1) p.b /= n1; y[P(p.a, p.b)] = p.c; } rep(i, 0, 1 << n / 2 + ((n / 2) % 2 ? 1 : 0)) { Y p; rep(j, 0, n / 2 + ((n / 2) % 2 ? 1 : 0)) { if(1 & i >> j) { p.a += v[j + n / 2].a; p.b += v[j + n / 2].b; p.c += v[j + n / 2].c; } } int n1 = p.a, n2 = p.b; if(n1 && n2) { while(n1 != n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } } int a1m1 - p.a, a2 = m2 - p.b; if(n1) a1 = m1 - p.a / n1; if(n1) a2 = m2 - p.b / n1; rep(i, 0, 10) { if(y[P(a1 + i, a2 + i)]) { ans = min(ans, p.c + y[P(a1 + i, a2 + i)]); } if(y[P(a2 + i, a1 + i)]) { ans = min(ans, p.c + y[P(a2 + i, a1 + i)]); } } } if(ans != 1145141919) { cout << ans << endl; }else { cout << -1 << endl; } }
a.cc: In function 'int main()': a.cc:73:14: error: expected initializer before '-' token 73 | int a1m1 - p.a, a2 = m2 - p.b; | ^ a.cc:74:12: error: 'a1' was not declared in this scope; did you mean 'n1'? 74 | if(n1) a1 = m1 - p.a / n1; | ^~ | n1 a.cc:75:12: error: 'a2' was not declared in this scope; did you mean 'n2'? 75 | if(n1) a2 = m2 - p.b / n1; | ^~ | n2 a.cc:78:14: error: 'a1' was not declared in this scope; did you mean 'n1'? 78 | if(y[P(a1 + i, a2 + i)]) { | ^~ | n1 a.cc:78:22: error: 'a2' was not declared in this scope; did you mean 'n2'? 78 | if(y[P(a1 + i, a2 + i)]) { | ^~ | n2 a.cc:81:14: error: 'a2' was not declared in this scope; did you mean 'n2'? 81 | if(y[P(a2 + i, a1 + i)]) { | ^~ | n2 a.cc:81:22: error: 'a1' was not declared in this scope; did you mean 'n1'? 81 | if(y[P(a2 + i, a1 + i)]) { | ^~ | n1
s888272990
p03806
C++
#include <iostream> using namespace std; const int nmax=40,abmax=10,inf=1000000; int a[nmax],b[nmax],c[nmax]; long long int dp[nmax+1][nmax*abmax+1][nmax*abmax+1]; int main() { int n,na,nb; cin>>n>>na>>nb; for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i]; for(int i=0;i<=n;i++){ for(int j=0;j<=nmax*abmax;j++){ for(int k=0;k<=nmax*abmax;k++){ dp[i][j][k]=inf; } } } dp[0][0][0]=0; for(int i=0;i<n;i++){ for(int j=0;j<=nmax*abmax;j++){ for(int k=0;k<=nmax*abmax;k++){ if(dp[i][j][k]==inf) continue; dp[i+1][j][k] =min(dp[i+1][j][k], dp[i][j][k]); dp[i+1][j+a[i]][k+b[i]] =min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]); } } } int ans=inf; for(int i=1;i<=nmax*abmax;++i){ for(int j=1;j<=nmax*abmax;j++){ if(i*na==j*nb) ans=min(ans,dp[n][i][j]); } } if(ans==inf)ans=-1; cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:42:47: error: no matching function for call to 'min(int&, long long int&)' 42 | if(i*na==j*nb) ans=min(ans,dp[n][i][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: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:42:47: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 42 | if(i*na==j*nb) ans=min(ans,dp[n][i][j]); | ~~~^~~~~~~~~~~~~~~~~ /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
s714325821
p03806
C++
#include <iostream> using namespace std; int n,na,nb; int na_max,nb_max; int a[45],b[45],c[45]; const long long int inf=1145141919; int main() { cin>>n>>na>>nb; for(int i=0;i<n;i++)cin>>a[i]>>b[i]>>c[i]; na_max=na*n*10; nb_max=nb*n*10; int dp[n+5][na_max][nb_max]; for(int i=0;i<n;i++){ for(int j=0;j<na_max;j++){ for(int k=0;k<nb_max;k++){ dp[i][j][k]=inf; } } } dp[0][0][0]=0; for(int i=0;i<n;i++){ for(int j=0;j<na_max;j++){ for(int k=0;k<nb_max;k++){ dp[i+1][j][k] =min(dp[i+1][j][k],dp[i][j][k]); dp[i+1][j+a[i+1]][k+b[i+1]] =min(dp[i+1][j+a[i+1]][k+b[i+1]],dp[i][j][k]+c[i+1]); } } } for(int i=0;i<n;i++){ cout<<""<<endl; for(int j=0;j<na;j++){ for(int k=0;k<nb;k++){ cout<<dp[i][j][k]<<endl;
a.cc: In function 'int main()': a.cc:40:57: error: expected '}' at end of input 40 | cout<<dp[i][j][k]<<endl; | ^ a.cc:39:46: note: to match this '{' 39 | for(int k=0;k<nb;k++){ | ^ a.cc:40:57: error: expected '}' at end of input 40 | cout<<dp[i][j][k]<<endl; | ^ a.cc:38:38: note: to match this '{' 38 | for(int j=0;j<na;j++){ | ^ a.cc:40:57: error: expected '}' at end of input 40 | cout<<dp[i][j][k]<<endl; | ^ a.cc:36:29: note: to match this '{' 36 | for(int i=0;i<n;i++){ | ^ a.cc:40:57: error: expected '}' at end of input 40 | cout<<dp[i][j][k]<<endl; | ^ a.cc:7:12: note: to match this '{' 7 | int main() { | ^
s204425414
p03806
C++
import sys from collections import deque import copy def get_read_func(fileobject): if fileobject == None : return raw_input else: return fileobject.readline def bfs(X, Ma, Mb): #node_list = deque([0, 1]) drug_dict = {} drug_dict[(0, 0)] = 0 drug_dict[(X[0][0], X[0][1])] = X[0][2] ## drug_dict[0] = ((0, 0) ,0) ## drug_dict[1] = ((X[0][0], X[0][1]), X[0][2]) ## depth = 1 min_cost = sys.maxint new_drug_dict = copy.deepcopy(drug_dict) for i in range(1, len(X)): for drug in drug_dict: cost = drug_dict[drug] new_drug = (drug[0] + X[i][0], drug[1] + X[i][1]) if new_drug not in drug_dict: new_drug_dict[new_drug] = cost + X[i][2] else: new_drug_dict[new_drug] = min(drug_dict[new_drug], cost + X[i][2]) if new_drug[1] * Ma == new_drug[0] * Mb: if new_drug_dict[new_drug] < min_cost: min_cost = new_drug_dict[new_drug] drug_dict = copy.deepcopy(new_drug_dict) return min_cost def main(): if len(sys.argv) > 1: f = open(sys.argv[1]) else: f = None read_func = get_read_func(f); input_raw = read_func().strip().split() [N, Ma, Mb] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])] X = [] for i in range(N): input_raw = read_func().strip().split() [a, b, c] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])] X.append((a, b, c)) cost = bfs(X, Ma, Mb) if cost < sys.maxint: print cost else: print -1 if __name__ == '__main__': main()
a.cc:13:6: error: invalid preprocessing directive #node_list 13 | #node_list = deque([0, 1]) | ^~~~~~~~~ a.cc:17:1: error: stray '##' in program 17 | ## drug_dict[0] = ((0, 0) ,0) | ^~ a.cc:18:1: error: stray '##' in program 18 | ## drug_dict[1] = ((X[0][0], X[0][1]), X[0][2]) | ^~ a.cc:19:1: error: stray '##' in program 19 | ## depth = 1 | ^~ a.cc:58:16: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes 58 | if __name__ == '__main__': | ^~~~~~~~~~ a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:15:5: error: 'drug_dict' does not name a type 15 | drug_dict[(0, 0)] = 0 | ^~~~~~~~~ a.cc:43:5: error: 'input_raw' does not name a type 43 | input_raw = read_func().strip().split() | ^~~~~~~~~
s113184980
p03806
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using pii=pair<int,int>; #define rep(i,n) for(int i=0;i<n;i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define INF 1e9 #define EPS 1e-9 #define MOD (1e9+7) void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);} template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;} template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);} int main(){ int n,ma,mb; cin>>n>>ma>>mb; vvi med(n,vi(3)); for(auto&l:med)for(auto&i:l)cin>>i; int dp[n+1][401][401]; fill(dp[0][0],dp[n+1][0],10000); dp[0][0][0]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=10*(i-1);j++){ for(int k=0;k<=10*(i-1);k++){ if(dp[i-1][j][k]!=10000){ dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); dp[i][j+med[i-1][0]][k+med[i-1][1]]= min(dp[i][j+med[i-1][0]][k+med[i-1][1]], dp[i-1][j][k]+med[i-1][2]); } } } } int ans=10000; for(int i=1;i*max(ma,mb)<=n*10+1 && i<dp[n].size();i++){ ans=min(ans,dp[n][ma*i][mb*i]); } cout<<(ans==10000?-1:ans)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:41:53: error: request for member 'size' in 'dp[n]', which is of non-class type 'int [401][401]' 41 | for(int i=1;i*max(ma,mb)<=n*10+1 && i<dp[n].size();i++){ | ^~~~
s763846069
p03806
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using pii=pair<int,int>; #define rep(i,n) for(int i=0;i<n;i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define INF 1e9 #define EPS 1e-9 #define MOD (1e9+7) void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);} template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;} template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);} int main(){ int n,ma,mb; cin>>n>>ma>>mb; vvi med(n,vi(3)); for(auto&l:med)for(auto&i:l)cin>>i; int dp[n+1][401][401]; fill(dp[0],dp[n],10000); dp[0][0][0]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=10*(i-1);j++){ for(int k=0;k<=10*(i-1);k++){ dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); dp[i][j+med[i-1][0]][k+med[i-1][1]]= min(dp[i][j+med[i-1][0]][k+med[i-1][1]], dp[i-1][j][k]+med[i-1][2]); } } } int ans=10000; for(int i=1;i*max(ma,mb)<=401;i++){ ans=min(ans,dp[n][ma*i][mb*i]); } cout<<(ans==10000?-1:ans)<<endl; return 0; }
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: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[401]; _Tp = int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]': /usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = int (*)[401]; _Tp = int]' 998 | { std::__fill_a1(__first, __last, __value); } | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = int (*)[401]; _Tp = int]' 1029 | std::__fill_a(__first, __last, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:25:6: required from here 25 | fill(dp[0],dp[n],10000); | ~~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const int' to 'int [401]' 952 | *__first = __tmp; | ~~~~~~~~~^~~~~~~
s098491613
p03806
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using pii=pair<int,int>; #define rep(i,n) for(int i=0;i<n;i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define INF 1e9 #define EPS 1e-9 #define MOD (1e9+7) void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);} template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;} template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);} int main(){ int n,ma,mb; cin>>n>>ma>>mb; vvi med(n,vi(3)); for(auto&l:med)for(auto&i:l)cin>>i; int dp[n+1][401][401]; fill(dp,10000); dp[0][0][0]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=10*(i-1);j++){ for(int k=0;k<=10*(i-1);k++){ dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); dp[i][j+med[i-1][0]][k+med[i-1][1]]= min(dp[i][j+med[i-1][0]][k+med[i-1][1]], dp[i-1][j][k]+med[i-1][2]); } } } int ans=10000; for(int i=1;i*max(ma,mb)<=401;i++){ ans=min(ans,dp[n][ma*i][mb*i]); } cout<<(ans==10000?-1:ans)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:25:13: error: no matching function for call to 'fill(int [(n + 1)][401][401], int)' 25 | fill(dp,10000); | ~~~~^~~~~~~~~~ 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:1022:5: note: candidate: 'template<class _ForwardIterator, class _Tp> void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)' 1022 | fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) | ^~~~ /usr/include/c++/14/bits/stl_algobase.h:1022:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: candidate expects 4 arguments, 2 provided
s770892520
p03806
C++
#include <bits/stdc++.h> using namespace std; using ll=long long; using vi=vector<int>; using vvi=vector<vi>; using pii=pair<int,int>; #define rep(i,n) for(int i=0;i<n;i++) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define INF 1e9 #define EPS 1e-9 #define MOD (1e9+7) void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);} template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;} template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);} int main(){ int n,ma,mb; cin>>n>>ma>>mb; vvi med(n,vi(3)); for(auto&l:med)for(auto&i:l)cin>>i; int dp[n+1],[401][401]={{{10000}}}; dp[0][0][0]=0; for(int i=1;i<=n;i++){ for(int j=0;j<=10*(i-1);j++){ for(int k=0;k<=10*(i-1);k++){ dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); dp[i][j+med[i-1][0]][k+med[i-1][1]]= min(dp[i][j+med[i-1][0]][k+med[i-1][1]], dp[i-1][j][k]+med[i-1][2]); } } } int ans=10000; for(int i=1;i*max(ma,mb)<=401;i++){ ans=min(ans,dp[n][ma*i][mb*i]); } cout<<(ans==10000?-1:ans)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:24:21: error: expected unqualified-id before '[' token 24 | int dp[n+1],[401][401]={{{10000}}}; | ^ a.cc:25:14: error: invalid types 'int[int]' for array subscript 25 | dp[0][0][0]=0; | ^ a.cc:29:38: error: invalid types 'int[int]' for array subscript 29 | dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); | ^ a.cc:29:54: error: invalid types 'int[int]' for array subscript 29 | dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); | ^ a.cc:29:68: error: invalid types 'int[int]' for array subscript 29 | dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k]); | ^ a.cc:30:38: error: invalid types 'int[int]' for array subscript 30 | dp[i][j+med[i-1][0]][k+med[i-1][1]]= | ^ a.cc:31:50: error: invalid types 'int[int]' for array subscript 31 | min(dp[i][j+med[i-1][0]][k+med[i-1][1]], | ^ a.cc:32:56: error: invalid types 'int[int]' for array subscript 32 | dp[i-1][j][k]+med[i-1][2]); | ^ a.cc:38:34: error: invalid types 'int[int]' for array subscript 38 | ans=min(ans,dp[n][ma*i][mb*i]); | ^
s813427962
p03806
C++
const int nmax=40,abmax=10,inf = 1000000; int a[nmax],b[nmax],c[nmax]; int dp[nmax+1][nmax*abmax+1][nmax*abmax+1]; int main(void){ int n,ma,mb; cin >> n >> ma >> mb; for(int i=0;i<n;++i){ cin >> a[i] >> b[i] >> c[i]; } for(int i = 0; i <= n; ++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ dp[i][ca][cb]=inf; } } } dp[0][0][0]=0; for(inti=0;i<n;++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ if(dp[i][ca][cb]==inf) continue; dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]); } } } int ans=inf; for(int ca = 1; ca <= nmax*abmax; ++ca){ for(int cb = 1; cb <= nmax*abmax; ++cb){ if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | cin >> n >> ma >> mb; | ^~~ a.cc:18:5: error: 'inti' was not declared in this scope; did you mean 'int'? 18 | for(inti=0;i<n;++i){ | ^~~~ | int a.cc:18:12: error: 'i' was not declared in this scope 18 | for(inti=0;i<n;++i){ | ^ a.cc:22:33: error: 'min' was not declared in this scope; did you mean 'main'? 22 | dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); | ^~~ | main a.cc:29:34: error: 'min' was not declared in this scope; did you mean 'main'? 29 | if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); | ^~~ | main a.cc:32:5: error: 'cout' was not declared in this scope 32 | cout << ans << endl; | ^~~~ a.cc:32:20: error: 'endl' was not declared in this scope 32 | cout << ans << endl; | ^~~~
s277185787
p03806
C
/* cat <<EOF >mistaken-paste */ #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> #define BIG 2000000007 #define VERYBIG 200000000000007LL #define MOD 1000000007 typedef uint64_t ull; typedef int64_t sll; #define N_MAX 200 #define M_MAX 400 #ifdef __cplusplus #include <queue> #include <stack> #include <tuple> using namespace std; // I'm NOT gonna use C++ without compro. shit typedef priority_queue<ull, vector<ull>, greater<ull> > upque123; typedef priority_queue<ull, vector<ull> > upque321; typedef priority_queue<sll, vector<sll>, greater<sll> > spque123; typedef priority_queue<sll, vector<sll> > spque321; #endif typedef struct { int32_t a; int32_t b; } hw; typedef struct { sll a; sll b; } hwll; typedef struct { hwll a; hwll b; } linell; typedef struct { ull s; ull t; int32_t c; } struct_a; typedef struct { int32_t from; int32_t to; sll cost; } struct_b; const hw vector8[8] = { {-1, -1}, {-1, 0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1, 0}, {+1, +1} }; ull n, m; ull h, w; ull k; ull q; ull vua, vub, vuc, vud, vue, vuf; sll vsa, vsb, vsc, vsd, vse, vsf; long double vra, vrb, vrc; double vda, vdb, vdc; size_t slen; size_t tlen; char ch, dh; void swap_adj (ull *a, ull *b) { if (*a != *b) { ull tmp = *b; *b = *a; *a = tmp; } return; } ull divide (ull a, ull b) { ull x = MOD - 2; ull ans = 1; while (x) { if (x & 1) ans = (ans * b) % MOD; b = (b * b) % MOD; x /= 2; } return (a * ans) % MOD; } int32_t digits (ull x) { int32_t i = 1; while (x >= 10) { x /= 10; i++; } return i; } ull umin (ull x, ull y) { return (x < y) ? x : y; } ull umax (ull x, ull y) { return (x > y) ? x : y; } sll smin (sll x, sll y) { return (x < y) ? x : y; } sll smax (sll x, sll y) { return (x > y) ? x : y; } ull gcd (ull x, ull y) { if (x < y) { return gcd(y, x); } else if (y == 0) { return x; } else { return gcd(y, x % y); } } ull bitpow (ull a, ull x, ull modulo) { ull result = 1; while (x) { if (x & 1) { result *= a; result %= modulo; } x /= 2; a = (a * a) % modulo; } return result; } int32_t targetdig (ull x, int32_t index /* 1-indexed */) { // static...? int32_t posmax = digits(x); if (posmax < index) return -1; while (posmax > index) { posmax--; x /= 10; } return x % 10; } int32_t charcomp (const char left, const char right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t pcharcomp (const void *left, const void *right) { char lval = *(char*)left; char rval = *(char*)right; return charcomp(lval, rval); } int32_t intcomp (const int32_t left, const int32_t right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t pintcomp (const void *left, const void *right) { int lval = *(int*)left; int rval = *(int*)right; return intcomp(lval, rval); } int32_t ullcomp (const ull left, const ull right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t pullcomp (const void *left, const void *right) { ull lval = *(ull*)left; ull rval = *(ull*)right; return ullcomp(lval, rval); } int32_t pullrevcomp (const void *left, const void *right) { ull lval = *(ull*)left; ull rval = *(ull*)right; return -ullcomp(lval, rval); } int32_t sllcomp (const sll left, const sll right) { if (left < right) { return -1; } else if (left > right) { return +1; } else { return 0; } } int32_t psllcomp (const void *left, const void *right) { sll lval = *(sll*)left, rval = *(sll*)right; return ullcomp(lval, rval); } int32_t hwllfraccomp (const hwll left, const hwll right) { return ullcomp(left.a * right.b, left.b * right.a); } int32_t phwAcomp (const hw *left, const hw *right) { return intcomp(left->a, right->a); } int32_t phwBcomp (const hw *left, const hw *right) { return intcomp(left->b, right->b); } int32_t phwABcomp (const hw *left, const hw *right) { int32_t x = phwAcomp(left, right); if (x) return x; return phwBcomp(left, right); } int32_t phwllAcomp (const hwll *left, const hwll *right) { return sllcomp(left->a, right->a); } int32_t phwllBcomp (const hwll *left, const hwll *right) { return sllcomp(left->b, right->b); } int32_t phwllABcomp (const void *left, const void *right) { hwll lval = *(hwll*)left, rval = *(hwll*)right; int32_t x = sllcomp(lval.a, rval.a); if (x) return x; return sllcomp(lval.b, rval.b); } int32_t phwllrAcBcomp (const hwll *left, const hwll *right) { int32_t x = -phwllAcomp(left, right); if (x) return x; return phwllBcomp(left, right); } int32_t phwllBAcomp (const hwll *left, const hwll *right) { int32_t x = phwllBcomp(left, right); if (x) return x; return phwllAcomp(left, right); } int32_t pstrAcomp (const struct_a *left, const struct_a *right) { int32_t x; if (x = ullcomp(left->t, right->t)) return x; if (x = ullcomp(left->s, right->s)) return x; if (x = intcomp(left->c, right->c)) return x; return 0; } int32_t bitlet (char c) { return (1 << (c - 'a')); } ull ullabs (ull a, ull b) { if (a >= b) { return a - b; } else { return b - a; } } sll sllabs (sll a, sll b) { if (a >= b) { return a - b; } else { return b - a; } } sll nibutanlobo (bool (*func)(sll arg), sll ok, sll ng) { while (sllabs(ok, ng) > 1) { sll med = (ok + ng) / 2; if (func(med)) { ok = med; } else { ng = med; } // printf("debug: [%lld %lld)\n", ok, ng); } if (!func(ok)) return ok * 2 - ng; return ok; } bool nextrouteint (int32_t arr[], int32_t n) { int32_t i = n - 1; int32_t j, x; while (i > 0 && arr[i - 1] > arr[i]) i--; if (i == 0) return false; x = n; for (j = i; j < n; j++) { if (arr[j] < arr[i - 1]) continue; if (x == n || arr[x] > arr[j]) x = j; } arr[i - 1] ^= arr[x]; arr[x] ^= arr[i - 1]; arr[i - 1] ^= arr[x]; qsort(&arr[i], n - i, sizeof(int32_t), pintcomp); return true; } bool nextrouteull (ull arr[], int32_t n) { int32_t i = n - 1; int32_t j, x; while (i > 0 && arr[i - 1] > arr[i]) i--; if (i == 0) return false; x = n; for (j = i; j < n; j++) { if (arr[j] < arr[i - 1]) continue; if (x == n || arr[x] > arr[j]) x = j; } arr[i - 1] ^= arr[x]; arr[x] ^= arr[i - 1]; arr[i - 1] ^= arr[x]; qsort(&arr[i], n - i, sizeof(ull), pintcomp); return true; } void printUquotient (ull left, ull right) { const int32_t digits = 20; printf("%llu.", left / right); left %= right; for (int32_t i = 0; i < digits; i++) { left *= 10; printf("%1d", left / right); left %= right; } puts(""); return; } void printSquotient (sll left, sll right) { if (left * right < 0) putchar('-'); printUquotient(sllabs(left, 0), sllabs(right, 0)); return; } int bitcount (ull n) { int result = 0; while (n) { if (n & 1) result++; n /= 2; } return result; } #ifdef __cplusplus typedef struct { int32_t to; sll cost; } edge; typedef pair<sll, int32_t> P; std::vector<edge> g[N_MAX]; void dijk_init (ull n, struct_b arr[]) { edge x; for (int32_t i = 0; i < n; i++) { x.to = arr[i].to; x.cost = arr[i].cost; g[arr[i].from].push_back(x); } } void dijk_distinit (int s, sll distance[], ull n) { for (int32_t i = 0; i < n; i++) { distance[i] = BIG; } distance[s] = 0; return; } bool dijkstra (int s, sll distance[]) { priority_queue<P, std::vector<P>, greater<P> > que; // (最短距離, 頂点番号) que.push(P(distance[s], s)); bool ischanged = false; while (!que.empty()) { P p = que.top(); que.pop(); sll v = p.second; if (distance[v] < p.first) continue; int32_t maxsize = g[v].size(); for (int32_t i = 0; i < maxsize; i++) { edge e = g[v][i]; if (distance[e.to] > distance[v] + e.cost) { distance[e.to] = distance[v] + e.cost; ischanged = true; que.push(P(distance[e.to], e.to)); } } } return ischanged; } #endif sll dist[N_MAX]; struct_b path[M_MAX * 2]; ull a[N_MAX]; // sll a[N_MAX]; // ull a[N_MAX][N_MAX]; ull b[N_MAX]; // sll b[N_MAX]; ull c[N_MAX]; // char c[N_MAX]; // char s[N_MAX + 1]; char s[N_MAX + 1][N_MAX + 1]; // char t[N_MAX + 1]; ull alphabets[26]; // char alphabets[26]; // ull dp[N_MAX + 1]; // ull dp[N_MAX + 1][N_MAX + 1]; // bool dp[N_MAX + 1][N_MAX + 1]; // hwll arr[N_MAX]; // typedef tuple<sll, int32_t, int32_t> P2d; ull times[25]; bool dpos[25]; double distance (sll x1, sll y1, sll x2, sll y2) { double xdist2, ydist2, origindist, dist; xdist2 = (x1 - x2) * (x1 - x2); ydist2 = (y1 - y2) * (y1 - y2); return sqrt(xdist2 + ydist2); } ull solve () { sll i, j, ki, l; ull result = 0; // sll result = 0; // double result = 0; ull maybe = 0; // sll maybe = 0; ull sum = 0; // sll sum = 0; ull item; ull *dpcell; // qsortの際には"p"ullcompを使う // result = VERYBIG; // for (i = 0; i < (1 << n); i++) { // if (bitcount(i) != k) continue; // maybe = 0; // ull prev = 0; // for (j = 0; j < n; j++) { // bool iswatched = (i & (1 << j)); // if (prev >= a[j]) { // if (iswatched) { // maybe += (prev + 1 - a[j]); // prev++; // } // } else { // prev = a[j]; // } // // printf("[%llu][%llu] %llu\n", i, j, maybe); // } // // printf("[%llu] %llu\n", i, maybe); // if (maybe < result) result = maybe; // } ull leftn = n / 2; ull rightn = n - leftn; ull leftsum = 0, rightsum = 0; for (i = 0; i < leftn; i++) leftsum += a[i]; for (j = 0; j < rightn; j++) rightsum += a[leftn + j]; for (i = 0; i <= M_MAX; i++) { for (j = 0; j <= M_MAX; j++) { leftall[i][j] = rightall[i][j] = BIG; } } leftall[0][0] = rightall[0][0] = 0; for (i = 0; i < (1 << leftn); i++) { ull asum = 0, bsum = 0, csum = 0; for (j = 0; j < leftn; j++) { if (i & (1 << j)) { asum += a[j]; bsum += b[j]; csum += c[j]; } } dpcell = &leftall[asum][bsum]; *dpcell = umin(*dpcell, csum); } for (i = 0; i < (1 << rightn); i++) { ull asum = 0, bsum = 0, csum = 0; for (j = 0; j < rightn; j++) { if (i & (1 << j)) { asum += a[leftn + j]; bsum += b[leftn + j]; csum += c[leftn + j]; } } dpcell = &rightall[asum][bsum]; *dpcell = umin(*dpcell, csum); } result = BIG; for (i = 0; i <= leftsum; i++) { for (j = 0; j <= rightsum; j++) { // if (j % 100 == 0) printf("[%llu %llu]\n", i, j); ull asum, bsum; asum = i; while (asum <= leftsum + rightsum) { if (((asum * vub) % vua) || !asum) { asum++; continue; } bsum = asum * vub / vua; if (asum > M_MAX || bsum > M_MAX) break; if (bsum >= j) { maybe = leftall[i][j] + rightall[asum - i][bsum - j]; // printf("[%llu + %llu][%llu + %llu] %llu\n", i, (asum - i), j, (bsum - j), maybe); if (maybe < result) result = maybe; } asum += vua / gcd(vua, vub); } // printf("[%llu][%lld] %llu\n", i, j, maybe); } } // ull asum = vua; // while (asum <= M_MAX) { // ull bsum = (asum / vua) * vub; // for (i = 0; i <= asum; i++) { // for (j = 0; j <= bsum; j++) { // maybe = leftall[i][j] + rightall[asum - i][bsum - j]; // if (maybe < result) result = maybe; // } // } // asum += vua; // } if (result == BIG) goto fail; printf("%llu\n", result); // printf("%.12lf\n", (double)result); // puts(s); return 0; success: puts("YES"); // puts("Yes"); // printf("%llu\n", result); // puts("Alice"); return 0; fail: // puts("NO"); // puts("No"); puts("0"); // puts("-1"); // puts("-1 -1 -1"); // puts("Eel"); return 1; } int32_t main (void) { int32_t i, j; int32_t x, y; // scanf("%lf%lf", &vda, &vdb); // scanf("%lld%lld%lld%lld", &vsa, &vsb, &vsc, &vsd); // scanf("%llu%llu", &vua, &vub, &vuc, &vud); // scanf("%llu%llu", &h, &w); scanf("%llu", &n, &m); // scanf("%*llu"); // scanf("%llu", &k, &m, &n); scanf("%llu%llu", &vua, &vub, &vuc, &vud, &vue); // scanf("%lld", &vsa, &vsb, &vsc); // scanf("%s", s); // scanf("%s", t); // scanf("%llu", &k); // for (i = 0; i < n; i++) { // scanf("%llu", &a[i]); // // a[i]--; // } // for (i = 0; i < m; i++) { // scanf("%llu", &b[i]); // } // for (i = 0; i < h; i++) { // scanf("%s", &s[i]); // } // for (i = 0; i < m; i++) { // scanf("%llu", &c[i]); // scanf("%llu", &arr[i].a); // scanf("%llu", &arr[i].b); // // arr[i].a--; // // arr[i].b--; // } // for (i = 0; i < n; i++) { // for (j = 0; j < n; j++) { // scanf("%llu", &a[i][j]); // } // } for (i = 0; i < n; i++) { scanf("%llu%llu%llu", &a[i], &b[i], &c[i]); } // scanf("%llu", &q); // for (i = 0; i < q; i++) { // // scanf("%s%s", s, t); // // solve(); // } // for (i = 0; i < m; i++) { // scanf("%llu%llu", &arr[i].a, &arr[i].b); // arr[i].a--; // arr[i].b--; // } // for (i = 0; i < n; i++) { // for (j = 0; j < m; j++) { // scanf("%llu", &a[i][j]); // a[i][j]--; // } // } solve(); // for (i = 0; i < m; i++) { // scanf("%llu%llu%llu", &vua, &vub, &vuc); // // scanf("%s%s", s, t); // // scanf("%f%f%f", &vda, &vdb, &vdc); // // scanf("%s", s); // solve(); // } // while (scanf("%llu%llu", &n, &k), n + k) { // for (i = 0; i < n; i++) { // scanf("%llu", &a[i]); // } // solve(); // } return 0; }
main.c: In function 'solve': main.c:532:25: error: 'leftall' undeclared (first use in this function) 532 | leftall[i][j] = rightall[i][j] = BIG; | ^~~~~~~ main.c:532:25: note: each undeclared identifier is reported only once for each function it appears in main.c:532:41: error: 'rightall' undeclared (first use in this function) 532 | leftall[i][j] = rightall[i][j] = BIG; | ^~~~~~~~
s492833524
p03806
C++
#include <algorithm> #include <climits> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <iostream> #include <sstream> #include <functional> #include <map> #include <string> #include <cstring> #include <vector> #include <queue> #include <stack> #include <deque> #include <set> #include <list> #include <numeric> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll,ll> P; const double PI = 3.14159265358979323846; const double EPS = 1e-12; const ll INF = 1LL<<29; const ll mod = 1e9+7; #define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i)) #define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d)) #define all(v) (v).begin(), (v).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset((m),(v),sizeof(m)) #define chmin(x,y) (x=min(x,y)) #define chmax(x,y) (x=max(x,y)) #define fst first #define snd second #define UNIQUE(x) (x).erase(unique(all(x)),(x).end()) template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;} #define N 500 ll dp[N][N]; int main(){ ll n, ma, mb; cin>>n>>ma>>mb; rep(i, N) fill(dp, dp+N, INF); dp[0][0] = 0; rep(i, n){ int a, b, c; cin>>a>>b>>c; for(int i = a; i < N; i++) for(int j = b; j < N; j++) chmin(dp[i][j], dp[i-a][j-b]+c); } ll res = INF; for(int i = 1; i*max(ma, mb)<N; i++) chmin(res, dp[i*ma][i*mb]); cout<<(res==INF?-1:res)<<endl; return 0; }
In file included from /usr/include/c++/14/algorithm:60, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'typename __gnu_cxx::__enable_if<std::__is_scalar<_Tp>::__value, void>::__type std::__fill_a1(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = long long int (*)[500]; _Tp = long long int; typename __gnu_cxx::__enable_if<__is_scalar<_Tp>::__value, void>::__type = void]': /usr/include/c++/14/bits/stl_algobase.h:998:21: required from 'void std::__fill_a(_FIte, _FIte, const _Tp&) [with _FIte = long long int (*)[500]; _Tp = long long int]' 998 | { std::__fill_a1(__first, __last, __value); } | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1029:20: required from 'void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = long long int (*)[500]; _Tp = long long int]' 1029 | std::__fill_a(__first, __last, __value); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:16: required from here 47 | rep(i, N) fill(dp, dp+N, INF); | ~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:952:18: error: incompatible types in assignment of 'const long long int' to 'long long int [500]' 952 | *__first = __tmp; | ~~~~~~~~~^~~~~~~
s948515628
p03806
C++
#include<iostream> #include<cstdio> #include<vector> #include<string> #include<functional> #include<queue> #include<map> #include<limits> #include<cmath> #include<algorithm> #include<bitset> #include<utility> #include<complex> #include<cstdlib> #include<set> #include<cctype> #define DBG cerr << '!' << endl; #define REP(i,n) for(int (i) = (0);(i) < (n);++i) #define rep(i,s,g) for(int (i) = (s);(i) < (g);++i) #define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i)) #define PB push_back #define MP make_pair #define FI first #define SE second #define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;} #define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;} #define ALL(v) v.begin(),v.end() using namespace std; typedef long long ll; typedef vector<int> iv; typedef vector<iv> iiv; typedef vector<string> sv; #define INF 10000000 int dp[2][401][401]; int main() { REP(k,2)REP(i,401)REP(j,401)dp[k][i][j] = INF; dp[0][0][0] = dp[1][0][0] = 0; int n,ma,mb; cin >> n >> ma >> mb; REP(v,n) { int a,b,c; cin >> a >> b >> c; REP(i,401-a)REP(j,401-b) { if(dp[v%2][i][j] != INF) { dp[(v+1)%2][i][j] = min(dp[v%2][i][j],vp[(v+1)][i][j]); dp[(v+1)%2][i+a][j+b] = min(dp[(v+1)%2][i+a][j+b],min(dp[v%2][i+a][j+b],dp[v%2][i][j] + c)); } } } int ans = INF; rep(i,1,401)rep(j,1,401) { if(ma*j == mb*i) ans = min(ans,min(dp[0][i][j],dp[1][i][j])); } if(ans != INF) { cout << ans << endl; } else { cout << -1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:57:71: error: 'vp' was not declared in this scope; did you mean 'v'? 57 | dp[(v+1)%2][i][j] = min(dp[v%2][i][j],vp[(v+1)][i][j]); | ^~ | v
s780788613
p03806
C++
#include <bits/stdc++.h> using namespace std; #define INF 900000000 #define LINF 9000000000000000000 typedef long long ll; typedef pair<int, int> P; int n, m1, m2; int a[40], b[40], c[40]; int ans = INF; void dfs(int x, int y, int idx, int sum) { if (x != 0 && y != 0 && sum != 0 && x/m1 == y/m2) { ans = min(ans, sum); return; } if (idx == n) return; dfs(x,y,idx+1,sum); dfs(x+a[idx],y+b[idx],idx+1,sum+c[idx]); } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m1 >> m2; for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i]; dfs(0,0,0,0); if (ans == INF) cout << "-1" << endl; else cout << ans << end; return 0; }
a.cc: In function 'int main()': a.cc:33:26: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 33 | else cout << ans << end; | ~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullpt
s359807722
p03806
C++
#include <bits/stdc++.h> using namespace std; #define INF 900000000 #define LINF 9000000000000000000 typedef long long ll; typedef pair<int, int> P; int n, m1, m2; int a[40], b[40], c[40]; int ans = INF; void dfs(int x, int y, int idx, int sum) { if (x != 0 && y != 0 && sum != 0 && x/m1 == y/m2) { ans = min(ans, sum); return; } if (idx == n) return; dfs(x,y,idx+1,sum); dfs(x+a[idx],y+b[idx],idx+1,sum+c[idx]); } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> n >> m1 >> m2; for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i]; dfs(0,0,0,0); if (ans == INF) cout << '-1' << endl; else cout << ans << end; return 0; }
a.cc:32:33: warning: multi-character character constant [-Wmultichar] 32 | if (ans == INF) cout << '-1' << endl; | ^~~~ a.cc: In function 'int main()': a.cc:33:26: error: no match for 'operator<<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 33 | else cout << ans << end; | ~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, from a.cc:1: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_C
s027553756
p03806
C++
#include<bits/stdc++.h> using namespace std; #define e8 100000000 #define r(i,n) for(int i=0;i<n;i++) int dp[42][4001][4001]; int a,b,c,a1,a2,n,b1; int u[42][4001][4001]; int main(){ r(i,42)r(j,4001)r(k,4001)dp[i][j][k]=e8; dp[0][0][0]=0; u[0][0][0]=1; cin>>n>>a1>>b1; r(i,n){ cin>>a>>b>>c; r(j,4001)r(k,4001) if(!u[i][j][k]){ if(dp[i+1][j+a][k+b]!=e8)dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c); else dp[i+1][j+a][k+b]=dp[i][j][k]+c; } r(j,4001)r(k,4001) if(dp[i][j][k]!=e8){ dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]); u[i+1][j][k]=1; } } int ans=e8; r(j,4001)r(k,4001)if(u[n][j][k])if(j&&k){ if(k*a1==j*b1){ ans=min(ans,dp[n][j][k]); } } cout<<ans<<endl; }
/tmp/ccZRFzlk.o: in function `main': a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `a1' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0xca): relocation truncated to fit: R_X86_64_PC32 against symbol `b1' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x193): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccZRFzlk.o a.cc:(.text+0x20e): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s452083798
p03806
C++
#include<bits/stdc++.h> using namespace std; #define e8 100000000 #define r(i,n) for(int i=0;i<n;i++) int dp[42][4001][4001],a,b,c,a1,a2,n,b1; int u[42][4001][4001]; main(){ r(i,42)r(j,4001)r(k,4001)dp[i][j][k]=e8; dp[0][0][0]=0; u[0][0][0]=1; cin>>n>>a1>>b1; r(i,n){ cin>>a>>b>>c; r(j,4001)r(k,4001) if(!u[i][j][k]){ if(dp[i+1][j+a][k+b]!=e8)dp[i+1][j+a][k+b]=min(dp[i+1][j+a][k+b],dp[i][j][k]+c); else dp[i+1][j+a][k+b]=dp[i][j][k]+c; } r(j,4001)r(k,4001) if(dp[i][j][k]!=e8){ dp[i+1][j][k]=min(dp[i][j][k],dp[i+1][j][k]); u[i+1][j][k]=1; } } int ans=e8; r(j,4001)r(k,4001)if(u[n][j][k])if(j&&k){ if(k*a1==j*b1){ ans=min(ans,dp[n][j][k]); } } cout<<ans<<endl; }
a.cc:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main(){ | ^~~~ /tmp/ccDjDdBz.o: in function `main': a.cc:(.text+0x8e): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `a1' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0xca): relocation truncated to fit: R_X86_64_PC32 against symbol `b1' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x119): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x170): relocation truncated to fit: R_X86_64_PC32 against symbol `u' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x193): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccDjDdBz.o a.cc:(.text+0x20e): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s920876621
p03806
C++
#include <bits/stdc++.h> #define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++) #define INF 1000000000LL using namespace std; typedef long long ll; ll N, MA, MB; vector<ll> A[2], B[2], C[2]; ll dp[2][201][201]; int main(void) { cin >> N >> MA >> MB; REP(i, 0, N) { ll a, b, c; cin >> a >> b >> c; A[i % 2].push_back(a); B[i % 2].push_back(b); C[i % 2].push_back(c); } if(N == 1) { cout << (MA * B[0][0] == MB * A[0][0] ? C[0][0] : -1) << endl; } else { REP(p, 0, 2) { ll n = A[p].size(); REP(i, 0, 201) REP(j, 0, 201) dp[p][i][j] = INF; REP(i, 0, 1 << n) { ll a = 0, b = 0, c = 0; REP(j, 0, n) if(i & (1 << j)) a += A[p][j], b += B[p][j], c += C[p][j]; dp[p][a][b] = min(dp[p][a][b], c); } } ll ans = INF; REP(i, 0, 201) REP(j, 0, 201) REP(k, 0, 201) if((i + k) % MA == 0) { ll l = MB * ((i + k) / MA) - j; if(i == 0 && j == 0 && k == 0 && l == 0) continue; ans = min(ans, dp[0][i][j] + dp[1][k][l]); } cout << ans != INF ? ans : -1 << endl; } }
a.cc: In function 'int main()': a.cc:39:17: error: no match for 'operator!=' (operand types are 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} and 'long long int') 39 | cout << ans != INF ? ans : -1 << endl; | ~~~~~~~~~~~ ^~ | | | std::basic_ostream<char>::__ostream_type {aka std::basic_ostream<char>} a.cc:39:17: note: candidate: 'operator!=(int, long long int)' (built-in) 39 | cout << ans != INF ? ans : -1 << endl; | ^ a.cc:39:17: note: no known conversion for argument 1 from 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} to 'int' In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1305 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed: a.cc:3:13: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1473 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed: a.cc:3:13: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'long long int' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1647 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 500 | operator!=(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1686 | operator!=(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1686:5: note: template argument deduction/substitution failed: a.cc:3:13: note: 'std::basic_ostream<char>::__ostream_type' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 3 | #define INF 1000000000LL | ^~~~~~~~~~~~ a.cc:39:20: note: in expansion of macro 'INF' 39 | cout << ans != INF ? ans : -1 << endl; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1753 | operator!=(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.
s716634495
p03806
C++
#include <bits/stdc++.h> using namespace std; #define all(c) (c).begin(), (c).end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) int dx[4] = {1, 0, -1, 0}; int dy[4] = {0, 1, 0, -1}; struct Data { int a, b, c; Data(int a = 1, int b = 1, int c = 0) : a(a), b(b), c(c) { int g = __gcd(a, b); a /= g; b /= g; } bool operator<(const Data &rhs) const { int c = rhs.a; int d = rhs.b; return make_pair(a * d, c) < make_pair(c * b, rhs.c); } }; int N, M[2]; int a[50], b[50], c[50]; vector<int> s[2]; vector<Data> d[2]; int main() { cin >> N >> M[0] >> M[1]; rep(i, N) cin >> a[i] >> b[i] >> c[i]; rep(i, N) { s[i % 2].push_back(i); } rep(i, 2) rep(S, 1 << s[i].size()) { int A = 0, B = 0, C = 0; if (S == 0) continue; rep(j, s[i].size()) if (S >> j & 1) { A += a[s[j]]; B += b[s[j]]; C += c[s[j]]; } d[i].push_back(Data(A, B, C)); } rep(i, 2) sort(all(d[i])); const int INF = 1e8; int ans = INF; rep(i, d[0].size()) { Data t(M[0] * d[0][i].b, M[1] * d[0][i].a, 0); int idx = lower_bound(all(d[1]), t) - d[1].begin(); if (idx == d[1].size()) continue; int A = d[0][i].a * d[1][idx].a; int B = d[0][i].b * d[1][idx].b; int G = __gcd(A, B); A /= G; B /= G; if (M[0] == A && M[1] == B) { ans = min(ans, d[0][i].c + d[1][idx].c); } } if (ans == INF) ans = -1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:19: error: no match for 'operator[]' (operand types are 'int [50]' and 'std::vector<int>') 36 | A += a[s[j]]; | ^ a.cc:37:19: error: no match for 'operator[]' (operand types are 'int [50]' and 'std::vector<int>') 37 | B += b[s[j]]; | ^ a.cc:38:19: error: no match for 'operator[]' (operand types are 'int [50]' and 'std::vector<int>') 38 | C += c[s[j]]; | ^
s452516511
p03806
C++
#include <iostream> #include <cmath> using namespace std; const int INF = 5000; int main() { int dp[40][405][405]; for (int i=0; i<40; ++i) { for (int j=0; j<405; ++j) { for (int k=0; k<405; ++k) { dp[i][j][k] = INF; } } } dp[0][0][0] = 0; int a[41], b[41], c[41]; for (int i=0; i<n; ++i) { cin >> a[i] >> b[i] >> c[i]; } int n, ma, mb; cin >> n >> ma >> mb; for (int i=0; i<n; ++i) { // int a, b, c; // cin >> a >> b >> c; for (int j=0; j<405; ++j) { for (int k=0; k<405; ++k) { if (dp[i][j][k]<INF) { dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]); dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c); } } } } int ans = INF; for (int i=1; i*ma<=405 && i*mb<=405; ++i) { ans = min(ans, dp[n][i*ma][i*mb]); } if (ans<INF) { cout << ans << endl; } else { cout << -1 << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:25: error: 'n' was not declared in this scope 20 | for (int i=0; i<n; ++i) { | ^ a.cc:35:70: error: no matching function for call to 'min(int&, int*)' 35 | dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:35:70: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'int*') 35 | dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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
s756290622
p03806
C++
const int nmax=40,abmax=10,inf = 1000000; int a[nmax],b[nmax],c[nmax]; int dp[nmax+1][nmax*abmax+1][nmax*abmax+1]; int main(void){ int n,ma,mb; cin >> n >> ma >> mb; for(int i=0;i<n;++i){ cin >> a[i] >> b[i] >> c[i]; } for(int i = 0; i <= n; ++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ dp[i][ca][cb]=inf; } } } dp[0][0][0]=0; for(int i = 0; i < n; ++i){ for(int ca = 0; ca <= nmax*abmax; ++ca){ for(int cb = 0; cb <= nmax*abmax; ++cb){ if(dp[i][ca][cb]==inf) continue; dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); dp[i+1][ca+a[i]][cb+b[i]]=min(dp[i+1][ca+a[i]][cb+b[i]],dp[i][ca][cb]+c[i]); } } } int ans=inf; for(int ca = 1; ca <= nmax*abmax; ++ca){ for(int cb = 1; cb <= nmax*abmax; ++cb){ if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); } } if(ans==inf) ans=-1; cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:1: error: 'cin' was not declared in this scope 8 | cin >> n >> ma >> mb; | ^~~ a.cc:29:41: error: 'min' was not declared in this scope; did you mean 'main'? 29 | dp[i+1][ca][cb]=min(dp[i+1][ca][cb],dp[i][ca][cb]); | ^~~ | main a.cc:38:38: error: 'min' was not declared in this scope; did you mean 'main'? 38 | if(ca*mb==cb*ma) ans=min(ans,dp[n][ca][cb]); | ^~~ | main a.cc:42:9: error: 'cout' was not declared in this scope 42 | cout << ans << endl; | ^~~~ a.cc:42:24: error: 'endl' was not declared in this scope 42 | cout << ans << endl; | ^~~~
s205964205
p03806
C++
g++ -Wall -W -fsanitize=address -o a a.cpp [j415820@calc-argon ~]$ ./a 1 1 10 10 10 10 10 10 10 -1 ^C [j415820@calc-argon ~]$ cat a.cpp #define _CRT_SECURE_NO_WARNINGS #define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define rep2(i,a,b) for(int i=(a);i<(b);++i) #define rrep(i,n) for(int i=(n)-1;i>=0;--i) #define rrep2(i,a,b) for(int i=(a)-1;i>=b;--i) #define range(i,a,b,c) for(int i=a; \ c>0?i<b: \ i>b; \ i+=c) #define chmax(a, b) (a = (a) < (b) ? (b) : (a)) #define chmin(a, b) (a = (a) > (b) ? (b) : (a)) using ll = long long; using ull = unsigned long long; using ld = long double; #define all(a) begin(a),end(a) #define ifnot(a) if(not (a)) #define dump(x) cerr << #x << " = " << (x) << endl #define int long long #ifdef _MSC_VER const bool test = true; #else const bool test = false; #endif int dx[] = { 1,0,-1,0 }; int dy[] = { 0,1,0,-1 }; const int INF = 1 << 28; const ll INFL = (ll)1 << 58; ll mod_n = (int)1e9 + 7; const double eps = 1e-10; typedef long double Real; // return -1, 0, 1 int sgn(const Real& r) { return (r > eps) - (r < -eps); } int sgn(const Real& a, const Real &b) { return sgn(a - b); } //..................... const int MAX = (int)2e5 + 5; vector<string> split(const string &str, char sep) { vector<string> v; stringstream ss(str); string buffer; while (getline(ss, buffer, sep)) { v.push_back(buffer); } return v; } template<class InputIterator> int sum(InputIterator begin, InputIterator end) { return accumulate(begin, end, 0ll); } void solve(); signed main() { cout << fixed << setprecision(20); solve(); while(true) { char s[MAX]; if (scanf("%s", s) == EOF) break; int n = strlen(s); for (int i = n - 1; i > -1; i--) { ungetc(s[i], stdin); } solve(); } return 0; } class Mycin { bool flag = true; public: Mycin& operator >> (int& a) {flag = scanf("%lld", &a) != EOF; return *this;} Mycin& operator >> (char& a) {flag = scanf("%c", &a) != EOF; return *this;} Mycin& operator >> (string& s) {flag = (bool)(cin >> s); return *this;} operator bool() {return flag;} } mycin; class Mycout { public: Mycout& operator << (const int& a) {printf("%lld", a); return *this;} Mycout& operator << (const char c) {printf("%c", c); return *this;} Mycout& operator << (const string& s) {printf("%s", s.c_str()); return *this;} } mycout; #define cin mycin #define cout mycout #define endl '\n' int n; int Ma, Mb; int a[40]; int b[40]; int c[40]; int dp[405][405]; void solve() { cin >> n >> Ma >> Mb; rep(i, n) cin >> a[i] >> b[i] >> c[i]; cerr << endl; rep(i, n) cerr << a[i] << " " << b[i] << " " << c[i] << endl; rep(i, 405) rep(j, 405) dp[i][j] = INF; dp[0][0] = 0; rep(i, n) { rrep(j,395) rrep(k, 395) { chmin(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]); } } int res = INF; rep2(i, 1, 1000) { int d = i * Ma; int e = i * Mb; if (d > 403) break; if (e > 403) break; chmin(res, dp[d][e]); } if (res == INF) cout << (int)-1 << endl; else cout << res << endl; }
a.cc:2:9: error: stray '@' in program 2 | [j415820@calc-argon ~]$ ./a | ^ a.cc:9:9: error: stray '@' in program 9 | [j415820@calc-argon ~]$ cat a.cpp | ^ a.cc:1:1: error: 'g' does not name a type 1 | g++ -Wall -W -fsanitize=address -o a a.cpp | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:13: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) nullptr_t; | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_tempbuf.h:59, from /usr/include/c++/14/bits/stl_algo.h:69, from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive] 132 | __attribute__((__externally_visible__)); | ^ /usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~~~ /usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; |
s002536914
p03806
C++
#include"bits/stdc++.h" //#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<b;i++) #define print(x) cout<<x<<endl; typedef long long ll; const int nmax = 40, abmax = 10, inf = 1000000; int a[nmax], b[nmax], c[nmax]; int dp[nmax + 1][nmax*abmax + 1][nmax*abmax + 1]; int main() { int n, ma, mb; cin >> n >> ma >> mb; rep(i, 0, n) { cin >> a[i] >> b[i] >> c[i]; } for (int i = 0; i <= n; i++) { for (int ca = 0; ca <= nmax*abmax; ca++) { for (int cb = 0; cb <= nmax*abmax; cb++) { dp[i][ca][cb] = inf; } } } dp[0][0][0] = 0; for (int i = 0; i <= n; i++) { for (int ca = 0; ca <= nmax*abmax; ca++) { for (int cb = 0; cb <= nmax*abmax; cb++) { if (dp[i][ca][cb] == inf)continue; dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]); dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]); } } } int ans = inf; for (int ca = 1; ca <= nmax*abmax; ca++) { for (int cb = 1; cb <= nmax*abmax; cb++) { if (ca*mb == cb*ma)ans = min(ans, dp[n][ca][cb]); } } if (ans == inf)ans = -1; print(ans); return 0; }
a.cc: In function 'int main()': a.cc:32:75: error: expected ',' before '+' token 32 | dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]); | ^~ | , a.cc:32:76: error: expected identifier before '+' token 32 | dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]); | ^ a.cc: In lambda function: a.cc:32:80: error: expected '{' before '[' token 32 | dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]); | ^ a.cc: In function 'int main()': a.cc:32:80: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int') a.cc:32:67: error: 'mindp' was not declared in this scope 32 | dp[i + 1][ca + a[i]][cb + b[i]] = mindp([i + 1][ca + a[i]][cb + b[i]], dp[i][ca][cb] + c[i]); | ^~~~~
s695965957
p03806
C++
#include<bits/stdc++.h> using namespace std; inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} typedef long long ll; typedef pair<ll,ll> P; const int INF=INT_MAX / 3; const ll LINF=LLONG_MAX / 3LL; #define CONST 1000000007 #define EPS (1e-8) #define PB push_back #define MP make_pair #define sz(a) ((int)(a).size()) #define reps(i,n,m) for(int i=(n);i<int(m);i++) #define rep(i,n) reps(i,0,n) #define SORT(a) sort((a).begin(),(a).end()) ll mod(ll a,ll m){return (a%m+m)%m;} int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0}; ll n,ma, mb; int main(){ vector<ll> as, bs, cs; cin >> n >> ma >> mb; ll suma = 0, sumb = 0; rep(i, n) { ll a, b, c; cin >> a >> b >> c; as.PB(a); bs.PB(b); cs.PB(c); suma += a; sumb += b; } map<P, ll> mp; for(ll x=0; x < (1<<(n/2)); ++x) { ll a = 0, b = 0, c = 0; rep(i, n/2) { if((x >> i) & 1LL) { a += as[i]; b += bs[i]; c += cs[i]; } } if(mp[P(a,b)] == 0 || mp[P(a, b)] > c) { mp[P(a,b)] = c; } } ll ans = LINF; for(ll x=0; x < (1<<(n - n/2)); ++x) { ll a = 0, b = 0, c = 0; rep(i, n-n/2) { if((x >> i) & 1LL) { a += as[i+n/2]; b += bs[i+n/2]; c += cs[i+n/2]; } } for (int i = 1;; i++) { if (suma < i*ma || sumb < i*mb) break;a ll xa = i * ma; ll xb = i * mb; ll da = xa - a; ll db = xb - b; if(da <= 0 || db <= 0) { continue; } if(mp[P(da, db)] != 0) { ans = min(ans, mp[P(da, db)] + c); } } } cout << ((ans==LINF) ? -1 : ans) << endl; return 0; }
a.cc: In function 'int main()': a.cc:64:46: error: expected ';' before 'll' 64 | if (suma < i*ma || sumb < i*mb) break;a | ^ | ; 65 | ll xa = i * ma; | ~~ a.cc:67:15: error: 'xa' was not declared in this scope; did you mean 'da'? 67 | ll da = xa - a; | ^~ | da
s170643797
p03806
C++
#include<bits/stdc++.h> using namespace std; #define inf 5000 #define priMax 100 #define perMax 10 #define NMax 40 int Calc(int *a,int *b,int *c,int N,int Ma,int Mb,int SN,int **dat){ int **sum; sum=new int**[SN*perMax+1]; for(int i=0;i<=SN;i++) sum[i]=new int*[SN*perMax+1]; for(int i=0;i<=SN*perMax;i++) for(int j=0;j<=N*perMax;j++) sum[i][j]=inf; sum[0][0]=0; if(SN==0) return Calc(a,b,c,N,Ma,Mb,SN+1,sum); for(int an=0;an<=SN*perMax;an++) for(int bn=0;bn<=SN*perMax;bn++){ sum[an][bn] = min(sum[an][bn],dat[an][bn]); sum[an+a[n]][bn+b[n]] = min(dat[an][bn]+c[n],sum[an+a[n]][bn+b[n]]); } if(SN!=N) return Calc(a,b,c,N,Ma,Mb,SN+1,sum); int res=inf; for(int an=0;an<=N*perMax;an++) for(int bn=0;bn<=N*perMax;bn++) if((an!=0||bn!=0)&&an*Mb==bn*Ma)res=min(sum[an][bn],res); if(res==inf) return -1; else return res; } int main(){ int N,Ma,Mb; cin>>N; cin>>Ma; cin>>Mb; int a[N],b[N],c[N]; for(int i=0;i<N;i++){ cin>>a[i]; cin>>b[i]; cin>>c[i]; } cout<<Calc(a,b,c,N,Ma,Mb,0,NULL)<<endl; return 0; }
a.cc: In function 'int Calc(int*, int*, int*, int, int, int, int, int**)': a.cc:10:9: error: cannot convert 'int***' to 'int**' in assignment 10 | sum=new int**[SN*perMax+1]; | ^~~~~~~~~~~~~~~~~~~~~~ | | | int*** a.cc:12:16: error: cannot convert 'int**' to 'int*' in assignment 12 | sum[i]=new int*[SN*perMax+1]; | ^~~~~~~~~~~~~~~~~~~~~ | | | int** a.cc:22:22: error: 'n' was not declared in this scope 22 | sum[an+a[n]][bn+b[n]] = min(dat[an][bn]+c[n],sum[an+a[n]][bn+b[n]]); | ^
s704632651
p03806
C++
#include <iostream> #include <vector> #include <algorithm> #include <utility> struct Med { int a, b, c; }; int N, Ma,Mb; std::vector<Med> vMed; int ans = INT_MAX; int eval(int seek,Med sum) { if (seek == N) return -1; if (!(sum.a ==0 && sum.b == 0) && sum.a*Mb == sum.b*Ma) return sum.c; int ans_0 = eval(seek + 1, sum); Med sum2 = sum; sum2.a += vMed[seek].a; sum2.b += vMed[seek].b; sum2.c += vMed[seek].c; int ans_1 = eval(seek + 1, sum2); if (ans_0 == -1 && ans_1 == -1) return -1; else if (ans_0 == -1) return ans_1; else if (ans_1 == -1) return ans_0; else return std::min(ans_0, ans_1); } int main() { std::cin >> N >> Ma >> Mb; for (int i = 0; i < N; i++) { Med m; std::cin >> m.a >> m.b >> m.c; vMed.push_back(m); } Med m; m.a = 0; m.b = 0; m.c = 0; std::cout << eval(0, m) << std::endl; return 0; }
a.cc:14:11: error: 'INT_MAX' was not declared in this scope 14 | int ans = INT_MAX; | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <utility> +++ |+#include <climits> 5 |
s959799516
p03806
C++
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<stack> #include<queue> #include<vector> typedef long long int ll; using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define REP(i,n) for (int i=0;i<(n);i++) #define EREP(i,n) for (int i=1;i<=(n);i++) const ll MOD = 1000000007; const int INF = 1000000; int N,M,x,y,ans=1,temp,A[45],B[45],C[60]; int dp[402][402][402]={INF}; int main(){ dp[0][0][0]=0; scanf("%d %d %d",&N,&x,&y); REP(i,N){ scanf("%d %d %d",&A[i],&B[i],&C[i]); } REP(i,N) REP(a,400) REP(b,400){ if(dp[i][a][b])continue; dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]); dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]); } ans=INF; EREP(i,400) EREP(j,400){ if(x*j==y*i)ans=min(ans,dp[N][i][j]); } if(ans==INF)ans=-1; cout<<ans; return 0; }
/tmp/cc3jBrWS.s: Assembler messages: /tmp/cc3jBrWS.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccnzT6XU.o: 'No space left on device' /tmp/cc3jBrWS.s: Fatal error: /tmp/ccnzT6XU.o: No such file or directory
s575102818
p03806
C++
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<stack> #include<queue> #include<vector> typedef long long int ll; using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define REP(i,n) for (int i=0;i<(n);i++) #define EREP(i,n) for (int i=1;i<=(n);i++) const ll MOD = 1000000007; const int INF = 1000000; int N,M,x,y,ans=1,temp,A[45],B[45],C[60]; double per; bool vis[100][100][100]={0}; int dp[402][402][402]={INF}; int main(){ dp[0][0][0]=0; scanf("%d %d %d",&N,&x,&y); REP(i,N){ scanf("%d %d %d",&A[i],&B[i],&C[i]); } REP(i,N) REP(a,400) REP(b,400){ if(dp[i][a][b])continue; dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]); dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]); } ans=INF; EREP(i,400) EREP(j,400){ if(x*j==y*i)ans=min(ans,dp[N][i][j]); } if(ans==INF)ans=-1; cout<<ans; return 0; }
/tmp/cczbGr4B.s: Assembler messages: /tmp/cczbGr4B.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccBZvhnl.o: 'No space left on device' /tmp/cczbGr4B.s: Fatal error: /tmp/ccBZvhnl.o: No such file or directory
s161510552
p03806
C++
#include<iostream> #include<cstdio> #include<cmath> #include<cstring> #include<string> #include<stack> #include<queue> #include<vector> typedef long long int ll; using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define REP(i,n) for (int i=0;i<(n);i++) #define EREP(i,n) for (int i=1;i<=(n);i++) const ll MOD = 1000000007; const int INF = 1000000; int N,M,x,y,ans=1,temp,A[45],B[45],C[60]; double per; bool vis[100][100][100]={0}; int dp[402][402][402]={INF}; int main(){ dp[0][0][0]=0; scanf("%d %d %d",N,x,y); per=x/y; REP(i,N){ scanf("%d %d %d",&A[i],&B[i],&C[i]); } REP(i,N) REP(a,400) REP(b,400){ if(dp[i][a][b])continue; dp[i+1][a][b]=min(dp[i+1][a][b],dp[i][a][b]); dp[i+1][a+A[i]][b+B[i]]=min(dp[i+1][a+A[i]][b+B[i]],dp[i][a][b]+C[i]); } ans=INF; EREP(i,400) EREP(j,400){ if(x*j==y*i)ans=min(ans,dp[N][i][j]); } if(ans==INF)ans=-1; cout<<ans; return 0; }
/tmp/ccQdbzeH.s: Assembler messages: /tmp/ccQdbzeH.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccTt8nLH.o: 'No space left on device' /tmp/ccQdbzeH.s: Fatal error: /tmp/ccTt8nLH.o: No such file or directory
s248442527
p03806
C++
#include<iostream> using namespace std; int main(void){ int N,Ma,Mb; cin>>N>>Ma>>Mb; //それぞれ物質Aの含有量,Bの含有量,値段の合計の最大値 const int amax=400; const int bmax=400; const int pmax=100000; //リストを作成してすべてを最大値に初期化 int list[N+1][amax+1][bmax+1]; for(int i=0;i<N+1;i++){ for(int a=0;a<amax+1;a++){ for(int b=0;b<bmax+1;b++){ list[i][a][b]=pmax; } } } //物質AもBもないのは何も買わず、コストも0 for(int i=0;i<=N;i++){ list[i][0][0]=0; } //動的計画法のメイン部分 int a,b,p; for(int i=1;i<=N;i++){ cin>>a>>b>>p; for(int anow=a;anow<=amax;anow++){ for(int bnow=b;bnow<=bmax;bnow++){ if( (list[i-1][anow-a][bnow-b]+p)<list[i-1][anow][bnow] ){ list[i][anow][bnow]=list[i-1][anow-a][bnow-b]+p; } else list[i][anow][bnow]=list[i-1][anow][bnow]; } } } /* for(a=0;a<=bmax;a++){ for(b=0;b<=bmax;b++){ cout<<list[N][a][b]; } cout<<endl; } */ int cost=INF; for(a=1;a<=bmax;a++){ for(b=1;b<=bmax;b++){ if(a*Mb==b*Ma&&list[N][a][b]<cost) cost=list[N][a][b]; } } if(cost==INF) cout<<"-1"; else cout<<cost; return 0; }
a.cc: In function 'int main()': a.cc:57:18: error: 'INF' was not declared in this scope 57 | int cost=INF; | ^~~
s445154953
p03806
C++
#include <iostream> #include <vector> #include <algorithm> #include <limits> using namespace std; int main() { int N, Ma, Mb, a, b, c; cin >> N >> Ma >> Mb; vector<int> veca(N); vector<int> vecb(N); vector<int> vecc(N); for (int i = 0; i < N; i++) cin >> veca[i] >> vecb[i] >> vecc[i]; int ZaiMax = N * 10; vector<int> vecCB(ZaiMax +1, INT_MAX); vector<vector<int>> vecCAB(ZaiMax +1, vecCB); vector<vector<vector<int>>> dp(N+1, vecCAB); dp[0][0][0] = 0; for (int i = 0; i < N; i++) { for (int ca = 0; ca <= ZaiMax; ca++) { for (int cb = 0; cb <= ZaiMax; cb++) { if (dp[i][ca][cb] == INT_MAX) continue; dp[i + 1][ca][cb] = min(dp[i + 1][ca][cb], dp[i][ca][cb]); dp[i + 1][ca + veca[i]][cb + vecb[i]] = min(dp[i + 1][ca + veca[i]][cb + vecb[i]], dp[i][ca][cb] + vecc[i]); } } } int res = INT_MAX; for (int ca = 1; ca <= ZaiMax; ca++) { for (int cb = 1; cb <= ZaiMax; cb++) { if (ca * Mb == cb * Ma) res = min(res, dp[N][ca][cb]); } } if (res == INT_MAX) res = -1; cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:19:38: error: 'INT_MAX' was not declared in this scope 19 | vector<int> vecCB(ZaiMax +1, INT_MAX); | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <limits> +++ |+#include <climits> 5 | using namespace std;
s317317991
p03806
C++
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <iostream> #include <algorithm> #include <stack> #include <numeric> #include <queue> #include <vector> #include <set> #include <map> #include <bitset> #include <functional> using namespace std; typedef long long ll; #define pl pair<ll,ll> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) for(int i=0;i<(n);++i) #define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++) #define dbg(x) cout << #x"="<< (x) << endl #define mp(a,b) make_pair((a),(b)) #define pb(a) push_back(a) #define in(x) cin >> x; #define all(x) (x).begin(), (x).end() #define INF 2147483600 #define fi first #define se second ll ans=0,ll ansc=0; //あとiだけ入る.今のスコア. どこまで見たか ll solve(int i, int j, int k, vector<pl> a){ if(i==0){ return j; }else if(i<0||k>=a.size()){ return INF; }else if(ans<j){ return INF; }else{ ans = min(ans,min(solve(i,j,k+1,a),solve(i-a[k].fi,j+a[k].se,k+1,a))); return ans; } } int main(){ ll n, ma, mb, temp1, temp2, temp3; cin>>n>>ma>>mb; //ans=0,INFになるならエラー vector<pl> a,b; vector<pl> total; vector<ll> c; rep(i,n){ cin>>temp1>>temp2>>temp3; //数学的考察から式を単純に temp1=mb*temp1-ma*temp2; if(temp1>0){ a.pb(mp(temp1,temp3)); }else if(temp1<0){ b.pb(mp(-1*temp1,temp3)); }else{ c.pb(temp3); } } if(c.size()!=0){ sort(all(c)); ansc=min(ansc,c[0]); } //2つに分けれた. if(a.size()==0||b.size()==0){ if(ans==0){ cout<<-1<<endl; }else{ cout<<ans<<endl; } }else{ ans=INF; sort(all(a)); sort(all(b)); if(a.size()<b.size()){ //これで2^20まで落とせたのでループで全探索できる. total.pb(mp(0,0)); rep(i,a.size()){ temp1=total.size(); rep(j,temp1){ temp2=total[j].fi+a[i].fi; temp3=total[j].se+a[i].se; total.pb(mp(temp2,temp3)); } } //全状態を列挙したらナップサック問題. FOR(i,1,total.size()){ //total[i].fiになる詰め込み方. solve(total[i].fi,total[i].se,0,b); } }else{ total.pb(mp(0,0)); rep(i,b.size()){ temp1=total.size(); rep(j,temp1){ temp2=total[j].fi+b[i].fi; temp3=total[j].se+b[i].se; total.pb(mp(temp2,temp3)); } } FOR(i,1,total.size()){ //total[i].fiになる詰め込み方. // dbg(ans); // dbg(solve(total[i].fi,total[i].se,0,a)); solve(total[i].fi,total[i].se,0,a); } } ans=min(ansc,ans); if(ans==0||ans==INF){ cout<<-1<<endl; }else{ cout<<ans<<endl; } } return 0; }
a.cc:32:13: error: expected initializer before 'ansc' 32 | ll ans=0,ll ansc=0; | ^~~~ a.cc: In function 'int main()': a.cc:68:17: error: 'ansc' was not declared in this scope; did you mean 'ans'? 68 | ansc=min(ansc,c[0]); | ^~~~ | ans a.cc:114:25: error: 'ansc' was not declared in this scope; did you mean 'ans'? 114 | ans=min(ansc,ans); | ^~~~ | ans
s612623745
p03806
C++
// g++ temp.cpp // C++ includes used for precompiling -*- C++ -*- // Copyright (C) 2003-2013 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file stdc++.h * This is an implementation file for a precompiled header. */ // 17.4.1.2 Headers // C //#ifndef _GLIBCXX_NO_ASSERT #include <cassert> #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> /* //#if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> */ // 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> /* //#if __cplusplus >= 201103L #include <array> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> */ using namespace std; #define fi first #define se second #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define each(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define maxch(x,y) x=max(x,y) #define minch(x,y) x=min(x,y) #define mp(a,b) make_pair(a,b) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define maxch(x,y) x=max(x,y) #define minch(x,y) x=min(x,y) #define uni(x) x.erase(unique(all(x)),x.end()) template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;} template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;} #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<P, int> PPI; #define INF INT_MAX/3 #define MAX_N int n,ma,mb,i,j,k; ll a[MAX_N+1]; ll b[MAX_N+1]; ll c[MAX_N+1]; ll dp[43][451][451]; void solve(){ cin.tie(0); ios::sync_with_stdio(false); cin>>n>>ma>>mb; rep(i,n){ cin>>a[i]>>b[i]>>c[i]; } ll min_price = INF; // rep(i,MAX_N) fill(dp[i][0],dp[i][MAX_N],-1); rep(i,41){ rep(j,401){ rep(k,401){ dp[i][k][j] = INF; } } } dp[0][0][0] = 0; rep(k,n){ rep(i,400){ rep(j,400){ dp[k+1][i][j] =min(dp[k+1][i][j],dp[k][i][j]); dp[k+1][i+a[k]][j+b[k]] = min(dp[k+1][i+a[k]][j+b[k]],dp[k][i][j]+c[k]); } } } rep(i=1;i*ma<=400&&j*mb<=400;j++){ min_price = min(min_price,dp[n][j*ma][j*mb]); } if(min_price == INF) cout<<-1<<endl; else cout<<min_price<<endl; } int main(){ solve(); return 0; }
a.cc:175:35: error: macro "rep" requires 2 arguments, but only 1 given 175 | rep(i=1;i*ma<=400&&j*mb<=400;j++){ | ^ a.cc:120:9: note: macro "rep" defined here 120 | #define rep(i,n) repl(i,0,n) | ^~~ a.cc: In function 'void solve()': a.cc:175:3: error: 'rep' was not declared in this scope 175 | rep(i=1;i*ma<=400&&j*mb<=400;j++){ | ^~~
s286537113
p03806
C
#include<stdio.h> #include<stdlib.h> int main(){ long int N,Ma,Mb,**abc,i,j,k,x[2],ans=INT32_MAX,tmp; scanf("%ld%ld%ld",&N,&Ma,&Mb); abc=malloc(sizeof(int)*N*3); for(i=0;i<N;i++)abc[i]=malloc(sizeof(int)*3); for(i=0;i<N;i++)for(j=0;j<3;j++)scanf("%ld",&abc[i][j]); for(i=0;i<N;i++){ for(j=i;j<N;j++){ x[0]= Ma*abc[j][1]-Mb*abc[j][0]; x[1]=-Ma*abc[i][1]+Mb*abc[i][0]; if (x[0]*x[1]>0){ tmp=x[0]*abc[i][2]+x[1]*abc[j][2]; if(tmp<0)tmp=-tmp; ans+=(tmp-ans)&(tmp-ans>>31); } } } if(ans^INT32_MAX)printf("%d\n",ans); else puts("-1"); }
main.c: In function 'main': main.c:5:41: error: 'INT32_MAX' undeclared (first use in this function) 5 | long int N,Ma,Mb,**abc,i,j,k,x[2],ans=INT32_MAX,tmp; | ^~~~~~~~~ main.c:3:1: note: 'INT32_MAX' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>' 2 | #include<stdlib.h> +++ |+#include <stdint.h> 3 | main.c:5:41: note: each undeclared identifier is reported only once for each function it appears in 5 | long int N,Ma,Mb,**abc,i,j,k,x[2],ans=INT32_MAX,tmp; | ^~~~~~~~~