submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s240294579
p03782
C++
#include <bits/stdc++.h> #define REP(i,n) for(long long i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) 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; } }; bool dpf[5050][5050]; bool dpe[5050][5050]; int main(){ long long n,k; cin>>n>>k; if(n==1){ cout<<0<<endl; return 0; } long long a[n]; REP(i,n){ cin>>a[i]; } REP(i,n){ if(i==0){ dpf[0][0]=true; if(a[i]<=5000){ dpf[0][a[i]]=true; } }else{ REP(x,k+1){ if(0<=x-a[i] && x-a[i]<=k){ dpf[i][x] = dpf[i-1][x] | dpf[i-1][x-a[i]]; }else{ dpf[i][x] = dpf[i-1][x]; } } } } for(long long i=n-1;i>=0;i--){ if(i==n-1){ dpe[i][0]=true; if(a[i]<=5000){ dpe[i][a[i]]=true; } }else{ REP(x,k+1){ if(0<=x-a[i] && x-a[i]<=k){ dpe[i][x] = dpe[i+1][x] | dpe[i+1][x-a[i]]; }else{ dpe[i][x] = dpe[i+1][x]; } } } } long long ans=n; REP(i,n){ if(i==0){ for(int x=max(k-a[i],0);x<k;x++){ if(dpe[1][x]){ ans--; break; } } continue; } if(i==n-1){ for(int x=max(k-a[i],0);x<k;x++){ if(dpf[n-2][x]){ ans--; break; } } } bool flag=false; for(int x=max(k-a[i],0);x<k;x++){ for(int y=0;y<=x;y++){ if(dpf[i-1][y] && dpe[i+1][x-y]){ ans--; flag = true; break; } } if(flag){ flag = false; break; } } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:139:20: error: no matching function for call to 'max(long long int, int)' 139 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:139:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 139 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:139:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 139 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ a.cc:149:20: error: no matching function for call to 'max(long long int, int)' 149 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:149:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 149 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:149:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 149 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ a.cc:158:18: error: no matching function for call to 'max(long long int, int)' 158 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:158:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 158 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:158:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 158 | for(int x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~
s931567471
p03782
C++
#include <bits/stdc++.h> #define REP(i,n) for(long long i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) 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; } }; bool dpf[5050][5050]; bool dpe[5050][5050]; int main(){ long long n,k; cin>>n>>k; if(n==1){ cout<<0<<endl; return 0; } long long a[n]; REP(i,n){ cin>>a[i]; } REP(i,n){ if(i==0){ dpf[0][0]=true; if(a[i]<=5000){ dpf[0][a[i]]=true; } }else{ REP(x,k+1){ if(0<=x-a[i] && x-a[i]<=k){ dpf[i][x] = dpf[i-1][x] | dpf[i-1][x-a[i]]; }else{ dpf[i][x] = dpf[i-1][x]; } } } } for(long long i=n-1;i>=0;i--){ if(i==n-1){ dpe[i][0]=true; if(a[i]<=5000){ dpe[i][a[i]]=true; } }else{ REP(x,k+1){ if(0<=x-a[i] && x-a[i]<=k){ dpe[i][x] = dpe[i+1][x] | dpe[i+1][x-a[i]]; }else{ dpe[i][x] = dpe[i+1][x]; } } } } long long ans=n; REP(i,n){ if(i==0){ for(long long x=max(k-a[i],0);x<k;x++){ if(dpe[1][x]){ ans--; break; } } continue; } if(i==n-1){ for(long long x=max(k-a[i],0);x<k;x++){ if(dpf[n-2][x]){ ans--; break; } } } bool flag=false; for(long long x=max(k-a[i],0);x<k;x++){ for(long long y=0;y<=x;y++){ if(dpf[i-1][y] && dpe[i+1][x-y]){ ans--; flag = true; break; } } if(flag){ flag = false; break; } } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:139:26: error: no matching function for call to 'max(long long int, int)' 139 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:139:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 139 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:139:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 139 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ a.cc:149:26: error: no matching function for call to 'max(long long int, int)' 149 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:149:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 149 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:149:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 149 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ a.cc:158:24: error: no matching function for call to 'max(long long int, int)' 158 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:158:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 158 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:158:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 158 | for(long long x=max(k-a[i],0);x<k;x++){ | ~~~^~~~~~~~~~
s034002113
p03782
C++
#include<iostream> #include<algorithm> #include<cmath> #include<cstring> #include<cstdlib> #include<ctime> #include<cstdio> #include<string> //#include<string> //#include<sstream> typedef long long ll; #define N 5050 int a[N]={0}; int main(){ ll n,k; cin>>n>>k; for(int i=0; i<n; i++){ cin>>a[i]; } sort(a,a+n);//排序,容易知道一定是最小的那几个是不需要的 ll sum = 0; ll p = n; for(ll i=n-1; i>=0; i--){ if(sum+a[i]<k){ sum +=a[i]; } else{ p = i; } } cout<<p<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 16 | cin>>n>>k; | ^~~ | 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:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'? 20 | sort(a,a+n);//排序,容易知道一定是最小的那几个是不需要的 | ^~~~ | std::sort In file included from /usr/include/c++/14/algorithm:86, from a.cc:2: /usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here 296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last); | ^~~~ a.cc:32:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 32 | cout<<p<<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:32:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 32 | cout<<p<<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) | ^~~~
s824252009
p03782
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; #defne N 5050 int a[N]={0}; int main(){ ll n,k; cin>>n>>k; for(int i=0; i<n; i++){ cin>>a[i]; } sort(a,a+n);//排序,容易知道一定是最小的那几个是不需要的 ll sum = 0; ll p = n; for(ll i=n-1; i>=0; i--){ if(sum+a[i]<k){ sum +=a[i]; } else{ p = i; break; } } cout<<p<<endl; return 0; }
a.cc:4:2: error: invalid preprocessing directive #defne; did you mean #define? 4 | #defne N 5050 | ^~~~~ | define a.cc:5:7: error: 'N' was not declared in this scope 5 | int a[N]={0}; | ^ a.cc: In function 'int main()': a.cc:10:14: error: 'a' was not declared in this scope 10 | cin>>a[i]; | ^ a.cc:12:10: error: 'a' was not declared in this scope 12 | sort(a,a+n);//排序,容易知道一定是最小的那几个是不需要的 | ^
s763123328
p03782
C++
#include <iostream> #include <bitset> #include <algorithm> #define ll long long #define INF 1000000005 #define MOD 1000000007 #define EPS 1e-10 #define rep(i,n) for(int i=0;i<(int)(n);++i) #define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i) #define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i) #define each(a,b) for(auto& (a): (b)) #define all(v) (v).begin(),(v).end() #define len(v) (int)(v).size() #define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end()) #define cmx(x,y) x=max(x,y) #define cmn(x,y) x=min(x,y) #define fi first #define se second #define pb push_back #define show(x) cout<<#x<<" = "<<(x)<<endl #define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl #define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl #define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl #define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl #define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl #define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl using namespace std; typedef pair<int,int> P; typedef pair<ll,ll> pll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<ll> vl; typedef vector<vl> vvl; typedef vector<double> vd; typedef vector<P> vp; typedef vector<string> vs; const int MAX_N = 5005; #define getchar getchar_unlocked inline int in() { int n = 0; short c; while ((c = getchar()) >= '0') n = n * 10 + c - '0'; return n; } int a[MAX_N], sm[MAX_N]; int main() { cin.tie(0); ios::sync_with_stdio(false); int n = in(), K = in(), id = 0; rep(i,n){ a[id] = in(); if(a[id] < K-1) id++; } n = id; sort(a, a+n, greater<int>()); rrep(i,n){ sm[i] = sm[i+1] + a[i]; } int ans = 0; bitset<MAX_N> dp; dp[0] = true; rep(i,n){ if(K+a[i]-sm[i] > 0){ bool flag = true; srep(j,max(0, K-sm[i]),K+a[i]-sm[i]){ if(dp[j]){ flag = false; break; } } ans += flag; } dp |= (dp << a[i]); } cout << ans << "\n"; return 0; }
a.cc:32:9: error: 'vector' does not name a type 32 | typedef vector<int> vi; | ^~~~~~ a.cc:33:9: error: 'vector' does not name a type 33 | typedef vector<vi> vvi; | ^~~~~~ a.cc:34:9: error: 'vector' does not name a type 34 | typedef vector<ll> vl; | ^~~~~~ a.cc:35:9: error: 'vector' does not name a type 35 | typedef vector<vl> vvl; | ^~~~~~ a.cc:36:9: error: 'vector' does not name a type 36 | typedef vector<double> vd; | ^~~~~~ a.cc:37:9: error: 'vector' does not name a type 37 | typedef vector<P> vp; | ^~~~~~ a.cc:38:9: error: 'vector' does not name a type 38 | typedef vector<string> vs; | ^~~~~~
s659064909
p03782
C++
#include <bits/stdc++.h> typedef long long ll; typedef long double ld; const int INF=1e9,MOD=1e9+7,ohara=1e6; const ll LINF=1e18; using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define rrep(i,a,b) for(int i=(a);i<(b);i++) #define rrrep(i,a,b) for(int i=(a);i>=(b);i--) #define all(v) (v).begin(), (v).end() #define Size(n) (n).size() #define Cout(x) cout<<(x)<<endl ll n,cnt,ans,a[ohara],b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k; ld doua; int dy[]={1,0,-1,0}; int dx[]={0,1,0,-1}; //int dy[]={-1,0,1,-1,1,-1,0,1}; //int dx[]={-1,-1,-1,0,0,1,1,1}; string alph("abcdefghijklmnopqrstuvwxyz"),s; bool fl; struct edge{int to,cost;}; //-------------------------↓↓↓↓↓↓------------------------ bool check(ll i){ bitset<5005> dp; dp[0]=true; rep(j,n){ if(i==j)continue; dp|=dp<<a[j]; } b=0; rep(j,k){ if(!dp[j])continue; if(j+a[i]>=k){ b=1; break; } } if(!b)return false; else return true; } int main(void){ cin.tie(0); ios::sync_with_stdio(false); cin>>n>>k; rep(i,n)cin>>a[i]; sort(a,a+n); ll le=0,ri=n-1,mid; while(ri-le>1){ mid=(le+ri)/2; if(check(mid))ri=mid; else le=mid; } rrrep(i,min(ri+500,n-1),max(le-500,0LL)){ bitset<5005> dp; dp[0]=true; rep(j,n){ if(i==j)continue; dp|=dp<<a[j]; } b=0; rep(j,k){ if(!dp[j])continue; if(j+a[i]>=k){ b=1; break; } } if(!b){ ans=max(ans,i+1); break; } } Cout(ans); return 0; }
a.cc: In function 'int main()': a.cc:75:20: error: no matching function for call to 'max(ll&, int)' 75 | ans=max(ans,i+1); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:75:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 75 | ans=max(ans,i+1); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:75:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 75 | ans=max(ans,i+1); | ~~~^~~~~~~~~
s496512862
p03782
C++
#include <bits/stdc++.h> #define int long long #define uint unsigned int #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = (n); i >= 0; --i) #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define FORR(i, a, b) for (int i = (a); i >= (b); --i) #define ALL(a) (a).begin(), (a).end() #define RALL(a) (a).rbegin(), (a).rend() #define SZ(a) ((int)(a).size()) #define PB(a) push_back(a) #define EB(...) emplace_back(__VA_ARGS__) #define MP(a, b) make_pair(a, b) #define MT(...) make_tuple(__VA_ARGS__) #define Bit(n) (1LL << (n)) using namespace std; using pii = pair<int, int>; template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } const int MOD = 1000000007; const int INF = 1LL << 30; const double EPS = 1e-10; int N, K; int a[5010]; int dp[5010]; bool check(int x) { fill(dp, dp+5010, 0); dp[0] = 1; REP(i, N) { if (i == x) continue; REPR(j, K+1) { if (j-a[i] >= 0) dp[j] |= dp[j-a[i]]; } } FOR(i, max(0LL< K-a[x]), K) if (dp[i]) return true; return false; } signed main() { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(10); cin >> N >> K; REP(i, N) cin >> a[i]; sort(a, a+N); int ng = -1, ok = N; while (ok-ng > 1) { int m = (ng+ok)/2; if (check(m)) ok = m; else ng = m; } if (ok < N && check(ok)) cout << ok << endl; else cout << N << endl; return 0; }
a.cc: In function 'bool check(long long int)': a.cc:38:13: error: no matching function for call to 'max(bool)' 38 | FOR(i, max(0LL< K-a[x]), K) if (dp[i]) return true; | ~~~^~~~~~~~~~~~~ a.cc:7:36: note: in definition of macro 'FOR' 7 | #define FOR(i, a, b) for (int i = (a); i < (b); ++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:2: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate expects 2 arguments, 1 provided /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: template argument deduction/substitution failed: a.cc:38:13: note: mismatched types 'std::initializer_list<_Tp>' and 'bool' 38 | FOR(i, max(0LL< K-a[x]), K) if (dp[i]) return true; | ~~~^~~~~~~~~~~~~ a.cc:7:36: note: in definition of macro 'FOR' 7 | #define FOR(i, a, b) for (int i = (a); i < (b); ++i) | ^ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate expects 2 arguments, 1 provided
s658042981
p03782
C++
#include <bits/stdc++.h> #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) for(int i=0;i<(n);++i) #define REPr(i,n) for(int i=(n)-1;i>=0; --i) #define FORq(i, m, n) for(int i = (m);i <= (n);++i) #define FORqr(i, m , n) for(int i = (n);i >=(m);--i) #define SCD(n) scanf("%d",&n) #define SCD2(m,n) scanf("%d%d",&m,&n) #define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k) #define SCLLD(n) scanf("%lld",&n) #define SCLLD2(m,n) scanf("%lld%lld",&m,&n) #define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k) #define PB push_back #define MP make_pair #define ARSCD(A,N) REP(i,N){SCD(A[i]);} #define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);} #define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);} #define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);} #define PRINTD(n) printf("%d\n",n) #define PRINTLLD(n) printf("%lld\n",n) #define DEBUG printf("%s\n","debug") #define fst first #define snd second #define SIN(x,S) (S.count(x) != 0) using namespace std; typedef pair<int,int> PII; typedef vector<int> VI; typedef vector < VI > VVI; typedef vector<long long> VL; typedef long long ll; typedef long long integer; #define M0(x) memset(x,0,sizeof(x)) #define FILL(x,y) memset(x,y,sizeof(x)) #define MM(x) memset(x,-1,sizeof(x)) #define ALL(x) (x).begin(),(x).end() //////////////////////////////////////////////////////////////////// const ll MOD = 1000000007; ll gcd(ll x,ll y){return y?gcd(y,x%y):x;} //////////////////////////////////////////////////////////////////// bool dp[5102][5102] = {}; int main(){ int N,K; SCD2(N,K); vector<int> a; int ans = N; VSCD(a,N); if (N>401) break; // for 300 REP(i,N){ vector<int> S; S.PB(0); // 1-indexed REP(j,N){ if (i==j) continue; S.PB(a[j]); } FORq(j,0,K){ dp[0][j] = false; } dp[0][0] = true; FORq(x,1,N-1){ FORq(y,0,K){ if (y-S[x] < 0) dp[x][y] = dp[x-1][y]; else dp[x][y] = ((dp[x-1][y]) or (dp[x-1][y-S[x]])); //printf("dp[%d][%d] = %d\n",x,y,dp[x][y]); } } FORq(k,K-a[i],K-1){ if (k < 0) continue; if (dp[N-1][k]) { ans -= 1; break; } } } PRINTD(ans); }
a.cc: In function 'int main()': a.cc:50:16: error: break statement not within loop or switch 50 | if (N>401) break; // for 300 | ^~~~~
s132828405
p03782
C++
#include <cstdio> #include <algorithm> using namespace std; int N, K, arr[5000]; bool isPos[5000]; bool judge(int ex) { memset(isPos, false, sizeof isPos); isPos[0] = true; if(K == 1 && arr[ex]) return true; for(int v = K-1; v >= 0; v--) { for(int i = 0; i < N; i++) { if(i != ex && v + arr[i] < K && isPos[v]) { isPos[v + arr[i]] = true; if(v + arr[i] >= K - arr[ex]) return true; } } } return false; } int main () { scanf("%d %d", &N, &K); for(int n = 0; n < N; n++) { scanf("%d", arr + n); } sort(arr, arr + N); int bot = -1, top = N; while(bot + 1 < top) { int mid = (bot + top) / 2; // printf("%d %d %d %d\n", bot, mid, top, judge(mid)); if(judge(mid)) { top = mid; } else{ bot = mid; } } printf("%d\n", bot+1); return 0; }
a.cc: In function 'bool judge(int)': a.cc:10:5: error: 'memset' was not declared in this scope 10 | memset(isPos, false, sizeof isPos); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | using namespace std;
s382535037
p03782
C++
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #include "set" #include "unordered_set" #include "stack" #include "tuple" #define rep(n) for (int i = 0; i < n; ++i) #define REP(n,i) for (int i = 0; i < n; ++i) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" #define mkp make_pair #define mkt make_tuple #define P pair<int,int> typedef long long ll; using namespace std; int n, k, a[5000], l, r; unordered_set<int>st; int main() { cin >> n >> k; rep(n) cin >> a[i]; sort(a, a + n); l = -1; r = n; while (l + 1 != r) { st.clear(); st.insert(0); rep(n) { if (i != (l + r) / 2) { auto it = st.end(); while(it!=st.begin()){ it--; if (*it + a[i] < k)st.insert(*it + a[i]); } } } /* for (auto it = st.begin(); it != st.end(); ++it) cout << *it << sp; cout << endl;*/ bool b = false; for (int i = k - a[(l + r) / 2]; i < k; ++i) { if (st.find(i) != st.end()) { b = true; break; } } if (b) r = (l + r) / 2; else l = (l + r) / 2; } cout << l + 1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:43: error: no 'operator--(int)' declared for postfix '--' [-fpermissive] 47 | it--; | ~~^~
s620918618
p03782
C++
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #include "set" #include "unordered_set" #include "stack" #include "tuple" #define rep(n) for (int i = 0; i < n; ++i) #define REP(n,i) for (int i = 0; i < n; ++i) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" #define mkp make_pair #define mkt make_tuple #define P pair<int,int> typedef long long ll; using namespace std; int n, k, a[5000], l, r; unordered_set<int>st; int main() { cin >> n >> k; rep(n) cin >> a[i]; sort(a, a + n); l = -1; r = n; while (l + 1 != r) { st.clear(); st.insert(0); rep(n) { if (i != (l + r) / 2) { auto it = st.end(); while(it!=st.begin()){ it--; if (*it + a[i] < k)st.insert(*it + a[i]); } } } /* for (auto it = st.begin(); it != st.end(); ++it) cout << *it << sp; cout << endl;*/ bool b = false; for (int i = k - a[(l + r) / 2]; i < k; ++i) { if (st.find(i) != st.end()) { b = true; break; } } if (b) r = (l + r) / 2; else l = (l + r) / 2; } cout << l + 1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:43: error: no 'operator--(int)' declared for postfix '--' [-fpermissive] 47 | it--; | ~~^~
s604827401
p03782
C++
#include "iostream" #include "algorithm" #include "string" #include "vector" #include "cmath" #include "bitset" #include "queue" #include "functional" #include "map" #include "unordered_map" #include "set" #include "unordered_set" #include "stack" #include "tuple" #define rep(n) for (int i = 0; i < n; ++i) #define REP(n,i) for (int i = 0; i < n; ++i) #define mod 1000000007 #define sp ' ' #define intmax 2147483647 #define llmax 9223372036854775807 #define nyan "(=^・ω・^=)" #define mkp make_pair #define mkt make_tuple #define P pair<int,int> typedef long long ll; using namespace std; int n, k, a[5000], l, r; unordered_set<int>st; int main() { cin >> n >> k; rep(n) cin >> a[i]; sort(a, a + n); l = -1; r = n; while (l + 1 != r) { st.clear(); st.insert(0); rep(n) { if (i != (l + r) / 2) { auto it = st.end(); while(it!=st.begin()){ --it; if (*it + a[i] < k)st.insert(*it + a[i]); } } } /* for (auto it = st.begin(); it != st.end(); ++it) cout << *it << sp; cout << endl;*/ bool b = false; for (int i = k - a[(l + r) / 2]; i < k; ++i) { if (st.find(i) != st.end()) { b = true; break; } } if (b) r = (l + r) / 2; else l = (l + r) / 2; } cout << l + 1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:41: error: no match for 'operator--' (operand type is 'std::__detail::_Node_iterator<int, true, false>') 47 | --it; | ^~~~
s248281424
p03782
C++
#include <bits/stdc++.h> #define FOR(i, begin, end) for(int i=(begin);i<(end);i++) #define REP(i, n) FOR(i,0,n) #define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--) #define IREP(i, n) IFOR(i,0,n) #define SORT(a) sort(a.begin(), a.end()) #define REVERSE(a) reverse(a.begin(), a.end()) //#define int long long #define INF 1000000000000000 using namespace std; typedef vector<int> vec; typedef vector<vec> mat; typedef pair<int, int> Pii; template<typename T> void readvec(vector<T> &a); void readindex(vector<int> &a); signed main(){ int N, K; cin >> N >> K; vec a(N); readvec(a); int U = 70; int Nu = N / U + min(1LL, N % U); mat a0(Nu, vec(0)); int sumv = 0; REP(i, Nu){ REP(j, U){ if(i * U + j < N) a0[i].push_back(a[i * U + j]); } } vector<vector<bool>> dp(Nu, vector<bool>(K, false)); REP(i, Nu) dp[i][0] = true; REP(i, Nu){ REP(i2, Nu){ if(i2 == i) continue; REP(j, a0[i2].size()){ vector<bool> dptmp = dp[i]; REP(k, K - a0[i2][j]){ if(dp[i][k]) dptmp[k + a0[i2][j]] = true; } dp[i] = dptmp; } } } int ans = 0; vec calced(K, 0); REP(i, Nu){ REP(j, a0[i].size()){ if(a0[i][j] >= K) continue; if(calced[a0[i][j]] == 1){ ans++; continue; }else if(calced[a0[i][j]] == 2){ continue; } vector<bool> dptmp = dp[i]; bool noneed = true; FOR(k, K - a0[i][j], K){ if(dptmp[k]){ noneed = false; break; } } if(!noneed){ calced[a0[i][j]] = 2; continue; } REP(j2, a0[i].size()){ if(j2 == j) continue; vector<bool> dptmp2 = dptmp; REP(k, K - a0[i][j2]){ if(dptmp[k]) dptmp2[k + a0[i][j2]] = true; } dptmp = dptmp2; } FOR(k, K - a0[i][j], K){ if(dptmp[k]){ noneed = false; break; } } if(noneed){ ans++; calced[a0[i][j]] = 1; }else{ calced[a0[i][j]] = 2; } } } cout << ans; return 0; } template<typename T> void readvec(vector<T> &a){ REP(i, a.size()){ cin >> a[i]; } } void readindex(vector<int> &a){ REP(i, a.size()){ cin >> a[i]; a[i]--; } }
a.cc: In function 'int main()': a.cc:28:25: error: no matching function for call to 'min(long long int, int)' 28 | int Nu = N / U + min(1LL, N % U); | ~~~^~~~~~~~~~~~ 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:28:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 28 | int Nu = N / U + min(1LL, N % U); | ~~~^~~~~~~~~~~~ /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:28:25: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 28 | int Nu = N / U + min(1LL, N % U); | ~~~^~~~~~~~~~~~
s424038773
p03782
C++
v
a.cc:1:1: error: 'v' does not name a type 1 | v | ^
s147379481
p03782
C++
#include<bits/stdc++.h> using namespace std; int n,k; int a[5010]; int f[5010][5010]; bool check(int x) { memset(f,0,sizeof(f)); f[0][0]=1; if (0>=k-a[x]&&0<k) return true; for (int i=1;i<=n;i++) { int tmp=a[i]; if (i==x) tmp=0; f[i][0]=1; for (int j=1;j<k;j++) { if (j>=tmp) f[i][j]=f[i-1][j]|f[i-1][j-tmp]; else f[i][j]=f[i-1][j]; if (j>=k-a[x]&&j<k&&f[i][j]) { return true; } } } return false; } int main() { scanf("%d%d",&n,&k); for (int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+n+1); int l=0,r=n; while (l<r) { int mid=(l+r)/2+1; if (check(mid)) r=mid-1; else l=mid; } else cout<<l<<endl; }
a.cc: In function 'int main()': a.cc:38:9: error: 'else' without a previous 'if' 38 | else cout<<l<<endl; | ^~~~
s645225982
p03782
C++
#include<bits/stdc++.h> using namespace std; int n,k; long a[5050]; int main() { cin>>n>>k; for (int i=1;i<=n;i++) { cin>>a[i]; } sort(a,a+n); int i=n,ans=n; while (i>0 && ans >0) { int s=0,j=i; while (s<k && j>0) { s+=a[j]; j--; } if (s>=k &&j==0) { ans==n; } if (s>=k && j!=0) { ans=j+1; } else { break; } i--; } cout<<n-ans; return 0; }#include<bits/stdc++.h> using namespace std; int n,k; long a[5050]; int main() { cin>>n>>k; for (int i=1;i<=n;i++) { cin>>a[i]; } sort(a,a+n); int i=n,ans=n; while (i>0 && ans >0) { int s=0,j=i; while (s<k && j>0) { s+=a[j]; j--; } if (s>=k &&j==0) { ans==n; } if (s>=k && j!=0) { ans=j+1; } else { break; } i--; } cout<<n-ans; return 0; }
a.cc:38:2: error: stray '#' in program 38 | }#include<bits/stdc++.h> | ^ a.cc:38:3: error: 'include' does not name a type 38 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:40:5: error: redefinition of 'int n' 40 | int n,k; | ^ a.cc:3:5: note: 'int n' previously declared here 3 | int n,k; | ^ a.cc:40:7: error: redefinition of 'int k' 40 | int n,k; | ^ a.cc:3:7: note: 'int k' previously declared here 3 | int n,k; | ^ a.cc:41:6: error: redefinition of 'long int a [5050]' 41 | long a[5050]; | ^ a.cc:4:6: note: 'long int a [5050]' previously declared here 4 | long a[5050]; | ^ a.cc:42:5: error: redefinition of 'int main()' 42 | int main() | ^~~~ a.cc:5:5: note: 'int main()' previously defined here 5 | int main() | ^~~~
s126646345
p03782
C++
#include <iostream> #include <algorithm> using namespace std; int N, K, T, Ans, A[5100]; int main() { cin >> N >> K ; for(register int i = 1; i <= n; i ++ ) cin >> A[i]; sort(A+1, A+N+1); for(register int i = N; i >= 1; i -- ) if(T+A[i] >= K) Ans = 0; else ans++, T += a[i]; cout << ans << endl; }
a.cc: In function 'int main()': a.cc:7:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 7 | for(register int i = 1; i <= n; i ++ ) cin >> A[i]; | ^ a.cc:7:38: error: 'n' was not declared in this scope 7 | for(register int i = 1; i <= n; i ++ ) cin >> A[i]; | ^ a.cc:9:26: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 9 | for(register int i = N; i >= 1; i -- ) | ^ a.cc:11:22: error: 'ans' was not declared in this scope; did you mean 'Ans'? 11 | else ans++, T += a[i]; | ^~~ | Ans a.cc:11:34: error: 'a' was not declared in this scope 11 | else ans++, T += a[i]; | ^ a.cc:12:17: error: 'ans' was not declared in this scope; did you mean 'Ans'? 12 | cout << ans << endl; | ^~~ | Ans
s258054861
p03782
C++
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; import java.util.NoSuchElementException; public class Main { static PrintWriter out; static InputReader ir; static boolean debug = false; static void solve() { long mod = (long) 1e9 + 7; int n = ir.nextInt(); int k = ir.nextInt(); int[] a = ir.nextIntArray(n); boolean[][] dp = new boolean[n][k]; for (int i = 0; i < n; i++) dp[i][0] = true; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (i == j) continue; for (int l = k - 1 - a[j]; l >= 0; l--) dp[i][l + a[j]] |= dp[i][l]; } } for (int i = 0; i < n; i++) { for (int j = k - 2; j >= 0; j--) { dp[i][j] |= dp[i][j + 1]; } } int res = n; for (int i = 0; i < n; i++) { if (dp[i][Math.max(k - a[i], 0)]) res--; } out.println(res); } public static long mod_inverse(long a, long MOD) { long[] ret = extgcd(a, MOD); return (MOD + ret[0] % MOD) % MOD; } public static long[] extgcd(long a, long b) { long[] ret = new long[3]; ret[2] = _extgcd(a, b, ret); return ret; } private static long _extgcd(long a, long b, long[] x) { long g = a; x[0] = 1; x[1] = 0; if (b != 0) { g = _extgcd(b, a % b, x); long temp = x[0]; x[0] = x[1]; x[1] = temp; x[1] -= (a / b) * x[0]; } return g; } private static long[] fact(int n, long MOD) { long[] ret = new long[n + 1]; ret[0] = 1 % MOD; for (int i = 1; i <= n; i++) { ret[i] = ret[i - 1] * i; ret[i] %= MOD; } return ret; } private static long[] factInv(int n, long MOD) { long[] ret = new long[n + 1]; ret[0] = 1; for (int i = 1; i <= n; i++) { ret[i] = ret[i - 1] * mod_inverse((long) i, MOD) % MOD; } return ret; } public static long comb(int n, int m, long[] fact, long[] factInv, long MOD) { long ret = fact[n]; ret *= factInv[m]; ret %= MOD; ret *= factInv[n - m]; ret %= MOD; return ret; } public static void main(String[] args) { ir = new InputReader(System.in); out = new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer = new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) { this.in = in; this.curbuf = this.lenbuf = 0; } public boolean hasNextByte() { if (curbuf >= lenbuf) { curbuf = 0; try { lenbuf = in.read(buffer); } catch (IOException e) { throw new InputMismatchException(); } if (lenbuf <= 0) return false; } return true; } private int readByte() { if (hasNextByte()) return buffer[curbuf++]; else return -1; } private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); } private void skip() { while (hasNextByte() && isSpaceChar(buffer[curbuf])) curbuf++; } public boolean hasNext() { skip(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } public int nextInt() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public long nextLong() { if (!hasNext()) throw new NoSuchElementException(); int c = readByte(); while (isSpaceChar(c)) c = readByte(); boolean minus = false; if (c == '-') { minus = true; c = readByte(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res = res * 10 + c - '0'; c = readByte(); } while (!isSpaceChar(c)); return (minus) ? -res : res; } public double nextDouble() { return Double.parseDouble(next()); } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public char[][] nextCharMap(int n, int m) { char[][] map = new char[n][m]; for (int i = 0; i < n; i++) map[i] = next().toCharArray(); return map; } } static void tr(Object... o) { if (debug) out.println(Arrays.deepToString(o)); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.IOException; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.InputStream; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.io.PrintWriter; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.Arrays; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: 'import' does not name a type 5 | import java.util.InputMismatchException; | ^~~~~~ a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:6:1: error: 'import' does not name a type 6 | import java.util.NoSuchElementException; | ^~~~~~ a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:1: error: expected unqualified-id before 'public' 8 | public class Main { | ^~~~~~
s328196308
p03782
C++
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const ll maxn = 5010; ll n,k,a[maxn],ans,sum; bool f[maxn]; int main() { scanf("%lld%lld",&n,&k); for (ll i = 0; i < n; i++) { scanf("%lld",&a[i]); sum += min(a[i],k); } sort(a,a + 1 + n); f[0] = 1; for (ll i = n; i >= 0; i--) { bool flag = true; for (ll j = k - 1; j >= max(0,k - sum); j--) if (f[j]) { flag = false; break; } if (flag) { ans = i; break; } for (ll j = k; j >= a[i]; j--) if (f[j - a[i]]) f[j] = 1; sum -= a[i]; } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:26:36: error: no matching function for call to 'max(int, ll)' 26 | for (ll j = k - 1; j >= max(0,k - sum); 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:3: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:26:36: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 26 | for (ll j = k - 1; j >= max(0,k - sum); j--) | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:26:36: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 26 | for (ll j = k - 1; j >= max(0,k - sum); j--) | ~~~^~~~~~~~~~~
s160143242
p03782
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int N, K; long long a[5002]; bool dp[5003][5000]; bool is_needed(int x){ for(int k = 0; k < K; k++){ dp[0][k] = false; } dp[0][0] = true; for(int i = 0; i < N; i++){ for(int k = 0; k < K; k++){ dp[i+1][k] = dp[i][k]; } if(i != x){ for(int k = 0; k < K; k++){ if(a[i] + k < K){ dp[i+1][a[i]+k] = dp[i][k] || dp[i+1][a[i]+k]; } } } } bool ret = false; for(int k = max(0, K - a[x]); k < K; k++){ ret = ret || dp[N][k]; } return ret; } // is_needed(begin) == false, is_needed(end) == true int find(int begin, int end){ if(end - begin == 1){ return begin; } int mid = (begin + end)/2; if(is_needed(mid)){ return find(begin, mid); }else{ return find(mid, end); } } int main(){ cin >> N >> K; for(int i = 0; i < N; i++){ cin >> a[i]; } sort(a, a+N); if(is_needed(0) == true){ cout << 0 << endl; return 0; } if(is_needed(N-1) == false){ cout << N << endl; return 0; } cout << find(0, N-1) + 1 << endl; }
a.cc: In function 'bool is_needed(int)': a.cc:30:20: error: no matching function for call to 'max(int, long long int)' 30 | for(int k = max(0, K - a[x]); k < K; k++){ | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 30 | for(int k = max(0, K - a[x]); k < K; k++){ | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 30 | for(int k = max(0, K - a[x]); k < K; k++){ | ~~~^~~~~~~~~~~~~
s438918817
p03782
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<random> #include<functional> #include<algorithm> #include<cstdio> #include<bitset> #include<unordered_map> using namespace std; //--------------------------------------------------- //ライブラリゾーン!!!! typedef long long ll; typedef long double ld; #define str string #define rep(i,j) for(ll i=0;i<(long long)(j);i++) #define all(a) (a).begin(),(a).end() const ll Mod = 1000000007; const ll gosenchou = 5000000000000000; short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } }; struct P { ll pos, cost; }; bool operator<(P a, P b) { return a.cost < b.cost; } bool operator>(P a, P b) { return a.cost > b.cost; } struct B {//隣接リスト表現 ll to, cost; }; struct E {//辺の情報を入れる変数 ll from, to, cost; }; bool operator<(E a, E b) { return a.cost < b.cost; } struct H { ll x, y; }; bool operator<(H a, H b) { if (a.x != b.x) return a.x < b.x; return a.y < b.y; } bool operator>(H a, H b) { if (a.x != b.x) return a.x > b.x; return a.y > b.y; } bool operator==(H a, H b) { return a.x == b.x&&a.y == b.y; } bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; } ll gcm(ll i, ll j) {//最大公約数 if (i > j) swap(i, j); if (i == 0) return j; return gcm(j%i, i); } ld rad(H a, H b) { return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0)); }//rad=座標上の2点間の距離 ll ari(ll a, ll b, ll c) { return (a + b)*c / 2; }//等差数列の和 ll fact(ll x, ll k, ll p) {//最大値、個数、あまり ll sum = 1; for (int i = 0; i < k; i++) { sum *= (x--); sum %= p; } return sum; }//階乗(正) ll mod_pow(ll x, ll n, ll p) { ll res = 1; while (n > 0) { if (n & 1) res = res*x%p; x = x*x%p; n >>= 1; } return res; }//x^n%p short ctos(char a) { return (int)(a - '0'); } #define int long long const long long Inf = 4523372036854775807; const int inf = 15000000000; //---------------------------------------------------- //++++++++++++++++++++++++++++++++++++++++++++++++++++ int n, k; int a[5000]; bool dp[5001]; vector<int>v, r; bool solve(int t) { for (int i = 0; i < k; i++) dp[i] = 0; dp[0] = 1; for (int i = 0; i < n; i++) { for (int z = 0; z < (i == t ? r[i] - 1 : r[i]); z++) { for (int j = k; j >= v[i]; j--) { if (dp[j - v[i]]) dp[j] = 1; } } } bool l = 0; for (int i = max(0, k - v[t]); i < k; i++) if (dp[i]) l = 1; return l; } signed main() { cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; if (a[i] >= k) i--, n--; } sort(a, a + n); reverse(a, a + n); int m = n; for (int i = 0; i < n; ) { int j = i; while (j < n&&a[i] == a[j]) j++; v.push_back(a[i]); r.push_back(j - i); i = j; } n = v.size(); int s = 0, e = n, t; while (e - s > 1) { t = (s + e) / 2; if (solve(t)) s = t; else e = t; } int ans = 0; if (!solve(0)) cout << m << endl; else { for (int i = e; i < n; i++) ans += r[i]; cout << ans << endl; } }
a.cc: In function 'bool solve(long long int)': a.cc:111:25: error: no matching function for call to 'max(int, long long int)' 111 | for (int i = max(0, k - v[t]); i < k; i++) | ~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:111:25: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 111 | for (int i = max(0, k - v[t]); i < k; i++) | ~~~^~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:12: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:111:25: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 111 | for (int i = max(0, k - v[t]); i < k; i++) | ~~~^~~~~~~~~~~~~
s447633630
p03782
C++
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx") //#include<bits/stdc++.h> #include <map> #include <set> #include <list> #include <cmath> #include <ctime> #include <deque> #include <queue> #include <stack> #include <string> #include <bitset> #include <cstdio> #include <limits> #include <vector> #include <climits> #include <cstring> #include <cstdlib> #include <fstream> #include <numeric> #include <sstream> #include <cassert> #include <iomanip> #include <iostream> #include <algorithm> #include <unordered_set> #include <unordered_map> #define _USE_MATH_DEFINES #define ll long long #define ins Not Needed Thing #define ull unsigned long long #define ld long double #define Accepted 0 #define pb push_back #define pii pair<int,int> #define pll pair<ll,ll> #define mp make_pair #define sz(x) (int)(x.size()) #define all(x) x.begin(),x.end() #define F first #define S second #define SORRY FUL Accepted #define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0) #define Toktama Kazakhstan using namespace std; const double eps = 0.000001; const ld pi = acos(-1); const int maxn = 1e7 + 9; const int mod = 1e9 + 7; const ll MOD = 1e18 + 9; const ll INF = 1e18 + 123; const int inf = 2e9 + 11; const int mxn = 1e6 + 9; const int N = 3e5 + 123; const int PRI = 555557; const int pri = 997; int tests = 1; int n, k, ans; int a[5005]; ll dp[5005][5005][2]; ll pre[5005]; inline void Solve () { //easy cin >> n >> k; dp[0][0][0] = dp[0][0][1] = 0; for (int i = 1; i <= n; i ++) { cin >> a[i]; for (int j = 0; j <= k; j ++) { dp[i][j][0] = dp[i][j][1] = INF; } for (int j = k - 1; j >= 0; j --) { int nxt = j + a[i]; nxt = min(nxt, k); if (dp[i][nxt][0] > dp[i][j][0] + a[i]) { dp[i][nxt][0] = dp[i][j][0] + a[i]; } } } reverse(a + 1, a + n + 1); for (int i = 1; i <= n; i ++) { for (int j = k - 1; j >= 0; j --) { int nxt = j + a[i]; nxt = min(nxt, k); if (dp[i][nxt][1] > dp[i][j][1] + a[i]) { dp[i][nxt][1] = dp[i][j][1] + a[i]; } } } for (int i = 1; i <= n; i ++) { for (int j = 1; j <= k; j ++) pre[j] = 0; for (int j = 0; j <= k; j ++) { if (dp[i - 1][j][0] < INF) pre[j] = 1; pre[j] += pre[j - 1]; } bool is = 0; for (int j = 0; j <= k; j ++) { if (dp[i + 1][j][1] < INF && pre[k] - pre[k - j]) } ans += is; } cout << ans; } int main () { SpeedForce; // freopen(".in", "r", stdin); // freopen(".out", "w", stdout); // cin >> tests; while(tests --) { Solve (); // Ee Zadrot } return Accepted; }
a.cc: In function 'void Solve()': a.cc:112:17: error: expected primary-expression before '}' token 112 | } | ^
s854414137
p03782
C++
#include<iostream> #include<vector> #include<alogorithm> using namespace std; int main() { int N, K, ans=0; bool tmp; cin >> N >> K; vector<int> vect(K, 0),old_vect(K,0); vector<int> avect(N); old_vect[0]++; for(int i=0 ; i<N ; i++){ cin >> avect[i]; for(int j=0 ; j < K ; j++){ if( j-avect[i] < 0){ vect[j] = old_vect[j]; }else{ vect[j] = (old_vect[j] + old_vect[j-avect[i]]); } } swap(vect, old_vect); } swap(vect, old_vect); for(int i=0; i<N ; i++){ tmp = false; if(avect[i] >= K) tmp = true; for(int j=max(0,K-avect[i]); j< K; j++){ tmp = tmp || (((j-avect[i]) >= 0) && ((vect[j] - vect[j-avect[i]]) > 0)); } if(!tmp) ans++; } cout << ans << endl; return 0; }
a.cc:3:9: fatal error: alogorithm: No such file or directory 3 | #include<alogorithm> | ^~~~~~~~~~~~ compilation terminated.
s197393210
p03782
C++
/* *** In The Name of God ... *** */ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; //#define int long long #define all(v) v.begin() , v.end() #define pb push_back #define endl '\n' template<typename T> inline bool smin(T &a, const T &b){ return b < a ? a = b,1:0;} template<typename T> inline bool smax(T &a, const T &b){ return a < b ? a = b,1:0;} const int N = 5000 + 10 ; int n , a [ N ] , k ; bool dp [ N ] ; bool chk ( int mid ) { memset ( dp , 0 , sizeof dp ) ; dp [ 0 ] = 1 ; for ( int i = 1 ; i <= mid ; i++ ) { for ( int j = N - 1 ; j >= a [ i ] ; j-- ) { dp [ j ] |= dp [ j - a [ i ] ] ; } } bool isFound = 0 ; for ( int i = max ( 0 , k - a [ mid ) ; i < k ; i++ ) isFound |= dp [ i ] ; return !isFound ; } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> k ; for ( int i = 1 ; i <= n ; i++ ) cin >> a [ i ] ; sort ( a + 1 , a + n + 1 ) ; int lo = -1 , hi = n + 1 ; while ( hi - lo > 1 ) { int mid = ( hi + lo ) >> 1 ; ( chk ( mid ) ? lo : hi ) = mid ; } cout << lo << '\n' ; }
a.cc: In function 'bool chk(int)': a.cc:31:44: error: expected ']' before ')' token 31 | for ( int i = max ( 0 , k - a [ mid ) ; i < k ; i++ ) | ^~ | ]
s229125402
p03782
C++
#include<bits/stdc++.h> #define int long long #define fi first #define se second #define PB push_back using namespace std; typedef pair<int, int> P1; typedef pair<int, pair<int, int> > P2; static const int INF = 1ll<<60; static const int dx[] = { 1, -1, 0, 0, }; static const int dy[] = { 0, 0, 1, -1 }; static const int mod = 1000000007; int N,K; int a[5005]; int dp[5005][5005]; vector<int> A; bool solve(int i){ A.erase(A.begin()+i); //cout<<a[i]<<endl; //for(auto a:A)cout<<a<<" "; //cout<<endl; int n=A.size(); for(int j=0;j<=N;++j)for(int k=0;k<=K;++k)dp[j][k]=0; if(A[0]<=K)dp[0][A[0]]=1; dp[0][0] = 1; int res=0; for(int j=1;j<n;++j){ for(int k=0;k<=K;++k){ if(k-A[j]<0)dp[j][k] = dp[j-1][k]; else dp[j][k] = (dp[j-1][k]||dp[j-1][k-A[j]]); } } //cout<<i<<endl; for(int k=max(0,K-a[i]);k<=K;++k){ //if(k<0)break; if(dp[n-1][k])res=1; //cout<<k<<" "<<dp[n-1][k]<<endl; } A.insert(A.begin()+i,a[i]); if(res)return true; else return false; } signed main(){ cin>>N>>K; for(int i=0;i<N;++i){ cin>>a[i]; A.PB(a[i]); } sort(a,a+N); sort(A.begin(),A.end()); int ans = 0; int res; int l=0,r=N; int mid; for(int i=0;i<30;++i){ mid = (l+r)/2; if(solve(mid))r=mid; else l=mid; //cout<<l<<" "<<r<<" "<<mid<<endl; } //cout<<l<<" "<<r<<" "<<mid<<endl; cout<<l+1<<endl; }
a.cc: In function 'bool solve(long long int)': a.cc:36:18: error: no matching function for call to 'max(int, long long int)' 36 | for(int k=max(0,K-a[i]);k<=K;++k){ | ~~~^~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:36:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 36 | for(int k=max(0,K-a[i]);k<=K;++k){ | ~~~^~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:36:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 36 | for(int k=max(0,K-a[i]);k<=K;++k){ | ~~~^~~~~~~~~~
s349154666
p03782
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int n,k,s,ss; int a[5010]; int ans; int f[5010]; int main() { scanf("%d%d",&n,&k); for(int i=1;i<=n;i++) { int x; scanf("%d",&x); if(x>=k)continue; a[++s]=x; ss+=x; } if(ss<=k) { printf("0");return 0; } sort(a+1,a+s+1); for(int i=1;i<=s;i++) { if(ss-a[i]<k)continue; memset(f,false,sizeof(f)); int mx; if(i!=s)mx=a[s];else mx=a[s-1]; if(mx>=k-a[i])continue; bool ff=false; for(int j=1;j<=s;j++) { if(i==j)continue; if(f[a[j]])f[a[j]]=2;else f[a[j]]=1; } for(int j=1;j<k;j++) { for(int l=1;l<=j/2;l++) { if(l==j-l && f[l]!=2)continue; if(f[l] && f[j-l]) { if(f[j])f[j]=2;else f[j]=1; if(j>=k-a[i])ff=true; break; } } if(ff)break; } if(!ff)ans++; } printf("%d",ans); return 0; }
a.cc: In function 'int main()': a.cc:28:17: error: 'memset' was not declared in this scope 28 | memset(f,false,sizeof(f)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s721769023
p03782
C++
include<bits/stdc++.h> using namespace std; long long N, K; long long a[5005]; bool ldp[5005][5005]; bool rdp[5005][5005]; int main(){ cin >> N >> K; for(long long i = 0; i < N; i++){ cin >> a[i]; } //ldp[i] <-- i 未満 for(long long i = 0; i < N; i++){ for(long long j = 0; j < K; j++){ if(j == 0 || ldp[i][j]){ ldp[i][j] = true; if(j + a[i] < K){ ldp[i+1][j+a[i]] = true; } } } } //for(int i = 0; i < N; i++){ // for(int j = 0; j < K; j++){ // cout << "ldp[" << i << "][" << j << "]=" << ldp[i][j] << endl; // } //} //rdp[i] <-- i 以上 for(long long i = N-1; i >= 0; i--){ for(long long j = 0; j < K; j++){ if(j == 0 || rdp[i+1][j]){ rdp[i][j] = true; if(j + a[i] < K){ rdp[i][j+a[i]] = true; } } } } //cout << endl; //for(int i = 0; i < N; i++){ // for(int j = 0; j < K; j++){ // cout << "rdp[" << i << "][" << j << "]=" << rdp[i][j] << endl; // } //} long long ans = 0; for(long long i = 0; i < N; i++){ //can I create [K-a[i], K) bool ok = false; for(long long create = K - a[i]; create < K && ok == false; create++){ for(long long left = 0; left <= create && ok == false; left++){ long long right = create - left; if((left == 0 || ldp[i][left]) && (right == 0 || rdp[i+1][right])){ ans++; ok = true; } } } } cout << ans << endl;; }
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc: In function 'int main()': a.cc:11:9: error: 'cin' was not declared in this scope 11 | cin >> N >> K; | ^~~ a.cc:67:9: error: 'cout' was not declared in this scope 67 | cout << ans << endl;; | ^~~~ a.cc:67:24: error: 'endl' was not declared in this scope 67 | cout << ans << endl;; | ^~~~
s473058329
p03782
C++
int N, K; int A[5010]; bool dp[5010][5010]; void solve() { cin >> N >> K; rep(i, 1, N + 1) cin >> A[i]; sort(A, A + N + 1); dp[N][min(K, A[N])] = true; dp[N][0] = true; for(int i = N - 1; i >= 1; i--) { int a = -1; for(int j = K; j >= 0; j--) { if(j - A[i] >= 0) dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - A[i]]); else dp[i][j] = dp[i + 1][j]; if(a == -1 && dp[i + 1][j]) a = j; } if(K - a <= A[N]) dp[i][K] = true; //debug(i, vec(dp[i], dp[i] + K + 1)); if(!dp[i][K] || A[N - 1] == A[N]) continue; bool ok = false; for(int j = K - 1; j >= K - A[i - 1]; j--) { if(dp[i][j]) { ok = true; break; } } if(!ok) { cout << i - 1 << "\n"; return; } } if(dp[1][K]) { cout << "0\n"; } else cout << N << "\n"; }
a.cc: In function 'void solve()': a.cc:7:9: error: 'cin' was not declared in this scope 7 | cin >> N >> K; | ^~~ a.cc:8:13: error: 'i' was not declared in this scope 8 | rep(i, 1, N + 1) cin >> A[i]; | ^ a.cc:8:9: error: 'rep' was not declared in this scope 8 | rep(i, 1, N + 1) cin >> A[i]; | ^~~ a.cc:9:9: error: 'sort' was not declared in this scope; did you mean 'short'? 9 | sort(A, A + N + 1); | ^~~~ | short a.cc:10:15: error: 'min' was not declared in this scope 10 | dp[N][min(K, A[N])] = true; | ^~~ a.cc:15:54: error: 'max' was not declared in this scope 15 | if(j - A[i] >= 0) dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - A[i]]); | ^~~ a.cc:30:25: error: 'cout' was not declared in this scope 30 | cout << i - 1 << "\n"; | ^~~~ a.cc:36:17: error: 'cout' was not declared in this scope 36 | cout << "0\n"; | ^~~~ a.cc:38:14: error: 'cout' was not declared in this scope 38 | else cout << N << "\n"; | ^~~~
s479171660
p03782
C++
#include <iostream> #include <vector> #include <queue> #include <cstdio> #include <algorithm> using namespace std; int a[5020]; int n,k; bool d[5020]; bool test(int idx){ if(a[idx]>=k) return true; memset(d,false,sizeof(d)); d[0]=true; for(int i=0;i<n;i++){ if(i==idx) continue; for(int j = k-1;j>=0;j--){ if(!d[j])continue; if(j+a[i]<=k) d[j+a[i]]=true; } } for(int i=k-a[idx];i<k;i++){ if(d[i]) return true; } return false; } int main(){ scanf("%d %d",&n,&k); for(int i=0;i<n;i++) scanf("%d",&a[i]); sort(a,a+n); int l = 0; int r = n-1; int ans = 0; /* for(int i=0;i<n;i++){ printf("%d ",test(i)); }printf("\n"); */ while(l<=r){ int mid = (l+r)/2; if(test(mid)){ r=mid-1; // ans = max(ans,mid); }else{ l=mid+1; ans = max(ans,mid); } } printf("%d\n",ans+1); return 0; }
a.cc: In function 'bool test(int)': a.cc:16:5: error: 'memset' was not declared in this scope 16 | memset(d,false,sizeof(d)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <algorithm> +++ |+#include <cstring> 6 |
s126997504
p03782
C++
# coding: utf-8 n, k = map(int, raw_input().split()) a = list(map(int, raw_input().split())) a.sort() left = 0 right = n - 1 while left != right: mid = (left + right + 1) / 2 dp = [[0 for j in range(k + 1)] for i in range(n + 1)] dp[0][0] = 1 for i in range(n): for j in range(k + 1): keep = dp[i][j] if j - a[i] >= 0: if i != mid: if dp[i][j - a[i]] == 1: keep = 1 dp[i + 1][j] = keep flag = 0 for i in range(k - a[mid], k): if dp[n][i] == 1: flag = 1 break if flag == 1: right = mid - 1 else: left = mid print(left + 1)
a.cc:1:3: error: invalid preprocessing directive #coding 1 | # coding: utf-8 | ^~~~~~ a.cc:3:1: error: 'n' does not name a type 3 | n, k = map(int, raw_input().split()) | ^
s811860184
p03782
C++
#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; int N,K; long long a[5000]; int dp[5000][5000]; int rec(int x, int y); bool need(int i); int main(){ int ans; int left,right; scanf("%d %d", &N,&K); for(int i=0;i<N;i++){ scanf("%lld",&a[i]); } sort(a,a+N); if(need(0)==true){ ans = 0; }else if(need(N-1)==false){ ans = N; }else{ left = 0; right = N-1; while(left<right-1){ int m = (right - left) / 2 + left; if(need(m)){ right = m; }else{ left = m; } } ans = right; } printf("%d\n",ans); return 0; } int rec(int x,int y){ if(dp[x][y]>=0){ return dp[x][y]; } if(x==0){ if(a[0]==y) return 1; else return 0; } else { int res = 0; if(rec(x-1,y)==1){ res = 1; } if(y>=a[x]){ if(rec(x-1,y-a[x])==1){ res = 1; } } dp[x][y] = res; return res; } } bool need(int i){ int temp = a[i]; a[i] = 0; memset(dp,-1,sizeof(dp)); bool found = false; for(int j=max(0,K-temp);j<K;j++){ if(rec(N-1,j)==1){ found = true; break; } } a[i] = temp; return found; }
a.cc: In function 'bool need(int)': a.cc:76:5: error: 'memset' was not declared in this scope 76 | memset(dp,-1,sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <algorithm> +++ |+#include <cstring> 4 | using namespace std;
s569177128
p03782
C++
#include <cstdio> #include <algorithm> using namespace std; int N,K; long long a[5000]; int dp[5000][5000]; int rec(int x, int y); bool need(int i); int main(){ int ans; int left,right; scanf("%d %d", &N,&K); for(int i=0;i<N;i++){ scanf("%lld",&a[i]); } sort(a,a+N); if(need(0)==true){ ans = 0; }else if(need(N-1)==false){ ans = N; }else{ left = 0; right = N-1; while(left<right-1){ int m = (right - left) / 2 + left; if(need(m)){ right = m; }else{ left = m; } } ans = right; } printf("%d\n",ans); return 0; } int rec(int x,int y){ if(dp[x][y]>=0){ return dp[x][y]; } if(x==0){ if(a[0]==y) return 1; else return 0; } else { int res = 0; if(rec(x-1,y)==1){ res = 1; } if(y>=a[x]){ if(rec(x-1,y-a[x])==1){ res = 1; } } dp[x][y] = res; return res; } } bool need(int i){ int temp = a[i]; a[i] = 0; memset(dp,-1,sizeof(dp)); bool found = false; for(int j=max(0,K-temp);j<K;j++){ if(rec(N-1,j)==1){ found = true; break; } } a[i] = temp; return found; }
a.cc: In function 'bool need(int)': a.cc:75:5: error: 'memset' was not declared in this scope 75 | memset(dp,-1,sizeof(dp)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <algorithm> +++ |+#include <cstring> 3 | using namespace std;
s529334773
p03782
C++
#include <iostream> #include <string> #include <list> #include <vector> #include <queue> #include <algorithm> #include <climits> #define int long long #define uint unsigned long long #define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end()) #define SORT(v) sort((v).begin(), (v).end()) #define RSORT(v) sort((v).rbegin(), (v).rend()) #define MAX(a,b) (((a) > (b)) ? (a) : (b)) #define MIN(a,b) (((a) < (b)) ? (a) : (b)) using namespace std; int a[5000]; int dp[5000][5000]; int func(int n, int k) //nまで使ったとき総和をkにできるか { if (k < 0) { return 0; } if (dp[n][k] >= 0) { return dp[n][k]; } if (n == 0) { return (a[0] == k) ? 1 : 0; } int res = 0; if (func(n - 1, k) == 1) { res = 1; } if (func(n - 1, k - a[n]) == 1) { res = 1; } dp[n][k] = res; return res; } signed main() { int N, K; cin >> N >> K; for (int i = 0; i < N; i++) { cin >> a[i]; } int cnt = 0; for (int i = 0; i < N; i++) { int temp = a[i]; a[i] = 0; memset(dp, -1, sizeof(dp)); for (int j = MAX(0, K - temp); j < K; j++) { if (func(N - 1, j) == 1) { cnt++; break; } } a[i] = temp; } cout << (N - cnt) << endl; }
a.cc: In function 'int main()': a.cc:64:17: error: 'memset' was not declared in this scope 64 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <climits> +++ |+#include <cstring> 8 | #define int long long
s874188767
p03782
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int c[5001]; bool dp[5001]; signed main() { int a, b; scanf("%d%d", &a, &b); int sum = 0;//個数 for (int d = 0; d < a; d++) { int e; scanf("%d", &e); if (e<b) { c[sum] = e; sum++; } } sort(c, c + sum); c[sum] = 1 << 29; sum++; int s = -1, g = sum-1;//[s,g) ぎりぎり必要なカード while (g - s > 1) { int d = (s + g) / 2; memset(dp, false, sizeof(dp)); dp[0] = true; for (int e = 0; e < sum; e++) { if (d == e)continue; for (int f = b; f >= c[e]; f--) { if (dp[f - c[e]])dp[f] = true; } } bool K = false; for (int i = b - c[d]; i < b; i++) { if (dp[i])K = true; } if (!K) {//不必要 s = d; } else { g = d; } } cout << g << endl; }
a.cc: In function 'int main()': a.cc:24:17: error: 'memset' was not declared in this scope 24 | memset(dp, false, sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s871069407
p03782
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int c[5000]; bool dp[5001]; signed main() { int a, b; scanf("%d%d", &a, &b); int sum = 0;//個数 for (int d = 0; d < a; d++) { int e; scanf("%d", &e); if (e<b) { c[sum] = e; sum++; } } sort(c, c + sum); int s = 0, g = sum;//[s,g) ぎりぎり必要なカード while (g - s > 1) { int d = (s + g) / 2; memset(dp, false, sizeof(dp)); dp[0] = true; for (int e = 0; e < sum; e++) { if (d == e)continue; for (int f = b; f >= c[e]; f--) { if (dp[f - c[e]])dp[f] = true; } } bool K = false; for (int i = b - c[d]; i < b; i++) { if (dp[i])K = true; } if (!K) {//不必要 s = d; } else { g = d; } } printf("%d\n", g); }
a.cc: In function 'int main()': a.cc:22:17: error: 'memset' was not declared in this scope 22 | memset(dp, false, sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include<algorithm> +++ |+#include <cstring> 4 | using namespace std;
s750198315
p03782
C++
#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9) + 7; 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 (a > b) { a = b; return true; } return false; } bitset<5010> left[5010], right[5010]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, K; cin >> N >> K; vector<int>a(N + 1, -INF); rep(i, 1, N + 1)cin >> a[i]; sort(all(a)); int ans(N); left[0][0] = right[0][0] = 1; rep(i, 1, N + 1) { left[i] = left[i - 1]; if (a[i] >= K)continue; rrep(j, 0, K - a[i]) { if (left[i][j]) { left[i][j + a[i]] = 1; } } } rep(i, 1, N + 1) { right[i] = right[i - 1]; if (a[N + 1 - i] >= K)continue; rrep(j, 0, K - a[i]) { if (right[i][j]) { right[i][j + a[i]] = 1; } } } rep(i, 1, N + 1) { if (a[i] >= K) { ans--; continue; } // left[i-1] right[N-i] rep(j, 0, K - a[i]) { // left[i-1][j] right[N-i][K-a[i]-j] bool f(false); rep(k, K - a[i] - j, K - j) { if (left[i - 1][j] && right[N - i][K - a[i] - j]) { f = true; break; } } if (f) { ans--; break; } } } //vector<bool>f; //rep(i, 0, N) { // f = vector<bool>(K + 100, false); // f[0] = true; // if (a[i] >= K) { // ans++; // continue; // } // rep(j, 0, N) { // if (i == j)continue; // rrep(k, a[j], K + 100) { // f[k] = f[k - a[j]] || f[k]; // } // } // bool g(false); // rep(k, K - a[i], K)g = f[k] || g; // ans += g; // dump(ans); // //rep(i, 0, K + 100)cout << i << (i == K + 100 - 1 ? '\n' : ' '); // //rep(i, 0, K + 100)cout << f[i] << (i == K + 100 - 1 ? '\n' : ' '); //} // cout << ans << endl; //sort(all(a)); //vector<int>s(a); //rep(i, 1, N)s[i] += s[i - 1]; //auto x = lower_bound(all(s), K); //if (x == s.end()) { // cout << N << endl; // return 0; //} //int i(0); //while (*x>=K) { // *x -= a[i]; // i++; //} //cout << i-1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:28:9: error: reference to 'left' is ambiguous 28 | left[0][0] = right[0][0] = 1; | ^~~~ In file included from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54, from a.cc:1: /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:28:22: error: reference to 'right' is ambiguous 28 | left[0][0] = right[0][0] = 1; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:30:17: error: reference to 'left' is ambiguous 30 | left[i] = left[i - 1]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:30:27: error: reference to 'left' is ambiguous 30 | left[i] = left[i - 1]; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:33:29: error: reference to 'left' is ambiguous 33 | if (left[i][j]) { | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:34:33: error: reference to 'left' is ambiguous 34 | left[i][j + a[i]] = 1; | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:39:17: error: reference to 'right' is ambiguous 39 | right[i] = right[i - 1]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:39:28: error: reference to 'right' is ambiguous 39 | right[i] = right[i - 1]; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:42:29: error: reference to 'right' is ambiguous 42 | if (right[i][j]) { | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:43:33: error: reference to 'right' is ambiguous 43 | right[i][j + a[i]] = 1; | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~ a.cc:58:37: error: reference to 'left' is ambiguous 58 | if (left[i - 1][j] && right[N - i][K - a[i] - j]) { | ^~~~ /usr/include/c++/14/bits/ios_base.h:1062:3: note: candidates are: 'std::ios_base& std::left(ios_base&)' 1062 | left(ios_base& __base) | ^~~~ a.cc:18:14: note: 'std::bitset<5010> left [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~ a.cc:58:55: error: reference to 'right' is ambiguous 58 | if (left[i - 1][j] && right[N - i][K - a[i] - j]) { | ^~~~~ /usr/include/c++/14/bits/ios_base.h:1070:3: note: candidates are: 'std::ios_base& std::right(ios_base&)' 1070 | right(ios_base& __base) | ^~~~~ a.cc:18:26: note: 'std::bitset<5010> right [5010]' 18 | bitset<5010> left[5010], right[5010]; | ^~~~~
s316413312
p03782
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <functional> using namespace std; int main() { int N; int K; int count = 0; vector<long long> a; long long sum = 0; cin >> N; cin >> K; bool dp[N+1][K+1]; for ( int n = 0; n <= N; n++ ) { for ( int k = 0; k <= K; k++ ) { dp[n][k] = false; } } for ( int n = 0; n < N; n++ ) { long long tmp; cin >> tmp; a.push_back( tmp ); sum += tmp; } if ( sum < K ) { cout << N << endl; return 0; } if ( n == 1 ) { cout << ( ( a[0] >= K ) ? 1 : 0 ) << endl; return 0; } for ( int n = 0; n < N; n++ ) { vector<long long> b; copy( a.begin(), a.end(), back_inserter(b) ); b.erase( b.begin() + n ); if ( a[n] >= K ) { for ( int i = 0; i < b.size(); i++ ) { if ( b[i] < K ) { count++; break; } } } else { for ( int i = b.size()-1; i >= 0; i-- ) { for ( int k = 1; k < K; k++ ) { // dp[i][k] = ( k == b[i] || dp[i+1][k] || ( k > b[i] && dp[i+1][ k-b[i] ] ) ); if ( k == b[i] ) {dp[i][k] = true; } if ( dp[i+1][k] ) {dp[i][k] = true; } if ( k > b[i] && dp[i+1][ k-b[i] ] ) {dp[i][k] = true; } } } for ( int k = K-a[n]; k < K; k++ ) { if ( dp[0][k] ) { count++; break; } } // for ( vector<long long>::iterator it = b.begin(); it != b.end(); it++ ) { // cout << *it << endl; // } // cout << endl; // for ( int n = 0; n <= N; n++ ) { // for ( int k = 0; k <= K; k++ ) { // cout << "n:" << n << "k:" << k << " " << (dp[n][k] ? "t" : "f") << endl; // } // } // cout << endl; for ( int n = 0; n <= N; n++ ) { for ( int k = 0; k <= K; k++ ) { dp[n][k] = false; } } } } cout << N - count << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:14: error: 'n' was not declared in this scope 42 | if ( n == 1 ) { | ^
s479290491
p03782
C++
#include <iostream> #include <vector> #include <algorithm> #include <iterator> #include <functional> using namespace std; int main() { int N; int K; int count = 0; vector<long long> a; long long sum = 0; cin >> N; cin >> K; bool dp[N+1][K+1]; for ( int n = 0; n <= N; n++ ) { for ( int k = 0; k <= K; k++ ) { dp[n][k] = false; } } for ( int n = 0; n < N; n++ ) { long long tmp; cin >> tmp; a.push_back( tmp ); sum += tmp; } if ( sum < K ) { cout << N << endl; return 0; } if ( n == 1 ) { cout << ( a[0] >= K ) ? 1 : 0; return 0; } for ( int n = 0; n < N; n++ ) { vector<long long> b; copy( a.begin(), a.end(), back_inserter(b) ); b.erase( b.begin() + n ); if ( a[n] >= K ) { for ( int i = 0; i < b.size(); i++ ) { if ( b[i] < K ) { count++; break; } } } else { for ( int i = b.size()-1; i >= 0; i-- ) { for ( int k = 1; k < K; k++ ) { // dp[i][k] = ( k == b[i] || dp[i+1][k] || ( k > b[i] && dp[i+1][ k-b[i] ] ) ); if ( k == b[i] ) {dp[i][k] = true; } if ( dp[i+1][k] ) {dp[i][k] = true; } if ( k > b[i] && dp[i+1][ k-b[i] ] ) {dp[i][k] = true; } } } for ( int k = K-a[n]; k < K; k++ ) { if ( dp[0][k] ) { count++; break; } } // for ( vector<long long>::iterator it = b.begin(); it != b.end(); it++ ) { // cout << *it << endl; // } // cout << endl; // for ( int n = 0; n <= N; n++ ) { // for ( int k = 0; k <= K; k++ ) { // cout << "n:" << n << "k:" << k << " " << (dp[n][k] ? "t" : "f") << endl; // } // } // cout << endl; for ( int n = 0; n <= N; n++ ) { for ( int k = 0; k <= K; k++ ) { dp[n][k] = false; } } } } cout << N - count << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:14: error: 'n' was not declared in this scope 42 | if ( n == 1 ) { | ^
s580711289
p03782
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; ll a[5100] = {}; bool dp_right[5010][5010] = {}; bool dp_left[5010][5010] = {}; int main(void){ // Here your code ! ll n,k; cin >> n >> k; for(int i = 0; i < n; i++){ cin >> a[i]; } sort(a,a+n); for(int i = 0; i < n; i++){ dp_right[i][0] = true; for(int j = 4999; j >= 0; j-- ){ if(!dp_right[i][j]) continue; int nj = min(j + a[i], K); dp_right[i + 1][j] = true; dp_right[i + 1][nj] = true; } } dp_left[n][0] = true; for(int i = n-1; i >= 0; i--){ dp_left[i][0] = true; for(int j = 4999; j >= 0; j-- ){ if(!dp_left[i + 1][j]) continue; int nj = min(j + a[i], K); dp_left[i][j] = true; dp_left[i][nj] = true; } } //必要なカードの数 ll res = 0; for(int i = 0; i < n ; i++){ if( a[i] >= k ){ res++; continue; } vector<int> x; for(int j = 0; j < k; j++) { if(dp_left[i + 1][j]) x.push_back(j); } for(int j = 0; j < k; j++){ if(!dp_right[i][j]) continue; //cout << i << " " << j << endl; auto it = lower_bound(x.begin(), x.end(), max(0LL, k - j - a[i])); if(it == x.end()) continue; if(*it + j < k){ res++; //cout << a[i] << endl; break; } } } cout << n - res << endl; }
a.cc: In function 'int main()': a.cc:30:48: error: 'K' was not declared in this scope 30 | int nj = min(j + a[i], K); | ^ a.cc:44:48: error: 'K' was not declared in this scope 44 | int nj = min(j + a[i], K); | ^
s792680041
p03782
C++
using System; namespace D_NoNeed { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int K = int.Parse(input[1]); input = Console.ReadLine().Split(' '); var A = new int[N]; for (int i = 0; i < A.Length; i++) A[i] = int.Parse(input[i]); // Array.Sort(A); bool[,] DP = new bool[N + 1, K]; for (int i = 0; i <= N; i++) for (int j = 0; j < K; j++) DP[i, j] = false; DP[0, 0] = true; int ans = 0; for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { int a = A[i]; if (i == k) { for (int j = 0; j < K; j++) DP[i + 1, j] = DP[i, j]; } else { for (int j = 0; j < K; j++) { DP[i + 1, j] = DP[i, j]; if (j - a >= 0) DP[i + 1, j] |= DP[i, j - a]; } } // for (int j = 0; j < K; j++) Console.Write(DP[i, j]? "o ": "x "); // Console.WriteLine(); } // for (int j = 0; j < K; j++) Console.Write(DP[N, j]? "o ": "x "); // Console.WriteLine(); bool flag = false; for (int j = Math.Max(0, K - A[k]); j < K; j++) { flag |= DP[N, j]; } if (!flag) ans++; // Console.WriteLine(); } Console.WriteLine(ans); } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:5:26: error: 'string' has not been declared 5 | static void Main(string[] args) { | ^~~~~~ a.cc:5:35: error: expected ',' or '...' before 'args' 5 | static void Main(string[] args) { | ^~~~ a.cc:46:6: error: expected ';' after class definition 46 | } | ^ | ; a.cc: In static member function 'static void D_NoNeed::Program::Main(int*)': a.cc:6:13: error: 'string' was not declared in this scope 6 | string[] input = Console.ReadLine().Split(' '); | ^~~~~~ a.cc:6:20: error: expected primary-expression before ']' token 6 | string[] input = Console.ReadLine().Split(' '); | ^ a.cc:7:21: error: expected primary-expression before 'int' 7 | int N = int.Parse(input[0]); | ^~~ a.cc:8:21: error: expected primary-expression before 'int' 8 | int K = int.Parse(input[1]); | ^~~ a.cc:9:13: error: 'input' was not declared in this scope; did you mean 'int'? 9 | input = Console.ReadLine().Split(' '); | ^~~~~ | int a.cc:9:21: error: 'Console' was not declared in this scope 9 | input = Console.ReadLine().Split(' '); | ^~~~~~~ a.cc:10:13: error: 'var' was not declared in this scope 10 | var A = new int[N]; | ^~~ a.cc:11:33: error: 'A' was not declared in this scope 11 | for (int i = 0; i < A.Length; i++) | ^ a.cc:12:24: error: expected primary-expression before 'int' 12 | A[i] = int.Parse(input[i]); | ^~~ a.cc:15:18: error: expected identifier before ',' token 15 | bool[,] DP = new bool[N + 1, K]; | ^ a.cc:15:18: error: expected ']' before ',' token a.cc:15:17: error: structured binding declaration cannot have type 'bool' 15 | bool[,] DP = new bool[N + 1, K]; | ^ a.cc:15:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:15:17: error: empty structured binding declaration a.cc:15:21: error: expected initializer before 'DP' 15 | bool[,] DP = new bool[N + 1, K]; | ^~ a.cc:18:21: error: 'DP' was not declared in this scope 18 | DP[i, j] = false; | ^~ a.cc:19:13: error: 'DP' was not declared in this scope 19 | DP[0, 0] = true; | ^~ a.cc:23:29: error: 'A' was not declared in this scope 23 | int a = A[i]; | ^ a.cc:38:30: error: 'Math' was not declared in this scope 38 | for (int j = Math.Max(0, K - A[k]); j < K; j++) { | ^~~~ a.cc:38:47: error: 'A' was not declared in this scope 38 | for (int j = Math.Max(0, K - A[k]); j < K; j++) { | ^
s630617172
p03782
C++
using System; namespace D_NoNeed { class Program { static void Main(string[] args) { string[] input = Console.ReadLine().Split(' '); int N = int.Parse(input[0]); int K = int.Parse(input[1]); input = Console.ReadLine().Split(' '); var A = new int[N]; for (int i = 0; i < A.Length; i++) A[i] = int.Parse(input[i]); // Array.Sort(A); bool[,] DP = new bool[N + 1, K]; for (int i = 0; i <= N; i++) for (int j = 0; j < K; j++) DP[i, j] = false; DP[0, 0] = true; int ans = 0; for (int k = 0; k < N; k++) { for (int i = 0; i < N; i++) { int a = A[i]; if (i == k) { for (int j = 0; j < K; j++) DP[i + 1, j] = DP[i, j]; } else { for (int j = 0; j < K; j++) { DP[i + 1, j] = DP[i, j]; if (j - a >= 0) DP[i + 1, j] |= DP[i, j - a]; } } // for (int j = 0; j < K; j++) Console.Write(DP[i, j]? "o ": "x "); // Console.WriteLine(); } // for (int j = 0; j < K; j++) Console.Write(DP[N, j]? "o ": "x "); // Console.WriteLine(); bool flag = false; for (int j = Math.Max(0, K - A[k]); j < K; j++) { flag |= DP[N, j]; } if (!flag) ans++; // Console.WriteLine(); } Console.WriteLine(ans); } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:5:26: error: 'string' has not been declared 5 | static void Main(string[] args) { | ^~~~~~ a.cc:5:35: error: expected ',' or '...' before 'args' 5 | static void Main(string[] args) { | ^~~~ a.cc:46:6: error: expected ';' after class definition 46 | } | ^ | ; a.cc: In static member function 'static void D_NoNeed::Program::Main(int*)': a.cc:6:13: error: 'string' was not declared in this scope 6 | string[] input = Console.ReadLine().Split(' '); | ^~~~~~ a.cc:6:20: error: expected primary-expression before ']' token 6 | string[] input = Console.ReadLine().Split(' '); | ^ a.cc:7:21: error: expected primary-expression before 'int' 7 | int N = int.Parse(input[0]); | ^~~ a.cc:8:21: error: expected primary-expression before 'int' 8 | int K = int.Parse(input[1]); | ^~~ a.cc:9:13: error: 'input' was not declared in this scope; did you mean 'int'? 9 | input = Console.ReadLine().Split(' '); | ^~~~~ | int a.cc:9:21: error: 'Console' was not declared in this scope 9 | input = Console.ReadLine().Split(' '); | ^~~~~~~ a.cc:10:13: error: 'var' was not declared in this scope 10 | var A = new int[N]; | ^~~ a.cc:11:33: error: 'A' was not declared in this scope 11 | for (int i = 0; i < A.Length; i++) | ^ a.cc:12:24: error: expected primary-expression before 'int' 12 | A[i] = int.Parse(input[i]); | ^~~ a.cc:15:18: error: expected identifier before ',' token 15 | bool[,] DP = new bool[N + 1, K]; | ^ a.cc:15:18: error: expected ']' before ',' token a.cc:15:17: error: structured binding declaration cannot have type 'bool' 15 | bool[,] DP = new bool[N + 1, K]; | ^ a.cc:15:17: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:15:17: error: empty structured binding declaration a.cc:15:21: error: expected initializer before 'DP' 15 | bool[,] DP = new bool[N + 1, K]; | ^~ a.cc:18:21: error: 'DP' was not declared in this scope 18 | DP[i, j] = false; | ^~ a.cc:19:13: error: 'DP' was not declared in this scope 19 | DP[0, 0] = true; | ^~ a.cc:23:29: error: 'A' was not declared in this scope 23 | int a = A[i]; | ^ a.cc:38:30: error: 'Math' was not declared in this scope 38 | for (int j = Math.Max(0, K - A[k]); j < K; j++) { | ^~~~ a.cc:38:47: error: 'A' was not declared in this scope 38 | for (int j = Math.Max(0, K - A[k]); j < K; j++) { | ^
s075673770
p03782
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <set> #include <map> #include <cmath> #include <iomanip> #include <codecvt> #include <locale> using namespace std; using ll = long long; int main() { int N, K; cin >> N >> K; vector<int> a(N); for(int i=0; i<N; ++i) { cin >> a[i]; } ll sum = accumulate(a.begin(), a.end(), 0LL); sort(a.rbegin(), a.rend()); int res = 0; vector<bool> dp(K); dp[0] = true; for(int i=0; i<N; ++i) { bool f = false; for(int j=0; j<K; ++j) { f |= dp[j] && j+sum >= K; } if(!f) { res++; } sum -= a[i]; for(int j=K-1-a[i]; j>=0; --j) { dp[j+a[i]] = dp[j+a[i]] | dp[j]; } } cout << res << endl; }
a.cc: In function 'int main()': a.cc:21:14: error: 'accumulate' was not declared in this scope 21 | ll sum = accumulate(a.begin(), a.end(), 0LL); | ^~~~~~~~~~
s189598639
p03782
C++
#if 1 #include <iostream> #include <fstream> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <queue> #include <stack> #include <array> #include <deque> #include <algorithm> #include <utility> #include <cstdint> #include <functional> #include <iomanip> #include <numeric> #define in std::cin #define out std::cout int32_t N, K; int32_t a[5000]; template<typename T> void fill_all(T& arr, const T& v) { arr = v; } template<typename T, typename ARR> void fill_all(ARR& arr, const T& v) { for (auto& i : arr) { fill_all(i, v); } } constexpr int32_t INF = 2'000'000'000; constexpr int32_t NUMBER = 5000; int32_t ignore = -1; int32_t sum[NUMBER + 1]; int8_t dp[NUMBER][NUMBER + 1]; //[i]以降でvalue「に」なるようにとることが可能ならtrue int8_t func(int i, int value) { if (value <= 0) { return value==0; } //if (i == N) { if (sum[i] < value) { return false; } if (dp[i][value] != -2) { return dp[i][value]; } auto pata = func(i + 1, value); if (i == ignore) { return dp[i][value] = std::move(pata); } return dp[i][value] = (pata | func(i + 1, value - a[i])); } int main() { using std::endl; in.sync_with_stdio(false); out.sync_with_stdio(false); in >> N >> K; for (size_t i = 0; i < N; i++) { in >> a[i]; if (a[i] >= K) { --N; --i; } } std::sort(a, a + N); for (int i = N - 1; i >= 0; i--) { sum[i] = a[i] + sum[i + 1]; } if (sum[0]<K) { out << N<<endl; return 0; } using BS_INT = int64_t; BS_INT beg = -1, end = N + 1; while (beg + 1 != end) { BS_INT mid = (beg + end) / 2; //ここに書く fill_all(dp, -2); ignore = mid; if (func(0, K - a[mid]) < a[mid] || func(0, K - a[mid]) == INF) { end = mid;//必要 } else { beg = mid;//不要 } } out << beg+1 << endl; return 0; } #endif
a.cc: In instantiation of 'void fill_all(ARR&, const T&) [with T = int; ARR = signed char]': a.cc:34:32: recursively required from 'void fill_all(ARR&, const T&) [with T = int; ARR = signed char [5001]]' 34 | for (auto& i : arr) { fill_all(i, v); } | ~~~~~~~~^~~~~~ a.cc:34:32: required from 'void fill_all(ARR&, const T&) [with T = int; ARR = signed char [5000][5001]]' a.cc:90:11: required from here 90 | fill_all(dp, -2); | ~~~~~~~~^~~~~~~~ a.cc:34:9: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 34 | for (auto& i : arr) { fill_all(i, v); } | ^~~ | std::begin In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/range_access.h:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:34:9: error: 'end' was not declared in this scope; did you mean 'std::end'? 34 | for (auto& i : arr) { fill_all(i, v); } | ^~~ | std::end /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~
s989488701
p03782
C++
#if 1 #include <iostream> #include <fstream> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <queue> #include <stack> #include <array> #include <deque> #include <algorithm> #include <utility> #include <cstdint> #include <functional> #include <iomanip> #include <numeric> #define in std::cin #define out std::cout int32_t N,K; int32_t a[5000]; constexpr int32_t INF = 2'000'000'000; constexpr int32_t NUMBER = 5000; int32_t ignore = -1; #if 1 int32_t sum[NUMBER + 1]; int32_t dp[NUMBER][NUMBER + 1]; //[i]以降でMIN以上になるようにとったときのMINからのはみ出しの最小 int32_t func(int i, int MIN) { if (MIN <= 0) { return { -MIN }; } //if (i == N) { if (sum[i] < MIN) { return { INF }; } if (dp[i][MIN] != INF) { return dp[i][MIN]; } auto pata = func(i + 1, MIN); if (i == ignore) { return dp[i][MIN] = std::move(pata); } auto patb = func(i + 1, MIN - a[i]); if (pata < patb) { return dp[i][MIN] = std::move(pata); } else { //patb.second.push_back(i); return dp[i][MIN] = std::move(patb); } } #endif int main() { using std::endl; in.sync_with_stdio(false); out.sync_with_stdio(false); in >> N >> K; for (size_t i = 0; i < N; i++) { in >> a[i]; if (a[i] >= K) { --N; --i; } } std::sort(a , a + N); for (int i = N - 1; i >= 0; i--) { sum[i] = a[i] + sum[i + 1]; } using BS_INT = int64_t; BS_INT beg = 1, end = N + 1; while (beg + 1 != end) { BS_INT mid = (beg + end) / 2; //ここに書く for (size_t k = 0; k < N; k++)for (size_t j = 0; j <= K; j++) { dp[k][j] = INF; } ignore = i; if (func(0, K - a[i]) < a[i] || func(0, K - a[i]) == INF) { end = mid; } else { beg = mid; } } out << beg << endl; return 0; } #endif
a.cc: In function 'int main()': a.cc:89:26: error: 'i' was not declared in this scope 89 | ignore = i; | ^
s095228554
p03782
C++
#include <iostream> #include <vector> #include <bitset> using namespace std; int N, K; vector<int> a; bitset<5001> dp; //is m necessary? bool sub(int m) { if(K <= a[m]) return true; dp.reset(); for(int i = 0; i < N; ++i) { if(i != m) dp |= dp << a[i]; } for(int b = K - a[m]; b < K; ++b) { if(dp[b]) return true; } return false; } int main(void) { cin >> N >> K; int s = 0; for(int i = 0; i < N; ++i) { int t; cin >> t; a.push_back(t); s += t; } sort(a.begin(), a.end()); if(s < K) { cout << N << '\n'; return 0; } if(sub(0)) { cout << "0\n"; return 0; } int L = 0, R = N; while(1 < R - L) { int m = (L + R) / 2; //cout << m << '\n'; (sub(m) ? R : L) = m; } cout << R << '\n'; return 0; }
a.cc: In function 'int main()': a.cc:33:9: error: 'sort' was not declared in this scope; did you mean 'short'? 33 | sort(a.begin(), a.end()); | ^~~~ | short
s228329268
p03782
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; long long a[5010]; long long dp[5010]; int main() { int n, k; while(~scanf("%d%d",&n, &k)) { for(int i=1; i<=n;i++) scanf("%lld",&a[i]); sort(a+1, a+1+n); long long sum = 0; for(int i=1;i<=n;i++) { sum += a[i]; } if(sum<k) { printf("%d\n",n); continue; } memset(dp,0,sizeof dp); dp[1] = a[1]<k?1:0; for(int i=2;i<=n;i++) { if(a[j]+a[i] >= k && a[i]<k) { break; } else if(a[i] == a[i-1]) dp[i]++; else dp[i]++; } if(dp[i] == i-1 && a[i] < k)//&& a[i] < k) { int ans = 0; sum = 0; for(int j=1;j<=i;j++) sum += a[j]; if(sum < k) dp[i] = i; else { for(int j=1;j<=i;j++) { if(sum-a[j] >= k) { ans++; sum -= a[j]; } } dp[i] = ans;} } } printf("%lld\n", dp[n]); } return 0; }
a.cc: In function 'int main()': a.cc:31:30: error: 'j' was not declared in this scope 31 | if(a[j]+a[i] >= k && a[i]<k) | ^ a.cc:41:31: error: 'i' was not declared in this scope 41 | if(dp[i] == i-1 && a[i] < k)//&& a[i] < k) | ^ a.cc: At global scope: a.cc:65:9: error: expected unqualified-id before 'return' 65 | return 0; | ^~~~~~ a.cc:66:1: error: expected declaration before '}' token 66 | } | ^
s471977428
p03782
C++
#include<iostream> #include<algorithm> using namespace std; int N, K; int a[5000]; bool is_needed(int i){ if(a[i]>=K) return true; int memo[N+1][K]; for(int j=0; j<N+1; j++)for(int k=0; k<K; k++) memo[j][k]=0; memo[0][0]=1; for(int j=0; j<N; j++){ for(int k=0; k<K; k++){ memo[j+1][k]|=memo[j][k]; if(i!=j and k+a[j]<K) memo[j+1][k+a[j]]|=memo[j][k]; } } bool need=false; for(int k=K-a[i]; k<K; k++) need|=memo[N][k]; return need; } int main(){ cin>> N>> K; for(int i=0; i<N; i++) cin>> a[i]; sort(a, a+N); int l=0, u=N; while(u-l>1){ int m=(u+l)/2; if(is_needed(m)) u=m; else l=m; } cout<< r<< endl; return 0; }
a.cc: In function 'int main()': a.cc:40:11: error: 'r' was not declared in this scope 40 | cout<< r<< endl; | ^
s783160106
p03782
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; long long a[5010]; long long dp[5010]; int main() { int n, k; while(~scanf("%d%d",&n, &k)) { for(int i=1; i<=n;i++) scanf("%lld",&a[i]); sort(a+1, a+1+n); long long sum = 0; for(int i=1;i<=n;i++) { sum += a[i]; } if(sum<k) { printf("%d\n",n); continue; } memset(dp,0,sizeof dp); dp[1] = a[1]<k?1:0; for(int i=2;i<=n;i++) { for(int j=1;j<=dp[i-1];j++) { if(a[j]+a[i] >= k && a[i]<k) { break; } else dp[i]++;} if(dp[i] == i-1 && a[i] < k))//&& a[i] < k) { int ans = 0; sum = 0; for(int j=1;j<=i;j++) sum += a[j]; if(sum < k) dp[i] = i; else { for(int j=1;j<=i;j++) { if(sum-a[j] >= k) { ans++; sum -= a[j]; } } dp[i] = ans;} } else dp[i]--; } printf("%lld\n", dp[n]); } return 0; }
a.cc: In function 'int main()': a.cc:40:53: error: expected primary-expression before ')' token 40 | if(dp[i] == i-1 && a[i] < k))//&& a[i] < k) | ^
s447815224
p03782
C++
#include <cstdio> #include <algorithm> #include <set> using namespace std; int nums[6000]; set<int> st; int main(){ int N, K,next; scanf("%d %d", &N, &K); for (int i = 0; i < N; i++) scanf("%d", nums + i); sort(nums, nums + N); int knot = N; st.clear(); st.insert(0); vector<int>temp; for (int i=N-1;i>=0;i--){ temp.clear(); up=0; for (auto a:st){ next=a+nums[i]; if (next >= K){knot = i;up=1;break;} else temp.push_back(next); } if(!up)break; for(auto a : temp) st.insert(a); } printf("%d\n", knot); return 0; }
a.cc: In function 'int main()': a.cc:16:9: error: 'vector' was not declared in this scope 16 | vector<int>temp; | ^~~~~~ a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 3 | #include <set> +++ |+#include <vector> 4 | using namespace std; a.cc:16:16: error: expected primary-expression before 'int' 16 | vector<int>temp; | ^~~ a.cc:18:9: error: 'temp' was not declared in this scope; did you mean 'mktemp'? 18 | temp.clear(); | ^~~~ | mktemp a.cc:19:17: error: 'up' was not declared in this scope 19 | up=0; | ^~
s542368611
p03782
C++
#include <iostream> #include <vector> using namespace std; int main() { int n,k; cin>>n>>k; vector<int>vec(n,k); vector<int>a(n); for(int i=0;i<n;i++)cin>>a[i]; sort(a.begin(),a.end()); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(i==j)continue; if(vec[i]-a[j]>0)vec[i]-=a[j]; } } int c=0; for(int i=0;i<n;i++){ if(vec[i]-a[i]>0){ c++; } } cout<<c<<endl; return 0; }
a.cc: In function 'int main()': a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'? 11 | sort(a.begin(),a.end()); | ^~~~ | short
s747376611
p03782
C++
#include<bits/stdc++.h> #define DEBUG 0 /* */ using namespace std; int main() { long long int N, K; cin >> N >> K; vector < long long int >A(N); for (size_t i = 0; i < N; i++) { cin >> A[i]; } vector<unordered_set<long long int>>dp1(N + 1), dp2(N + 1); dp1[0].insert(0); for (size_t i = 0; i < N; i++) { dp1[i + 1] = dp1[i]; for (auto x : dp1[i]) { if (x + A[i] < K) { dp1[i + 1].insert(x + A[i]); } else { break; } } } dp2[N].insert(0); for (int i = N - 1; i >= 0; i--) { dp2[i] = dp2[i + 1]; for (auto x : dp2[i + 1]) { if (x + A[i] < K) { dp2[i].insert(x + A[i]); } else { break; } } } long long int ans = 0; for (size_t i = 0; i < N; i++) { auto ite1 = dp1[i].begin(); auto ite2 = dp2[i + 1].rbegin(); while (ite1 != dp1[i].end() && ite2 != dp2[i + 1].rend()) { if (*ite1 + *ite2 < K - A[i]) { ite1++; } else if (K <= *ite1 + *ite2) { ite2++; } else { ans++; break; } } } cout << N - ans << endl; if (DEBUG) { int ewataeoprgjpsrteog; cin >> ewataeoprgjpsrteog; } }
a.cc: In function 'int main()': a.cc:52:40: error: '__gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<long long int> >, std::unordered_set<long long int> >::value_type' {aka 'class std::unordered_set<long long int>'} has no member named 'rbegin'; did you mean 'begin'? 52 | auto ite2 = dp2[i + 1].rbegin(); | ^~~~~~ | begin a.cc:53:67: error: '__gnu_cxx::__alloc_traits<std::allocator<std::unordered_set<long long int> >, std::unordered_set<long long int> >::value_type' {aka 'class std::unordered_set<long long int>'} has no member named 'rend'; did you mean 'end'? 53 | while (ite1 != dp1[i].end() && ite2 != dp2[i + 1].rend()) | ^~~~ | end
s772941712
p03782
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) #define orep(i, n) for (int i = 1; i <= (int)n; i++) #define vec vector int main(void) { int n, k; cin >> n >> k; vec<int> a(n + 1); orep(i, n) cin >> a[i]; int ans = 0; orep(t, n) { vec<int> cur(k + 5, 0); vec<int> prev(k + 5, 0); cur[0][0] = 1; orep(i, n) { prev = cur; rep(j, k + 1) { cur[j] += prev[j]; if (i == t) continue; if (k < j + a[i]) cur[k] += prev[j]; else cur[j + a[i]] += prev[j]; } } int flag = 1; for (int i = k - a[t]; i < k; i++) { if (cur[i]) { flag = 0; break; } } if (flag) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:23: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 22 | cur[0][0] = 1; | ^
s965192877
p03782
C++
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[5010]; int dp[5010]; int main() { int n, k; while(~scanf("%d%d",&n, &k)) { for(int i=1; i<=n;i++) scanf("%d",&a[i]); sort(a+1, a+1+n); long long sum = 0; for(int i=1;i<=n;i++) { sum += a[i]; } if(sum<k) { printf("%d\n",n); continue; } memset(dp,0,sizeof dp); dp[1] = a[1]<k?1:0; for(int i=2;i<=n;i++) { for(int j=1;j<=dp[i-1];i++) if(arr[j]+a[i] >= k) { //dp[i] = j-1; break; } else dp[i]++; if(dp[i] == i-1) { int ans = 0; for(int j=1;j<=i;j++) { if(sum-a[j] >= k) { ans++; sum -= a[j]; } } dp[i] = ans; } } printf("%d\n", dp[n]); } return 0; }
a.cc: In function 'int main()': a.cc:32:28: error: 'arr' was not declared in this scope 32 | if(arr[j]+a[i] >= k) | ^~~
s589565533
p03782
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #include <complex> #include <unordered_map> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b)) #define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d)) #define PW(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define MODU 1000000007 #define bitcheck(a,b) ((a >> b) & 1) #define bitset(a,b) ( a |= (1 << b)) #define bitunset(a,b) (a &= ~(1 << b)) #define MP(a,b) make_pair((a),(b)) #define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second)) #define pritnf printf #define scnaf scanf #define itn int #define PI 3.141592653589 #define PAD(a,b) MP(((a).first + (b).first),((a).second, (b).second)) #define izryt bool using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template<typename A, size_t N, typename T> void Fill(A(&array)[N], const T &val) { std::fill((T*) array, (T*) (array + N), val); } pii Dir[8] = { //移動 { 0, 1 }, { -1, 0 }, { 1, 0 }, { 0, -1 }, { 1, 1 }, { 1, -1 }, { -1, 1 }, { -1, -1 } }; signed main() { int n; ll m; scanf("%d %lld", &n, &m); vector<ll> num(n); REP(i, n){ scanf("%lld", &num[i]); } sort(ALL(num),greater<int>()); int last = 0; int can[5001] = { -1 }; function<bool(int,ll)> dfs = [&](int cur, int nok){ bool ret; if (nok <= 0) return true; if (cur == n) return false; if (can[nok] == 1) return true; else if(can[nok] == 0) return false; ret = dfs(cur+1, nok); if (dfs(cur + 1, nok - num[cur])){ ret = 1; last = max(last, cur+1); } return can[nok] = ret; }; dfs(0, m); printf("%d\n", n-last); return 0; }
a.cc: In lambda function: a.cc:80:33: error: inconsistent types 'bool' and 'int' deduced for lambda return type 80 | return can[nok] = ret; | ~~~~~~~~~^~~~~
s128679320
p03782
C++
#include <bits/stdc++.h> using namespace std; const int N = 5009; const int inf = (int) 2e9; int a[N]; int b[N]; int main () { int n, k; cin >> n >> k; for (int i = 0; i < n; i++) { cin >> a[i]; b[i] = a[i]; } sort (b, b + n); int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (j == i) { a[j] = 0; } else { a[j] = b[j]; } } sort (a, a + n); int mn = inf; for (int l = 0, r = 0, s = t; l < n; l++) { while (s < k && r + 1 < n) { s += a[++r]; } mn = min (mn, s); s -= a[l]; } if (mn < k || mn - t >= k) { ans++; } } cout << ans; }
a.cc: In function 'int main()': a.cc:28:36: error: 't' was not declared in this scope 28 | for (int l = 0, r = 0, s = t; l < n; l++) { | ^ a.cc:35:28: error: 't' was not declared in this scope 35 | if (mn < k || mn - t >= k) { | ^
s748270017
p03782
C++
#include <iostream> #include <iomanip> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <functional> #include <utility> #include <tuple> #define INF 0x3f3f3f3f #define MOD 1000000007 #define PI 4*atan(1.0) typedef long long ll; typedef long double ld; using namespace std; int dx[4]={0,0,-1,1}; int dy[4]={-1,1,0,0}; typedef long long int; signed main(){ const ll MAX=5001; ll N,K; cin>>N>>K; ll a[MAX]={}; for(int i=0;i<N;i++){ cin>>a[i]; } bool flag[MAX]={}; //ソートする sort(a,a+N,greater<ll>()); for(int i=0;i<N;i++){ //cout<<a[i]<<endl; } //カードiを除いた集合から、コストK未満K-a[i]以上の組み合わせが作れるかどうかを試していく for(int i=0;i<N;i++){ ll sum=0; for(int j=0;j<N;j++){ if(j!=i){ ll temp=sum+a[j]; if(temp<K-a[i]){ sum=temp; //cout<<sum<<endl; } else if(temp<K){ flag[i]=1; //cout<<"!"<<sum<<endl; break; } } } } ll ans=0; for(int i=0;i<N;i++){ if(!flag[i]){ //cout<<i<<endl; ans++; } } cout<<ans<<endl; return 0; }
a.cc:26:19: error: declaration does not declare anything [-fpermissive] 26 | typedef long long int; | ^~~
s543757200
p03782
C++
#if 1 #include <iostream> #include <fstream> #include <string> #include <vector> #include <map> #include <set> #include <unordered_map> #include <unordered_set> #include <queue> #include <stack> #include <array> #include <deque> #include <algorithm> #include <utility> #include <cstdint> #include <functional> #include <iomanip> #include <numeric> #define in std::cin #define out std::cout constexpr int32_t INF = 2'000'000'000; int32_t N , K; int32_t a[5000]; constexpr int32_t NUMBER = 400; int32_t ignore = -1; #if 1 int32_t dp[NUMBER][NUMBER + 1]; //[i]以降でMIN以上になるようにとったときのMINからのはみ出しの最小 int32_t func(int i, int MIN) { if (MIN <= 0) { return { -MIN,{} }; } if (i == N) { return { INF,{} }; } if (dp[i][MIN] != INF) { return dp[i][MIN]; } auto pata = func(i + 1, MIN); if (i == ignore) { return dp[i][MIN] = std::move(pata); } auto patb = func(i + 1, MIN - a[i]); if (pata < patb) { return dp[i][MIN] = std::move(pata); } else { //patb.second.push_back(i); return dp[i][MIN] = std::move(patb); } } int main() { using std::endl; in.sync_with_stdio(false); out.sync_with_stdio(false); in >> N >> K; for (size_t i = 0; i < N; i++)for (size_t j = 0; j <= K; j++) { dp[i][j].first = INF; } for (size_t i = 0; i < N; i++) { in >> a[i]; if (a[i] >= K) { --N; --i; } } //std::sort(a , a + N); if (std::accumulate(a, a + N, (uint64_t)0) < K) { out << N; return 0; } int32_t count = 0; for (size_t i = 0; i < N; i++) { for (size_t k = 0; k <= i; k++)for (size_t j = 0; j <= K; j++) { dp[i][j].first = INF; } ignore = i; if (func(0, K - a[i]) < a[i] || func(0, K - a[i]) == INF) { } else { ++count; } //a[i]が入っている可能性 //一つもない可能性=>絶対必要(OK) } out << count << endl; return 0; } #endif #if 0 std::pair<int32_t, std::vector<int32_t>> dp[NUMBER][NUMBER+1]; //[i]以降でMIN以上になるようにとったときのMINからのはみ出しの最小 std::pair<int32_t, std::vector<int32_t>> func(int i, int MIN) { if (MIN <= 0) { return { -MIN,{} }; } if (i == N) { return {INF, {}}; } if (dp[i][MIN].first != INF) { return dp[i][MIN]; } auto pata = func(i + 1, MIN); if (i == ignore) { return dp[i][MIN] = std::move(pata); } auto patb = func(i + 1, MIN - a[i]); if (pata.first < patb.first) { return dp[i][MIN] = std::move(pata); } else { //patb.second.push_back(i); return dp[i][MIN] = std::move(patb); } } int main() { using std::endl; in.sync_with_stdio(false); out.sync_with_stdio(false); in >> N>>K; for (size_t i = 0; i < N; i++)for (size_t j = 0; j <= K; j++) { dp[i][j].first = INF; } for (size_t i = 0; i < N; i++) { in >> a[i]; if (a[i] >= K) { --N; --i; } } //std::sort(a , a + N); if (std::accumulate(a,a+N,(uint64_t)0) < K) { out << N; return 0; } int32_t count = 0; for (size_t i = 0; i < N; i++) { for (size_t k = 0; k <= i; k++)for (size_t j = 0; j <= K; j++) { dp[i][j].first = INF; } ignore = i; if (func(0, K - a[i]).first < a[i] || func(0, K - a[i]).first == INF) { } else{ ++count; } //a[i]が入っている可能性 //一つもない可能性=>絶対必要(OK) } out << count << endl; return 0; } #endif #endif
a.cc: In function 'int32_t func(int, int)': a.cc:38:34: error: cannot convert '<brace-enclosed initializer list>' to 'int32_t' {aka 'int'} in return 38 | return { -MIN,{} }; | ^ a.cc:41:33: error: cannot convert '<brace-enclosed initializer list>' to 'int32_t' {aka 'int'} in return 41 | return { INF,{} }; | ^ a.cc: In function 'int main()': a.cc:69:26: error: request for member 'first' in 'dp[i][j]', which is of non-class type 'int32_t' {aka 'int'} 69 | dp[i][j].first = INF; | ^~~~~ a.cc:88:34: error: request for member 'first' in 'dp[i][j]', which is of non-class type 'int32_t' {aka 'int'} 88 | dp[i][j].first = INF; | ^~~~~
s341113035
p03782
C++
#include <bits/stdc++.h> using namespace std; const int N = 5005; int n, k; vector<int> a; bitset<N> t, t2; int main() { cin >> n >> k; int ans = n; for (int i = 0, x; i < n; i++) { cin >> x; if (x >= k) ans --; else a.pb(x); } n = (int)a.size(); t.set(0); for (int i = 0; i < n; i++) { if (i) t = (t << a[i - 1]) | t; t2 = t; for (int j = i + 1; j < n; j++) t2 = (t2 << a[j]) | t2; for (int j = k - a[i]; j < k; j++) if (t2.test(j)) { --ans; break; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:17:24: error: 'class std::vector<int>' has no member named 'pb' 17 | else a.pb(x); | ^~
s838168654
p03782
C++
#include <cstdio> #include <iostream> #include <vector> #include <map> #include <unordered_map> #include <set> #include <unordered_set> #include <string> #include <cstring> #include <sstream> #include <algorithm> #include <functional> #include <queue> #include <stack> #include <cmath> #include <iomanip> #include <list> #include <tuple> #include <bitset> #include <ciso646> #include <cassert> using namespace std; #define int long long #define double long double typedef pair<int, int> P; typedef tuple<int, int, int> T; template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); } template<class T> T sqr(T x) { return x*x; } template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; } int toint(string s) { int v; stringstream i(s); i >> v; return v; } bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; } int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } int lcm(int a, int b) { return a / gcd(a, b) * b; } #define REP(i,a,b) for(int (i) = (a);i < (b);(i)++) #define rep(i,n) REP(i,0,n) #define PER(i,a,b) for(int (i) = (a-1);i >= (b);(i)--) #define per(i,n) PER(i,n,0) #define each(i,n) for(auto &i : n) #define clr(a) memset((a), 0 ,sizeof(a)) #define mclr(a) memset((a), -1 ,sizeof(a)) #define all(a) (a).begin(),(a).end() #define dump(val) cerr << #val " = " << val << endl; #define dum(val) cerr << #val " = " << val; #define FILL(a,v) fill(a,a+sizeof(a)/sizeof(*a),v) const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 }; const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 }; const int mod = 1e9 + 7; const int INF = 1e9 + 9; signed main() { cin.tie(0); ios_base::sync_with_stdio(false); int n, k; cin >> n >> k; if (n > 400 || k > 400)return; //ai が 必要 => aiを除いて 総和xが (k - ai) <= x < k を満たす集合が存在する // => aiを含めて k <= x < k + aiを満たす集合が存在する //ai >= k は絶対必要 <= 取り除いてよい vector<int> a; for (int i = 0; i < n; i++) { int t; cin >> t; if (t < k) { a.push_back(t); } } n = a.size(); int ans = 0; rep(i, n) { vector<int> vis(k * 2, 0); vector<vector<int>> dp(n, vector<int>(k * 2, -1)); function<void(int, int)> dfs = [&](int t, int sum) { if (t == n) { return; } if (t == i) { dfs(t + 1, sum); return; } if (dp[t][sum] != -1)return; dp[t][sum] = 1; vis[sum] = 1; vis[sum + a[t]] = 1; dfs(t + 1, sum); dfs(t + 1, sum + a[t]); }; dfs(0, a[i]); bool need = false; for (int j = k; j < k + a[i]; j++) { if (vis[j]) need = true; } if (need == false) ans++; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:64:32: error: return-statement with no value, in function returning 'int' [-fpermissive] 64 | if (n > 400 || k > 400)return; | ^~~~~~
s669737066
p03782
C++
#include<bits/stdc++.h> using namespace std; typedef long long LL; LL t,n,m,ans,tot; LL f[5111],g[111]; int main() { LL i,j,k,l,ca=0,u,v,w; cin>>n>>m;w=m; for(i=1;i<=n;i++) cin>>f[i],ans+=f[i]; if(ans<m){ cout<<n<<endl; return 0; } sort(f+1,f+n+1); for(i=n;i>0;i--) if(f[i]>=m)n--; for(i=n;i>0&&m>0;i--){ m-=f[i]; n--; } for(tot=0,i=1;i<=n&&tot<w;i++) tot+=f[i]; for(i=1;i<=n&&tot>=w;i++) tot-=f[i]; cout<<max(0,min(n,i-2) )<<endl; return 0; }
a.cc: In function 'int main()': a.cc:30:18: error: no matching function for call to 'max(int, const long long int&)' 30 | cout<<max(0,min(n,i-2) )<<endl; | ~~~^~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:30:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 30 | cout<<max(0,min(n,i-2) )<<endl; | ~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:30:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 30 | cout<<max(0,min(n,i-2) )<<endl; | ~~~^~~~~~~~~~~~~~~
s151737067
p03782
C++
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <set> #include <iostream> #include <string> #include <vector> #include <algorithm> #include <sstream> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cstring> #include <iterator> #include <bitset> #include <unordered_set> #include <unordered_map> #include <fstream> #include <iomanip> #include <cassert> #include <utility> #include <memory> #include <functional> #include <deque> #include <cctype> #include <ctime> #include <numeric> #include <list> #include <iomanip> #if __cplusplus >= 201103L #include <array> #include <tuple> #include <initializer_list> #include <forward_list> #define cauto const auto& #else #endif using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<int> vint; typedef vector<vector<int> > vvint; typedef vector<long long> vll, vLL; typedef vector<vector<long long> > vvll, vvLL; #define VV(T) vector<vector< T > > template <class T> void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){ v.assign(a, vector<T>(b, t)); } template <class F, class T> void convert(const F &f, T &t){ stringstream ss; ss << f; ss >> t; } #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define reep(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) reep((i),0,(n)) #define ALL(v) (v).begin(),(v).end() #define PB push_back #define F first #define S second #define mkp make_pair #define RALL(v) (v).rbegin(),(v).rend() #define DEBUG #ifdef DEBUG #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #else #define dump(x) #define debug(x) #endif #define MOD 1000000007LL #define EPS 1e-8 #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL #define maxs(x,y) x=max(x,y) #define mins(x,y) x=min(x,y) bool pre[5010][5010]; bool suf[5010][5010]; void mainmain(){ int n; cin>>n; int K; cin>>K; vll v(n); rep(i,n) cin>>v[i]; sort(ALL(v)); int ans = 0; // int m = 100010; pre[0][0] = true; suf[n-1][0] = true; rep(i,n){ if(i) rep(j,5010){ pre[i][j] = pre[i-1][j]; } if(v[i]>=K) continue; for(int j = K; j >= v[i]; j--){ pre[i][j] |= pre[i][j-v[i]]; } } for(int i = n-1; i>=0; i--){ if(i!=n-1){ rep(j,5010){ suf[i][j] = suf[i+1][j]; } } if(v[i]>=K) continue; for(int j = K; j >= v[i]; j--){ suf[i][j] |= suf[i][j-v[i]]; } } vvint aa(n); vvint bb(n); rep(i,n){ rep(j,5010){ if(pre[i][j]) aa[i].PB(j); if(suf[i][j]) bb[i].PB(j); } } if(i==1){ if(v[0] >= K) cout<<0<<endl; else cout<<1<<endl; return; } rep(i,n){ bool ok = false; if(i==0){ for(cauto x: bb[i+1]){ if(x>=K) break; if(x + v[i] >= K) ok = true; } } else if(i==n-1){ for(cauto x: aa[i-1]){ if(x>=K) break; if(x + v[i] >= K) ok = true; } } else{ for(cauto x: aa[i-1]){ // cout<<i<<" "<<x<<endl; if(K-x-v[i]<0) continue; auto it = lower_bound(ALL(bb[i+1]), K-x-v[i]); if(it==bb[i+1].end()) continue; // cout<< *it << endl; if(*it + x < K){ ok=true; // cout<<"hh "<<i<<" "<< *it << x << endl; } } } if(v[i] >= K) ok=true; if(!ok){ ans++; // cout<<i<<" "<<v[i]<<endl; } } cout<<ans<<endl; } signed main() { ios_base::sync_with_stdio(false); cin.tie(0); cout<<fixed<<setprecision(20); mainmain(); }
a.cc: In function 'void mainmain()': a.cc:140:12: error: 'i' was not declared in this scope 140 | if(i==1){ | ^
s127049493
p03782
C++
#include <iostream> #include <vector> #include <cstdint> #include<algorithm> #include<set> #include<map> #include<queue> #include<math.h> using namespace std; typedef long long ll; double abs(double d){ if(d>=0)return d; return -1.0*d; } int main() { ll n,k; cin>>n>>k; vector<ll>a(n); ll sum=0; for(int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; } sort(a.begin(),a.end()); if(sum<k){ cout<<n<<endl; return 0; } sum=0; int mai=0; for(int i=0;i<n;i++){ sum+=a[i]; if(sum>=k){ mai=i; break; } } int i; for(i=0;i<n;i++){ if(sum-a[i]>=k){ sum-=a[i]; } else { break; } } while(i<n&&a[i]==a[i+1]{ i++; }) cout<<i<<endl; return 0; }
a.cc:14:20: error: 'double abs(double)' conflicts with a previous declaration 14 | double abs(double d){ | ^ In file included from /usr/include/c++/14/cstdlib:81, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/std_abs.h:71:3: note: previous declaration 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ a.cc: In function 'int main()': a.cc:50:28: error: expected ')' before '{' token 50 | while(i<n&&a[i]==a[i+1]{ | ~ ^ | ) a.cc:52:6: error: expected primary-expression before ')' token 52 | }) | ^
s650879215
p03782
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 100000 + 10; const int M = 1000000007; const double PI = atan(1) * 4; const int oo = 1000000000; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> ii; #define pb push_back #define all(c) (c).begin(),(c).end() int v[5010]; ll dp[5010]; int main(){ int n,k; cin>>n>>k; for(int i=0; i<n; ++i) cin>>v[i]; int ans=0; for(int t=0; t<n; ++t){ for(int i=0; i<=k; ++i) dp[i]=0; dp[0]=1; for(int i=0; i<n; ++i){ if(i==t)continue; for(int j=k-v[i]; j>=0; --j) dp[j+v[i]]+=dp[j]; } bool f=v[i]>=k; for(int i=max(k-v[t],0); !f&&i<k; ++i) f|=dp[i]!=0; if(!f)++ans; } cout<<ans; }
a.cc: In function 'int main()': a.cc:30:26: error: 'i' was not declared in this scope 30 | bool f=v[i]>=k; | ^
s797048452
p03782
C++
#include <iostream> using ll = long long; int n, k; int a[5010]; bool stat[5010]; ll dp[5010][5100]; ll dfs(int idx, ll sum) { if(sum >= k) { return sum; } if(idx >= n) { return 0; } if(dp[idx][sum] != -1) { return dp[idx][sum]; } ll min = 1e18; for(int i = idx; i < n; ++i) { auto r = dfs(i + 1, sum + a[i]); if(r != 0) { if(r - a[i] < k) { // std::cout << idx << " " << i << " " << sum << " " << r << std::endl; stat[i] = true; } min = std::min(min, r); } } if(min == 1e18) { return dp[idx][sum] = 0; } return dp[idx][sum] = min; } int main() { memset(dp, -1, sizeof(dp)); std::cin >> n >> k; for(int i = 0; i < n; ++i) std::cin >> a[i]; dfs(0, 0); int cnt = 0; for(int i = 0; i < n; ++i) { if(stat[i]) ++cnt; } std::cout << n - cnt << std::endl; }
a.cc: In function 'int main()': a.cc:41:5: error: 'memset' was not declared in this scope 41 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s488526106
p03782
C++
#include <algorithm> #include <fstream> #include <iostream> using namespace std; short pref[5005][5005]; short suf[5005][5005]; int main() { //ifstream cin("f.iun"); int n, k; cin >> n >> k; vector<int> v; for (int x, i = 1; i <= n; ++ i) { cin >> x; if (x < k) { v.push_back(x); } } n = v.size(); for (int i = 0; i < k; ++ i) { pref[0][i] = 1; } for (int i = 1; i <= n; ++ i) { int val = v[i - 1]; for (int j = k - val - 1; j >= 0; -- j) { if (pref[i - 1][j] - (j ? pref[i - 1][j - 1] : 0)) { pref[i][j + val] = 1; } } for (int j = 0; j < k; ++ j) { if (pref[i - 1][j] - (j ? pref[i - 1][j - 1] : 0)) { pref[i][j] = 1; } if (j) { pref[i][j] += pref[i][j - 1]; } } } for (int i = 0; i < k; ++ i) { suf[n + 1][i] = 1; } for (int i = n; i >= 1; -- i) { int val = v[i - 1]; for (int j = k - val - 1; j >= 0; -- j) { if (suf[i + 1][j] - (j ? suf[i + 1][j - 1] : 0)) { suf[i][j + val] = 1; } } for (int j = 0; j < k; ++ j) { if (suf[i + 1][j] - (j ? suf[i + 1][j - 1] : 0)) { suf[i][j] = 1; } if (j) { suf[i][j] += suf[i][j - 1]; } } } int cnt = 0; for (int i = 1; i <= n; ++ i) { bool ok = false; for (int j = 0; j < k; ++ j) { if ((j == 0 && pref[i - 1][j]) || (j != 0 && pref[i - 1][j] - pref[i - 1][j - 1])) { int min_sum_right = max(k - v[i - 1] - j, 0); int max_sum_right = k - 1 - j; if ((min_sum_right == 0 && suf[i + 1][max_sum_right]) || (min_sum_right != 0 && suf[i + 1][max_sum_right] - suf[i + 1][min_sum_right - 1])) { ok = true; break; } } } if (!ok) { ++ cnt; } } cout << cnt << "\n"; return 0; }
a.cc: In function 'int main()': a.cc:13:5: error: 'vector' was not declared in this scope 13 | vector<int> v; | ^~~~~~ a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 3 | #include <iostream> +++ |+#include <vector> 4 | using namespace std; a.cc:13:12: error: expected primary-expression before 'int' 13 | vector<int> v; | ^~~ a.cc:17:13: error: 'v' was not declared in this scope 17 | v.push_back(x); | ^ a.cc:20:9: error: 'v' was not declared in this scope 20 | n = v.size(); | ^
s714054360
p03782
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; typedef long long int lli; typedef pair<lli, lli> pii; int main(){ lli n, k; std::cin >> n >> k; vector<pii> a(n); for (int i = 0; i < n; i++) { std::cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end()); reverse(a.begin(), a.end()); lli pos = 0; for (int i = 0; i < n; i++) { lli sum = 0; for (int j = i; j < n; j++) { sum += a[j].first; if(sum >= k){ pos = max(pos, j + 1); break; } if(j == n - 1){ std::cout << n - pos << std::endl; return 0; } } } std::cout << 0 << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:24:18: error: no matching function for call to 'max(lli&, int)' 24 | pos = max(pos, j + 1); | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:24:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 24 | pos = max(pos, j + 1); | ~~~^~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:24:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 24 | pos = max(pos, j + 1); | ~~~^~~~~~~~~~~~
s475809875
p03782
C++
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> #include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <map> #include <set> #include <numeric> #include <unordered_map> #include <unordered_set> #include <complex> #include <iterator> #include <array> #include <memory> //cin.sync_with_stdio(false); //streambuf using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; using vi = vector<int>; using vll = vector<ll>; using vpii = vector<pii>; using vpll = vector<pll>; using ti3 = tuple<int, int, int>; using vti3 = vector<ti3>; template<class T, int s>using va = vector<array<T, s>>; template<class T, class T2> using umap = unordered_map<T, T2>; template<class T> using uset = unordered_set<T>; template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; } template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; } #define ALL(a) a.begin(),a.end() #define rep(i,a) for(int i=0;i<a;i++) #define rep1(i,a) for(int i=1;i<=a;i++) #define rrep(i,a) for(int i=(a)-1;i>=0;i--) #define rrep1(i,a) for(int i=a;i;i--) const ll mod = 1000000007; #define REP rep template<class T>using heap = priority_queue<T, vector<T>, greater<T>>; template<class T>using pque = priority_queue<T, vector<T>, function<T(T, T)>>; template <class T> inline void hash_combine(size_t & seed, const T & v) { hash<T> hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } namespace std { template<typename S, typename T> struct hash<pair<S, T>> { inline size_t operator()(const pair<S, T> & v) const { size_t seed = 0; hash_combine(seed, v.first); hash_combine(seed, v.second); return seed; } }; // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl{ static void apply(size_t& seed, Tuple const& tuple){ HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0>{ static void apply(size_t& seed, Tuple const& tuple){ hash_combine(seed, std::get<0>(tuple)); } }; template <typename ... TT> struct hash<std::tuple<TT...>>{ size_t operator()(std::tuple<TT...> const& tt) const{ size_t seed = 0; HashValueImpl<std::tuple<TT...> >::apply(seed, tt); return seed; } }; } template<class T>int id(vector<T> &a, T b) { return lower_bound(ALL(a), b) - a.begin(); } ll pow(ll base, ll i, ll mod) { ll a = 1; while (i) { if (i & 1) { a *= base; a %= mod; } base *= base; base %= mod; i /= 2; } return a; } ll gcd(ll a, ll b) { while (b) { ll c = a%b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } int popcnt(unsigned long long a) { a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555); a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333); a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f); a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff); a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff); return (a & 0xffffffff) + (a >> 32); } class unionfind { vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う public: unionfind(int n) :par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); } int find(int x) { if (par[x] == x)return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); par[y] = x; size_[x] += size_[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return size_[find(x)]; } }; template<class T, class Func = function<T(T, T)>> class segtree { vector<T> obj; int offset; Func updater; T e; int bufsize(int num) { int i = 1; for (; num >i; i <<= 1); offset = i - 1; return (i << 1) - 1; } T query(int a, int b, int k, int l, int r) { if (r <= a || b <= l)return e; if (a <= 1 && r <= b)return obj[k]; else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r)); } public: T query(int a, int b) {//[a,b) return query(a, b, 0, 0, offset + 1); } void updateall(int l = 0, int r = -1) { if (r < 0)r = offset + 1; l += offset, r += offset; do { l = l - 1 >> 1, r = r - 1 >> 1; for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]); } while (r) } void update(int k, T &a) { k += offset; obj[k] = a; while (k) { k = k - 1 >> 1; obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]); } } segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {} segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) { copy(vec.begin(), vec.end(), obj.begin() + offset); updateall(); } typename vector<T>::reference operator[](int n) { return obj[n + offset]; } }; template<class T = int> class BIT {//多次元BITはループをネストすればいいらしい。 vector<T> bit; int n; public: BIT(int n) :obj(n + 1, 0) {} void add(int i, T x) { i++; while (i <= n) { bit[i] += x; i += i&-i; } } T sum(int i) { T s = 0; i++; while (i) { s += bit[i]; i &= i - 1; } return s; } }; template<class T = int> class rangeadd { BIT<T> b0, b1; public: rangeadd(int n) :b0(n), b1(n) {}; void add(int l, int r, T x) {//[l,r) b0.add(l, -x*(l - 1)); b1.add(l, x); b0.add(r, x*r); b1.add(r, -x); } T sum(int i) { if (i < 0)return 0; return b0.sum(i) + b1.sum(i)*i; } T sum(int l,int r) { return sum(r - 1) - sum(l - 1); } }; //end of lib //template<class S=void,int ptr_num, class T = char>class trie { // umap<T, trie<S, ptr_num, T> next; //public: // S key; // trie<S, ptr_num, T>* ptr[ptr_num] = {}; // trie(S &&data) :key(data) {} // trie(const S &data) :key(data) {} // void add(T x,S data) { // if (!next.find(x))next.insert(x, data); // } // trie& operator[](T x) { // return next[x]; // } // bool find(T x) { // retun next.find(x); // } //}; //template<class T=char>class AhoCorasick { // trie<pair<bool,int>, 2, T> tree; // AhoCorasick(vector<string> p) { // int num = 0; // vector<decltype(&tree)> que(p.size(),&tree); // for (int i = 0;; i++) { // bool end = 1; // int i = 0; // for (auto a : p) { // if (i >= a.size())break; // end = ;0 // que[i] = (*que[i])[a[i]]; // i++; // } // if (end)break; // } // } //}; int main() { int n, k; cin >> n >> k; vi a(n),c(k); for (auto &b : a)cin >> b; int del = 0; rep(t,n){ fill(ALL(c), 0); c[0] = 1; rep(i, n) { if (t == i)continue; rrep(j, k - 1 - a[i]) { c[j + a[i]] |= c[j]; } } bool f = 1; for (int j = max(0, k - a[t]); j < k; j++)if (c[j]) { f = 0; break; } if (f)del++; } cout << del << endl; }
a.cc: In member function 'void segtree<T, Func>::updateall(int, int)': a.cc:174:9: error: expected ';' before '}' token 174 | } | ^ a.cc: In constructor 'BIT<T>::BIT(int)': a.cc:197:21: error: class 'BIT<T>' does not have any field named 'obj' 197 | BIT(int n) :obj(n + 1, 0) {} | ^~~
s735492860
p03782
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<map> #include<set> #include<functional> #include<unordered_map> #include<unordered_set> #include<queue> #include<vector> using namespace std; int c[405]; bool dp[405]; signed main() { int a, b; scanf("%d%d", &a, &b); if (a > 400 || b > 400)return 0; int ans = 0; int sum = 0;//個数 for (int d = 0; d < a; d++) { int e; scanf("%d", &e); if(e<b){ c[sum] = e; sum++; } } for (int d = 0; d < sum; d++) {//dが必要か? memset(dp, false, sizeof(dp)); dp[0] = true; for (int e = 0; e < sum; e++) { if (d == e)continue; for (int f = b; f >= c[e]; f--) { if (dp[f - c[e]])dp[f] = true; } } bool K = false; for (int i = b - c[d]; i < b; i++) { if (dp[i])K = true; } if (!K)ans++; } printf("%d\n", ans); }
a.cc: In function 'int main()': a.cc:28:17: error: 'memset' was not declared in this scope 28 | memset(dp, false, sizeof(dp)); | ^~~~~~ a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 9 | #include<queue> +++ |+#include <cstring> 10 | #include<vector>
s738700332
p03783
C++
#include <bits/stdc++.h> using namespace std; #define int int64_t typedef pair<int, int> ii; const int infinity = 1e18; int number; ii segment[100001]; int f[401][401]; int32_t main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> number; for (int i = 1; i <= number; i++) cin >> segment[i].first >> segment[i].second; for (int i = 0; i <= 400; i++) for (int j = 0; j <= 400; j++) f[i][j] = infinity; for (int j = 1; j <= 400; j++) { int l = segment[1].first, r = segment[1].second; f[1][j] = ((l <= j && j <= r) ? 0 : (j < l) ? l - j : j - r); } for (int i = 2; i <= number; i++) for (int j = 1; j <= 400; j++) { int l = segment[i].first, r = segment[i].second; int cost = ((l <= j && j <= r) ? 0 : (j < l) ? l - j : j - r); int segment_length = r - l + 1; for (int k = max(1LL, l - segment_length); k <= r; k++) f[i][j] = min(f[i][j], f[i - 1][k] + cost); } int answer = infinity; for (int i = 1; i <= 400; i++) answer = min(answer, f[number][i]); cout << answer; }
a.cc: In function 'int32_t main()': a.cc:37:41: error: no matching function for call to 'max(long long int, int64_t)' 37 | for (int k = max(1LL, l - segment_length); k <= r; k++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:37:41: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int64_t' {aka 'long int'}) 37 | for (int k = max(1LL, l - segment_length); k <= r; k++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:37:41: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 37 | for (int k = max(1LL, l - segment_length); k <= r; k++) | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s868671915
p03783
C++
解説見た(2回目) CHTかなーとか考えた
a.cc:1:9: error: expected constructor, destructor, or type conversion before '(' token 1 | 解説見た(2回目) | ^
s092312511
p03783
C++
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> #include<cassert> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; const ll mod = 1000000007; typedef double ld; typedef complex<ld> Point; const ll INF = mod * mod; typedef pair<int, int> P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) const ld eps = 1e-6; const ld pi = acos(-1.0); typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; void solve() { int n; cin >> n; vector<ll> l(n), r(n), len(n); rep(i, n)cin >> l[i] >> r[i]; rep(i, n)len[i] = r[i] - l[i]; ll ml = l[0], mr = l[0]; ll my = 0; multiset<ll> sl, sr; ll adle = 0, adri = 0; rep1(i, n - 1) { ml -= len[i]; mr += len[i - 1]; if (l[i] <= ml) { ll dif = ml - l[i]; sl.insert(dif-adle); my += dif; sr.insert(- adri);adri += mr - ml; mr = ml; ll nl = *sl.begin(); sl.erase(sl.begin()); nl += adle; ml -= nl; adle -= nl; } else if (l[i] => mr) { ll dif = l[i] - mr; sr.insert(dif - adri); my += dif; sl.insert(- adle); adle += mr - ml; ml = mr; ll nr = *sr.begin(); sr.erase(sr.begin()); nr += adri; mr += nr; adri -= nr; } else { sl.insert(-adle), sr.insert(-adri); adle += l[i] - ml; adri += mr - l[i]; ml = mr = l[i]; } } cout << my << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); solve(); stop return 0; }
a.cc: In function 'void solve()': a.cc:63:32: error: expected primary-expression before '>' token 63 | else if (l[i] => mr) { | ^
s842008254
p03783
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <queue> using namespace std; typedef long long ll; priority_queue <ll> P; priority_queue <ll,vector <ll>,greater <ll> > Q; int main() { int n; ll A=0,B=0,ans=0; cin>>n; for(int i=1;i<=n;i++) { cin>>l>>r; B+=r-l; P.push(r-A),Q.push(r-B); while(P.top()+A>Q.top()+B) { ll x=P.top()+A,y=Q.top()+B; P.pop(),Q.pop(),ans+=x-y; P.push(y-A),Q.push(x-B); } A-=r-l; } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:17:14: error: 'l' was not declared in this scope 17 | cin>>l>>r; | ^ a.cc:17:17: error: 'r' was not declared in this scope 17 | cin>>l>>r; | ^
s755739923
p03783
C++
#include<stdio.h> #include<stdlib.h> int compare(const void *a,const void *b){ k=*(long*)a; t=*(long*)b; if(k<t) return -1; else return 1; } int main(){ int n,i; long l[111111],r[111111],m[222222],p,ans=0; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%ld%ld",&l[i],&r[i]); m[i*2]=l[i]; m[i*2+1]=r[i]; } qsort(m,n*2,sizeof(long),compare); p=m[n]; for(i=0;i<n;i++){ if(l[i]>p) ans+=l[i]-p; if(r[i]<p) ans+=p-r[i]; } printf("%ld",ans); return 0; }
a.cc: In function 'int compare(const void*, const void*)': a.cc:4:1: error: 'k' was not declared in this scope 4 | k=*(long*)a; | ^ a.cc:5:1: error: 't' was not declared in this scope 5 | t=*(long*)b; | ^ a.cc:10:1: warning: control reaches end of non-void function [-Wreturn-type] 10 | } | ^
s416457393
p03783
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 1000000007 #define pa pair<int,int> #define ll long long #define pal pair<double,double> #define ppap pair<pa,int> // #define PI 3.14159265358979323846 #define paa pair<int,char> #define mp make_pair #define pb push_back #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b))<EPS) int dx[4]={0,-1,0,1}; int dy[4]={1,0,-1,0}; using namespace std; class pa3{ public: int x,y,z; pa3(int x=0,int y=0,int z=0):x(x),y(y),z(z) {} bool operator < (const pa3 &p) const{ if(x!=p.x) return x<p.x; if(y!=p.y) return y<p.y; return z<p.z; //return x != p.x ? x<p.x: y<p.y; } bool operator > (const pa3 &p) const{ if(x!=p.x) return x>p.x; if(y!=p.y) return y>p.y; return z>p.z; //return x != p.x ? x<p.x: y<p.y; } bool operator == (const pa3 &p) const{ return x==p.x && y==p.y && z==p.z; } bool operator != (const pa3 &p) const{ return !( x==p.x && y==p.y && z==p.z); } }; class pa4{ public: double x; int y,z,w; pa4(double x=0,int y=0,int z=0,int w=0):x(x),y(y),z(z),w(w) {} bool operator < (const pa4 &p) const{ if(x!=p.x) return x<p.x; if(y!=p.y) return y<p.y; if(z!=p.z)return z<p.z; return w<p.w; //return x != p.x ? x<p.x: y<p.y; } bool operator > (const pa4 &p) const{ if(x!=p.x) return x>p.x; if(y!=p.y) return y>p.y; if(z!=p.z)return z>p.z; return w>p.w; //return x != p.x ? x<p.x: y<p.y; } bool operator == (const pa4 &p) const{ return x==p.x && y==p.y && z==p.z &&w==p.w; } }; class pa2{ public: int x,y; pa2(int x=0,int y=0):x(x),y(y) {} pa2 operator + (pa2 p) {return pa2(x+p.x,y+p.y);} pa2 operator - (pa2 p) {return pa2(x-p.x,y-p.y);} bool operator < (const pa2 &p) const{ return y != p.y ? y<p.y: x<p.x; } bool operator > (const pa2 &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const pa2 &p) const{ return abs(x-p.x)==0 && abs(y-p.y)==0; } bool operator != (const pa2 &p) const{ return !(abs(x-p.x)==0 && abs(y-p.y)==0); } }; #define ppa pair<int,pas> class Point{ public: double x,y; Point(double x=0,double y=0):x(x),y(y) {} Point operator + (Point p) {return Point(x+p.x,y+p.y);} Point operator - (Point p) {return Point(x-p.x,y-p.y);} Point operator * (double a) {return Point(x*a,y*a);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {return sqrt(norm());} double norm() {return x*x+y*y;} bool operator < (const Point &p) const{ return x != p.x ? x<p.x: y<p.y; } bool operator == (const Point &p) const{ return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS; } }; typedef Point Vector; #define pl pair<int,pas> struct Segment{ Point p1,p2; }; double dot(Vector a,Vector b){ return a.x*b.x+a.y*b.y; } double cross(Vector a,Vector b){ return a.x*b.y-a.y*b.x; } bool parareru(Point a,Point b,Point c,Point d){ // if(abs(cross(a-b,d-c))<EPS)cout<<"dd "<<cross(a-b,d-c)<<endl; return abs(cross(a-b,d-c))<EPS; } double distance_ls_p(Point a, Point b, Point c) { if ( dot(b-a, c-a) < EPS ) return (c-a).absv(); if ( dot(a-b, c-b) < EPS ) return (c-b).absv(); return abs(cross(b-a, c-a)) / (b-a).absv(); } bool is_intersected_ls(Segment a,Segment b) { if(a.p1==b.p1||a.p2==b.p1||a.p1==b.p2||a.p2==b.p2) return false; if(parareru((a.p2),(a.p1),(a.p1),(b.p2))&&parareru((a.p2),(a.p1),(a.p1),(b.p1))){ // cout<<"sss"<<endl; if(dot(a.p1-b.p1,a.p1-b.p2)<EPS) return true; if(dot(a.p2-b.p1,a.p2-b.p2)<EPS) return true; if(dot(a.p1-b.p1,a.p2-b.p1)<EPS) return true; if(dot(a.p1-b.p2,a.p2-b.p2)<EPS) return true; return false; } else return ( cross(a.p2-a.p1, b.p1-a.p1) * cross(a.p2-a.p1, b.p2-a.p1) < EPS ) && ( cross(b.p2-b.p1, a.p1-b.p1) * cross(b.p2-b.p1, a.p2-b.p1) < EPS ); } double segment_dis(Segment a,Segment b){ if(is_intersected_ls(a,b))return 0; double r=distance_ls_p(a.p1, a.p2, b.p1); r=min(r,distance_ls_p(a.p1, a.p2, b.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p1)); return r; } Point intersection_ls(Segment a, Segment b) { Point ba = b.p2-b.p1; double d1 = abs(cross(ba, a.p1-b.p1)); double d2 = abs(cross(ba, a.p2-b.p1)); double t = d1 / (d1 + d2); return a.p1 + (a.p2-a.p1) * t; } string itos( int i ) { ostringstream s ; s << i ; return s.str() ; } int gcd(int v,int b){ if(v>b) return gcd(b,v); if(v==b) return b; if(b%v==0) return v; return gcd(v,b%v); } double distans(double x1,double y1,double x2,double y2){ double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); return sqrt(rr); } int mod; int pr[2000010]; int inv[2000010]; int beki(int wa,int rr,int warukazu){ if(rr==0) return 1%warukazu; if(rr==1) return wa%warukazu; if(rr%2==1) return (beki(wa,rr-1,warukazu)*wa)%warukazu; int zx=beki(wa,rr/2,warukazu); return (zx*zx)%warukazu; } double bekid(double w,int r){ if(r==0) return 1.0; if(r==1) return w; if(r%2) return bekid(w,r-1)*w; double f=bekid(w,r/2); return f*f; } int comb(int nn,int rr){ int r=pr[nn]*inv[rr]; r%=mod; r*=inv[nn-rr]; r%=mod; return r; } void gya(int ert){ pr[0]=1; for(int i=1;i<ert;i++){ pr[i]=(pr[i-1]*i)%mod; } for(int i=0;i<ert;i++) inv[i]=beki(pr[i],mod-2,mod); } // cin.tie(0); // ios::sync_with_stdio(false); //priority_queue<pa3,vector<pa3>,greater<pa3>> pq; //sort(ve.begin(),ve.end(),greater<int>()); //----------------kokomade tenpure------------ //vector<double> ans(100000000),ans2(100000000) int l[100020],d[100020]; multiset<int> s1,s2; signed main(){ int n; cin>>n; for(int i=0;i<n;i++){ cin>>l[i]>>d[i]; d[i]-=l[i]; } s2.insert(l[0]); s1.insert(l[0]); int de=0; int h=l[0],m=l[0]; int w=0,e=0; for(int i=1;i<n;i++){ //cout<<h-w<<" "<<m+e<<" "<<de<<endl; w+=d[i]; e+=d[i-1]; //cout<<h-w<<" "<<m+e<<" "<<l[i]<<endl; if(h-w>l[i]){ de+= -l[i]+(h-w); s1.insert(l[i]+w); s1.insert(l[i]+w); auto it=s1.end(); it--; int g=*it; s1.erase(it); g-= w+e; s2.insert(g); m=g; it=s1.end(); it--; h=*it; } else if(h-w<l[i] && l[i]<m+e){ s1.insert(l[i]+w); s2.insert(l[i]-e); h=l[i]+w; m=l[i]-e; } else if(l[i]>m+e){ de+= -(m+e)+l[i]; s2.insert(l[i]-e); s2.insert(l[i]-e); auto it=s2.begin(); int g=*it; s2.erase(it); g+= w+e; s1.insert(g); h=g; it=s2.begin(); m=*it; } else if(m+e==h-w){ s1.insert(l[i]+w); s2.insert(l[i]-e); } else(h-w==l[i]){ s1.insert(l[i]+w); s2.insert(l[i]-e); h=l[i]+w; m=l[i]-e; } } cout<<de<<endl; return 0; }
a.cc: In function 'int main()': a.cc:296:32: error: expected ';' before '{' token 296 | else(h-w==l[i]){ | ^ | ;
s592321178
p03783
C++
#define _USE_MATH_DEFINES #pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <iterator> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <bitset> #include <queue> #include <set> #include <map> #include <stack> #include <list> #include <ctime> //// #include <random>// #pragma endregion //#include ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)4e18+20; const LD PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; ///////// #pragma region Math #pragma region long long ext_gcd(long long a,long long b,long long& x,long long& y){ if(b==0){ x=1;y=0;return a; } long long q = a/b; long long g = ext_gcd(b,a-q*b,x,y); x = x - q*y; swap(x,y); return g; } template<class T> inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;} #pragma endregion // 最大公約数 gcd #pragma region template<class T> inline T lcm(T a, T b){return a / gcd(a, b) * b;} #pragma endregion // 最小公倍数 lcm #pragma region LL powMod(LL num,LL n,LL mod=(LL)MOD){//(num**n)%mod num %= mod;// if( n == 0 ){ return (LL)1; } LL mul = num; LL ans = (LL)1; while(n){ if( n&1 ){ ans = (ans*mul)%mod; } mul = (mul*mul)%mod; n >>= 1; } return ans; } LL mod_inverse(LL num,LL mod=MOD){ return powMod(num,MOD-2,MOD); } #pragma endregion //繰り返し二乗法 powMod #pragma region template<class T> vector<T> getDivisor(T n){ vector<T> v; for(int i=1;i*i<=n;++i){ if( n%i == 0 ){ v.push_back(i); if( i != n/i ){//平方数で重複して数えないように v.push_back(n/i); } } } sort(v.begin(), v.end()); return v; } #pragma endregion //約数列挙 getDivisor(n):O(√n) #pragma endregion //math //Utility:便利な奴 #pragma region template<class T> void UNIQUE(vector<T>& vec){ sort(vec.begin(),vec.end()); vec.erase(unique(vec.begin(),vec.end()),vec.end() ); } #pragma endregion // sort erase unique //////////////////////////////// #pragma region long long bitcount64(long long bits) { bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >>16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >>32 & 0x00000000ffffffff); } #pragma endregion //その他 //////////////////////////////// struct edge_base{int to;LL cost;}; edge_base make_edge_base(int to,LL cost){ edge_base ret = {to,cost}; return ret; } #pragma region GRL #pragma region //グラフ template<class T,class EDGE> void dijkstra(int root,int V,vector<T>& dist,vector<int>& prev, vector< vector<EDGE> > G ){ priority_queue<pair<T,int>,vector<pair<T,int> >,greater<pair<T,int> > > que; dist.assign(V,LINF); prev.assign(V,-1); dist[root] = 0; que.push(pair<T,int>(0,root));//距離、頂点番号 while( !que.empty() ){ pair<T,int> p = que.top();que.pop(); int v = p.second; if( dist[v] < p.first ) continue; for(int i=0;i < (int)G[v].size();++i){ EDGE e = G[v][i]; if( dist[e.to] > dist[v] + e.cost ){ dist[e.to] = dist[v] + e.cost; prev[e.to] = v; que.push(pair<T,int>(dist[e.to],e.to)); } } } } //経路復元,dijkstraにprev入れた //http://ronly.hatenablog.com/entry/2017/06/17/161641 vector<int> get_path(vector<int>& prev,int t){ vector<int> path; while(t!=-1){ path.push_back( t ); t = prev[t]; } reverse(path.begin(),path.end()); return path; } #pragma endregion //ダイクストラ法:O(|E|log|V|) #pragma region //グラフ void warshall_floyd(vector<vector<LL> >& dist,int V,const LL inf=LINF){ for(int k=0;k<V;++k){ for(int i=0;i<V;++i){ if( dist[i][k] >= inf ) continue; for(int j=0;j<V;++j){ if( dist[k][j] >= inf )continue; dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j]); } } } } #pragma endregion //ワーシャルフロイド:O(|V|**3) #pragma region namespace FLOW{ //vector< vector<FLOW:edge> > G; struct edge_flow : public edge_base{ LL cap;//LD cap;// int rev; }; edge_flow make_edge_flow(int to,LL cap,int rev,LL cost=1){ //edge_flow make_edge_flow(int to,LD cap,int rev,LL cost=1){ edge_flow ret; ret.to = to; ret.cost = cost; ret.cap = cap; ret.rev = rev; return ret; } //* class Graph{ public: int V; vector< vector<FLOW::edge_flow> > G; vector< LL > dist; vector< int > iter; vector< bool > used; void init(int v){ V = v; G.resize(V); } void reset(){ iter.assign(V,0); used.assign(V,false); } //directed graph void add_edge(int from,int to,LL cap){ G[from].push_back( FLOW::make_edge_flow(to,cap,G[to].size()) ); G[to].push_back( FLOW::make_edge_flow(from,0,G[from].size()-1) ); } private: //sから最短距離をBFSで計算する void bfs(int s){//許容量もチェックしている queue<int> que; dist = vector<LL>(V,-1); dist[s] = 0; que.push(s); while(!que.empty()){ int v = que.front();que.pop(); for(int i=0;i<(int)G[v].size();++i){ edge_flow &e = G[v][i]; if( e.cap > 0 && dist[e.to] < 0 ){ dist[e.to] = dist[v] + 1; que.push(e.to); } } } } private: //増加パスをDFSで探す LL dfs(int v,int t,LL f){ if( v==t ) return f; for(int &i = iter[v];i<(int)G[v].size();++i){//? FLOW::edge_flow &e = G[v][i]; if( e.cap>0 && dist[v] < dist[e.to]){ LL d = this->dfs(e.to, t, min(f,e.cap) ); if( d > 0){ e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } public: //sからtへの最大流量を求める LL max_flow(int s,int t){ LL flow = 0; for(;;){ this->bfs(s); if( dist[t] < 0 ) return flow; iter = vector<int>(V,0); LL f = this->dfs(s,t,LINF); do{ flow += f; f = this->dfs(s,t,LINF); }while( f > 0 ); } } }; //*/ } #pragma endregion //dinic :O(|E||V|^2) #pragma region //グラフ bool is_bipartite(int v,int c,vector< vector<int> >& G,vector<int>& Color){ Color[v] = c; for(int i=0;i < (int)G[v].size();++i){//隣接グラフ if(Color[ G[v][i] ] == c ) return false; if(Color[ G[v][i] ] == 0 && !is_bipartite(G[v][i],-c,G,Color) ){ return false; } } return true; } bool is_bipartite(int Root,vector< vector<int> >& Graph){ int GraphSize = Graph.size(); vector<int> Color(GraphSize,0); const int ColorNo = 1; return is_bipartite(Root,ColorNo,Graph,Color); } #pragma endregion //二部グラフチェック is_bipartite(root,GraphList) #pragma region namespace matching{ //https://beta.atcoder.jp/contests/soundhound2018/tasks/soundhound2018_c int V; //頂点数 vector< vector<int> > G;//グラフ vector<int> match;//match[i]:頂点[i]がどことマッチされているか vector<bool > used;// void add_edge(int u,int v){ G[u].push_back(v); G[v].push_back(u); } bool dfs(int v){ /* https://mathtrain.jp/bipartitematching 未マッチ辺・マッチ辺・未マッチ辺 これを マッチ辺・未マッチ辺・マッチ辺 に変えると 1マッチが2マッチになる。 未[済未] 増加路を求めている。 */ used[v] = true;//dfsのroot前に初期化される int size = G[v].size(); for(int i=0;i<size;++i){ int u = G[v][i];// int w = match[u];// if( w<0 || ((used[w]==false) && dfs(w)) ){ /* マッチングされていない|| 使われてない&& */ match[v] = u; match[u] = v; return true; } } return false; } int bipartite_matching(){ int res = 0; match = vector<int>(V,-1);//未マッチ状態に初期化 for(int v=0;v<V;++v){ if( match[v] < 0 ){ used = vector<bool>(V,false); if( dfs(v) ){ ++res; } } } return res; } } #pragma endregion //二部グラフの最大マッチング bipartite_matching() #pragma endregion // #pragma region vector< vector<LL> > NCK;//初期値:0 //http://sugarknri.hatenablog.com/entry/2016/07/16/165715 void makeinv(vector<LL>& inv,const LL P){ int i; //const int varMAX = max(100000,(int)inv.size()); const int varMAX = max(300010,(int)inv.size()); inv = vector<LL>( varMAX+1,0); inv[1]=1; for(i=2;i<=varMAX;i++){ inv[i] = (inv[P%i] * (P-P/i)%P ) % P;//OVF //inv[i] = powMod(i,P-2,P); } } LL nCk(LL N,LL k,LL mod = MOD){ static vector<LL> inv;//modの逆元 if( inv.size() == 0 ){ makeinv(inv,mod);//modは素数を入れる } k = min(k,N-k); if( k < 0 || k > N){return 0;} if( k == 0 ){return 1;} if( k == 1 ){return N%mod;} LL ret = 1; for(int i=1;i<=k;++i){ ret = (ret * ((N+1-i)%mod) )%mod;//ret*N:OVF ret = (ret * inv[i] )%mod; } return ret; } LL nCk_once(LL N,LL k,LL mod = MOD){//modは素数 k = min(k,N-k); if( k < 0 || k > N ){return 0;} if( k == 0 ){return 1;} if( k == 1 ){return N%mod;} LL ret = 1; LL A=1; for(LL i=0;i<k;++i){ A = (A * ((N-i)%mod) ) % mod; } LL B=1; for(LL i=2;i<=k;++i){ B = (B * (i%mod) ) % mod; } ret = ( A * powMod(B,mod-2,mod) ) % mod; return ret; } #pragma endregion //組み合わせnCk(,10^5) #pragma region LL nCk_base(int N,int K,LL mod=MOD){ if( K<0 || N < K ) return 0;//多く取り過ぎ K = min(K,N-K); if( K==0 ){return 1%mod;} if( K==1 ){return N%mod;}//%MOD; if( N<=10000 && NCK[N][K] ){ return NCK[N][K]; } //N個目を使わない:nCk(N-1,k) //N個目を使う :nCk(N-1,k-1) LL ans = (nCk_base(N-1,K)+nCk_base(N-1,K-1) )%mod;//%MOD; if( N<=10000 ){ NCK[N][K] = ans; } return ans; } #pragma endregion //組み合わせ メモ? #pragma region DSL class UnionFind{ public: int cNum;//要素数 vector<int> parent; vector<int> count; vector< vector<int> > GList; UnionFind(int n){ cNum = n; parent = vector<int>(n); count = vector<int>(n,1); GList.resize(n); for(int i=0;i<n;++i){ parent[i] = i; GList[i].push_back(i); } } int find(int x){ if( parent[x] == x ){return x;} return parent[x] = find( parent[x] ); } bool same(int x,int y){return find(x) == find(y);} int Count(int x){return count[find(x)];} void add(int x,int y){//union x = find(x); y = find(y); if( x==y )return; parent[x] = y; count[y] += count[x]; if( GList[y].size() < GList[x].size() ){ swap(GList[x],GList[y]); } GList[y].insert( GList[y].end(), GList[x].begin(),GList[x].end() ); } }; #pragma endregion //UnionFind #pragma region DSL class BITree{//1-index int N; vector<LL> bit; public: BITree(int n){ N = n; bit = vector<LL>(N+1,0);//1-index } void add(int a,LL w){//aにwを足す if( a <= 0 || N < a) return;//a:[1,N] for(int i=a;i<=N;i += i & -i){ bit[i] += w; } } LL sum(int a){//[1,a]の和,a:[1,N] /* 1番目からa番目までの和、1-index */ LL ret = 0; if( a > N ) a = N; for(int i=a; i > 0; i -= i & -i){ ret += bit[i]; } return ret; } }; #pragma endregion //BIndexTree #pragma region template <typename T> class segment_base{ int N;//要素数 vector< T > dat1; T VAL_E;//初期値 T VAL_NULL;//空の値 public: segment_base(){}; segment_base(int n,T val_E ):N(n),VAL_E(val_E){ dat1.resize(2*n); dat1.assign(2*n,val_E);//初期化 } void init(int n,T val_E,T val_N){ N = n; VAL_E = val_E; VAL_NULL = val_N; int size = 2; while(size<N){ size<<1; } N = size; dat1.resize(2*N); dat1.assign(2*N,val_E); } T SELECT(T& L,T& R){//扱う演算子 T ans; ans = min(L,R);// return ans; } //index番目の値をvalに変更,indexは"0-index" void update(int i,T& val){ i += N-1; dat1[i] = val; while(i>0){ i = (i-1)/2; dat1[i] = SELECT(dat1[i*2+1],dat1[i*2+2]); } } //区間[L,R)のSELECT /* 調べている範囲[a,b),階数k,見る場所[L,R) */ T query(int a,int b,int k,int L,int R){ if( R<=a || b<=L ){ return VAL_E;//交差しない } if( a<=L && R<=b && dat1[k] != VAL_NULL ){ return dat1[k]; } T res = VAL_E; int mid = (L+R)/2; if( a < mid ) res = SELECT(res,query(a,b,k*2+1,L,mid) ); if( mid < b ) res = SELECT(res,query(a,b,k*2+2,mid,R) ); return res; } T query(int L,int R){ return query(L,R,0,0,N); } }; #pragma endregion //segment_tree #pragma region //行列の積 namespace mymat{ LL matMOD = MOD;//初期値10^9 + 7 }; template<class T> vector< vector<T> > operator*( vector<vector<T> >& A,vector< vector<T> >& B){ LL mod = mymat::matMOD; int R = A.size(); int cen = A[0].size(); int C = B[0].size(); vector< vector<T> > ans(R,vector<T>(C,0) ); for(int row=0;row<R;++row){ for(int col=0;col<C;++col){ for(int inner=0;inner< cen;++inner){ /*ans[row][col] = (ans[row][col] + A[row][inner]*B[inner][col])%mod; //ans[row][col] = (ans[row][col] + A[row][inner]*B[inner][col]); ans[row][col] = (ans[row][col] + mod) % mod; //負になるときの処理 */ ans[row][col] = (ans[row][col] + A[row][inner]*B[inner][col])%mod; } } } return ans; } template<class T> vector< vector<T> > powMod(const vector< vector<T> >& mat,LL N,LL mod=MOD){ mymat::matMOD = mod; int R = mat.size(); int C = mat[0].size(); //R==C vector< vector<T> > I(R,vector<T>(C,0));//単位元 for(int i=0;i<R && i<C;++i){ I[i][i] = 1; } if( N == 0 ){ return I; } vector< vector<T> > mul(R,vector<T>(C)),ans(R,vector<T>(C)); ans = I; mul = mat; while(N){ if( N & 1 ){ ans = ans*mul; } N >>= 1; mul = mul*mul; } return ans; } #pragma endregion //行列 #pragma region namespace TIME{ unsigned long long get_cycle(){ return __rdtsc(); } unsigned long long start,limit; void time_start(){ start = get_cycle(); } //あたいをーさぐらないとーだめー void time_set(unsigned long long num){limit = num;} bool check(){return (get_cycle() < start+limit);} } #pragma endregion //時間計測 #pragma region namespace RAND{ unsigned long xor128(){ static unsigned long x=123456789,y=362436069,z=521288629,w=88675123; unsigned long t; t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) ); } LL getRAND(LL P){ return ((xor128()%P)+P)%P; } } #pragma endregion //乱数 #pragma region #pragma endregion // ////////////////// //aのmod mにおける逆元を返す。 //aとmは互いに素であることが要請される。 long long invMod(long long a,long long m){ long long x,y; ext_gcd(a,m,x,y); x %= m; if(x<0) x += m; return x; } /* LL powMod(LL x,LL e,LL mod){ LL prod = 1%mod; for(int i=63;i>=0;--i){ prod = prod*prod % mod; if(e&1LL<<i)prod=prod*x%mod; } return prod; } */ /////////////////// /* thx http://kmjp.hatenablog.jp/entry/2017/03/19/0930 */ int N; vector<int> L(101010,0),R(101010,0); multiset<LL> LS,RS; LL ofL,ofR; LL ret; /* \/これが[x-L,x+R]範囲のminを取ると \_/になる。 */ void minWide(LL L,LL R){ //傾き0の範囲が広がる。 ofL -= L; ofR += R; } void addABSfunc(int L){ /* f(x) = abs(x-L) の関数を足す。 */ multiset<LL>::iterator Left,Right; Left = LS.rbegin(); Right = RS.begin(); if( L < *Left + ofL ){ /* Leftが左に傾き1=右に傾き0の分岐点 */ LL temp = *Left + ofL; ret += (temp - L); LS.erase( Left );//pro:一つだけ消すのでイテレータ使う LS.insert( L - ofR ); LS.insert( L - ofR ); RS.insert( temp - ofR ); }else if( *Right + ofR < L ){ LL temp = *Right + ofR; ret += (L - temp); RS.erase( Right ); RS.insert( L - ofR );//元々あった|Right-x|の効果 RS.insert( L - ofR );//|L-x|の効果 LS.insert( temp - ofL ); }else{ //傾きが0の範囲にLがある //retは変わらない。 LS.insert( L - ofL ); RS.insert( L - ofR ); } } multiset<LL> Mset; LL offsetL,offsetR; LL ret2; multiset<LL>::iterator div0,div1; void add2init(){ Mset.insert(-1LL<<60); Mset.insert(1LL<<60); div0 = Mset.begin(); ret2 = 0; } void addABSfunc2(int L,int R,int pos){ //傾き0の範囲が広がる。 offsetL -= L; offsetR += R; ///// div1 = div0; div1++; LL Left = *div0 + offsetL; LL Right =*(div1) + offsetR; if( pos < Left ){ LL temp = *div0 + ofL; ret += (temp - L); Mset.insert(pos); Mset.insert(pos); div0--; }else if(Right < pos){ LL temp = *(div1) + ofR; ret += (L - temp); Mset.insert(pos); Mset.insert(pos); div0++; }else{ Mset.insert(pos); Mset.insert(pos); div0++; } } void input(){ cin >> N; for(int i=0;i<N;++i){ cin>>L[i]>>R[i]; } } void solve(){ input(); LS.insert(-1LL<<60); RS.insert(1LL<<60); for(int i=0;i<N;++i){ if(i){ ofL -= R[i]-L[i]; ofR += R[i-1]-L[i-1]; } if(L[i]<*LS.rbegin()+ofL){ ret += *LS.rbegin()+ofL-L[i]; }else if(*RS.begin()+ofR<L[i]){ ret += L[i]-(*RS.begin()+ofR); } if(L[i]<*LS.rbegin()+ofL){ RS.insert(*LS.rbegin()+ofL-ofR); LS.insert(L[i]-ofL); LS.insert(L[i]-ofL); LS.erase(LS.find(*LS.rbegin())); } else if(*RS.begin()+ofR<L[i]){ LS.insert(*RS.begin()+ofR-ofL); RS.insert(L[i]-ofR); RS.insert(L[i]-ofR); RS.erase(RS.begin()); } else{ LS.insert(L[i]-ofL); RS.insert(L[i]-ofR); } } cout << ret << endl; } void solve2(){ input(); LS.insert(-1LL<<60); RS.insert(1LL<<60); for(int i=0;i<N;++i){ if(i){ minWide(R[i]-L[i],R[i-1]-L[i-1]); } addABSfunc( L[i] ); } cout << ret << endl; } void solve3(){ input(); add2init(); addABSfunc2(0,0,L[0]); for(int i=1;i<N;++i){ addABSfunc2(R[i]-L[i],R[i-1]-L[i-1],L[i]); } cout << ret2 << endl; } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
a.cc: In function 'long long unsigned int TIME::get_cycle()': a.cc:610:16: error: '__rdtsc' was not declared in this scope 610 | return __rdtsc(); | ^~~~~~~ a.cc: In function 'void addABSfunc(int)': a.cc:689:26: error: no match for 'operator=' (operand types are 'std::multiset<long long int>::iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'} and 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'}) 689 | Left = LS.rbegin(); | ^ In file included from /usr/include/c++/14/set:62, from a.cc:19: /usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<long long int>& std::_Rb_tree_const_iterator<long long int>::operator=(const std::_Rb_tree_const_iterator<long long int>&)' 324 | struct _Rb_tree_const_iterator | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'} to 'const std::_Rb_tree_const_iterator<long long int>&' /usr/include/c++/14/bits/stl_tree.h:324:12: note: candidate: 'constexpr std::_Rb_tree_const_iterator<long long int>& std::_Rb_tree_const_iterator<long long int>::operator=(std::_Rb_tree_const_iterator<long long int>&&)' /usr/include/c++/14/bits/stl_tree.h:324:12: note: no known conversion for argument 1 from 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'} to 'std::_Rb_tree_const_iterator<long long int>&&'
s226113197
p03783
C++
#include <bits/stdc++.h> #define db double #define ls rt << 1 #define rs rt << 1 | 1 #define pb push_back #define ll long long #define mp make_pair #define pii pair<int, int> #define X first #define Y second #define pcc pair<char, char> #define vi vector<int> #define vl vector<ll> #define rep(i, x, y) for(int i = x - 1; i < y; i ++) #define rrep(i, x, y) for(int i = x; i >= y; i - - ) #define eps 1e - 9 #define all(x) (x).begin(), (x).end() using namespace std; inline int read() { int x = 0, f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == ' - ') f = - 1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; } typedef pair<int,int> P; int n; ll l[100001],r[100001]; multiset<ll> L, R; int main() { n = read(); rep(i, 1, n) scanf("%lld%lld",&l[i],&r[i]); L.insert( - 1LL << 60); R.insert(1LL << 60); ll ol = 0, Or = 0; ll res = 0; rep(i, 1, n) { if(i > 0) ol - = r[i] - l[i], Or += r[i - 1] - l[i - 1]; if(l[i] < *L.rbegin() + ol) res += *L.rbegin() + ol - l[i]; else if(*R.begin() + Or < l[i]) res += l[i] - (*R.begin() + Or); if(l[i]<*L.rbegin() + ol) { R.insert(*L.rbegin() + ol - Or); L.insert(l[i] - ol); L.insert(l[i] - ol); L.erase(L.find(*L.rbegin())); } else if(*R.begin() + Or < l[i]) { L.insert(*R.begin() + Or - ol); R.insert(l[i] - Or); R.insert(l[i] - Or); R.erase(R.begin()); } else { L.insert(l[i] - ol); R.insert(l[i] - Or); } } printf("%lld\n",res); return 0; }
a.cc:22:50: warning: multi-character character constant [-Wmultichar] 22 | while (ch < '0' || ch > '9') { if (ch == ' - ') f = - 1; ch = getchar(); } | ^~~~~ a.cc: In function 'int main()': a.cc:44:33: error: expected primary-expression before '=' token 44 | if(i > 0) ol - = r[i] - l[i], Or += r[i - 1] - l[i - 1]; | ^
s716901802
p03783
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; ll l, r, len; ll pbl = 0, pbr = 0, ans = 0; priority_queue<ll> ql; priority_queue<ll, vector<ll>, greater<ll>> qr; while (n--) { cin >> l >> r; len = r - l; pbr += len; ql.push(r - pbl); qr.push(r - pbr); while ((L = ql.top() + pbl) > (R = pbr + qr.top())) { ans += L - R; ql.pop(); qr.pop(); ql.push(R - pbl); qr.push(L - pbr); } pbl -= len; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:25: error: 'L' was not declared in this scope 27 | while ((L = ql.top() + pbl) > (R = pbr + qr.top())) { | ^ a.cc:27:48: error: 'R' was not declared in this scope 27 | while ((L = ql.top() + pbl) > (R = pbr + qr.top())) { | ^
s674215731
p03783
C++
#include <bits/stdc++.h> using namespace std; int len[N]; priority_queue<long long> PQL, PQR; long long pbl, pbr; long long Ans; int main() { int n; cin >> n; for (int i = 0;i < n;i++) { scanf("%d%d", &pos[i].first, &pos[i].second); len[i] = pos[i].second - pos[i].first; } ll l, r, len; for (int i = 0;i < n;i++) { cin >> l >> r; len = r - l; pbr += len; PQL.push(r - pbl); PQR.push(pbr - r); while (true) { long long L = PQL.top() + pbl; long long R = -PQR.top() + pbr; if (L <= R) { break; } Ans += L - R; PQL.pop(), PQR.pop(); PQL.push(R - pbl), PQR.push(pbr - L); } pbl -= len; } cout << Ans << endl; return 0; }
a.cc:4:9: error: 'N' was not declared in this scope 4 | int len[N]; | ^ a.cc: In function 'int main()': a.cc:16:32: error: 'pos' was not declared in this scope; did you mean 'pow'? 16 | scanf("%d%d", &pos[i].first, &pos[i].second); | ^~~ | pow a.cc:17:17: error: 'len' was not declared in this scope 17 | len[i] = pos[i].second - pos[i].first; | ^~~ a.cc:20:9: error: 'll' was not declared in this scope 20 | ll l, r, len; | ^~ a.cc:23:24: error: 'l' was not declared in this scope 23 | cin >> l >> r; | ^ a.cc:23:29: error: 'r' was not declared in this scope 23 | cin >> l >> r; | ^ a.cc:24:17: error: 'len' was not declared in this scope 24 | len = r - l; | ^~~
s298721695
p03783
C++
/* % D a l a o --InterestingLSY */ #include <iostream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <stack> #include <queue> #include <algorithm> #include <set> #include <map> #define pb push_back #define mp make_pair #define INF 9999999 #define LINF 999999999999999999 #define SINF "%" #define uint unsigned int #define msn(a,v) memset(a,v,sizeof(a)) #define ms(a) msn(a,0) #define NONE -1 #define ll long long #define uchar unsigned char #define sint short int #define usint unsigned sint using namespace std; #define MAXN 500 int n; int l[MAXN],r[MAXN]; int len[MAXN]; ll mem[MAXN][MAXN]; ll dp(int pos,int lastl){ if(pos == n+1) return 0; if(mem[pos][lastl] != -1) return mem[pos][lastl]; ll ans = LINF; for(int nowl = lastl-len[pos];nowl <= lastl+len[pos-1];nowl++) ans = min( ans , dp(pos+1,nowl) + abs(l[pos]-nowl) ); mem[pos][lastl] = ans; return ans; } int main(){ /freopen("E.txt","r",stdin); msn(mem,-1); scanf("%d",&n); for(int i = 1;i <= n;i++){ scanf("%d %d",&l[i],&r[i]); len[i] = r[i] - l[i]; } ll ans = LINF; for(int i = 0;i <= MAXN;i++) ans = min( ans , dp(2,i) + abs(i-l[1]) ); printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:47:9: error: expected primary-expression before '/' token 47 | /freopen("E.txt","r",stdin); | ^
s437653726
p03783
C++
#include <cstdio> #include <algorithm> #include <iostream> #include <cstring> using namespace std; int n; int l[405],r[405]; int d[405][405]; int go(int now,int leftx){ if(now == n) return 0; int &ans = d[now][leftx]; if(ans!=-1) return ans; int rightend = leftx + r[now-1]-l[now-1]; ans = 987654321; for(int k=1;k<=400;k++){ int rnew = k + r[now] - l[now]; if(rnew < leftx || rnow < k) continue; //if(max(k,leftx) <= min(rnew,rightend)){ ans = min(ans,go(now+1,k) + abs(k-l[now])); //} } return ans; } int main() { scanf("%d",&n); if(n>=401) return 0; for(int i=0;i<n;i++){ scanf("%d %d",&l[i],&r[i]); } memset(d,-1,sizeof(d)); int res = 987654321; for(int i=1;i<=400;i++){ res = min(res,go(1,i)+abs(i-l[0])); } printf("%d\n",res); }
a.cc: In function 'int go(int, int)': a.cc:23:28: error: 'rnow' was not declared in this scope; did you mean 'rnew'? 23 | if(rnew < leftx || rnow < k) continue; | ^~~~ | rnew
s920360958
p03783
C++
#include <algorithm> #include <iostream> #include <sstream> #include <string> #include <cstring> #include <vector> #include <queue> #include <set> #include <map> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <list> #include <cassert> #include <ctime> #include <climits> using namespace std; #define PB push_back #define MP make_pair #define SZ(v) ((int)(v).size()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FORE(i,a,b) for(int i=(a);i<=(b);++i) #define REPE(i,n) FORE(i,0,n) #define FORSZ(i,a,v) FOR(i,a,SZ(v)) #define REPSZ(i,v) REP(i,SZ(v)) typedef long long ll; typedef unsigned long long ull; ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); } const int MAXN=100000; int n; int a[MAXN],b[MAXN]; void run() { scanf("%d",&n); REP(i,n) scanf("%d%d",&a[i],&b[i]); map<ll,int> L,R; ll dl=a[0],dr=a[0]; L[0]=+1; R[0]=+1; ll ret=0; FOR(i,1,n) { dl-=b[i]-a[i]; dr+=b[i-1]-a[i-1]; ll lmx; { map<ll,int>::iterator it=L.end(); assert(it!=L.begin()); --it; lmx=dl+it->first; } ll rmn; { map<ll,int>::iterator it=R.begin(); assert(it!=R.end()); rmn=dr+it->first; } if(a[i]<lmx) { ret+=lmx-a[i]; L[a[i]-dl]+=2; map<ll,int>::iterator it=L.end(); assert(it!=L.begin()); --it; assert(lmx==dl+it->first); --it->second; if(it->second==0) L.erase(it); R[lmx-dr]++; } else if(a[i]>rmn) { ret+=a[i]-rmn; R[a[i]-dr]+=2; map<ll,int>::iterator it=R.begin(); assert(it!=R.end()); rmn=dr+it->first; assert(rmn==dr+it->first); --it->second; if(it->second==0) R.erase(it); L[rmn-dl]++; } else { L[a[i]-dl]++; R[a[i]-dr]++; } //printf("ret=%lld\n",ret); //printf("L:"); for(map<ll,int>::iterator it=L.begin();it!=L.end();++it) printf(" %lld:%d",dl+it->first,it->second); puts(""); //printf("R:"); for(map<ll,int>::iterator it=R.begin();it!=R.end();++it) printf(" %lld:%d",dr+it->first,it->second); puts(""); } printf("%lld\n",cur); } int main() { run(); return 0; }
a.cc: In function 'void run()': a.cc:70:25: error: 'cur' was not declared in this scope 70 | printf("%lld\n",cur); | ^~~
s304472923
p03783
C++
#include <iostream> #include <algorithm> #include <cmath> #include <vector> using namespace std; int main(int argc, char* argv[]) { int n; vector<int> l, r; for (int i=0; i<n; i++) { int l_, r_; cin >> l_, r_; l.push_back(l_); r.push_back(r_); } if(n > 400){ return 0; } long min_loss = -1; int loss_pos = -1; for(int i=1; i<=400;i++){ long loss = 0 for (int j=0, j < n; j++) { if (r[j] < i) { loss += i - r[j]; } eles if (l[j] > i) { loss += l[j] > i; } } if (loss < min_loss || loss_pos == -1) { loss_pos = j; min_loss = loss; } } cout << min_loss << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:22:17: error: expected ',' or ';' before 'for' 22 | for (int j=0, j < n; j++) { | ^~~ a.cc:22:38: error: 'j' was not declared in this scope 22 | for (int j=0, j < n; j++) { | ^
s116742198
p03783
C++
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <cstdio> #include <numeric> #include <cstring> #include <ctime> #include <cstdlib> #include <set> #include <map> #include <unordered_map> #include <unordered_set> #include <list> #include <cmath> #include <bitset> #include <cassert> #include <queue> #include <deque> #include <cassert> #define For(i, a, b) for (int i = a; i < b; ++i) #define Out(i, a, b) for (int i = a - 1; i >= b; --i) #define pb push_back #define x first #define y second #define files(FileName) read(FileName); write(FileName) #define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin) #define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout) using namespace std; template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; } template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; } const string FileName = "input"; typedef long long base; const int MAXN = 2e4; int n; int LR[401][2]; int dp[401][401]; int main() { ios::sync_with_stdio(0); //read(FileName); //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); cin >> n; for (int i = 0; i < n; ++i) { cin >> LR[i][0] >> LR[i][1]; --LR[i][0], --LR[i][1]; } for (int i = 0; i < 400; ++i) { for (int j = 0; j < 400; ++j) { dp[i][j] = 1e9; } } for (int i = 0; i < 400; ++i) { dp[0][i] = abs(i - LR[0][0]); } for (int i = 1; i < n; ++i) { int Ln = LR[i][0], Rn = LR[i][1]; for (int j = 0; j < 400; ++j) { // if (j <= 5) { // cout << i - 1 << ' ' << j << ' ' << dp[i - 1][j] << endl; // } // int L = j, R = j - LR[i][0] + LR[i][1]; // if (j <= 5) { // cout << Ln << ' ' << Rn << ' ' << L << ' ' << R << endl; // } if (max(L, Ln) <= min(R, Rn)) { chkmin(dp[i][L], dp[i - 1][j]); for (int q = Ln - R + L; q <= Rn; ++q) { if (q >= 0 && q <= 399) chkmin(dp[i][q], dp[i - 1][q] + abs(q - L)); } } else { if (R < Ln) { for (int q = Ln - R + L, d = Ln - R; q <= Rn; ++q, ++d) { if (q >= 0 && q <= 399) chkmin(dp[i][q], dp[i - 1][q] + d); } } else { for (int q = Rn, d = L - Rn; q - L + R >= Ln; --q, ++d) { if (q >= 0 && q <= 399) chkmin(dp[i][q], dp[i - 1][q] + d); } } } } } int ans = 1e9; for (int i = 0; i < 399; ++i) { chkmin(ans, dp[n - 1][i]); } cout << ans << endl; } /* 2 AB 11 2!2 3 ABB 122 3!3 4 ABB 2222 4!3 5 ABBBB 12222 5!5 6 ABBB 121222 6!4 7 ABBBB 1212122 7!5 8 ABBB 12121212 8!4 9 ABBBBBBBB 122222222 9!9 10 ABBBBB 1212222222 10!6 11 ABBBBBBBB 12121222222 11!9 12 ABBBBB 121212122222 12!6 13 ABBBBBBBB 1212121212222 13!9 14 ABBBBB 12121212121222 14!6 15 ABBBBBBBB 121212121212122 15!9 16 ABBBBB 1212121212121212 16!6 17 ABBBBBBBBBBBBBBBB 12222222222222222 17!17 18 ABBBBBBBBB 121222222222222222 18!10 19 ABBBBBBBBBBBBBBBB 1212122222222222222 19!17 20 ABBBBBBBBB 12121212222222222222 20!10 [Finished in 3.1s] */
a.cc: In function 'int main()': a.cc:72:21: error: 'L' was not declared in this scope 72 | if (max(L, Ln) <= min(R, Rn)) { | ^ a.cc:72:35: error: 'R' was not declared in this scope 72 | if (max(L, Ln) <= min(R, Rn)) { | ^ a.cc:80:74: error: 'd' was not declared in this scope 80 | for (int q = Ln - R + L, d = Ln - R; q <= Rn; ++q, ++d) { | ^
s053920463
p03783
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll N; ll a[100005],b[100005]; ll dp[2][405]; void solve(){ if(N==1){ cout<<0<<endl; return 0; } ll INF=(1LL<<60); fill( dp[0],dp[2] , INF); for(int i=1;i<=400;i++){ dp[1][ i ]= abs(a[1]-i); } ll ans=INF; for(int i=1;i+1<=N;i++){ int ai=i%2; int bi=1-ai; for(int j=0;j<405;j++)dp[bi][j]=INF; for(int j=1;j<=400;j++){ int len0=b[i]-a[i]+1; int len1=b[i+1]-a[i+1]+1; int fi=j-len1+1; int se=j+len0-1; if(fi<1)fi=1; if(se>400)se=400; for(int k=fi;k<=se;k++){ dp[bi][k]=min(dp[bi][k],dp[ai][j]+abs(a[i+1]-k)); if(i+1==N)ans=min(ans,dp[bi][k]); } } } cout<<ans<<endl; } int main(){ cin>>N; assert(N<=400);///////////////////////////////////////// for(int i=1;i<=N;i++){ cin>>a[i]>>b[i]; assert(a[i]<=400);///////////////////////////////////////// assert(b[i]<=400);///////////////////////////////////////// } solve(); return 0; }
a.cc: In function 'void solve()': a.cc:13:12: error: return-statement with a value, in function returning 'void' [-fpermissive] 13 | return 0; | ^
s517851367
p03784
C++
#include <bits/stdc++.h> using namespace std; int main() { cin.tie(0); ios::sync_with_stdio(false); int a, b; cin >> a >> b; if(a <= b){ cout << "Impossible" << endl; return 0; } vector<int> x; x.emplace_back(0); for(int i = 1; i < n; i++){ cout << "? " << x.back() << " " << i << endl; char c; cin >> c; if(c == 'Y') x.emplace_back(i); else{ x.pop_back(); if(x.size() == 0){ x.emplace_back(i + 1); i++; } } } vector<int> ans(n, 0); ans.at(x.back()) = 1; for(int i = 0; i < n; i++){ cout << "? " << x.back() << " " << i << endl; char c; cin >> c; if(c == 'Y') ans.at(i) = 1; } cout << "! "; for(int i = 0; i < n; i++){ cout << ans.at(i); } cout << endl; }
a.cc: In function 'int main()': a.cc:18:22: error: 'n' was not declared in this scope 18 | for(int i = 1; i < n; i++){ | ^ a.cc:32:19: error: 'n' was not declared in this scope 32 | vector<int> ans(n, 0); | ^
s003727065
p03784
C++
#include <bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second const int N = 4007; int a, b, n, ans[N]; stack <int> st; string s; int ask(int x, int y){ int ret = 0; #ifndef Dat cout << "? " << x << " " << y << endl; cin >> s; if(s == 'Y') ret = 1; else ret = 0; #endif // Dat #ifdef Dat if(s[x - 1] == '1') ret = s[y - 1] - '0'; else{ ret = rand() % 2; } #endif // Dat return ret; } int main(){ ios_base::sync_with_stdio(0); srand(time(NULL)); cin >> a >> b; #ifdef Dat cin >> s; #endif // Dat if(a <= b) return cout << "Impossible" << endl, 0; n = a + b; for(int i = 1; i <= n; i++){ if(st.empty()){ st.push(i); continue; } int p = ask(st.top(), i); if(!p){ st.pop(); } else{ st.push(i); } } int pos = st.top(); for(int i = 1; i <= n; i++){ ans[i] = ask(pos, i); } cout << "! "; for(int i = 1; i <= n; i++) cout << ans[i]; cout << endl; }
a.cc: In function 'int ask(int, int)': a.cc:19:22: error: no match for 'operator==' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and 'char') 19 | if(s == 'Y') ret = 1; | ~ ^~ ~~~ | | | | | char | std::string {aka std::__cxx11::basic_string<char>} In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1274 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1441 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed: a.cc:19:25: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'char' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1613 | operator==(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 19 | if(s == 'Y') ret = 1; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::pair<_T1, _T2>' 19 | if(s == 'Y') ret = 1; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 441 | operator==(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 486 | operator==(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1667 | operator==(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 19 | if(s == 'Y') ret = 1; | ^~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1737 | operator==(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 19 | if(s == 'Y') ret = 1; | ^~~ In file included from /usr/include/c++/14/bits/char_traits.h:42, from /usr/include/c++/14/string:42, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)' 192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::fpos<_StateT>' 19 | if(s == 'Y') ret = 1; | ^~~ In file included from /usr/include/c++/14/string:43: /usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)' 235 | operator==(const allocator<_T1>&, const allocator<_T2>&) | ^~~~~~~~ /usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed: a.cc:19:25: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::allocator<_CharT>' 19 | if(s == 'Y') ret = 1; | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:629:5: note: candidate: 'template<class _CharT, class
s821706586
p03784
C++
#include<bits/stdc++.h> using namespace std; int N, A, B; struct TGrader{ string s; TGrader() { #ifdef ONLINE_JUDGE cin >> A >> B; N = A + B; #else s = "10001110001110011100101010111"; for(int i = 0; i < Grader.s.size(); ++i) { N++; if(Grader.s[i] == '1') A++; else B++; } #endif } bool ask(int x, int y) { #ifdef ONLINE_JUDGE cout << "? " << x << " " << y << endl; string w; cin >> w; return (w == "Y"); #else if(s[x] == '1') return (s[y] == '1'); return rand() % 2; #endif } void guess(string t) { #ifdef ONLINE_JUDGE cout << "! " << t << endl; #else if(s == t) cout << "Correct!!!"; else cout << "Wrong answer" << endl; #endif } }Grader; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); if(B >= A) { cout << "Impossible" << endl; return 0; } deque<int> vec; for(int i = 0; i < N; ++i) { if(vec.empty()) { vec.push_back(i); continue; } if(Grader.ask(vec.back(), i)) { vec.push_back(i); continue; } else { vec.pop_back(); } } string ans; for(int i = 0; i < N; ++i) { ans += char('0' + (Grader.ask(vec.back(), i))); } Grader.guess(ans); return 0; }
a.cc: In constructor 'TGrader::TGrader()': a.cc:14:26: error: 'Grader' was not declared in this scope; did you mean 'TGrader'? 14 | for(int i = 0; i < Grader.s.size(); ++i) { | ^~~~~~ | TGrader
s442027486
p03784
C++
#include <bits/stdc++.h> using namespace std; int ax[100005]; int top=0; bool ok[100005]; signed main() { int a, b; cin>>a>>b; if(a<=b) { cout<<"Impossible"<<endl; return 0; } int n=a+b; for(int i=1; i<=n; i++) { if(top==0) { top++; ax[top]=i; } else { cout<<"? "<<ax[top]<<" "<<i<<endl; char ans; cin>>ans; if(ans=="Y") { top++; ax[top]=i; } else { top--; } } } for(int i=1; i<=n; i++) { cout<<"? "<<ax[top]<<" "<<i<<endl; char ans; cin>>ans; if(ans=="Y") { ok[i]=1; } } cout<<"! "; for(int i=1; i<=n; i++) { cout<<ok[i]; } cout<<endl; }
a.cc: In function 'int main()': a.cc:31:31: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 31 | if(ans=="Y") | ~~~^~~~~ a.cc:47:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 47 | if(ans=="Y") | ~~~^~~~~
s279405793
p03784
C++
#include<bits/stdc++.h> using namespace std; int main() { int A, B; cin >> A >> B; if (A <= B) { cout << "Impossible" << '\n'; exit(0); } stack<int> s; s.push(0); for (int i = 1; i < N; i++) { cout << '?' << ' ' << s.top() << ' ' << i << '\n' << flush; char c; cin >> c; if (c == 'N') s.pop(); else s.push(i); } string ans; for (int i = 0; i < N; i++) { cout << '?' << ' ' << s.top() << ' ' << i << '\n' << flush; char c; cin >> c; if (c == 'Y') ans += '1'; else ans += '0'; } cout << '!' << ' ' << ans << '\n'; exit(0); }
a.cc: In function 'int main()': a.cc:9:23: error: 'N' was not declared in this scope 9 | for (int i = 1; i < N; i++) { | ^ a.cc:16:23: error: 'N' was not declared in this scope 16 | for (int i = 0; i < N; i++) { | ^
s669346683
p03784
C++
#include <bits/stdc++.h> using namespace std; bool f[4050]; char ch[2]; int main() { int a, b, n; scanf("%d%d", &a, &b); if(a <= b) { puts("Impossible"); return 0; } n = a + b; stack<int> q; for(int i = 1; i <= n; i++) { if(!q.size()) { printf("? %d %d\n", i, i + 1); fflush(stdout); scanf("%s", ch); if(ch[0] == 'Y') q.push(i), q.push(i + 1); i++; } else printf("? %d %d\n", q.top(), i); fflush(stdout); scanf("%s", ch); if(ch[0] == 'Y') q.push(i); else q.pop(); } int u = q.front(); for(int i = 1; i <= n; i++) { printf("? %d %d\n", u, i); fflush(stdout); scanf("%s", ch); f[i] = ch[0] == 'Y'; } printf("! "); for(int i = 1; i <= n; i++) printf(f[i] ? "1" : "0"); puts(""); return 0; }
a.cc: In function 'int main()': a.cc:30:19: error: 'class std::stack<int>' has no member named 'front' 30 | int u = q.front(); | ^~~~~
s121676219
p03784
C++
#include <bits/stdc++.h> #define int long long using namespace std; const int INF = 1e10; const int MOD = 1e9 + 7; #define dump(x) cout << #x << " = " << (x) << endl; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define pb push_back #define all(v) (v).begin(), (v).end() #define V vector<int> #define P pair<int, int> #define mp make_pair<int, int> int N, l[100010], r[100010]; Vector<P> p; int getscore(int i, int p) { if (l[i] > p) { return l[i] - p; } else if (r[i] < p) { return p - r[i]; } else { return 0; } } void solve() { FOR(i, 0, N) { p.push_back(mp(l[i], -1)); p.push_back(mp(r[i], 1)); } sort(all(p)); int ans = 0; FOR(i, 0, N) { ans += getscore(i, 0); } int now = 0; int d = N; int u = 0; FOR(i, 0, N * 2) { int t = ans - (d - u) * (p[i].first - now); ans = min(ans, t); now = p[i].first; if (p[i].second == -1) { d--; } else { u++; } } cout << ans << endl; } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N; FOR(i, 0, N) cin >> l[i] >> r[i]; solve(); return 0; }
a.cc:14:1: error: 'Vector' does not name a type 14 | Vector<P> p; | ^~~~~~ a.cc: In function 'void solve()': a.cc:29:9: error: 'p' was not declared in this scope 29 | p.push_back(mp(l[i], -1)); | ^ a.cc:29:27: error: cannot bind rvalue reference of type 'long long int&&' to lvalue of type 'long long int' 29 | p.push_back(mp(l[i], -1)); | ~~~^ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]' 1132 | make_pair(_T1&& __x, _T2&& __y) | ~~~~~~^~~ a.cc:30:27: error: cannot bind rvalue reference of type 'long long int&&' to lvalue of type 'long long int' 30 | p.push_back(mp(r[i], 1)); | ~~~^ /usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]' 1132 | make_pair(_T1&& __x, _T2&& __y) | ~~~~~~^~~ a.cc:32:14: error: 'p' was not declared in this scope 32 | sort(all(p)); | ^ a.cc:9:17: note: in definition of macro 'all' 9 | #define all(v) (v).begin(), (v).end() | ^
s507318599
p03784
C++
#include <bits/stdc++.h> #define int long long using namespace std; const int INF = 1e20; const int MOD = 1e9 + 7; #define dump(x) cout << #x << " = " << (x) << endl; #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define pb push_back #define all(v) (v).begin(), (v).end() #define V vector<int> #define P pair<int, int> #define mp make_pair<int, int> int N, l[100010], r[100010]; Vector<P> p; int getscore(int i, int p) { if (l[i] > p) { return l[i] - p; } else if (r[i] < p) { return p - r[i]; } else { return 0; } } void solve() { FOR(i, 0, N) { p.push_back(mp(l[i], -1)); p.push_back(mp(r[i], 1)); } sort(all(p)); int ans = 0; FOR(i, 0, N) { ans += getscore(i, 0); } int now = 0; int d = N; int u = 0; FOR(i, 0, N * 2) { int t = ans - (d - u) * (p[i].first - now); ans = min(ans, t); now = p[i].first; if (p[i].second == -1) { d--; } else { u++; } } cout << ans << endl; } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N; FOR(i, 0, N) cin >> l[i] >> r[i]; solve(); return 0; }
a.cc:4:17: warning: overflow in conversion from 'double' to 'long long int' changes value from '1.0e+20' to '9223372036854775807' [-Woverflow] 4 | const int INF = 1e20; | ^~~~ a.cc:14:1: error: 'Vector' does not name a type 14 | Vector<P> p; | ^~~~~~ a.cc: In function 'void solve()': a.cc:29:9: error: 'p' was not declared in this scope 29 | p.push_back(mp(l[i], -1)); | ^ a.cc:29:27: error: cannot bind rvalue reference of type 'long long int&&' to lvalue of type 'long long int' 29 | p.push_back(mp(l[i], -1)); | ~~~^ 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, from a.cc:1: /usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]' 1132 | make_pair(_T1&& __x, _T2&& __y) | ~~~~~~^~~ a.cc:30:27: error: cannot bind rvalue reference of type 'long long int&&' to lvalue of type 'long long int' 30 | p.push_back(mp(r[i], 1)); | ~~~^ /usr/include/c++/14/bits/stl_pair.h:1132:21: note: initializing argument 1 of 'constexpr std::pair<typename std::__strip_reference_wrapper<typename std::decay<_Tp>::type>::__type, typename std::__strip_reference_wrapper<typename std::decay<_Tp2>::type>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = long long int; _T2 = long long int; typename __strip_reference_wrapper<typename decay<_Tp>::type>::__type = long long int; typename decay<_Tp>::type = long long int; typename __strip_reference_wrapper<typename decay<_Tp2>::type>::__type = long long int; typename decay<_Tp2>::type = long long int]' 1132 | make_pair(_T1&& __x, _T2&& __y) | ~~~~~~^~~ a.cc:32:14: error: 'p' was not declared in this scope 32 | sort(all(p)); | ^ a.cc:9:17: note: in definition of macro 'all' 9 | #define all(v) (v).begin(), (v).end() | ^
s808714916
p03784
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",&s);} string s; int main() { int a,b,n; cin>>a>>b; n=a+b; bool m[20000]; query(0,2); if(s=="NO"){m[0]=0;b--;} else{m[0]=1;a--;} for(int j=1;j<n;j++){query(j,0); if(s=="NO"){m[j]=0;b--;} else{m[j]=1;a--;} } if(a!=0||b!=0){cout<<"Impossible";return 0;} cout<<"! "; for(int j=0;j<n;j++) cout<<m[j]; return 0; }
a.cc: In function 'void query(int, int)': a.cc:5:76: error: 's' was not declared in this scope 5 | void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",&s);} | ^
s047361518
p03784
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);} string s; int main() { int a,b,n; cin>>a>>b; n=a+b; bool m[20000]; query(0,2); if(s=="NO"){m[0]=0;b--} else{m[0]=1;a--;} for(int j=1;j<n;j++){query(j,0); if(s=="NO"){m[j]=0;b--} else{m[j]=1;a--;} } if(a!=0||b!=0){cout<<"Impossible";return 0;} cout<<"! "; for(int j=0;j<n;j++) cout<<m[j]; return 0; }
a.cc: In function 'void query(int, int)': a.cc:5:75: error: 's' was not declared in this scope 5 | void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);} | ^ a.cc: In function 'int main()': a.cc:14:27: error: expected ';' before '}' token 14 | if(s=="NO"){m[0]=0;b--} | ^ | ; a.cc:17:31: error: expected ';' before '}' token 17 | if(s=="NO"){m[j]=0;b--} | ^ | ;
s963232080
p03784
C++
#include<iostream> #include<cstring> using namespace std; void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);} string s; int main() { int a,b,n; cin>>a>>b; n=a+b; bool m[20000]; query(0,2); if(s=="NO"){m[0]=0;b--} else{m[0]=1;a--;} for(int j=1;j<n;j++){query(j,0); if(s=="NO"){m[j]=0;b--} else{m[j]=1;a--;} } if(a!=0||b!=0){cout<<"Impossible";return 0;} cout<<"! "; for(int j=0;j<n;j++) cout<<m[j]; return 0; }
a.cc: In function 'void query(int, int)': a.cc:4:75: error: 's' was not declared in this scope 4 | void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);} | ^ a.cc: In function 'int main()': a.cc:13:27: error: expected ';' before '}' token 13 | if(s=="NO"){m[0]=0;b--} | ^ | ; a.cc:16:31: error: expected ';' before '}' token 16 | if(s=="NO"){m[j]=0;b--} | ^ | ;
s714460382
p03784
C++
/*Program from Luvwgyx*/ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; char s[10];int top,sta[maxn],ans[maxn]; int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } void print(int x){ if(x<0)putchar('-'),x=-x; if(x>9)print(x/10); putchar(x%10+'0'); } void write(int x){print(x);puts("");} void query(int x,int y){printf("? %d %d\n",x,y);fflush(stdout);scanf("%s",s);} int main(){ int a=read(),b=read(),n=a+b; if(a<=b){puts("Impossible");return 0;} for(int i=0;i<n;i++){ if(!top)sta[++top]=i; else { if(query(sta[top],i))sta[++top]=i; else top--; } }for(int i=0;i<n;i++)ans[i]=query(sta[top],i); printf("! ");for(int i=0;i<26;i++)printf("%d",ans[i]);puts(""); return 0; }
a.cc:6:24: error: 'maxn' was not declared in this scope 6 | char s[10];int top,sta[maxn],ans[maxn]; | ^~~~ a.cc:6:34: error: 'maxn' was not declared in this scope 6 | char s[10];int top,sta[maxn],ans[maxn]; | ^~~~ a.cc: In function 'int main()': a.cc:24:17: error: 'sta' was not declared in this scope; did you mean 'std'? 24 | if(!top)sta[++top]=i; | ^~~ | std a.cc:26:22: error: 'sta' was not declared in this scope; did you mean 'std'? 26 | if(query(sta[top],i))sta[++top]=i; | ^~~ | std a.cc:29:26: error: 'ans' was not declared in this scope; did you mean 'abs'? 29 | }for(int i=0;i<n;i++)ans[i]=query(sta[top],i); | ^~~ | abs a.cc:29:39: error: 'sta' was not declared in this scope; did you mean 'std'? 29 | }for(int i=0;i<n;i++)ans[i]=query(sta[top],i); | ^~~ | std a.cc:30:51: error: 'ans' was not declared in this scope; did you mean 'abs'? 30 | printf("! ");for(int i=0;i<26;i++)printf("%d",ans[i]);puts(""); | ^~~ | abs
s285324375
p03784
C++
#include <stdio.h> #include <string.h> #include <algorithm> const int N=200005; int ans[N],stack[N],top; int main(void) { int a,b; scanf("%d%d",&a,&b); if (a<=b) return 0&printf("Impossible\n"); int n=a+b; rep(i,0,n-1) { if (!top) { stack[++top]=i; continue; } printf("? %d %d\n", stack[top],i); fflush(stdout); char ch[2]; scanf("%s",ch); if (ch[0]=='Y') stack[++top]=i; else top--; } ans[stack[top]]=1; rep(i,0,n-1) if (i!=stack[top]) { printf("? %d %d\n", stack[top],i); fflush(stdout); char ch[2]; scanf("%s",ch); if (ch[0]=='Y') ans[i]=1; } printf("! "); rep(i,0,n-1) putchar(ans[i]+'0'); puts(""); return 0; }
a.cc: In function 'int main()': a.cc:13:13: error: 'i' was not declared in this scope 13 | rep(i,0,n-1) { | ^ a.cc:13:9: error: 'rep' was not declared in this scope 13 | rep(i,0,n-1) { | ^~~
s628866051
p03784
C++
#include <iostream> #include <vector> #include <ctime> #include <algorithm> #include <string> using namespace std; int A, B, N; bool used[4009]; char p[4009][4009]; char ask(int x, int y) { if (p[x][y] == 'Y' || p[x][y] == 'N') return p[x][y]; cout << "? " << x << " " << y << endl; cin >> p[x][y]; return p[x][y]; } int main() { srand((unsigned)time(NULL)); cin >> A >> B; N = A + B; if (A <= B) { cout << "Impossible" << endl; return 0; } vector<int>vec; for (int i = 0; i < N; i++) vec.push_back(i); while (vec.size() > 1) { if (vec.size() == 3) { vector<int>vec2; for (int i = 0; i < vec.size(); i++) { int s1 = vec[i], s2 = vec[(i + 1) % vec.size()]; char c = ask(s1, s2); if (c == 'Y') vec2.push_back(s2); } vec = vec2; continue; } while (true) { vector<int>A, B; for (int i = 0; i < vec.size(); i++) { if (i % 2 == 0) A.push_back(vec[i]); else B.push_back(vec[i]); } for (int i = 0; i < 1000; i++) { int s = rand() % A.size(); int t = rand() % B.size(); swap(A[s], B[t]); } for (int i = 0; i < B.size(); i++) used[i] = false; for (int i = 0; i < A.size(); i++) { int s1 = A[i], s2 = B[min(i, (int)B.size() - 1)]; char c = ask(s1, s2); char c; cin >> c; if (c == 'N') used[s2] = true; } vector<int>vec2; for (int i = 0; i < B.size(); i++) { if (used[B[i]] == false) vec2.push_back(B[i]); } if (vec2.size() >= 1) { vec = vec2; break; } } } string S = ""; for (int i = 0; i < N; i++) { if (i == vec[0]) S += "1"; else { cout << "? " << vec[0] << " " << i << endl; char c; cin >> c; if (c == 'Y') S += "1"; else S += "0"; } } cout << "! " << S << endl; return 0; }
a.cc: In function 'int main()': a.cc:53:38: error: redeclaration of 'char c' 53 | char c; cin >> c; | ^ a.cc:52:38: note: 'char c' previously declared here 52 | char c = ask(s1, s2); | ^
s429439751
p03784
C++
#include <bits/stdc++.h> using namespace std; inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return x*f; } int A,B,stt[6000],top=0; string tt; int main() { A=read(); B=read(); if(A<=B) {puts("Impossible"); return 0;} for(int i=0;i<A+B;i++) { if(top==0) {stt[++top]=i; continue;} printf("? %d %d\n",stt[top],i); cin >> tt; if(tt[0]=='Y') stt[++top]=i; else top--; } cout << "! " for(int i=0;i<A+B;i++) { printf("? %d %d\n",stt[top],i); cin >> tt; putchar(tt[0]=='Y'? '1':'0'); } puts(""); return 0; }
a.cc: In function 'int main()': a.cc:25:21: error: expected ';' before 'for' 25 | cout << "! " | ^ | ; 26 | for(int i=0;i<A+B;i++) | ~~~ a.cc:26:21: error: 'i' was not declared in this scope 26 | for(int i=0;i<A+B;i++) | ^
s229552355
p03784
C++
#include <bits/stdc++.h> using namespace std; inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return x*f; } int A,B,stt[6000],top=0; string tt; int main() { A=read(); B=read(); if(A<=B) {puts("Impossible"); return 0;} for(int i=0;i<A+B;i++) { if(top==0) {stt[++top]=i; continue;} printf("? %d %d\n",stt[top],i); cin >> tt; if(tt[0]=='Y') stt[++top]=i; else top--; } cout << "! " for(int i=0;i<A+B;i++) { printf("? %d %d\n",stt[top],i); cin >> tt; putchar(tt[0]=='Y'? '1':'0'); } puts(""); return 0; }
a.cc: In function 'int main()': a.cc:25:21: error: expected ';' before 'for' 25 | cout << "! " | ^ | ; 26 | for(int i=0;i<A+B;i++) | ~~~ a.cc:26:21: error: 'i' was not declared in this scope 26 | for(int i=0;i<A+B;i++) | ^