submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s507917694
p03971
C++
#include<bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD=1000000007; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) long long gcd(long long a,long long b){ ll gcdmax=max(a,b); ll gcdmin=min(a,b); while(true){ if(gcdmax%gcdmin==0)break; else gcdmax%=gcdmin; swap(gcdmin,gcdmax); } return gcdmin; } ll powerup(ll N,ll P,ll M){ if(P==0)return 1; else if(P%2==0){ ll t=powerup(N,P/2,M); return t*t%M; } else return N*powerup(N,P-1,M)%M; } vector<ll> find_divisor(ll N){ ll k=1; while(k*k<=N){ k++; } vector<ll> A(1); rep(i,k){ if(i==1)A.at(0)=1; else if(i>=2){ if(N%i==0)A.push_back(i); } } ll t=0; t=A.size(); rep(i,t){ if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i)); } return A; } int main() { ll N,X,Y; cin>>N>>X>>Y; char C; ll A=0; ll B=0; rep(i,N){ cin>>C; if(C=='a'){ if(A<X+Y){ A++; cout<<"Yes"<<endl; } else cout<<"No"<<endl; } else if(C=='b'){ if(A<X+Y&&B<Y){ A++; B++; cout<<"Yes"<<endl; } else cout<<"No"<<endl; } else cout<<"No"<<endl; }
a.cc: In function 'int main()': a.cc:69:2: error: expected '}' at end of input 69 | } | ^ a.cc:45:1: note: to match this '{' 45 | { | ^
s627040400
p03971
C++
#include<bits/stdc++.h> using namespace std; typedef int64_t ll; typedef long double ld; const ll MOD=1000000007; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) long long gcd(long long a,long long b){ ll gcdmax=max(a,b); ll gcdmin=min(a,b); while(true){ if(gcdmax%gcdmin==0)break; else gcdmax%=gcdmin; swap(gcdmin,gcdmax); } return gcdmin; } ll powerup(ll N,ll P,ll M){ if(P==0)return 1; else if(P%2==0){ ll t=powerup(N,P/2,M); return t*t%M; } else return N*powerup(N,P-1,M)%M; } vector<ll> find_divisor(ll N){ ll k=1; while(k*k<=N){ k++; } vector<ll> A(1); rep(i,k){ if(i==1)A.at(0)=1; else if(i>=2){ if(N%i==0)A.push_back(i); } } ll t=0; t=A.size(); rep(i,t){ if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i)); } return A; } int main() { ll N,X,Y; cin>>N>>X>>Y; char C; ll A=0; ll B=0; rep(i,N){ cin>>C; if(C=='a'){ if(A<X+Y){ A++; cout<<"Yes"<<endl; } else cout<<"No"<,endl; } else if(C=='b'){ if(A<X+Y&&B<Y){ A++; B++; cout<<"Yes"<<endl; } else cout<<"No"<<endl; } else cout<<"No"<<endl; }
a.cc: In function 'int main()': a.cc:58:23: error: expected primary-expression before ',' token 58 | else cout<<"No"<,endl; | ^ a.cc:69:2: error: expected '}' at end of input 69 | } | ^ a.cc:45:1: note: to match this '{' 45 | { | ^
s547220590
p03971
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n,a,b; cin>>n>>a>>b; string s; cin>>s; int cnt1, cnt2; cnt1 = cnt2 = 0; for(auto e:s){ if(e == 'a'){ puts("Yes"); cn1++; }else if(e == 'b'){ if(cnt2 < b){ puts("Yes"); cnt1++; cnt2++; }else{ puts("No"); } }else{ puts("No"); } } return 0; }
a.cc: In function 'int main()': a.cc:13:7: error: 'cn1' was not declared in this scope; did you mean 'cnt1'? 13 | cn1++; | ^~~ | cnt1
s451852048
p03971
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef vector<int> vi; typedef vector<ll> vll; // #define int long long #define pb push_back #define mp make_pair #define eps 1e-9 #define INF 2000000000 // 2e9 #define LLINF 2000000000000000000ll // 2e18 (llmax:9e18) #define fi first #define sec second #define all(x) (x).begin(), (x).end() #define sq(x) ((x) * (x)) #define dmp(x) cerr << #x << ": " << x << endl; template <class T> void chmin(T &a, const T &b) { if (a > b) a = b; } template <class T> void chmax(T &a, const T &b) { if (a < b) a = b; } template <class T> using MaxHeap = priority_queue<T>; template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>; template <class T> vector<T> vect(int len, T elem) { return vector<T>(len, elem); } template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.fi << ',' << p.sec; return os; } template <class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.fi >> p.sec; return is; } template <class T> ostream &operator<<(ostream &os, const vector<T> &vec) { for (int i = 0; i < vec.size(); i++) { os << vec[i]; if (i + 1 < vec.size()) os << ' '; } return os; } template <class T> istream &operator>>(istream &is, vector<T> &vec) { for (int i = 0; i < vec.size(); i++) is >> vec[i]; return is; } void fastio() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); } namespace Math { template <int MOD> // if inv is needed, this shold be prime. struct ModInt { ll val; ModInt() : val(0ll) {} ModInt(const ll &v) : val(((v % MOD) + MOD) % MOD) {} bool operator==(const ModInt &x) const { return val == x.val; } bool operator!=(const ModInt &x) const { return !(*this == x); } bool operator<(const ModInt &x) const { return val < x.val; } bool operator>(const ModInt &x) const { return val > x.val; } bool operator>=(const ModInt &x) const { return !(*this < x); } bool operator<=(const ModInt &x) const { return !(*this > x); } ModInt operator-() const { return ModInt(MOD - val); } ModInt inv() const { return this->pow(MOD - 2); } ModInt &operator+=(const ModInt &x) { if ((val += x.val) >= MOD) val -= MOD; return *this; } ModInt &operator-=(const ModInt &x) { if ((val += MOD - x.val) >= MOD) val -= MOD; return *this; } ModInt &operator*=(const ModInt &x) { (val *= x.val) %= MOD; return *this; } ModInt &operator/=(const ModInt &x) { return *this *= x.inv(); }; ModInt operator+(const ModInt &x) const { return ModInt(*this) += x; } ModInt operator-(const ModInt &x) const { return ModInt(*this) -= x; } ModInt operator*(const ModInt &x) const { return ModInt(*this) *= x; } ModInt operator/(const ModInt &x) const { return ModInt(*this) /= x; } friend istream &operator>>(istream &i, ModInt &x) { ll v; i >> v; x = v; return i; } friend ostream &operator<<(ostream &o, const ModInt &x) { o << x.val; return o; } ModInt pow(ll x) const { auto res = ModInt(1ll); auto b = *this; while (x) { if (x & 1) res *= b; x >>= 1; b *= b; } return res; } }; template <int MOD> ModInt<MOD> pow(ModInt<MOD> a, ll x) { ModInt<MOD> res = ModInt<MOD>(1ll); while (x) { if (x & 1) res *= a; x >>= 1; a *= a; } return res; } constexpr int MOD = 1e9 + 7; // constexpr int MOD = 998244353; using mint = ModInt<MOD>; vector<mint> inv, fac, facinv; // notice: 0C0 = 1 ModInt<MOD> nCr(int n, int r) { assert(!(n < r)); assert(!(n < 0 || r < 0)); return fac[n] * facinv[r] * facinv[n - r]; } void init(int SIZE) { fac.resize(SIZE + 1); inv.resize(SIZE + 1); facinv.resize(SIZE + 1); fac[0] = inv[1] = facinv[0] = mint(1ll); for (int i = 1; i <= SIZE; i++) fac[i] = fac[i - 1] * mint(i); for (int i = 2; i <= SIZE; i++) inv[i] = mint(0ll) - mint(MOD / i) * inv[MOD % i]; for (int i = 1; i <= SIZE; i++) facinv[i] = facinv[i - 1] * inv[i]; return; } template <class T> int digit(T x) { int res = 0; while (x) { x /= T(10); res++; } return res; } template <class T> int digit_sum(T x) { int res = 0; while (x) { res += x % 10; x /= 10; } return res; } template <class T> T mygcd(T x, T y) { if (y == T(0)) return x; else return mygcd(y, x % y); } template <class T> T mylcm(T x, T y) { assert(x / mygcd(x, y) <= numeric_limits<T>::max() / y); return x / mygcd(x, y) * y; } } // namespace Math template <class T> vector<pair<T, int>> runLength(vector<T> v) { vector<pair<T, int>> res; for (int i = 0; i < v.size(); i++) { if (res.empty() || res.back().first != v[i]) res.push_back(make_pair(v[i], 1)); else res.back().second++; } return res; } #define endl "\n" void solve() { int n, a, b; stirng s; cin >> n >> a >> b; cin >> s; int p = 0, q = 0; for(int i=0;i<n;i++){ if(s[i]=='c'){ cout << "No" << endl; continue; } if(s[i]=='a'){ if(p<a+b){ cout << "Yes" << endl; p++; }else{ cout << "No" << endl; } } if(s[i]=='b'){ if(p<a+b&&q<b){ cout << "Yes" << endl; p++; q++; }else{ cout << "No" << endl; } } } return; } signed main() { fastio(); solve(); // int t; cin >> t; while(t--)solve(); return 0; }
a.cc: In function 'void solve()': a.cc:207:3: error: 'stirng' was not declared in this scope 207 | stirng s; | ^~~~~~ a.cc:209:10: error: 's' was not declared in this scope 209 | cin >> s; | ^
s229039863
p03971
C++
#define _USE_NATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> #include <random> #include <tuple> using namespace std; #define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i ) #define rep (i,n) REP(i,0,n) using ll = long long; #define EPS 1e-9 const int INF = 1050000000; const long long LINF = 1LL << 60; const ll MOD = 1e9 + 7; const int MINF = -1050000000; template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; } int main() { int n, a, b; cin >> n >> a >> b; string s; cin >> s; int now = 0, kaigai = 0; for(int i =0; i<s.size();i++;) { if(s[ i] == 'a') { if (now < a + b) { now++; cout << "Yes" << endl; continue; } } else if (s[i] == 'b'){ if (now < a + b && kaigai < b) { now++; kaigai++; cout << "Yes" << endl; continue; } } cout << "No" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:48:46: error: expected ')' before ';' token 48 | for(int i =0; i<s.size();i++;) { | ~ ^ | ) a.cc:48:47: error: expected primary-expression before ')' token 48 | for(int i =0; i<s.size();i++;) { | ^
s015588935
p03971
C++
#define _USE_NATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> #include <random> #include <tuple> using namespace std; #define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i ) #define rep (i,n) REP(i,0,n) using ll = long long; #define EPS 1e-9 const int INF = 1050000000; const long long LINF = 1LL << 60; const ll MOD = 1e9 + 7; const int MINF = -1050000000; template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; } int main() { int n, a, b; cin >> n >> a >> b; string s; cin >> s; int now = 0, kaigai = 0; rep(i, s.size()) { if(s[ i] == 'a') { if (now < a + b) { now++; cout << "Yes" << endl; continue; } } else if (s[i] == 'b'){ if (now < a + b && kaigai < b) { now++; kaigai++; cout << "Yes" << endl; continue; } } cout << "No" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:30:14: error: 'i' was not declared in this scope 30 | #define rep (i,n) REP(i,0,n) | ^ a.cc:48:18: note: in expansion of macro 'rep' 48 | rep(i, s.size()) { | ^~~ a.cc:29:16: error: 'm' was not declared in this scope 29 | #define REP (i,m,n) for(int i=( int)m ; i < (int ) n ; ++i ) | ^ a.cc:30:19: note: in expansion of macro 'REP' 30 | #define rep (i,n) REP(i,0,n) | ^~~ a.cc:48:18: note: in expansion of macro 'rep' 48 | rep(i, s.size()) { | ^~~
s062456150
p03971
C
main.c:1:1: error: expected '=', ',', ';', 'asm' or '__attribute__' at end of input 1 | あ | ^~
s380749065
p03971
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i=0; i<(n); ++i) #define REP(i, d, n) for(int i=(d); i<(n); ++i) #define all(v) v.begin(), v.end() using ll = long long; using P = pair<int, int>; int main() { int n, a, b; string s; cin >> >> n >> a >> b >> s; int cnt = 0; rep(i, n){ if(s[i] == 'a'){ if(cnt < a+b){ cnt++; cout << "Yes" << endl; } else{ cout << "Yes" << endl; } } else if(s[i] == 'b'){ if(i+1 <= b && cnt < a+b){ cnt++; cout << "Yes" << endl; } else{ cout << "Yes" << endl; } } else{ cout << "Yes" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:13:10: error: expected primary-expression before '>>' token 13 | cin >> >> n >> a >> b >> s; | ^~
s517442568
p03971
C++
#include <bits/stdc++.h> using namespace std; int main(){ int N,A,B; cin >> N >> A >> B; int pp = 0; fp = 0; char c; for (int i = 0; i < N; i++){ cin >> c; if (c = 'a'){ if (pp < A + B){ cout << "Yes" << endl; pp++; } else { cout << "No" << endl; } } if (c = 'b'){ if (pp < A + B && fp < B){ cout << "Yes" << endl; pp++; fp++; } else { cout << "No" << endl; } } } }
a.cc: In function 'int main()': a.cc:6:15: error: 'fp' was not declared in this scope; did you mean 'pp'? 6 | int pp = 0; fp = 0; | ^~ | pp
s470756692
p03971
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, a, b; string str; cin >> n >> a >> b >> str; int tmp = 0; int foreign = 0; for (int i = 0; i < n; i++) { string ans; if (str.at(i) == 'a') { if (tmp < a+b) { tmp++; ans = "Yes"; } else { ans = "No"; } } else if (str.at(i) == 'b') { foreing++; if (tmp < a+b) { if (foreing <= b) { tmp++; ans = "Yes"; } else { ans = "No"; } } else { ans = "No"; } } else { ans = "No"; } cout << ans << endl; } }
a.cc: In function 'int main()': a.cc:20:7: error: 'foreing' was not declared in this scope; did you mean 'foreign'? 20 | foreing++; | ^~~~~~~ | foreign
s674272697
p03971
C++
#include<bits/stdc++.h> using namespace std; signed main(){ int a,b,n=0,d; string c; cin>>a>>b>>d cin>>c; for(int i=0;i<c.size();i++){ if(c[i]=='c') cout<<"No"; else{ if(c[i]=='b'&&i<=d){ if(n<=b+d){ n++; cout<<"Yes"; } else cout<<"No"; } else{ if(n<=b+d){ n++; cout<<"Yes"; } else cout<<"No"; } } } cout<<"\n";}
a.cc: In function 'int main()': a.cc:6:15: error: expected ';' before 'cin' 6 | cin>>a>>b>>d | ^ | ; 7 | cin>>c; | ~~~
s021707687
p03971
C++
#include "bits/stdc++.h" using namespace std; #define INF 1e9 #define rep(i, n) for(int i = 0; i < n; i++) #define ALL(x) (x).begin(), (x).end() //昇順 #define RALL(x) (x).rbegin(), (x).rend() // 降順 const long long mod = 1e9+7; typedef priority_queue<int> PQ; typedef vector<long long> VL; typedef vector<bool> VB; typedef vector<int> VI; // VI a(n); typedef vector<string> VS; typedef vector<char> VC; typedef vector<VS> VSS; typedef vector<VC> VCC; typedef vector<VI> VII; // VII a(n,vector<int>(m)) n * m typedef vector<VL> VLL; typedef pair<int, int> PII; typedef map<int, int> MP; //MP a; typedef vector<pair<int, int> > PS; typedef long long ll; //ll とdoubleは違う template <class T> // chmax(max, a); bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; } template <class T> //chmin(min,a) bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; } template<typename T> // operator << (cout,a); ostream& operator << (ostream& os, vector<T>& v) { os << "{"; rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); } os << "}"; return os; } template<typename T> bool all_same(vector<T> v1,vector<T> v2) { sort(ALL(v1)); sort(ALL(v2),greater<T>()); return v1 == v2; } // g++ -std=c++11 prac.cpp ll Max=-1e9,Min=1e9+1; int main(){ ll a,b,d,x=0,y=0,z,n,m,k,lank=1,w,sum=0,sum2=0,ans=0; string s,t; bool ok=true; cin >> s; t = "" rep(i,s.size()){ if(s[i]=='a'){ if(a+b>sum){ sum++; cout << "Yes" << endl; } else{ cout << "No" << endl; } } else if(s[i] == 'b'){ if((a+b > sum) && lank <= b){ lank++; sum++; cout << "Yes" << endl; } else{ cout << "No" << endl; } } else{ cout << "No" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:65:11: error: expected ';' before 'for' 65 | t = "" | ^ | ; a.cc:66:9: error: 'i' was not declared in this scope 66 | rep(i,s.size()){ | ^ a.cc:4:34: note: in definition of macro 'rep' 4 | #define rep(i, n) for(int i = 0; i < n; i++) | ^
s660397882
p03971
C++
#include <iostream> #include <string> using namespace std; int main() { int n = 0, a = 0, b = 0; cin >> n >> a >> b; string s = ""; cin >> s; int ab = 0, bb = 0; for (int i=0; i<n; i++) { if (s.at(i) == 'a') { if (aa < a + b) { cout << "Yes" << endl; aa++; } else { cout << "No" << endl; } } else if (s.at(i) == 'b') { if (aa < a + b && bb < b) { cout << "Yes" << endl; aa++; bb++; } else { cout << "No" << endl; } } else { cout << "No" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:14:11: error: 'aa' was not declared in this scope; did you mean 'ab'? 14 | if (aa < a + b) { | ^~ | ab a.cc:21:11: error: 'aa' was not declared in this scope; did you mean 'ab'? 21 | if (aa < a + b && bb < b) { | ^~ | ab
s332821018
p03971
C++
#include <iostream> #include <string> using namespace std; int main() { int n = 0, a = 0, b = 0; cin >> n >> a >> b; string s = ""; cin >> s; int ab = 0; bb = 0; for (int i=0; i<n; i++) { if (s.at(i) == 'a') { if (aa < a + b) { cout << "Yes" << endl; aa++; } else { cout << "No" << endl; } } else if (s.at(i) == 'b') { if (aa < a + b && bb < b) { cout << "Yes" << endl; aa++; bb++; } else { cout << "No" << endl; } } else { cout << "No" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:11:15: error: 'bb' was not declared in this scope; did you mean 'ab'? 11 | int ab = 0; bb = 0; | ^~ | ab a.cc:14:11: error: 'aa' was not declared in this scope; did you mean 'ab'? 14 | if (aa < a + b) { | ^~ | ab a.cc:21:11: error: 'aa' was not declared in this scope; did you mean 'ab'? 21 | if (aa < a + b && bb < b) { | ^~ | ab
s643403112
p03971
C++
#include<bits/stdc++.h> using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<n;i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; #define INF 1000000000 #define mod 1000000007 typedef long long ll; const ll LINF = 1001002003004005006ll; int dx[]={1,0,-1,0}; int dy[]={0,1,0,-1}; ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,a,b;cin>>n>>a>>; string s;cin>>s; int A=0,B=0; for(auto x:s){ if(x=='c'){ cout<<"No"<<endl; } else if(x=='a'){ if(A+B<a+b) cout<<"Yes"<<endl; else cout<<"No"<<endl; A++; } else{ if(A+B<a+b&&b<B) cout<<"Yes"<<endl; else cout<<"No"<<endl; B++; } } return 0; }
a.cc: In function 'int main()': a.cc:20:26: error: expected primary-expression before ';' token 20 | int n,a,b;cin>>n>>a>>; | ^
s098655267
p03971
Java
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int A = sc.nextInt(); int B = sc.nextInt(); String S = sc.next(); int pass = 0; int bRank = 0; for (int i = 0; i < N; i++) { char c = S.charAt(i); boolean ans = false; if (c == a && pass < A+B) { pass++; ans = true; } else if (c == b) { bRank++; if (pass < A+B && bRank <= B) { pass++; ans = true; } } System.out.println(ans ? "Yes" : "No"); } } }
Main.java:16: error: cannot find symbol if (c == a && pass < A+B) { ^ symbol: variable a location: class Main Main.java:19: error: cannot find symbol } else if (c == b) { ^ symbol: variable b location: class Main 2 errors
s181957212
p03971
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = sc.nextInt(); int b = sc.nextInt(); char c = sc.next().toCharArray(); int cntA = 0; int cntB = 0; for(int i = 0;i < n;i++){ if(c[i]=='a'&&cntA+cntB<a+b){ System.out.println("Yes"); cntA++; }else if(c[i]=='b'&&cntA+cntB<a+b&&cntB<=b){ System.out.println("Yes"); cntB++; }else System.out.println("No"); } } }
Main.java:8: error: incompatible types: char[] cannot be converted to char char c = sc.next().toCharArray(); ^ Main.java:12: error: array required, but char found if(c[i]=='a'&&cntA+cntB<a+b){ ^ Main.java:15: error: array required, but char found }else if(c[i]=='b'&&cntA+cntB<a+b&&cntB<=b){ ^ 3 errors
s595715609
p03971
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,a,b; cin >> n >> a >> b; string s; cin >> s; int x=0,y=0; for(int i=0;i<s.size();i++){ if(s[i]=='c'){ cout << "No" << endl; } else if(s[i]=='b'){ if(x<a+b&&y<b){ x++; y++; cout << "Yes" << endl; } else{ cout << "No" << enld; } } else{ if(x<a+b){ cout << "Yes" << endl; } else{ cout << "No" << endl; } } } }
a.cc: In function 'int main()': a.cc:20:25: error: 'enld' was not declared in this scope 20 | cout << "No" << enld; | ^~~~
s587685983
p03971
C++
package main import( "fmt" ) func main(){ var n,a,b int fmt.Scan(&n,&a,&b) var s string fmt.Scan(&s) pass := 0 brank := 0 for i := 0; i < len(s); i++ { if s[i] == 'a' && pass < a+b { pass++ fmt.Println("Yes") } else if s[i] == 'b' && pass<a+b && brank < b { pass++ brank++ fmt.Println("Yes") } else { fmt.Println("No") } } }
a.cc:1:1: error: 'package' does not name a type 1 | package main | ^~~~~~~
s141931731
p03971
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<n;i++) #define REPP(i,n) for(int i=1;i<=n;i++) //typedef pair<long long,long long> P; const double PI = acos(-1); const double EPS = 1e-15; long long INF=(long long)1E17; #define i_7 (long long)(1E9+7) long mod(long a){ long long c=a%i_7; if(c>=0)return c; return c+i_7; } using namespace std; bool prime(int n){ if(n==1){ return false; }else if(n==2){ return true; }else{ for(int i=2;i<=sqrt(n);i++){ if(n%i==0){ return false; } } return true; } } long long gcd(long long a, long long b){ if(a<b){ swap(a,b); } if(a%b==0){ return b; }else{ return gcd(b,a%b); } } long long lcm(long long x, long long y){ return (x/gcd(x,y))*y; } class UnionFind { public: //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。 vector<int> Parent; //クラスを作るときは、Parentの値を全て-1にする。 //以下のようにすると全てバラバラの頂点として解釈できる。 UnionFind(int N) { Parent = vector<int>(N, -1); } //Aがどのグループに属しているか調べる int root(int A) { if (Parent[A] < 0) return A; return Parent[A] = root(Parent[A]); } //自分のいるグループの頂点数を調べる int size(int A) { return -Parent[root(A)];//先祖をrootで取っておきたい。 } //AとBをくっ付ける bool connect(int A, int B) { //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける A = root(A); B = root(B); if (A == B) { //すでにくっついてるからくっ付けない return false; } //大きい方(A)に小さいほう(B)をくっ付けたい //大小が逆だったらAとBをひっくり返す。 if (size(A) < size(B)) swap(A, B); //Aのサイズを更新する Parent[A] += Parent[B]; //Bの親をAに変更する Parent[B] = A; return true; } }; int main(){ int n,a,b; cin>>n>>a>>b; string s; cin>>s; int map<char,int> mp; int p=0; REP(i,n){ map[s[i]]++; if(s[i]=='a'){ if(p<a+b){ p++; cout<<"Yes"<<endl; }else{ cout<<"No"<<endl; } }else if(s[i]=='b'){ if(p<a+b && mp['b']<=b){ p++; cout<<"Yes"<<endl; }else{ cout<<"No"<<endl; } }else{ cout<<"No"<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:95:21: error: invalid declarator before 'mp' 95 | int map<char,int> mp; | ^~ a.cc:98:10: error: expected ']' before '[' token 98 | map[s[i]]++; | ^ | ] a.cc:98:14: error: expected initializer before '++' token 98 | map[s[i]]++; | ^~ a.cc:98:14: error: expected ';' before '++' token a.cc:107:19: error: 'mp' was not declared in this scope; did you mean 'p'? 107 | if(p<a+b && mp['b']<=b){ | ^~ | p
s672624781
p03971
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <inttypes.h> #include <ctype.h> #include <stdint.h> #include <string.h> #include <wchar.h> #include <math.h> #define N_MAX (100) #define P_MAX (100) #define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1) #define MIN(a, b) ((a) < (b) ? (a) : (b)) #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define ABS(a) ((a) < 0 ? -(a) : (a)) #define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a)) int compare_sz_desc(const void* a, const void* b) { return *((size_t*)a) > * ((size_t*)b) ? -1 : 1; } int compare_i64_asc(const void* a, const void* b) { return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1; } int compare_c_asc(const void* a, const void* b) { return *((char*)a) < *((char*)b) ? -1 : 1; } int compare_c_desc(const void* a, const void* b) { return *((char*)a) > * ((char*)b) ? -1 : 1; } int compare_f(const void* a, const void* b) { return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1; } int compare_f2(const void* a, const void* b) { return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1; } static size_t comb(const size_t n, const size_t r) { size_t result = 1; for (size_t i = 0; i < r; i++) { result *= n - i; result /= i + 1; } return result; } static uint64_t combU64(const uint64_t n, const uint64_t r) { uint64_t result = 1; for (uint64_t i = 0; i < r; i++) { result *= n - i; result /= i + 1; } return result; } static uint64_t gcdU64(uint64_t m, uint64_t n) { uint64_t temp; while (m % n != 0) { temp = n; n = m % n; m = temp; } return n; } static size_t gcdZu(size_t m, size_t n) { size_t temp; while (m % n != 0) { temp = n; n = m % n; m = temp; } return n; } static char S[100001]; int main(void) { size_t N, A, B; scanf("%zu %zu %zu\n%s", &N, &A, &B, S); size_t aCount = 0; size_t bCount = 0; for (size_t i = 0; i < N; i++) { if (S[i] == 'a') { if (aCount + bCount < A + B) { puts("Yes"); aCount++; } else { puts("No"); } } else if (S[i] == 'b') { if (aCount + bCount < A + B && bCount < B) { puts("Yes"); bCount++; } else { puts("No"); } } else { puts("No"); } } if (2 * N < M) { printf("%"PRIu64, N + (M - 2 * N) / 4); } else { printf("%"PRIu64, M / 2); } return 0; }
main.c: In function 'main': main.c:126:17: error: 'M' undeclared (first use in this function) 126 | if (2 * N < M) { | ^ main.c:126:17: note: each undeclared identifier is reported only once for each function it appears in
s059833241
p03971
C
#include <bits/stdc++.h> #include <cstdio> #include <vector> using namespace std; int main(void){ int n,a,b; scanf("%d%d%d",&n,&a,&b); string s; cin >> s ; int d=0,ab=0; for(int i=0;i<n;i++){ if(s[i]=='c')cout<< "No" << endl; else if(s[i]=='a'){ if(d+ab<a+b){ d++; cout<<"Yes"<<endl; }else{ cout<<"No"<<endl; } }else{ if(d+ab<a+b && ab<b){ ab++; cout<<"Yes"<<endl; }else cout<<"No"<<endl; } } return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s950550655
p03971
C++
#include<bits/stdc++.h> #include<vector> #include<string> #include<set> #include<iomanip> #include<algorithm> using namespace std; //int main() { int n,a,b,coub,cnt;cin >> n >> a >> b; cnt = 0; string s,scoub;cin >> s; int c = a+b; for(int i=0;i<n;i++){ if(s[i]=='a'){ if(cnt<=c){ cout << "Yes" << endl; cnt++; }else{ cout << "No" << endl; } }else if(s[i]=='b'){ if(cnt>c){ cout << "No" << endl; break; } scoub = s.substr(0,i); coub = count(scoub.begin(),scoub.end(),'b'); if(coub<=b){ cout << "Yes" << endl; cnt++; }else{ cout << "No" << endl; } }else{ cout << "No" << endl; } } }
a.cc:10:22: error: 'cin' does not name a type 10 | int n,a,b,coub,cnt;cin >> n >> a >> b; | ^~~ a.cc:11:3: error: 'cnt' does not name a type; did you mean 'int'? 11 | cnt = 0; | ^~~ | int a.cc:12:18: error: 'cin' does not name a type 12 | string s,scoub;cin >> s; | ^~~ a.cc:14:3: error: expected unqualified-id before 'for' 14 | for(int i=0;i<n;i++){ | ^~~ a.cc:14:15: error: 'i' does not name a type 14 | for(int i=0;i<n;i++){ | ^ a.cc:14:19: error: 'i' does not name a type 14 | for(int i=0;i<n;i++){ | ^ a.cc:39:1: error: expected declaration before '}' token 39 | } | ^
s086197049
p03971
C++
#include<iostream> using namespace std; int main(){ int n, a, b; cin >> n >> a >> b; char x; int in = 1, out = 1; for(int i = 0; i < n; i++){ cin >> x; if(x == 'a' && in+out <= a+b){ cout << "Yes" << endl; in++; }else if(x == 'b' && in+out <= a+b && out <= b){ cout << "Yes" << endl; out++; }else{ cout << "No" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:23:10: error: expected '}' at end of input 23 | } | ^ a.cc:4:11: note: to match this '{' 4 | int main(){ | ^
s966578244
p03971
C++
#include <iostream> #include <algorithm> #include <cmath> #include <limits> #include <vector> #include <cstdio> #include <bits/stdc++.h> #include <set> #include <stdio.h> using namespace std; using ll =long long; int main (void) { int N,A,B; cin >> N >> A >>B; string S; cin >> S; int pass=0; int kpass=0; for(int i=0;i<N;i++){ if(S[i]=='c'){ cout << "No"<< endl; continue; } else if(pass<A+B && S[i]=='a'){ cout << "Yes" <<endl; pass++; } else if(pass<A+B && S[i]=='b' && kpass<B){ cout << "Yes" << endl; pass++ kpass++ } else { cout << "No"<< endl; } } }
a.cc: In function 'int main()': a.cc:31:13: error: expected ';' before 'kpass' 31 | pass++ | ^ | ; 32 | kpass++ | ~~~~~
s086478110
p03971
C
/* cat <<EOF >mistaken-paste */ #pragma GCC diagnostic ignored "-Wincompatible-pointer-types" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> #include <math.h> #define BIG 2000000007 #define MOD 1000000007 typedef unsigned long long ull; typedef signed long long sll; #define N_MAX 200000 #define M_MAX 200 typedef struct { int a; int b; } hw; typedef struct { sll a; sll b; } hwll; typedef struct { ull a; int i; } struct_a; typedef struct { ull cost; int left; int right; } struct_b; const hw vector8[8] = { {-1, -1}, {-1, 0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1, 0}, {+1, +1} }; ull n, m; ull h, w; ull k; ull va, vb, vc, vd, ve, vf; // ull a[N_MAX]; // sll a[N_MAX]; // ull wall[N_MAX][M_MAX]; // ull b[N_MAX]; // sll b[N_MAX]; char s[N_MAX + 1]; // char t[N_MAX + 1]; // char s[N_MAX][M_MAX + 1]; // ull dp[N_MAX]; // sll dp[N_MAX]; // ull dp[N_MAX + 1][N_MAX + 1]; // ull dp[N_MAX][M_MAX + 1]; // hw arr[N_MAX]; // hwll arr[N_MAX]; // hw brr[M_MAX]; // ull digitdp[102][ 2][ 2]; // pos less carry // struct_a arr[N_MAX * 2]; // struct_b brr[N_MAX * 2]; void swap_adj(ull *a, ull *b){ ull tmp = *b; *b = *a; *a = tmp; return; } ull divide(ull a, ull b){ ull x = MOD - 2; ull ans = 1; while (x) { if (x & 1) ans = (ans * b) % MOD; b = (b * b) % MOD; x /= 2; } return (a * ans) % MOD; } int digits(ull x){ int i = 1; while (x >= 10) { x /= 10; i++; } return i; } ull umin(ull x, ull y){ return (x < y) ? x : y; } ull umax(ull x, ull y){ return (x > y) ? x : y; } sll smin(sll x, sll y){ return (x < y) ? x : y; } sll smax(sll x, sll y){ return (x > y) ? x : y; } ull gcd(ull x, ull y){ if (x < y) { return gcd(y, x); } else if (y == 0) { return x; } else { return gcd(y, x % y); } } ull bitpow(ull a, ull x){ ull result = 1; while (x) { if (x & 1) { result *= a; result %= MOD; } x /= 2; a = (a * a) % MOD; } return result; } // int nextroute(int arr[]){ // int i = n - 1; // int j, x; // while (arr[i - 1] > arr[i]) i--; // x = n; // for (j = i; j < n; j++) { // if (arr[j] < arr[i - 1]) continue; // if (x == n || arr[x] > arr[j]) x = j; // } // arr[i - 1] ^= arr[x]; // arr[x] ^= arr[i - 1]; // arr[i - 1] ^= arr[x]; // qsort(&arr[i], n - i, sizeof(int), comp); // return 0; // } int targetdig(ull x, int index /* 1-indexed */){ // static...? int posmax = digits(x); if (posmax < index) return -1; while (posmax > index) { posmax--; x /= 10; } return x % 10; } int charcmp(const char *left, const char *right){ if (*left < *right) { return -1; } else if (*left > *right) { return +1; } else { return 0; } } int intcomp(const int *left, const int *right){ if (*left < *right) { return -1; } else if (*left > *right) { return +1; } else { return 0; } } int ullcomp(const ull *left, const ull *right){ if (*left < *right) { return -1; } else if (*left > *right) { return +1; } else { return 0; } } int sllcomp(const sll *left, const sll *right){ if (*left < *right) { return -1; } else if (*left > *right) { return +1; } else { return 0; } } int hwAcomp(const hw *left, const hw *right){ return intcomp(&(left->a), &(right->a)); } int hwBcomp(const hw *left, const hw *right){ return intcomp(&(left->b), &(right->b)); } int hwABcomp(const hw *left, const hw *right){ int x = hwAcomp(left, right); if (x) return x; return hwBcomp(left, right); } int hwllAcomp(const hwll *left, const hwll *right){ return sllcomp(&(left->a), &(right->a)); } int hwllBcomp(const hwll *left, const hwll *right){ return sllcomp(&(left->b), &(right->b)); } int hwllABcomp(const hwll *left, const hwll *right){ int x = hwllAcomp(left, right); if (x) return x; return hwllBcomp(left, right); } // int hw_lowerbound(hw arr[], int length, const hw x){ // int ok = 0; // int ng = length; // while (ok + 1 < ng) { // int med = (ok + ng) / 2; // if (hwABcomp(&arr[med], &x) >= 0) { // ok = med; // } else { // ng = med; // } // } // return ok; // } // int hw_upperbound(hw arr[], int length, const hw x){ // int ok = 0; // int ng = length; // while (ok + 1 < ng) { // int med = (ok + ng) / 2; // if (hwABcomp(&arr[med], &x) > 0) { // ok = med; // } else { // ng = med; // } // } // return ok; // } int strAcomp(const struct_a *left, const struct_a *right){ return ullcomp(&(left->a), &(right->a)); } int strBcomp(const struct_b *left, const struct_b *right){ return ullcomp(&(left->cost), &(right->cost)); } int bitlet(char c){ return (1 << (c - 'a')); } ull ulldiff(ull a, ull b){ if (a >= b) { return a - b; } else { return b - a; } } int fullfill(int x, int a, int b){ int u = x / a; while (u >= 0) { if ((x - a * u) % b == 0) break; u--; } return u; } ull solve(){ int i, j, ki; ull result = 0; ull inner = 0, outer = 0; qsort(a, n, sizeof(ull), ullcomp); for (i = 0; i < n; i++) { switch (s[i]) { case 'a': if (inner + outer < va + vb) { puts("Yes"); inner++; } break; case 'a': if (inner + outer < va + vb && outer < vb) { puts("Yes"); outer++; } break; case 'c': puts("No"); break; } } // printf("%llu\n", bitpow(2, n / 2)); return 0; } int main(void){ int i, j; int x, y; scanf("%llu", &n, &m); // scanf("%llu%llu", &h, &w); scanf("%llu%llu", &va, &vb); scanf("%s", s); // scanf("%s", t); // for (i = 0; i < n; i++) { // scanf("%llu", &a[i], &b[i]); // } solve(); // for (i = 0; i < m; i++) { // scanf("%llu%llu", &va, &vb); // solve(); // } return 0; }
main.c: In function 'solve': main.c:312:15: error: 'a' undeclared (first use in this function) 312 | qsort(a, n, sizeof(ull), ullcomp); | ^ main.c:312:15: note: each undeclared identifier is reported only once for each function it appears in main.c:322:17: error: duplicate case value 322 | case 'a': | ^~~~ main.c:316:17: note: previously used here 316 | case 'a': | ^~~~
s974328765
p03971
C++
#include <cstdio> const int N = 100500; char buf[N]; int main() { int n, a, b; scanf("%d %d %d", &n, &a, &b); scanf("%s", buf); int ab = a + b, sum = 0, cb = 0; for (int i = 0; i < n; i++) { if (buf[i] == 'a') { if (ca + cb < ab) { sum++; puts("Yes"); } else { puts("No"); } } else if (buf[i] == 'b') { if (ca + cb < ab && cb < b) { sum++; cb++; puts("Yes"); } else { puts("No"); } } else{ puts("No"); } } }
a.cc: In function 'int main()': a.cc:14:17: error: 'ca' was not declared in this scope; did you mean 'cb'? 14 | if (ca + cb < ab) { | ^~ | cb a.cc:21:17: error: 'ca' was not declared in this scope; did you mean 'cb'? 21 | if (ca + cb < ab && cb < b) { | ^~ | cb
s621715883
p03971
Java
public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); int N = s.nextInt(); int A = s.nextInt(); int B = s.nextInt(); String S = s.next(); int count = 0; for(int i = 0; i < N; i++) { if(S.charAt(i) == 'a' && count < A + B) { count++; System.out.println("Yes"); } else if(S.charAt(i) == 'b' && count < A + B && count <= B) { count++; System.out.println("Yes"); } else { System.out.println("No"); } } } }
Main.java:3: error: cannot find symbol Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner s = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s799190371
p03971
Java
import java.util.Scanner; /** * Created by apple on 10/21/16. */ public class Main { public static void main(String[] args) { Scanner s1 = new Scanner(System.in); int N = s1.nextInt(); int A = s2.nextInt(); int B = s3.nextInt(); String S = s4.nextLine(); int count = 0; for(int i = 0; i < N; i++) { if(S.charAt(i) == 'a' && count < A + B) { count++; System.out.println("Yes"); } else if(S.charAt(i) == 'b' && count < A + B && count <= B) { count++; System.out.println("Yes"); } else { System.out.println("No"); } } } }
Main.java:10: error: cannot find symbol int A = s2.nextInt(); ^ symbol: variable s2 location: class Main Main.java:11: error: cannot find symbol int B = s3.nextInt(); ^ symbol: variable s3 location: class Main Main.java:12: error: cannot find symbol String S = s4.nextLine(); ^ symbol: variable s4 location: class Main 3 errors
s675412634
p03971
C++
#include <iostream> #include <string.h> using namespace std; int main(){ int num, a, b; scanf("%d %d %d", &num, &a, &b); char str[num+1]; scanf("%s", str); for(int i = 0; i < std::strlen(str); i++){ if(str[i] == 'a'){ if(a > 0) a--; else if( b > 0) b--; else{ printf("No\n"); continue; } printf("Yes\n"); } else if(str[i] == 'b'){ if(b > 0) b--; else{ printf("No\n"); continue; } printf("Yes\n"); } else printf("No\n"); } return 0; }
a.cc: In function 'int main()': a.cc:13:29: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'? 13 | for(int i = 0; i < std::strlen(str); i++){ | ^~~~~~ | mbrlen
s192432452
p03971
C++
#include <string> #include <iostream> int main(){ int num, a, b; scanf("%d %d %d", &num, &a, &b); char str[num+1]; scanf("%s", str); for(int i = 0; i < strlen(str); i++){ if(str[i] == 'a'){ if(a > 0) a--; else if( b > 0) b--; else{ printf("No\n"); continue; } printf("Yes\n"); } else if(str[i] == 'b'){ if(b > 0) b--; else{ printf("No\n"); continue; } printf("Yes\n"); } else printf("No\n"); } return 0; }
a.cc: In function 'int main()': a.cc:11:24: error: 'strlen' was not declared in this scope 11 | for(int i = 0; i < strlen(str); i++){ | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <iostream> +++ |+#include <cstring> 3 |
s890949550
p03971
C++
#include <iostream> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(int)(b);i++) #define rep(i,n) FOR(i,0,n) int n,a,b; string s; int main() { cin>>n>>a>>b; cin>>s; int c = a+b; int p=0, q=0; rep(i,n) { bool f = false; if(s[i]=='a'){ if(p < c) { f = true; } p++; }else if(s[i]=='b'){ q++; if(p<c and q<=b) { f = true; p++; } } cout << (f ? "Yes" : "No") << endl } return 0; }
a.cc: In function 'int main()': a.cc:30:43: error: expected ';' before '}' token 30 | cout << (f ? "Yes" : "No") << endl | ^ | ; 31 | } | ~
s031900619
p03971
Java
import java.util.*; import java.io.*; public class Main { public static void main(String [] args)throws Exception{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken()); int a = Integer.parseInt(st.nextToken()); int b = Integer.parseInt(st.nextToken()); StringBuilder sb = new StringBuilder(); int cnt = 0; for(int i = 0;i < str.length();i++){ if(str.charAt(i) == 'c') sb.append("NO"); else if(cnt < a + b){ ++cnt; sb.append("YES"); } else sb.append("NO"); sb.append('\n'); } System.out.print(sb); } }
Main.java:12: error: cannot find symbol for(int i = 0;i < str.length();i++){ ^ symbol: variable str location: class Main Main.java:13: error: cannot find symbol if(str.charAt(i) == 'c') ^ symbol: variable str location: class Main 2 errors
s853933267
p03971
C++
#include<iostream> #include<string> #include<vector> using namespace std; int main() { int n,a,b; vector<int> v(2,0); cin>>n>>a>>b; string s; cin>>s; int n = s.size(); for(int j=0;j<n;++j) { if(s[j]=='a'){ if(v[0]+v[1]<a+b)cout<<"yes"<<endl; v[0]++; } else if(s[j]=='c'){ if((v[0]+v[1])<(a+b)&&v[1]<b) cout<<"yes"<<endl; else cout<<"no"<<endl; v[1]++; } else cout<<"no"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: redeclaration of 'int n' 12 | int n = s.size(); | ^ a.cc:7:9: note: 'int n' previously declared here 7 | int n,a,b; | ^
s045248375
p03971
C
< 1 || total <1) { printf("NO\n"); } else { printf("YES\n"); B = B - 1; total = total - 1; } } else { if(total < 1) { printf("NO\n"); } else { printf("YES\n"); total = total - 1; } } } } return 0; }
main.c:1:2: error: expected identifier or '(' before '<' token 1 | < 1 || total <1) | ^ main.c:5:33: error: expected identifier or '(' before 'else' 5 | else | ^~~~ main.c:11:25: error: expected identifier or '(' before '}' token 11 | } | ^ main.c:12:25: error: expected identifier or '(' before 'else' 12 | else | ^~~~ main.c:25:17: error: expected identifier or '(' before '}' token 25 | } | ^ main.c:27:9: error: expected identifier or '(' before '}' token 27 | } | ^ main.c:28:9: error: expected identifier or '(' before 'return' 28 | return 0; | ^~~~~~ main.c:29:1: error: expected identifier or '(' before '}' token 29 | } | ^
s453750336
p03971
C++
int main() { unsigned int n, a, b; cin >> n >> a >> b; string str; cin >> str; int i; int overseas = 0; for(i = 0; i < n; ++i) { switch(str[i]) { case 'a' : { if(a+b > 0) { cout << "Yes" << endl; a--; break; } } case 'b' : { if(a+b > 0 && overseas < b) { cout << "Yes" << endl; overseas++; break; } } case 'c' : { ; } default: cout << "No" << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: 'cin' was not declared in this scope 5 | cin >> n >> a >> b; | ^~~ a.cc:7:9: error: 'string' was not declared in this scope 7 | string str; | ^~~~~~ a.cc:9:16: error: 'str' was not declared in this scope; did you mean 'std'? 9 | cin >> str; | ^~~ | std a.cc:21:41: error: 'cout' was not declared in this scope 21 | cout << "Yes" << endl; | ^~~~ a.cc:21:58: error: 'endl' was not declared in this scope 21 | cout << "Yes" << endl; | ^~~~ a.cc:29:41: error: 'cout' was not declared in this scope 29 | cout << "Yes" << endl; | ^~~~ a.cc:29:58: error: 'endl' was not declared in this scope 29 | cout << "Yes" << endl; | ^~~~ a.cc:39:34: error: 'cout' was not declared in this scope 39 | default: cout << "No" << endl; | ^~~~ a.cc:39:50: error: 'endl' was not declared in this scope 39 | default: cout << "No" << endl; | ^~~~
s102199753
p03971
C++
#include <iostream> using namespace std; main() { int N, A, B; int a = 0; //countA int b = 0; //coutnB char s[100000]; int i = 0; cin >> N >> A >> B; cin >> s; for (i, i < 100000; i++;) { switch (s[i]) { case 'a': if (a <= A + B) { cout << "Yes"; a++; } else { cout << "No"; } break; case 'b': if (b <= A + B || b <= B) { cout << "Yes"; a++; b++; } else { cout << "No"; } break; case 'c': cout << "No"; default: break; } } } return 0; }
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() { | ^~~~ a.cc:48:9: error: expected unqualified-id before 'return' 48 | return 0; | ^~~~~~ a.cc:49:1: error: expected declaration before '}' token 49 | } | ^
s773207736
p03971
C++
#include <iostream> using namespace std; main() { int N, A, B; int a = 0; //countA int b = 0; //coutnB char s[100000]; int i = 0; cin >> N >> A >> B; cin >> s; for (i, i < 100000; i++;) { switch (s[i]) { case 'a': if (a < A + B) { cout << "Yes"; a++; } else { cout << "No"; } break; case 'b': if (b < A + B || b < B) { cout << "Yes"; b++; } else { cout << "No"; } break; case 'c': cout << "No"; default: break; } if (s[i] == NULL) { break; } } return 0; } return 0; }
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() { | ^~~~ a.cc: In function 'int main()': a.cc:46:29: warning: NULL used in arithmetic [-Wpointer-arith] 46 | if (s[i] == NULL) { | ^~~~ a.cc: At global scope: a.cc:53:9: error: expected unqualified-id before 'return' 53 | return 0; | ^~~~~~ a.cc:54:1: error: expected declaration before '}' token 54 | } | ^
s069030950
p03971
C++
#include <iostream> using namespace std; main() { int N, A, B; int a = 0; //countA int b = 0; //coutnB char s[100000]; int i = 0; cin >> N >> A >> B; cin >> s; for (i, i < 100000; i++;) { switch (s[i]) { case 'a': if (a < A + B) { cout << "Yes"; a++; } else { cout << "No"; } break; case 'b': if (b < A + B || b < B) { cout << "Yes"; b++; } else { cout << "No"; } break; case 'c': cout << "No"; default: break; } return 0; }
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main() { | ^~~~ a.cc: In function 'int main()': a.cc:45:10: error: expected '}' at end of input 45 | } | ^ a.cc:4:8: note: to match this '{' 4 | main() { | ^
s686118317
p03971
C++
#define REP(I,A,B) for(int I = (A); I < (B); ++I) #define REPN(I,A,B) for(int I = (A); I > (B); --I) #define MAX(A,B) ((A) > (B) ? (A) : (B)); int dirx[8] = {-1,0,0,1,-1,-1,1,1}; int diry[8] = {0,1,-1,0,-1,1,-1,1}; int rb[200000]; int lb[200000]; int main() { int n,a,b; cin >> n >> a>> b; REP(i, 0, n) { char ch; cin >> ch; if (ch == 'a' && (a + b) > 0) { cout << "Yes" << endl; if (a == 0) b--; else a--; continue; } if (ch == 'b' && b > 0) { cout << "Yes" << endl; b--; continue; } cout << "No" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:13:9: error: 'cin' was not declared in this scope 13 | cin >> n >> a>> b; | ^~~ a.cc:18:25: error: 'cout' was not declared in this scope 18 | cout << "Yes" << endl; | ^~~~ a.cc:18:42: error: 'endl' was not declared in this scope 18 | cout << "Yes" << endl; | ^~~~ a.cc:26:25: error: 'cout' was not declared in this scope 26 | cout << "Yes" << endl; | ^~~~ a.cc:26:42: error: 'endl' was not declared in this scope 26 | cout << "Yes" << endl; | ^~~~ a.cc:31:17: error: 'cout' was not declared in this scope 31 | cout << "No" << endl; | ^~~~ a.cc:31:33: error: 'endl' was not declared in this scope 31 | cout << "No" << endl; | ^~~~
s787962090
p03971
Java
import java.util.Scanner;; public class Qualification_simulator { public static void main(String[] args) { // TODO Auto-generated method stub @SuppressWarnings("resource") Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int A = sc.nextInt(); int B = sc.nextInt(); @SuppressWarnings("resource") Scanner sc1 = new Scanner(System.in); String S = sc1.nextLine(); findyes(S,N,A,B); } public static void findyes(String S,int N,int A,int B) { int suma = 0; int sumb = 0; for(int i=0;i<S.length();i++) { if(S.charAt(i) == 'a') { suma++; if((suma+sumb) <= (A+B)) { System.out.println("Yes"); } else { System.out.println("No"); } } if(S.charAt(i) == 'b') { sumb++; if((suma+sumb) <= (A+B) && sumb <=B) { System.out.println("Yes"); } else { sumb--; System.out.println("No"); } } if(S.charAt(i) == 'c') { System.out.println("No"); } } } }
Main.java:2: error: class Qualification_simulator is public, should be declared in a file named Qualification_simulator.java public class Qualification_simulator { ^ 1 error
s093127270
p03971
C++
#include <iostream> #include <string> using namespace std; int rank(string s,int point){ int count = 0; for(int i=0;i<point;i++){ if(s[i] == 'b'){ count++; } } return count; } int main(){ int n,a,b; cin >> n >> a >> b; string s; cin >> s; int count = 0; for(int i=0;i<s.size();i++){ if(s[i] == 'c'){ cout << "No" << endl; }else if(s[i] == 'a' && a+b > count){ count++; cout << "Yes" << endl; }else if(s[i] == 'b' && rank(s,i) <= b && a+b > count){ count++; cout << "Yes" << endl; }else{ cout << "No" << endl; } } }
a.cc: In function 'int main()': a.cc:29:33: error: reference to 'rank' is ambiguous 29 | }else if(s[i] == 'b' && rank(s,i) <= b && a+b > count){ | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:5: note: 'int rank(std::string, int)' 6 | int rank(string s,int point){ | ^~~~
s111591803
p03971
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 整数の入力 int n = sc.nextInt(); int a = sc.nextInt(); // スペース区切りの整数の入力 int b = sc.nextInt(); // 文字列の入力 String s = sc.next(); String sa[]; sa = new String[s.length()]; int countA = 0; int countB = 0; int countY = 0; for(int i=0; i<s.length(); i++){ if(i < c.length() -1){ sa[i] = s.substring(i, i+1); } else{ sa[i] = s.substring(i); } switch (sa[i]){ case "a": countA = countA + 1; if(countY < a + b){ countY = countY + 1; System.out.println("Yes" + "\n"); } else{ System.out.println("No" + "\n"); } break; case "b": countB = countB + 1; if(countY < a + b && countB <= b){ countY = countY + 1; System.out.println("Yes" + "\n"); } else{ System.out.println("No" + "\n"); } break; case "c": System.out.println("No" + "\n"); break; } } // 出力 } }
Main.java:18: error: cannot find symbol if(i < c.length() -1){ ^ symbol: variable c location: class Main 1 error
s009633164
p03971
C++
#include <iostream> #include <string> using namespace std; int rank(string s,int point){ int count = 0; for(int i=0;i<point;i++){ if(s[i] == 'b'){ count++; } } return count; } int main(){ int n,a,b; cin >> n >> a >> b; string s; cin >> s; int count = 0; for(int i=0;i<s.size();i++){ if(s[i] == 'c') cout << "No" << endl; else if(s[i] == 'a' && a+b > count){ count++; cout << "Yes" << endl; }else if(s[i] == 'b' && rank(s,i) <= b && a+b > count){ count++; cout << "Yes" << endl; }else{ cout << "No" << endl; } } }
a.cc: In function 'int main()': a.cc:28:33: error: reference to 'rank' is ambiguous 28 | }else if(s[i] == 'b' && rank(s,i) <= b && a+b > count){ | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:6:5: note: 'int rank(std::string, int)' 6 | int rank(string s,int point){ | ^~~~
s029741655
p03971
Java
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // 整数の入力 int n = sc.nextInt(); int a = sc.nextInt(); // スペース区切りの整数の入力 int b = sc.nextInt(); // 文字列の入力 String s = sc.next(); String sa[]; sa = new String[s.length()]; int countA = 0; int countB = 0; int countY = 0; for(int i=0; i<s.length(); i++){ if(i < c.length() -1){ sa[i] = s.substring(i, i+1); } else{ sa[i] = s.substring(i); } switch (sa[i]){ case "a": countA = countA + 1; if(countY < a + b){ countY = countY + 1; System.out.println("Yes" + "\n"); } else{ System.out.println("No" + "\n"); } break; case "b": countB = countB + 1; if(countY < a + b && countB =< b){ countY = countY + 1; System.out.println("Yes" + "\n"); } else{ System.out.println("No" + "\n"); } break; case "c": System.out.println("No" + "\n"); break; } } // 出力 } }
Main.java:38: error: > or ',' expected if(countY < a + b && countB =< b){ ^ 1 error
s824852538
p03971
C++
#include<bits/stdc++.h> typedef long long ll; using namespace std; int main() { int n, a, b; cin >> n >> a >> b; int c = a+b; string s; cin >> s; int r1 = 0, total = 0, r2 = 0; for(int i=0; i<n; i++) { if(s[i] == 'c') { cout << "No" << endl; } else if(s[i] == 'a') { if(total < c) { total++; cout << "Yes" << endl; }else cout << "No" << endl; } else { if(total < c) { r2++; if(r2 <=b) { total++; cout << "Yes" << endl; } else cout << "No" << endl; } else { cout << "No" << endl; } } } }
a.cc:13:31: error: extended character   is not valid in an identifier 13 | for(int i=0; i<n; i++) { | ^ a.cc: In function 'int main()': a.cc:13:31: error: '\U00003000' was not declared in this scope 13 | for(int i=0; i<n; i++) { | ^~
s818169400
p03971
C++
#include <iostream> #include <string> using namespace std; int main() { int n,a,b; cin >> n >> a >> b; string s; cin >> s; std::string nihon("a"); std::string kaigai("b"); for (int i = 0; i < n; ++i) { if(a+b>0){ if(s[i]=="a"){ cout << "Yes" << endl; a--; }else if (s[i]=="b" && b>0){ cout << "Yes" << endl; b--; }else{ cout << "No" << endl; } }else{ cout << "No" << endl; } } // 出力 return 0; }
a.cc: In function 'int main()': a.cc:15:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 15 | if(s[i]=="a"){ a.cc:18:27: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 18 | }else if (s[i]=="b" && b>0){
s414288177
p03971
Java
import java.util.Scanner; public class Maiin { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int a = scanner.nextInt(); int b = scanner.nextInt(); int ta = 0, tb = 0; String string = scanner.next(); for (int i = 0; i < n; i++) { switch (string.charAt(i)) { case 'a': if (ta + tb < a + b) { ta++; System.out.println("Yes"); break; } System.out.println("No"); break; case 'b': if (ta + tb < a + b && tb < b) { tb++; System.out.println("Yes"); break; } System.out.println("No"); break; case 'c': System.out.println("No"); break; } } } }
Main.java:3: error: class Maiin is public, should be declared in a file named Maiin.java public class Maiin { ^ 1 error
s799292939
p03971
C++
#include <iostream> #include <string> using namespace std; int main() { int N, A, B; cin >> N >> A >> B; string S; cin >> S; int exceed = 0; int orderB = 0; for (int i = 0; i < N; i++) { char c = S.at[i]; switch(c){ case 'a': if (exceed < A + B) { cout << "Yes" << endl; exceed++; } else { cout << "No" << endl; } break; case 'b': orderB++; if (exceed < A + B && orderB <= B) { cout << "Yes" << endl; exceed++; } else{ cout << "No" << endl; } break; case 'c': cout << "No" << endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:13:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 13 | char c = S.at[i]; | ^
s906183186
p03971
Java
import java.util.*; import java.lang.*; import java.io.*; public static void Main (String[] args) throws java.lang.Exception { Scanner reader = new Scanner(System.in); int N = reader.nextInt(); int A = reader.nextInt(); int B = reader.nextInt(); reader.nextLine(); String input = reader.nextLine(); int foreigners = 0; int disqualified = 0; int counter = 0; for(int i = 0; i < input.length(); i++){ boolean printed = false; if(input.charAt(i) == 'b'){ foreigners++; } if(input.charAt(i) == 'c'){ disqualified++; System.out.println("No"); printed = true; } else if(i <= (A+B+disqualified)){ if(input.charAt(i) == 'a'){ System.out.println("Yes"); printed = true; } else if(input.charAt(i) == 'b'){ if(foreigners <= B){ System.out.println("Yes"); printed = true; } } } if(printed == false){ System.out.println("No"); } } }
Main.java:6: error: unnamed classes are a preview feature and are disabled by default. public static void Main (String[] args) throws java.lang.Exception ^ (use --enable-preview to enable unnamed classes) 1 error
s079751659
p03971
C++
#include <iostream> #include <string> using namespace std; int main() { int N, A, B; cin >> N >> A >> B; string S; cin >> S; int exceed = 0; int orderB = 0; for (int i = 0; i < N; i++) { switch (S.at[i]) { case 'a': if (exceed < A + B) { cout << "Yes" << endl; exceed++; } else { cout << "No" << endl; } break; case 'b': orderB++; if (exceed < A + B && orderB <= B) { cout << "Yes" << endl; exceed++; } else{ cout << "No" << endl; } break; case 'c': cout << "No" << endl; break; } } return 0; }
a.cc: In function 'int main()': a.cc:13:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 13 | switch (S.at[i]) { | ^
s211951597
p03971
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a) ;i < (b) ;i++) #define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) int main(){ int N, A, B ; string S ; cin>>N >>A>>B ; cin>>S ; int a = 0, b = 0 ; for (int i = 0 ;i < N ;i++){ if (s[i] == 'c')cout<<"No"<<endl ; if (s[i] == 'a'){ if (a + b < A + B){ a++ ; cout<<"Yes"<<endl ; } else cout<<"No"<<endl ; } if (s[i] == 'b'){ if (a + b < A + B && b < B){ b++ ; cout<<"Yes"<<endl ; } else cout<<"No"<<endl ; } } return 0 ; }
a.cc: In function 'int main()': a.cc:12:21: error: 's' was not declared in this scope 12 | if (s[i] == 'c')cout<<"No"<<endl ; | ^ a.cc:13:21: error: 's' was not declared in this scope 13 | if (s[i] == 'a'){ | ^ a.cc:20:21: error: 's' was not declared in this scope 20 | if (s[i] == 'b'){ | ^
s840471395
p03971
C++
#include <iostream> using namespace std; int main(){ int n,a,b,cnt,c; cnt=0; c=0; string s; cin>>n>>a>>b>>s; for(int i=0;i<s.length(),++i){ switch(s[i]){ case 'a': if(cnt<a+b) { cout<<'Yes'<<endl; cnt++; } else{ cout<<"No"<<endl; } break; case 'b': if(cnt<a+b&&c<b){ cout<<"Yes"<<endl; cnt++; c++; }else{ cout<<"No"<<endl; } break; case 'c': cout<<"No"<<endl; break; } } return 0; }
a.cc:15:27: warning: multi-character character constant [-Wmultichar] 15 | cout<<'Yes'<<endl; | ^~~~~ a.cc: In function 'int main()': a.cc:11:33: error: expected ';' before ')' token 11 | for(int i=0;i<s.length(),++i){ | ^ | ;
s922417522
p03971
C++
#include<bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef long long ll; typedef vector<int> vi; #define rep(i,j) for(int i=0;i<(j);i++) #define reps(i,j,k) for(int i=j;i<=k;i++) #define in(i,j,k) ((i)>=(j)&&(i)<=(k)) #define INF (1<<28) #define pb(i) push_back(i) #define fs first #define sc second const char dx[]={0,1,0,-1},dy[]={1,0,-1,0}; int main(){ int n,a,b; string s; cin >> n >> a >> b >> s; rep(i,n){ if(s[i]=='a'){ if(a>0){ cout << "Yes" << endl; a--; }else if(b>0){ cout << "Yes" << endl; b--; }else cout << "No"< << endl; }else if(s[i]=='b'){ if(b>0){ cout << "Yes" << endl; b--; }else cout << "No"<< endl; }else cout << "No" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:30:45: error: expected primary-expression before '<<' token 30 | }else cout << "No"< << endl; | ^~
s108990124
p03972
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define rrep(i,n) for(int i = (n)-1; i >= 0; i--) #define rep1(i,n) for(int i = 1; i <= (n); i++) #define rrep1(i,n) for(int i = (n); i > 0; i--) #define ll long long #define pi pair<int, int> #define pll pair<ll, ll> #define MOD 1000000007 #define INF 1000000000000000LL using namespace std; int main(){ int w,h;cin>>w>>h; vector<pll>pq(w+h); rep(i, w+h){ cin>>pq[i].first; pq[i].second = i; } sort(pq.begin(), pq.end()); UnionFind uf(w+h); ll cw=w+1, ch=h+1; ll result = 0; for(auto p: pq){ if(p.second >= w){ result += p.first*cw; ch--; }else{ result += p.first*ch; cw--; } } cout<<result<<endl; return 0; }
a.cc: In function 'int main()': a.cc:26:3: error: 'UnionFind' was not declared in this scope 26 | UnionFind uf(w+h); | ^~~~~~~~~
s081541611
p03972
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pii; #define F first #define S second #define pb push_back #define all(x) (x).begin(), (x).end() ll n, m, ans; vector<pii> data; int main() { cin >> n >> m; for (ll i = 0; i < n; i++) { ll x; cin >> x; data.pb({x, 0}); } for (ll i = 0; i < m; i++) { ll x; cin >> x; data.pb({x, 1}); } sort(all(data)); n++, m++; for (pii p: data) { if (p.S == 0) { ans += p.F * m; n--; } else { ans += p.F * n; m--; } } cout << ans; }
a.cc: In function 'int main()': a.cc:19:17: error: reference to 'data' is ambiguous 19 | data.pb({x, 0}); | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:13:13: note: 'std::vector<std::pair<long long int, long long int> > data' 13 | vector<pii> data; | ^~~~ a.cc:23:17: error: reference to 'data' is ambiguous 23 | data.pb({x, 1}); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:13:13: note: 'std::vector<std::pair<long long int, long long int> > data' 13 | vector<pii> data; | ^~~~ a.cc:25:18: error: reference to 'data' is ambiguous 25 | sort(all(data)); | ^~~~ a.cc:10:17: note: in definition of macro 'all' 10 | #define all(x) (x).begin(), (x).end() | ^ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:13:13: note: 'std::vector<std::pair<long long int, long long int> > data' 13 | vector<pii> data; | ^~~~ a.cc:25:18: error: reference to 'data' is ambiguous 25 | sort(all(data)); | ^~~~ a.cc:10:30: note: in definition of macro 'all' 10 | #define all(x) (x).begin(), (x).end() | ^ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:13:13: note: 'std::vector<std::pair<long long int, long long int> > data' 13 | vector<pii> data; | ^~~~ a.cc:27:21: error: reference to 'data' is ambiguous 27 | for (pii p: data) { | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:13:13: note: 'std::vector<std::pair<long long int, long long int> > data' 13 | vector<pii> data; | ^~~~
s627036172
p03972
C++
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> #define _GLIBCXX_DEBUG using namespace std; using ll = long long; using vec = vector<ll>; using vect = vector<double>; using Graph = vector<vector<ll>>; #define endl '\n' #define loop(i, n) for (ll i = 0; i < n; i++) #define Loop(i, m, n) for (ll i = m; i < n; i++) #define pool(i, n) for (ll i = n; i >= 0; i--) #define Pool(i, m, n) for (ll i = n; i >= m; i--) #define mod 1000000007ll //#define mod 998244353ll #define flagcount(bit) __builtin_popcount(bit) #define flag(x) (1ll << x) #define flagadd(bit, x) bit |= flag(x) #define flagpop(bit, x) bit &= ~flag(x) #define flagon(bit, i) bit &flag(i) #define flagoff(bit, i) !(bit & (1ll << i)) #define all(v) v.begin(), v.end() #define low2way(v, x) lower_bound(all(v), x) #define high2way(v, x) upper_bound(all(v), x) #define idx_lower(v, x) (distance(v.begin(), low2way(v, x))) //配列vでx未満の要素数を返す #define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す #define idx_lower2(v, x) (v.size() - idx_lower(v, x)) //配列vでx以上の要素数を返す #define idx_upper2(v, x) (v.size() - idx_upper(v, x)) //配列vでxより大きい要素の数を返す #define putout(a) cout << a << '\n' #define Sum(v) accumulate(all(v), 0ll) ll ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return -1; } template <typename T> string make_string(T N) { string ret; T now = N; while (now > 0) { T x = now % 10; ret += (char)('0' + x); now /= 10; } reverse(all(ret)); return ret; } template <typename T> T gcd(T a, T b) { if (a % b == 0) { return (b); } else { return (gcd(b, a % b)); } } template <typename T> T lcm(T x, T y) { T z = gcd(x, y); return x * y / z; } template <typename T> bool primejudge(T n) { if (n < 2) return false; else if (n == 2) return true; else if (n % 2 == 0) return false; double sqrtn = sqrt(n); for (T i = 3; i < sqrtn + 1; i++) { if (n % i == 0) { return false; } i++; } return true; } template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; // aをbで更新 return true; } return false; } template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; // aをbで更新 return true; } return false; } //場合によって使い分ける //const ll dx[4]={1,0,-1,0}; //const ll dy[4]={0,1,0,-1}; const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1}; const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1}; //2次元配列の宣言 //vector<vector<ll>> field(h, vector<ll>(w)); int main() { cout << fixed << setprecision(30); ios::sync_with_stdio(false); cin.tie(nullptr); ll W, H; cin >> W >> H; vector<pair<ll, bool>> pairs(W + H); vector<ll> p(W), q(H); loop(i, W) { cin >> p[i]; pairs[i] = make_pair(p[i], 1); } loop(i, H) { cin >> q[i]; pairs[W + i] = make_pair(q[i], 0); } sort(all(pairs)); ll a = W + 1, b = H + 1; ll ans = 0; for (ll i = 0; a && b; i++) { auto p = pairs[i]; if (p.second) { ans += b * p.first; a--; } else { ans += a * p.first; b--; } } putout(ans); return 0; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:3: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<std::pair<long long int, bool>, std::allocator<std::pair<long long int, bool> > >::_Vector_impl::~_Vector_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::pair<long long int, bool>]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53: /usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here 132 | struct _Vector_impl | ^~~~~~~~~~~~
s764881274
p03972
C++
import sys from operator import itemgetter read = sys.stdin.read readline = sys.stdin.readline W, H, *pq = map(int, read().split()) pq = list(zip(pq[:W], ['p'] * W)) + list(zip(pq[W:], ['q'] * H)) pq.sort(key=itemgetter(0)) answer = 0 x = W + 1 y = H + 1 for cost, i in pq: if i == 'p': answer += cost * y x -= 1 else: answer += cost * x y -= 1 print(answer)
a.cc:1:1: error: 'import' does not name a type 1 | import sys | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
s330365240
p03972
C++
#include<iostream> #include<string> #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<deque> #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; typedef long double ld; const int inf=1e9+7; const ll INF=1LL<<60 ; const ll mod=1e9+7 ; #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++) typedef complex<ld> Point; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair<int, int> P; typedef pair<ld, ld> LDP; typedef pair<ll, ll> LP; #define fr first #define sc second #define all(c) c.begin(),c.end() #define pb push_back #define debug(x) cout << #x << " = " << (x) << endl; using Graph = vector<vector<int> >; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } //#define int long long void solve() { int w, h; cin >> w >> h; vector<pair<ll, int>> es(w + h); rep(i, h + w) { cin >> es[i].fr; if(i < w) es[i].sc = 0; else es[i].sc = 1; } sort(all(e)); ll ans = 0; int a = h + 1, b = w + 1; for(auto e: es) { if(e.sc == 0) { ans += e .fr * a; --b; } else { ans += e.fr * b; --a; } } cout << ans << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); //cout << fixed << setprecision(10); //init(); solve(); //cout << "finish" << endl; return 0; }
a.cc: In function 'void solve()': a.cc:62:14: error: 'e' was not declared in this scope; did you mean 'es'? 62 | sort(all(e)); | ^ a.cc:45:16: note: in definition of macro 'all' 45 | #define all(c) c.begin(),c.end() | ^
s115034291
p03972
C++
include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) typedef long long ll; typedef pair<ll,ll> P; int main(){ ll w, h; cin >> w >> h; ll p, q; priority_queue<P,vector<P>,greater<P>> que; rep(i,w) { cin >> p; que.push(P(p,0)); } rep(i,h) { cin >> q; que.push(P(q,1)); } ll ans = 0; ll n = 0; p = w + 1; q = h + 1; while(!que.empty()){ P a = que.top(); que.pop(); if(a.second == 0) { if(q > 0) ans += a.first*q; else ans += a.first; p--; } else { if(p > 0) ans += a.first*p; else ans += a.first; q--; } } cout << ans << endl; return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include <bits/stdc++.h> | ^~~~~~~ a.cc:5:9: error: 'pair' does not name a type 5 | typedef pair<ll,ll> P; | ^~~~ a.cc: In function 'int main()': a.cc:9:5: error: 'cin' was not declared in this scope 9 | cin >> w >> h; | ^~~ a.cc:11:5: error: 'priority_queue' was not declared in this scope 11 | priority_queue<P,vector<P>,greater<P>> que; | ^~~~~~~~~~~~~~ a.cc:11:20: error: 'P' was not declared in this scope 11 | priority_queue<P,vector<P>,greater<P>> que; | ^ a.cc:11:22: error: 'vector' was not declared in this scope 11 | priority_queue<P,vector<P>,greater<P>> que; | ^~~~~~ a.cc:11:31: error: expected primary-expression before ',' token 11 | priority_queue<P,vector<P>,greater<P>> que; | ^ a.cc:11:32: error: 'greater' was not declared in this scope 11 | priority_queue<P,vector<P>,greater<P>> que; | ^~~~~~~ a.cc:11:44: error: 'que' was not declared in this scope 11 | priority_queue<P,vector<P>,greater<P>> que; | ^~~ a.cc:24:10: error: expected ';' before 'a' 24 | P a = que.top(); | ^~ | ; a.cc:26:12: error: 'a' was not declared in this scope 26 | if(a.second == 0) { | ^ a.cc:36:5: error: 'cout' was not declared in this scope 36 | cout << ans << endl; | ^~~~ a.cc:36:20: error: 'endl' was not declared in this scope 36 | cout << ans << endl; | ^~~~
s157147430
p03972
C++
// 素集合データ構造 struct UnionFind { // par[i]:データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである vector<int> par; // sizes[i]:根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる vector<int> sizes; UnionFind(int n) : par(n), sizes(n, 1) { // 最初は全てのデータiがグループiに存在するものとして初期化 rep(i,n) par[i] = i; } // データxが属する木の根を得る int find(int x) { if (x == par[x]) return x; return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す } // 2つのデータx, yが属する木をマージする void unite(int x, int y) { // データの根ノードを得る x = find(x); y = find(y); // 既に同じ木に属しているならマージしない if (x == y) return; // xの木がyの木より大きくなるようにする if (sizes[x] < sizes[y]) swap(x, y); // xがyの親になるように連結する par[y] = x; sizes[x] += sizes[y]; // sizes[y] = 0; // sizes[y]は無意味な値となるので0を入れておいてもよい } // 2つのデータx, yが属する木が同じならtrueを返す bool same(int x, int y) { return find(x) == find(y); } // データxが含まれる木の大きさを返す int size(int x) { return sizes[find(x)]; } }; // 頂点a, bをつなぐコストcostの(無向)辺 struct Edge { int a, b, cost; // コストの大小で順序定義 bool operator<(const Edge& o) const { return cost < o.cost; } }; // 頂点数と辺集合の組として定義したグラフ struct Graph { int n; // 頂点数 vector<Edge> es; // 辺集合 // クラスカル法で無向最小全域木のコストの和を計算する // グラフが非連結のときは最小全域森のコストの和となる int kruskal() { // コストが小さい順にソート sort(es.begin(), es.end()); UnionFind uf(n); int min_cost = 0; rep(ei, es.size()) { Edge& e = es[ei]; if (!uf.same(e.a, e.b)) { // 辺を追加しても閉路ができないなら、その辺を採用する min_cost += e.cost; uf.unite(e.a, e.b); } } return min_cost; } }; // 標準入力からグラフを読み込む Graph input_graph() { Graph g; int W,H; cin >> W >> H; g.n=(W+1)*(H+1); rep(i, W){ Edge e; cin >> e.cost; rep(j,H+1){ e.a=(W+1)*j; e.b=(W+1)*j+1; g.es.push_back(e); } } rep(i, H){ Edge e; cin >> e.cost; rep(j,W+1){ e.a=j; e.b=j+(H+1); g.es.push_back(e); } } return g; } int main(){ Graph g = input_graph(); cout << g.kruskal() << endl; return 0; }
a.cc:5:3: error: 'vector' does not name a type 5 | vector<int> par; | ^~~~~~ a.cc:7:3: error: 'vector' does not name a type 7 | vector<int> sizes; | ^~~~~~ a.cc: In constructor 'UnionFind::UnionFind(int)': a.cc:9:22: error: class 'UnionFind' does not have any field named 'par' 9 | UnionFind(int n) : par(n), sizes(n, 1) { | ^~~ a.cc:9:30: error: class 'UnionFind' does not have any field named 'sizes' 9 | UnionFind(int n) : par(n), sizes(n, 1) { | ^~~~~ a.cc:11:9: error: 'i' was not declared in this scope 11 | rep(i,n) par[i] = i; | ^ a.cc:11:5: error: 'rep' was not declared in this scope 11 | rep(i,n) par[i] = i; | ^~~ a.cc: In member function 'int UnionFind::find(int)': a.cc:16:14: error: 'par' was not declared in this scope 16 | if (x == par[x]) return x; | ^~~ a.cc:17:12: error: 'par' was not declared in this scope 17 | return par[x] = find(par[x]); // 根を張り替えながら再帰的に根ノードを探す | ^~~ a.cc: In member function 'void UnionFind::unite(int, int)': a.cc:30:9: error: 'sizes' was not declared in this scope; did you mean 'size'? 30 | if (sizes[x] < sizes[y]) swap(x, y); | ^~~~~ | size a.cc:30:30: error: 'swap' was not declared in this scope 30 | if (sizes[x] < sizes[y]) swap(x, y); | ^~~~ a.cc:33:5: error: 'par' was not declared in this scope 33 | par[y] = x; | ^~~ a.cc:34:5: error: 'sizes' was not declared in this scope; did you mean 'size'? 34 | sizes[x] += sizes[y]; | ^~~~~ | size a.cc: In member function 'int UnionFind::size(int)': a.cc:45:12: error: 'sizes' was not declared in this scope; did you mean 'size'? 45 | return sizes[find(x)]; | ^~~~~ | size a.cc: At global scope: a.cc:64:3: error: 'vector' does not name a type 64 | vector<Edge> es; // 辺集合 | ^~~~~~ a.cc: In member function 'int Graph::kruskal()': a.cc:70:10: error: 'es' was not declared in this scope 70 | sort(es.begin(), es.end()); | ^~ a.cc:70:5: error: 'sort' was not declared in this scope; did you mean 'short'? 70 | sort(es.begin(), es.end()); | ^~~~ | short a.cc:75:9: error: 'ei' was not declared in this scope 75 | rep(ei, es.size()) { | ^~ a.cc:75:5: error: 'rep' was not declared in this scope 75 | rep(ei, es.size()) { | ^~~ a.cc: In function 'Graph input_graph()': a.cc:92:3: error: 'cin' was not declared in this scope 92 | cin >> W >> H; | ^~~ a.cc:94:7: error: 'i' was not declared in this scope 94 | rep(i, W){ | ^ a.cc:94:3: error: 'rep' was not declared in this scope 94 | rep(i, W){ | ^~~ a.cc: In function 'int main()': a.cc:118:3: error: 'cout' was not declared in this scope 118 | cout << g.kruskal() << endl; | ^~~~ a.cc:118:26: error: 'endl' was not declared in this scope 118 | cout << g.kruskal() << endl; | ^~~~
s283126041
p03972
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) struct path{ int cst,char wh; path(){}; path(int cst_,char wh_){ cst=cst_;wh=wh_; }; bool operator<(const path& o)const{return cst>o.cst;} }; signed main(){ int w,h;cin>>w>>h; vector<int>p(w),q(h); for(auto&& u:p)cin>>u; for(auto&& u:q)cin>>u; priority_queue<path> pq; int nw=0,nh=0,cst=0,num=0; for(auto&& u:p)pq.push(path(u,'w')); for(auto&& u:q)pq.push(path(u,'h')); while(!pq.empty()){ auto&& x=pq.top();pq.pop(); if(x.wh=='w'){ cst+=x.cst*(h-1-nh); num+=h-1-nh; nw++; }else if(x.wh=='h'){ cst+=x.cst*(w-1-nw); num+=w-1-nw; nh++; } if(num>=(h-1)*(w-1)-1)break; } cout<<cst<<endl; }
a.cc:7:25: error: expected unqualified-id before 'char' 7 | int cst,char wh; | ^~~~ a.cc: In constructor 'path::path(long long int, char)': a.cc:10:34: error: 'wh' was not declared in this scope; did you mean 'wh_'? 10 | cst=cst_;wh=wh_; | ^~ | wh_ a.cc: In function 'int main()': a.cc:27:22: error: 'const struct path' has no member named 'wh' 27 | if(x.wh=='w'){ | ^~ a.cc:31:28: error: 'const struct path' has no member named 'wh' 31 | }else if(x.wh=='h'){ | ^~
s484957616
p03972
C++
#include<bits/stdc++.h> using namespace std; #define int long long #define rep(i,n) for(int i=0;i<(n);i++) struct path{ int cst,char wh; path(){}; path(int cst_,char wh_){ cst=cst_,wh=wh_; }; bool operator<(const path& o)const{return cst>o.cst;} }; signed main(){ int w,h;cin>>w>>h; vector<int>p(w),q(h); for(auto&& u:p)cin>>u; for(auto&& u:q)cin>>u; priority_queue<path> pq; int nw=0,nh=0,cst=0,num=0; for(auto&& u:p)pq.push(path(u,'w')); for(auto&& u:q)pq.push(path(u,'h')); while(!pq.empty()){ auto&& x=pq.top();pq.pop(); if(x.wh=='w'){ cst+=x.cst*(h-1-nh); num+=h-1-nh; nw++; }else if(x.wh=='h'){ cst+=x.cst*(w-1-nw); num+=w-1-nw; nh++; } if(num>=(h-1)*(w-1)-1)break; } cout<<cst<<endl; }
a.cc:7:25: error: expected unqualified-id before 'char' 7 | int cst,char wh; | ^~~~ a.cc: In constructor 'path::path(long long int, char)': a.cc:10:34: error: 'wh' was not declared in this scope; did you mean 'wh_'? 10 | cst=cst_,wh=wh_; | ^~ | wh_ a.cc: In function 'int main()': a.cc:27:22: error: 'const struct path' has no member named 'wh' 27 | if(x.wh=='w'){ | ^~ a.cc:31:28: error: 'const struct path' has no member named 'wh' 31 | }else if(x.wh=='h'){ | ^~
s686085863
p03972
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll w,h;cin>>w>>h; vector<ll> p(w),q(h); ll ans=0; for(ll i=0;i<w;i++){ cin>>p[i]; ans+=p[i]; } sort(p.begin(),p.end()); ll sum[w+1]; sum[0]=0; for(ll i=0;i<w;i++){ sum[i+1]=sum[i]+p[i]; } for(ll j=0;j<h;j++){ cin>>q[i]; ans+=q[i]; ll c=lower_bound(p,p+n,q[i])-p.begin(); ans+=sum[c]+q[i]*(w-c); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:19:12: error: 'i' was not declared in this scope 19 | cin>>q[i]; | ^ a.cc:21:26: error: 'n' was not declared in this scope 21 | ll c=lower_bound(p,p+n,q[i])-p.begin(); | ^
s049188185
p03972
C++
#include <bits/stdc++.h> using namespace std; // 変数ダンプ先。coutかcerr #define DUMPOUT cerr // 提出時はコメントアウト #define DEBUG_ // #define int long long struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast; /* cpp template {{{ */ /* short */ #define pb push_back #define eb emplace_back #define mp make_pair #define Fi first #define Se second #define ALL(v) begin(v), end(v) #define RALL(v) rbegin(v), rend(v) #define X real() #define Y imag() /* REPmacro */ #define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i) #define REP(i, n) REPS(i, 0, n) #define RREP(i, n) REPS(i, 1, n + 1) #define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i) #define DEP(i, n) DEPS(i, n, 0) #define EACH(i, n) for (auto&& i : n) /* debug */ #define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n'; /* alias */ using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using pii = pair<int, int>; using D = double; using P = complex<D>; using vs = vector<string>; template <typename T> using PQ = priority_queue<T>; template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>; /* const */ const int INF = 1001001001; const ll LINF = 1001001001001001001ll; const int MOD = 1e9 + 7; const D EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; /* func */ inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;} inline int in() {int x; cin >> x; return x;} inline ll IN() {ll x; cin >> x; return x;} inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;} template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;} template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;} template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;} template <typename T> inline void print(const T& x) {cout << x << '\n';} template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);} template <typename T> inline void print(const vector<T>& v, string s = " ") {REP(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");} // clang-format on /* }}} */ #ifdef DEBUG_ #define DEB #else // DEB と打つとデバッグ時以外はコメントアウトになる #define DEB /##/ #endif // 変数ダンプ用マクロ。デバッグ時以外は消滅する // 引数はいくつでもどんな型でも可(ストリーム出力演算子があればOK) #define dump(...) DEB DUMPOUT<<" "; \ DUMPOUT<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl; \ DUMPOUT<<" "; \ dump_func(__VA_ARGS__) // デバッグ用変数ダンプ関数 void dump_func() { DUMPOUT << endl; } template <class Head, class... Tail> void dump_func(Head&& head, Tail&&... tail) { DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...); } // vector出力 template<typename T> ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) { os << vec[i] << (i + 1 == vec.size() ? "" : ", "); } os << "}"; return os; } signed main() { //my-code int W, H; cin << W << H; vi p(W), q(H); REP(i, W){ cin << p[i]; } REP(i, H){ cin << q[i]; } ll ans = 0; int x = 0; int y = 0; sort(p.begin(), p.end()); sort(q.begin(), q.end()); int pc = 0; int qc = 0; while (pc != W && qc != H) { int cost; bool from_p; if (pc == W) { cost = q[qc]; qc++; from_p = false; } else if (qc == H) { cost = p[pc]; pc++; from_p = true; } else if (p[pc] <= q[qc]) { cost = p[pc]; pc++; from_p = true; } else { cost = q[pc]; qc++; from_p = false; } if (from_p) { ans += (H+1-y)*cost; y++; } else { ans += (W+1-x)*cost; x++; } } cout << ans << endl; return 0; } // https://github.com/kurokoji/.cpp-Template/wiki テンプレートについて // http://www.creativ.xyz/dump-cpp-652 dump()について // https://gist.github.com/rigibun/7905920 色々
a.cc: In function 'int main()': a.cc:115:19: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int') 115 | int W, H; cin << W << H; | ~~~ ^~ ~ | | | | | int | std::istream {aka std::basic_istream<char>} a.cc:115:19: note: candidate: 'operator<<(int, int)' (built-in) 115 | int W, H; cin << W << H; | ~~~~^~~~ a.cc:115:19: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int' a.cc:104:10: note: candidate: 'template<class T> std::ostream& operator<<(std::ostream&, std::vector<_Tp>&)' 104 | ostream& operator << (ostream& os, vector<T>& vec) { | ^~~~~~~~ a.cc:104:10: note: template argument deduction/substitution failed: a.cc:115:22: note: mismatched types 'std::vector<_Tp>' and 'int' 115 | int W, H; cin << W << H; | ^ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)' 1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41: /usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)' 125 | operator<<(byte __b, _IntegerType __shift) noexcept | ^~~~~~~~ /usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed: a.cc:115:15: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte' 115 | int W, H; cin << W << H; | ^~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)' 763 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 4077 | operator<<(basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)' 1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os, | ^~~~~~~~ /usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ In file included from /usr/include/c++/14/bits/ios_base.h:46, from /usr/include/c++/14/streambuf:43, from /usr/include/c++/14/bits/streambuf_iterator.h:35, from /usr/include/c++/14/iterator:66, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54: /usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)' 339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) | ^~~~~~~~ /usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ In file included from /usr/include/c++/14/memory:80, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56: /usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)' 70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os, | ^~~~~~~~ /usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ In file included from /usr/include/c++/14/istream:41, from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)' 563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c) | ^~~~~~~~ /usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)' 573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)' 579 | operator<<(basic_ostream<char, _Traits>& __out, char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)' 590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)' 595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c) | ^~~~~~~~ /usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 115 | int W, H; cin << W << H; | ^ /usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)' 654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed: a.cc:115:22: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 115 | int W, H; cin << W << H; | ^ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)' 307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:307:5: note: template argumen
s046897013
p03972
C++
while (i < H || j < W) { if (i == H) { ans += p[j]; j++; } else if (j == W) { ans += q[i]; i++; } else { if (q[i] < p[j]) { ans += (W - j + 1) * q[i]; i++; } else { ans += (H - i + 1) * p[j]; j++; } } } cout << ans << endl; return 0; }
a.cc:1:5: error: expected unqualified-id before 'while' 1 | while (i < H || j < W) { | ^~~~~ a.cc:18:5: error: 'cout' does not name a type 18 | cout << ans << endl; | ^~~~ a.cc:20:5: error: expected unqualified-id before 'return' 20 | return 0; | ^~~~~~ a.cc:21:1: error: expected declaration before '}' token 21 | } | ^
s509125470
p03972
C++
import java.util.Arrays; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(); } int W,H,N; long[]p; long[]q; long INF=Long.MAX_VALUE/2; void solve(){ Scanner sc=new Scanner(System.in); W=sc.nextInt(); H=sc.nextInt(); N=(W+1)*(H+1); p=new long[W]; q=new long[H]; for(int i=0;i<W;i++) { p[i]=sc.nextLong(); } for(int i=0;i<H;i++) { q[i]=sc.nextLong(); } Arrays.sort(p); Arrays.sort(q); int a=W, b=H; int i=0,j=0; long ans=0; while(a>0 || b>0) { if(i==W) { ans+=q[j]*(a+1); j++; b--; }else if(j==H) { ans+=p[i]*(b+1); i++; a--; }else if(p[i]<q[j]) { ans+=p[i]*(b+1); i++; a--; }else { ans+=q[j]*(a+1); j++; b--; } } System.out.println(ans); } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.Arrays; | ^~~~~~ 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.util.PriorityQueue; | ^~~~~~ 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.util.Scanner; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s954383117
p03972
C++
#include <iostream> #include <vector> #include <cmath> #include <cstdio> #include <string> #include <algorithm> #include <queue> #include <unordered_map> #include <map> #define ll long long using namespace std; #define MOD 1000000007 class Solve { private: ll w, h; vector<ll> p; vector<ll> q; public: Solve(){ cin >> w >> h; for (ll i = 0; i < w; ++i) { ll tmp; cin >> tmp; p.push_back(tmp); } for (ll i = 0; i < h; ++i) { ll tmp; cin >> tmp; q.push_back(tmp); } sort(p.begin(), p.end()); sort(q.begin(), q.end()); } void exec(){ ll i1 = 0; ll i2 = 0; ll ans = 0; for (ll i = 0; i < w + h; ++i) { if(i1 == w) { ans += q[i2] * (w - i1 + 1); i2++; continue; } if(i2 == h) { ans += p[i1] * (h - i2 + 1); i1++; continue; } if(p[i1] < q[i2]) { ans += p[i1] * (h - i2 + 1); i1++; } else { ans += q[i2] * (w - i1 + 1); i2++; } } cout << ans << endl; } }; ll main(){ Solve solver = Solve(); solver.exec(); }
cc1plus: error: '::main' must return 'int'
s459871435
p03972
C++
#include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<map> #include<queue> #include<vector> #include<cstdlib> #define range(i,a,b) for(int i = (a); i <= (b); i++) #define rrange(i,a,b) for(int i = (a); i >= (b); i--) #define rep(i,b) for(int i = 1; i <= (b); i++) #define rrep(i,b) for(int i = (b); i >= 1; i--) #define all(a) (a).begin(), (a).end() #define show(x) cout << #x << " = " << (x) << endl; using namespace std; typedef long long ll; const int N=1e5+11; const int INF = 1001001001; const ll LLINF = 1001001001001001001LL; template<typename T> void chmin(T& a, T b) { if (a > b) a = b; } template<typename T> void chmax(T& a, T b) { if (a < b) a = b; } int h,w,n; ll ans,t; struct node{ ll c;int id; operator <(node &b){ return c<b.c; } }cost[N<<1]; 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 f*x; } ll ll_read(){ ll 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 f*x; } int main(){ // freopen("ex.in","r",stdin); w=read();h=read(); n=h+w; rep(i,n){ cost[i].c=ll_read(); if(i<=w) cost[i].id=0; else cost[i].id=1; } sort(cost+1,cost+1+n); rep(i,n){ if(cost[i].id==0){ t=h+1; w--; } else{ t=w+1; h--; } ans+=t*cost[i].c; } printf("%lld",ans); return 0; }
a.cc:26:9: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive] 26 | operator <(node &b){ | ^~~~~~~~
s309114707
p03972
C++
#include<iostream> #include<unordered_map> #include<cstdio> #include<algorithm> #define count Count #define P pair<int,int> #define ll long long using namespace std; P c[200000]; int count[2]; int n[2]; signed main() { int a, b; scanf("%d%d", &a, &b); n[0] = a; n[1] = b; for (int d = 0; d < a; d++) { int e; scanf("%d", &e); c[d] = { e,0 }; } for (int d = 0; d < b; d++) { int e; scanf("%d", &e); c[a+d] = { e,1 }; } sort(c, c + a + b); ll ans = 0; for (int i = 0; i < a+b; i++) { ans += ll(c[i].first)*(n[(c[i].second + 1) & 1]- count[(c[i].second + 1) & 1]+1); count[c[i].second]++; } printf("%lld\n", ans); }
a.cc: In function 'int main()': a.cc:7:12: error: expected primary-expression before 'long' 7 | #define ll long long | ^~~~ a.cc:27:24: note: in expansion of macro 'll' 27 | ans += ll(c[i].first)*(n[(c[i].second + 1) & 1]- count[(c[i].second + 1) & 1]+1); | ^~
s576096207
p03972
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int W, H; cin >> W >> H; vector<int> p(W); vector<int> q(H); for(int i = 0; i < W; i++) cin >> p[i]; for(int i = 0; i < H; i++) cin >> q[i]; sort(p.begin(), p.end()); sort(q.begin(), q.end()); int w = W + 1, h = H + 1; long long res = 0; int i = 0; j = 0; while(i < W || j < H){ if(j < H && (i == W || p[i] > q[j])){ res += q[j]*w; --h; ++j; } else{ res += p[i] * h; --w; ++i; } } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:15: error: 'j' was not declared in this scope 21 | int i = 0; j = 0; | ^
s676306944
p03972
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(){ int W, H; cin >> W >> H; vector<int> p(W); vector<int> q(H); for(int i = 0; i < W; i++) cin >> p[i]; for(int i = 0; i < H; i++) cin >> q[i]; sort(p.begin(), p.end()); sort(q.begin(), q.end()); int w = W + 1, h = H + 1; long long res = 0; int i = 0; j = 0; while(i < W || j < H){ if(j < H && (i == W || P[i] > Q[j])){ res += Q[j]*w; --h; ++j; } else{ res += P[i] * h; --w; ++i; } } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:15: error: 'j' was not declared in this scope 21 | int i = 0; j = 0; | ^ a.cc:23:28: error: 'P' was not declared in this scope 23 | if(j < H && (i == W || P[i] > Q[j])){ | ^ a.cc:23:35: error: 'Q' was not declared in this scope 23 | if(j < H && (i == W || P[i] > Q[j])){ | ^
s736451278
p03972
C++
#include <bits/stdc++.h> using namespace std; int w,h; int main() { cin >> w >> h; multimap<long long, int > v; long long temp; long long cost = 0; for (int i = 0; i < w; ++i) { cin >> temp; v.insert(pair<long long,int>(temp, 1)); } for (int i = 0; i < h; ++i) { cin >> temp; v.insert(pair<long long,int>(temp, 2)); } int a = w+1; int b = h+1; for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) { if ((*i).second == 1) { cost += b * (*i).first; if (a>1) { a--; } }else if ((*i).second == 2) { cost += a * (*i).first; if (b>1) { b--; } } } cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:48: error: conversion from '_Rb_tree_iterator<pair<const long long int,[...]>>' to non-scalar type '_Rb_tree_iterator<pair<const int,[...]>>' requested 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ~~~~~~~^~ a.cc:31:53: error: no match for 'operator!=' (operand types are 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and 'std::multimap<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'}) 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ~^~~~~~~~~ | | | | | _Rb_tree_iterator<pair<const long long int,[...]>> | _Rb_tree_iterator<pair<const int,[...]>> In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1305 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1473 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<long long int, int>::iterator' {aka 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1647 | operator!=(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)' 2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::pair<_T1, _T2>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 455 | operator!=(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed: a.cc:31:61: note: 'std::multimap<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>' 31 | for (multimap<int, int>::iterator i=v.begin(); i!=v.end(); i++) | ^ /usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constex
s691316963
p03972
C++
#include <bits/stdc++.h> #define EPS 1e-9 #define INF 1070000000LL #define MOD 1000000007LL #define fir first #define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++) #define numa(x,a) for(auto x: a) #define ite iterator #define mp make_pair #define rep(i,n) rep2(i,0,n) #define rep2(i,m,n) for(int i=m;i<(n);i++) #define pb push_back #define pf push_front #define sec second #define sz(x) ((int)(x).size()) #define ALL( c ) (c).begin(), (c).end() #define gcd(a,b) __gcd(a,b) #define mem(x,n) memset(x,n,sizeof(x)) #define endl "\n" using namespace std; template <int POS, class TUPLE> void deploy(std::ostream &os, const TUPLE &tuple){} template <int POS, class TUPLE, class H, class ...Ts> void deploy(std::ostream &os, const TUPLE &t){ os << (POS == 0 ? "" : ", ") << get<POS>(t); deploy<POS + 1, TUPLE, Ts...>(os, t); } template <class T,class U> std::ostream& operator<<(std::ostream &os, std::pair<T,U> &p){ os << "(" << p.first <<", " << p.second <<")";return os; } template <class T> std::ostream& operator<<(std::ostream &os, std::vector<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template <class T> std::ostream& operator<<(std::ostream &os, std::set<T> &v){ int remain = v.size(); os << "{"; for(auto e: v) os << e << (--remain == 0 ? "}" : ", "); return os; } template <class T, class K> std::ostream& operator<<(std::ostream &os, std::map<T, K> &mp){ int remain = mp.size(); os << "{"; for(auto e: mp) os << "(" << e.first << " -> " << e.second << ")" << (--remain == 0 ? "}" : ", "); return os; } #define DEBUG1(var0) { std::cerr << (#var0) << "=" << (var0) << endl; } #define DEBUG2(var0, var1) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG1(var1); } #define DEBUG3(var0, var1, var2) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG2(var1,var2); } #define DEBUG4(var0, var1, var2, var3) { std::cerr << (#var0) << "=" << (var0) << ", ";DEBUG3(var1,var2,var3); } using ll = long long; int main() { cin.tie(0); ios_base::sync_with_stdio(0); int H,W; cin >> W >> H; vector <ll> p(W); vector <ll> q(H); rep(i,W){ cin >> p[i]; } rep(i,H){ cin >> q[i]; } sort(ALL(p)); sort(QLL(q)); p.push_back(INF); q.push_back(INF); reverse(ALL(p)); reverse(ALL(q)); int w = W, h = H; ll ans = 0; while (true) { if (w == 0 || h == 0) { break; } if (p.back() < q.back()) { ans += q.back() * (w + 1); q.pop_back(); h -= 1; }else{ ans += p.back() * (h + 1); p.pop_back(); w -= 1; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:47:22: error: 'QLL' was not declared in this scope; did you mean 'ALL'? 47 | sort(ALL(p)); sort(QLL(q)); | ^~~ | ALL
s716941684
p03972
C++
#include <vector> #include <iostream> #include <algorithm> #include <string> #include <deque> #include <queue> using namespace std; struct TEdge { int From; int To; int Type; int Cost; }; bool operator < (const TEdge& lhs, const TEdge& rhs) { return lhs.Cost > rhs.Cost; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n[2]; cin >> n[0] >> n[1]; vector<int> p[2]; for (int i = 0; i < 2; ++i) { p[i].resize(n[i]); for (int j = 0; j < n[i]; ++j) { cin >> p[i][j]; } } TDsu dsu[2]; int cn[2]; for (int i = 0; i < 2; ++i) { dsu[i].Init(n[i] + 1); cn[i] = n[i] + 1; } priority_queue<TEdge> q; for (int i = 0; i < 2; ++i) { for (int j = 0; j < n[i]; ++j) { q.push(TEdge{j, j + 1, i, p[i][j]}); } } long long cost = 0; while (!q.empty()) { TEdge e = q.top(); q.pop(); cost += 1LL * e.Cost * cn[1 - e.Type]; cn[e.Type] -= 1; } cout << cost << endl; return 0; }
a.cc: In function 'int main()': a.cc:35:5: error: 'TDsu' was not declared in this scope 35 | TDsu dsu[2]; | ^~~~ a.cc:38:9: error: 'dsu' was not declared in this scope 38 | dsu[i].Init(n[i] + 1); | ^~~
s237954901
p03972
Java
import ARC.Tools.PriorityQue; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.util.PriorityQueue; /** * Created by jaga on 9/22/16. */ public class Main{ public static void solve(PrintWriter out, FastScanner in){ int W = in.nextInt(); int H = in.nextInt(); PriorityQueue<Pair> ps = new PriorityQueue<>(); //W以上のidxはHのために使う for(int i= 0;i < W;i++) { ps.add(new Pair(in.nextLong(), i)); } for(int i= 0;i < H;i++) { ps.add(new Pair(in.nextLong(), i + W)); } long res = 0; int w = W + 1; int h = H + 1; while (!ps.isEmpty()) { Pair p = ps.poll(); long val = p.first; long idx = p.second; if (idx < W && h > 0) { //x座標方向の時 res += h * val; w --; } else if (idx >= W &&W > 0) { res += w * val; h --; } } out.println(res); } static class Pair implements Comparable { long first, second; Pair(long a, long b) { first = a; second = b; } public int compareTo(Object other) { Pair p1 = (Pair) other; return (int)(this.first - ((Pair) other).first); // IDの値に従い昇順で並び替えたい場合 // return -(this.first - ((Pair) other).first); // IDの値に従い降順で並び替えたい場合 } } /*以下はテンプレ*/ public static void main(String args[]) { OutputStream outputStream = System.out; PrintWriter out = new PrintWriter(outputStream); FastScanner in = new FastScanner(); solve(out, in); out.close(); } public static class FastScanner { private final InputStream in = System.in; private final byte[] buffer = new byte[1024]; private int ptr = 0; private int bufferLength = 0; private boolean hasNextByte() { if (ptr < bufferLength) { return true; } else { ptr = 0; try { bufferLength = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (bufferLength <= 0) { return false; } } return true; } private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1; } private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126; } private void skipUnprintable() { while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; } boolean hasNext() { skipUnprintable(); return hasNextByte(); } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = readByte(); while (isPrintableChar(b)) { sb.appendCodePoint(b); b = readByte(); } return sb.toString(); } long nextLong() { if (!hasNext()) throw new NoSuchElementException(); long n = 0; boolean minus = false; int b = readByte(); if (b == '-') { minus = true; b = readByte(); } if (b < '0' || '9' < b) { throw new NumberFormatException(); } while (true) { if ('0' <= b && b <= '9') { n *= 10; n += b - '0'; } else if (b == -1 || !isPrintableChar(b)) { return minus ? -n : n; } else { throw new NumberFormatException(); } b = readByte(); } } double nextDouble() { return Double.parseDouble(next()); } double[] nextDoubleArray(int n) { double[] array = new double[n]; for (int i = 0; i < n; i++) { array[i] = nextDouble(); } return array; } double[][] nextDoubleMap(int n, int m) { double[][] map = new double[n][]; for (int i = 0; i < n; i++) { map[i] = nextDoubleArray(m); } return map; } public int nextInt() { return (int) nextLong(); } public int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; i++) array[i] = nextInt(); return array; } public long[] nextLongArray(int n) { long[] array = new long[n]; for (int i = 0; i < n; i++) array[i] = nextLong(); return array; } public String[] nextStringArray(int n) { String[] array = new String[n]; for (int i = 0; i < n; i++) array[i] = next(); return array; } public char[][] nextCharMap(int n) { char[][] array = new char[n][]; for (int i = 0; i < n; i++) array[i] = next().toCharArray(); return array; } public int[][] nextIntMap(int n, int m) { int[][] map = new int[n][]; for (int i = 0; i < n; i++) { map[i] = nextIntArray(m); } return map; } } }
Main.java:2: error: package ARC.Tools does not exist import ARC.Tools.PriorityQue; ^ 1 error
s889882074
p03972
C++
#include <string> #include <vector> #include <map> #include <set> #include <cassert> #include <iostream> #include <algorithm> #include <sstream> #include <list> using namespace std; void read(int &w){ cin >> w; } int main(int argc, char * argv [] ) { /** 4 3 2 4 8 1 2 9 3 https://code-festival-2016-qualb.contest.atcoder.jp/submit?task_id=2081 */ int w, h; cin >> w >> h; vector<long long> p(w); vector<long long> q(h); for_each(p.begin(), p.end(), read); for_each(q.begin(), q.end(), read); sort(p.begin(), p.end()); sort(q.begin(), q.end()); long long sum = 0; for (int i = 0, j = 0; i != w || j != h;) { if (i < w && j < h) { if (p.at(i) < q.at(j)) { sum += p.at(i++) * (h - j + 1); } else { sum += q.at(j++) * (w - i + 1); } } else if (i < w) { sum += p.at(i++) * (h - j + 1); } else { sum += q.at(j++) * (w - i + 1); } } cout << sum << endl; return 0; }
In file included from /usr/include/c++/14/algorithm:61, from a.cc:7: /usr/include/c++/14/bits/stl_algo.h: In instantiation of '_Funct std::for_each(_IIter, _IIter, _Funct) [with _IIter = __gnu_cxx::__normal_iterator<long long int*, vector<long long int> >; _Funct = void (*)(int&)]': a.cc:35:13: required from here 35 | for_each(p.begin(), p.end(), read); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:3786:12: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'long long int' 3786 | __f(*__first); | ~~~^~~~~~~~~~
s731121976
p03972
C++
/* *************************************** Author :Scau.ion Created Time :2016/10/10 19:56:54 UTC+8 File Name :ion.cpp *************************************** */ #include <bits/stdc++.h> #define LL long long #define ULL unsigned long long #define PB push_back #define MP make_pair #define PII pair<int,int> #define VI vector<int> #define VPII vector<PII> #define X first #define Y second #define IOS ios::sync_with_stdio(0);cin.tie(0); #define IN freopen("in", "r", stdin); #define OUT freopen("out", "w", stdout); using namespace std; const int maxn=200010; struct edge { int val; bool ty; operator <(const edge &b)const { return val<b.val; } }ed[maxn]; int main() { int n[2]; scanf("%d%d",&n[0],&n[1]); int nn=n[0]+n[1]; for (int j=1;j<=n[0];++j) { scanf("%d",&ed[j].val); ed[j].ty=0; } for (int j=1;j<=n[1];++j) { scanf("%d",&ed[n[0]+j].val); ed[n[0]+j].ty=1; } sort(ed+1,ed+nn+1); LL ans=0; for (int j=1;j<=nn;++j) { ans+=1LL*ed[j].val*(n[!(ed[j].ty)]+1); --n[(ed[j].ty)]; } cout<<ans<<endl; return 0; }
a.cc:30:5: error: ISO C++ forbids declaration of 'operator<' with no type [-fpermissive] 30 | operator <(const edge &b)const | ^~~~~~~~
s886159835
p03972
C++
#include <iostream> #include <vector> #include <string> #include <queue> #define INT_MAX = 100000001; using namespace std; struct node { int x; int y; int dis; node* p; node(int _x, int _y, int d) :x(_x), y(_y), dis(d), p(NULL){}; }; struct com { bool operator()(node x, node y) { return x.dis > y.dis; } }; int main() { int w, h; cin >> w >> h; vector<int>p; vector<int>q; for (int i = 0; i < w; ++i) { int temp; cin >> temp; p.push_back(temp); } for (int i = 0; i < h; ++i) { int temp; cin >> temp; q.push_back(temp); } int res = 0; priority_queue < node, vector<node>, com> heap; vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); for (int i = 0; i <= w; ++i) { for (int j = 0; j <= h; ++j) { node temp(i, j, INT_MAX); arr[i][j] = temp; } } arr[0][0].dis = 0; node cur = arr[0][0]; heap.push(cur); vector<vector<bool> >flag(w+1, vector<bool>(h+1, false)); //flag[0][0] = true; int count = 0; while (count < (h+1) * (w+1)) { cur = heap.top(); heap.pop(); if (flag[cur.x][cur.y]) continue; count++; //cout << cur.x << cur.y << endl; flag[cur.x][cur.y] = true; if(!(cur.x == 0&& cur.y == 0)) res += cur.dis; if (cur.x > 0) { if (arr[cur.x - 1][cur.y].dis > p[cur.x - 1]) { arr[cur.x - 1][cur.y].dis = p[cur.x - 1]; arr[cur.x - 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x - 1][cur.y]); } if(cur.x < w) { if (arr[cur.x + 1][cur.y].dis > p[cur.x]) { arr[cur.x + 1][cur.y].dis = p[cur.x]; arr[cur.x + 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x + 1][cur.y]); } if (cur.y < h) { if(arr[cur.x][cur.y + 1].dis > q[cur.y]); { arr[cur.x][cur.y + 1].dis = q[cur.y]; arr[cur.x][cur.y + 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y+1]); } if (cur.y > 0) { if (arr[cur.x][cur.y - 1].dis > q[cur.y - 1]) { arr[cur.x][cur.y - 1].dis = q[cur.y - 1]; arr[cur.x][cur.y - 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y - 1]); } } cout << res; cin.get(); return 0; }
a.cc: In function 'int main()': a.cc:43:51: error: expected primary-expression before '(' token 43 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^ a.cc:43:60: error: expected primary-expression before '(' token 43 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^ a.cc:6:17: error: expected primary-expression before '=' token 6 | #define INT_MAX = 100000001; | ^ a.cc:43:67: note: in expansion of macro 'INT_MAX' 43 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^~~~~~~ a.cc:43:74: error: expected primary-expression before ')' token 43 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^ a.cc:6:17: error: expected primary-expression before '=' token 6 | #define INT_MAX = 100000001; | ^ a.cc:48:41: note: in expansion of macro 'INT_MAX' 48 | node temp(i, j, INT_MAX); | ^~~~~~~ a.cc:48:48: error: expected primary-expression before ')' token 48 | node temp(i, j, INT_MAX); | ^
s499301618
p03972
C++
#include <iostream> #include <vector> #include <string> #include <queue> using namespace std; struct node { int x; int y; int dis; node* p; node(int _x, int _y, int d) :x(_x), y(_y), dis(d), p(NULL){}; }; struct com { bool operator()(node x, node y) { return x.dis > y.dis; } }; int main() { int w, h; cin >> w >> h; vector<int>p; vector<int>q; for (int i = 0; i < w; ++i) { int temp; cin >> temp; p.push_back(temp); } for (int i = 0; i < h; ++i) { int temp; cin >> temp; q.push_back(temp); } int res = 0; priority_queue < node, vector<node>, com> heap; vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); for (int i = 0; i <= w; ++i) { for (int j = 0; j <= h; ++j) { node temp(i, j, INT_MAX); arr[i][j] = temp; } } arr[0][0].dis = 0; node cur = arr[0][0]; heap.push(cur); vector<vector<bool> >flag(w+1, vector<bool>(h+1, false)); //flag[0][0] = true; int count = 0; while (count < (h+1) * (w+1)) { cur = heap.top(); heap.pop(); if (flag[cur.x][cur.y]) continue; count++; //cout << cur.x << cur.y << endl; flag[cur.x][cur.y] = true; if(!(cur.x == 0&& cur.y == 0)) res += cur.dis; if (cur.x > 0) { if (arr[cur.x - 1][cur.y].dis > p[cur.x - 1]) { arr[cur.x - 1][cur.y].dis = p[cur.x - 1]; arr[cur.x - 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x - 1][cur.y]); } if(cur.x < w) { if (arr[cur.x + 1][cur.y].dis > p[cur.x]) { arr[cur.x + 1][cur.y].dis = p[cur.x]; arr[cur.x + 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x + 1][cur.y]); } if (cur.y < h) { if(arr[cur.x][cur.y + 1].dis > q[cur.y]); { arr[cur.x][cur.y + 1].dis = q[cur.y]; arr[cur.x][cur.y + 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y+1]); } if (cur.y > 0) { if (arr[cur.x][cur.y - 1].dis > q[cur.y - 1]) { arr[cur.x][cur.y - 1].dis = q[cur.y - 1]; arr[cur.x][cur.y - 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y - 1]); } } cout << res; cin.get(); return 0; }
a.cc: In function 'int main()': a.cc:42:67: error: 'INT_MAX' was not declared in this scope 42 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <queue> +++ |+#include <climits> 5 |
s109180890
p03972
C++
#include<vector> #include<random> #include<stack> #include<sstream> #include<list> #include<iomanip> #include<numeric> #include<algorithm> #include<map> #include<cstdlib> #include<string> #include<cstring> #include<cstdio> #include<limits> #include<cmath> #include<deque> #include<iostream> #include<unordered_map> #include<unordered_set> #include<queue> using namespace std; template<typename T> void pprintv(T arr) { for(int i=0;i<arr.size();++i) { cout<<arr[i]<<" "; } cout<<endl; } typedef pair<int,int> point; struct edge { point end; int weight; edge(point e,int w):end(e),weight(w){} }; bool operator<(const edge& a,const edge& b) { return a.weight>b.weight; } void solve() { int w,h; cin>>w>>h; vector<int>pw; vector<int>qh; vector<vector<bool>>used(w+1,vector<bool>(h+1,false)); std::priority_queue<edge> pq; pq.push(edge(point(0,0),point(0,0),0)); long long result=0; for(int i=0;i<w;++i) { int t; cin>>t; pw.push_back(t); } for(int i=0;i<h;++i) { int t; cin>>t; qh.push_back(t); } int counter=0; for(;counter<(w+1)*(h+1);) { if(used[pq.top().end.first][pq.top().end.second]) { pq.pop(); continue; } result+=pq.top().weight; used[pq.top().end.first][pq.top().end.second]=true; int ii=pq.top().end.first; int jj=pq.top().end.second; pq.pop(); if(ii>0&&!used[ii-1][jj])pq.push(edge(point(ii-1,jj),pw[ii-1])); if(jj>0&&!used[ii][jj-1])pq.push(edge(point(ii,jj-1),qh[jj-1])); if(ii<w&&!used[ii+1][jj])pq.push(edge(point(ii+1,jj),pw[ii])); if(jj<h&&!used[ii][jj+1])pq.push(edge(point(ii,jj+1),qh[jj])); ++counter; } cout<<result; } int main() { //freopen("input","r",stdin); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:55:45: error: no matching function for call to 'edge::edge(point, point, int)' 55 | pq.push(edge(point(0,0),point(0,0),0)); | ^ a.cc:37:9: note: candidate: 'edge::edge(point, int)' 37 | edge(point e,int w):end(e),weight(w){} | ^~~~ a.cc:37:9: note: candidate expects 2 arguments, 3 provided a.cc:33:8: note: candidate: 'constexpr edge::edge(const edge&)' 33 | struct edge | ^~~~ a.cc:33:8: note: candidate expects 1 argument, 3 provided a.cc:33:8: note: candidate: 'constexpr edge::edge(edge&&)' a.cc:33:8: note: candidate expects 1 argument, 3 provided
s605715577
p03972
C++
#include <iostream> #include <vector> #include <string> #include <queue> using namespace std; struct node { int x; int y; int dis; node* p; node(int _x, int _y, int d) :x(_x), y(_y), dis(d), p(NULL){}; }; struct com { bool operator()(node x, node y) { return x.dis > y.dis; } }; int main() { int w, h; cin >> w >> h; vector<int>p; vector<int>q; for (int i = 0; i < w; ++i) { int temp; cin >> temp; p.push_back(temp); } for (int i = 0; i < h; ++i) { int temp; cin >> temp; q.push_back(temp); } int res = 0; priority_queue < node, vector<node>, com> heap; vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); for (int i = 0; i <= w; ++i) { for (int j = 0; j <= h; ++j) { node temp(i, j, INT_MAX); arr[i][j] = temp; } } node cur = arr[0][0]; cur.dis = 0; heap.push(cur); vector<vector<bool> >flag(w+1, vector<bool>(h+1, false)); //flag[0][0] = true; int count = 0; int pre = 0; while (count < (h+1) * (w+1)) { cur = heap.top(); heap.pop(); if (flag[cur.x][cur.y]) continue; count++; flag[cur.x][cur.y] = true; if(cur.x != 0&& cur.y != 0) res += cur.dis - cur.p->dis; if (cur.x > 0) { if (arr[cur.x - 1][cur.y].dis > cur.dis + p[cur.x - 1]) { arr[cur.x - 1][cur.y].dis = cur.dis + p[cur.x - 1]; arr[cur.x - 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x - 1][cur.y]); } if(cur.x < w) { if (arr[cur.x + 1][cur.y].dis > cur.dis + p[cur.x]) { arr[cur.x + 1][cur.y].dis = cur.dis + p[cur.x]; arr[cur.x + 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x + 1][cur.y]); } if (cur.y < h) { if(arr[cur.x][cur.y + 1].dis > cur.dis + q[cur.y]); { arr[cur.x][cur.y + 1].dis = cur.dis + q[cur.y]; arr[cur.x][cur.y + 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y+1]); } if (cur.y > 0) { if (arr[cur.x][cur.y - 1].dis, cur.dis + q[cur.y - 1]) { arr[cur.x][cur.y - 1].dis = cur.dis + q[cur.y - 1]; arr[cur.x][cur.y - 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y - 1]); } } cout << res; cin.get(); return 0; }
a.cc: In function 'int main()': a.cc:42:67: error: 'INT_MAX' was not declared in this scope 42 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <queue> +++ |+#include <climits> 5 |
s792158375
p03972
C++
#include <iostream> #include <vector> #include <string> #include <queue> using namespace std; struct node { int x; int y; int dis; node* p; node(int _x, int _y, int d) :x(_x), y(_y), dis(d), p(NULL){}; }; struct com { bool operator()(node x, node y) { return x.dis > y.dis; } }; int main() { int w, h; cin >> w >> h; vector<int>p; vector<int>q; for (int i = 0; i < w; ++i) { int temp; cin >> temp; p.push_back(temp); } for (int i = 0; i < h; ++i) { int temp; cin >> temp; q.push_back(temp); } int res = 0; priority_queue < node, vector<node>, com> heap; vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); for (int i = 0; i <= w; ++i) { for (int j = 0; j <= h; ++j) { node temp(i, j, INT_MAX); arr[i][j] = temp; } } node cur = arr[0][0]; cur.dis = 0; heap.push(cur); vector<vector<bool> >flag(w+1, vector<bool>(h+1, false)); //flag[0][0] = true; int count = 0; int pre = 0; while (count < (h+1) * (w+1)) { cur = heap.top(); heap.pop(); if (flag[cur.x][cur.y]) continue; count++; flag[cur.x][cur.y] = true; res += cur.dis - cur.p->dis; if (cur.x > 0) { if (arr[cur.x - 1][cur.y].dis > cur.dis + p[cur.x - 1]) { arr[cur.x - 1][cur.y].dis = cur.dis + p[cur.x - 1]; arr[cur.x - 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x - 1][cur.y]); } if(cur.x < w) { if (arr[cur.x + 1][cur.y].dis > cur.dis + p[cur.x]) { arr[cur.x + 1][cur.y].dis = cur.dis + p[cur.x]; arr[cur.x + 1][cur.y].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x + 1][cur.y]); } if (cur.y < h) { if(arr[cur.x][cur.y + 1].dis > cur.dis + q[cur.y]); { arr[cur.x][cur.y + 1].dis = cur.dis + q[cur.y]; arr[cur.x][cur.y + 1].p = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y+1]); } if (cur.y > 0) { if (arr[cur.x][cur.y - 1].dis, cur.dis + q[cur.y - 1]) { arr[cur.x][cur.y - 1].dis = cur.dis + q[cur.y - 1]; arr[cur.x][cur.y - 1].dis = &arr[cur.x][cur.y]; } heap.push(arr[cur.x][cur.y - 1]); } } cout << res; cin.get(); return 0; }
a.cc: In function 'int main()': a.cc:42:67: error: 'INT_MAX' was not declared in this scope 42 | vector<vector<node> >arr(w+1, vector<node>(h+1,node(0, 0, INT_MAX))); | ^~~~~~~ a.cc:5:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 4 | #include <queue> +++ |+#include <climits> 5 | a.cc:99:61: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<node>, node>::value_type*' {aka 'node*'} to 'int' [-fpermissive] 99 | arr[cur.x][cur.y - 1].dis = &arr[cur.x][cur.y];
s289010583
p03972
C++
#include <iostream> #include <set> #include <algorithm> using namespace std; int main() { #define int long long int W, H; cin >> W >> H; set<pair<int, bool>> S; for (int i = 0; i < W; i++) { int k; cin >> k; S.insert(make_pair(k, true)); } for (int i = 0; i < H; i++) { int k; cin >> k; S.insert(make_pair(k, false)); } long long res = 0; W++; H++; while (!S.empty()) { auto it = S.begin(); if (it->second) { res += max(H, 0) * it->first; W--; } else { res += max(W, 0) * it->first; H--; } S.erase(S.begin()); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:28:23: error: no matching function for call to 'max(long long int&, int)' 28 | res += max(H, 0) * it->first; | ~~~^~~~~~ 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:28:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 28 | res += max(H, 0) * it->first; | ~~~^~~~~~ /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:28:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 28 | res += max(H, 0) * it->first; | ~~~^~~~~~ a.cc:31:23: error: no matching function for call to 'max(long long int&, int)' 31 | res += max(W, 0) * it->first; | ~~~^~~~~~ /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:31:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 31 | res += max(W, 0) * it->first; | ~~~^~~~~~ /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:31:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 31 | res += max(W, 0) * it->first; | ~~~^~~~~~
s745506972
p03972
C++
#include <iostream> #include <set> #include <algorithm> using namespace std; int main() { #define int long long; int W, H; cin >> W >> H; set<pair<int, bool>> S; for (int i = 0; i < W; i++) { int k; cin >> k; S.insert(make_pair(k, true)); } for (int i = 0; i < H; i++) { int k; cin >> k; S.insert(make_pair(k, false)); } long long res = 0; W++; H++; while (!S.empty()) { auto it = S.begin(); if (it->second) { res += max(H, 0) * it->first; W--; } else { res += max(W, 0) * it->first; H--; } S.erase(S.begin()); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:8:21: error: declaration does not declare anything [-fpermissive] 8 | #define int long long; | ^~~~ a.cc:9:5: note: in expansion of macro 'int' 9 | int W, H; | ^~~ a.cc:9:9: error: 'W' was not declared in this scope 9 | int W, H; | ^ a.cc:9:12: error: 'H' was not declared in this scope 9 | int W, H; | ^ a.cc:8:21: error: wrong number of template arguments (1, should be 2) 8 | #define int long long; | ^~~~ a.cc:11:14: note: in expansion of macro 'int' 11 | set<pair<int, bool>> S; | ^~~ In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair' 3013 | struct pair; | ^~~~ a.cc:11:9: error: template argument 1 is invalid 11 | set<pair<int, bool>> S; | ^ a.cc:11:9: error: template argument 2 is invalid a.cc:11:9: error: template argument 3 is invalid a.cc:11:17: error: expected primary-expression before ',' token 11 | set<pair<int, bool>> S; | ^ a.cc:11:19: error: expected primary-expression before 'bool' 11 | set<pair<int, bool>> S; | ^~~~ a.cc:8:21: error: declaration does not declare anything [-fpermissive] 8 | #define int long long; | ^~~~ a.cc:12:10: note: in expansion of macro 'int' 12 | for (int i = 0; i < W; i++) { | ^~~ a.cc:12:14: error: 'i' was not declared in this scope 12 | for (int i = 0; i < W; i++) { | ^ a.cc:12:26: error: expected ')' before ';' token 12 | for (int i = 0; i < W; i++) { | ~ ^ | ) a.cc:12:28: error: 'i' was not declared in this scope 12 | for (int i = 0; i < W; i++) { | ^ a.cc:8:21: error: declaration does not declare anything [-fpermissive] 8 | #define int long long; | ^~~~ a.cc:17:10: note: in expansion of macro 'int' 17 | for (int i = 0; i < H; i++) { | ^~~ a.cc:17:26: error: expected ')' before ';' token 17 | for (int i = 0; i < H; i++) { | ~ ^ | ) a.cc:25:13: error: 'S' was not declared in this scope 25 | while (!S.empty()) { | ^
s735654982
p03972
C++
#include <iostream> #include <set> #include <algorithm> using namespace std; int main() { #define int long long; int W, H; cin >> W >> H; set<pair<int, bool>> S; for (int i = 0; i < W; i++) { int k; cin >> k; S.insert(make_pair(k, true)); } for (int i = 0; i < H; i++) { int k; cin >> k; S.insert(make_pair(k, false)); } long long res = 0; W++; H++; while (!S.empty()) { auto it = S.begin(); if (it->second) { res += max(H, 0) * it->first; W--; } else { res += max(W, 0) * it->first; H--; } S.erase(S.begin()); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:8:21: error: declaration does not declare anything [-fpermissive] 8 | #define int long long; | ^~~~ a.cc:9:5: note: in expansion of macro 'int' 9 | int W, H; | ^~~ a.cc:9:9: error: 'W' was not declared in this scope 9 | int W, H; | ^ a.cc:9:12: error: 'H' was not declared in this scope 9 | int W, H; | ^ a.cc:8:21: error: wrong number of template arguments (1, should be 2) 8 | #define int long long; | ^~~~ a.cc:11:14: note: in expansion of macro 'int' 11 | set<pair<int, bool>> S; | ^~~ In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair' 3013 | struct pair; | ^~~~ a.cc:11:9: error: template argument 1 is invalid 11 | set<pair<int, bool>> S; | ^ a.cc:11:9: error: template argument 2 is invalid a.cc:11:9: error: template argument 3 is invalid a.cc:11:17: error: expected primary-expression before ',' token 11 | set<pair<int, bool>> S; | ^ a.cc:11:19: error: expected primary-expression before 'bool' 11 | set<pair<int, bool>> S; | ^~~~ a.cc:8:21: error: declaration does not declare anything [-fpermissive] 8 | #define int long long; | ^~~~ a.cc:12:10: note: in expansion of macro 'int' 12 | for (int i = 0; i < W; i++) { | ^~~ a.cc:12:14: error: 'i' was not declared in this scope 12 | for (int i = 0; i < W; i++) { | ^ a.cc:12:26: error: expected ')' before ';' token 12 | for (int i = 0; i < W; i++) { | ~ ^ | ) a.cc:12:28: error: 'i' was not declared in this scope 12 | for (int i = 0; i < W; i++) { | ^ a.cc:8:21: error: declaration does not declare anything [-fpermissive] 8 | #define int long long; | ^~~~ a.cc:17:10: note: in expansion of macro 'int' 17 | for (int i = 0; i < H; i++) { | ^~~ a.cc:17:26: error: expected ')' before ';' token 17 | for (int i = 0; i < H; i++) { | ~ ^ | ) a.cc:25:13: error: 'S' was not declared in this scope 25 | while (!S.empty()) { | ^
s358774471
p03972
C++
#include <iostream> #include <set> #include <algorithm> using namespace std; #define int long long; int main() { int W, H; cin >> W >> H; set<pair<int, bool>> S; for (int i = 0; i < W; i++) { int k; cin >> k; S.insert(make_pair(k, true)); } for (int i = 0; i < H; i++) { int k; cin >> k; S.insert(make_pair(k, false)); } long long res = 0; W++; H++; while (!S.empty()) { auto it = S.begin(); if (it->second) { res += max(H, 0) * it->first; W--; } else { res += max(W, 0) * it->first; H--; } S.erase(S.begin()); } cout << res << endl; }
a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:9:1: note: in expansion of macro 'int' 9 | int main() { | ^~~ a.cc:9:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 9 | int main() { | ^~~~ a.cc: In function 'int main()': a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:10:5: note: in expansion of macro 'int' 10 | int W, H; | ^~~ a.cc:10:9: error: 'W' was not declared in this scope 10 | int W, H; | ^ a.cc:10:12: error: 'H' was not declared in this scope 10 | int W, H; | ^ a.cc:7:18: error: wrong number of template arguments (1, should be 2) 7 | #define int long long; | ^~~~ a.cc:12:14: note: in expansion of macro 'int' 12 | set<pair<int, bool>> S; | ^~~ In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:3013:12: note: provided for 'template<class _T1, class _T2> struct std::pair' 3013 | struct pair; | ^~~~ a.cc:12:9: error: template argument 1 is invalid 12 | set<pair<int, bool>> S; | ^ a.cc:12:9: error: template argument 2 is invalid a.cc:12:9: error: template argument 3 is invalid a.cc:12:17: error: expected primary-expression before ',' token 12 | set<pair<int, bool>> S; | ^ a.cc:12:19: error: expected primary-expression before 'bool' 12 | set<pair<int, bool>> S; | ^~~~ a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:13:10: note: in expansion of macro 'int' 13 | for (int i = 0; i < W; i++) { | ^~~ a.cc:13:14: error: 'i' was not declared in this scope 13 | for (int i = 0; i < W; i++) { | ^ a.cc:13:26: error: expected ')' before ';' token 13 | for (int i = 0; i < W; i++) { | ~ ^ | ) a.cc:13:28: error: 'i' was not declared in this scope 13 | for (int i = 0; i < W; i++) { | ^ a.cc:7:18: error: declaration does not declare anything [-fpermissive] 7 | #define int long long; | ^~~~ a.cc:18:10: note: in expansion of macro 'int' 18 | for (int i = 0; i < H; i++) { | ^~~ a.cc:18:26: error: expected ')' before ';' token 18 | for (int i = 0; i < H; i++) { | ~ ^ | ) a.cc:26:13: error: 'S' was not declared in this scope 26 | while (!S.empty()) { | ^
s618734121
p03972
C++
#include <bits/stdc++.h> /* Karen {{{ ___ ____ |_ ||_ _| | |_/ / ,--. _ .--. .---. _ .--. | __'. `'_\ : [ `/'`\]/ /__\\[ `.-. | _| | \ \_ // | |, | | | \__., | | | | |____||____|\'-;__/[___] '.__.'[___||__] }}} */ /* cpp template {{{*/ using namespace std; #define endl '\n' #define REP(i, n) for (int i = 0; i < (n); i++) #define REPS(i, a, n) for (int i = (a); i < (n); i++) #define RREP(i, n) for (int i = 1; i <= (n); i++) #define X real() #define Y imag() #define EQ(n,m) (abs((n)-(m)) < EPS) #define pb push_back #define mp make_pair #define fi first #define se second #define ALL(v) v.begin(), v.end() typedef double D; typedef long long ll; typedef long double lb; typedef complex<D> P; typedef vector<P> VP; typedef vector<int> vi; typedef vector<vector<int> > vii; typedef pair<int, int> pii; typedef pair<int, string> pis; typedef pair<string, int> psi; inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);} inline int in() {int x; std::cin >> x; return x;} template <typename T> void print(std::vector<T>& v, char c = ' ') { REP(i, v.size()) { if (i != 0) std::cout << c; std::cout << v[i]; } std::cout << endl; } template <typename T> void print(T x) { std::cout << x << '\n'; } /* }}} */ /* 定数 {{{*/ const ll MOD = 1e9 + 7; const ll INF = 1e9 + 9; const D EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; /* }}} */ // {{{ const ll MAX_H = 1e5, MAX_W = 1e5; const ll MAX_N = MAX_H * MAX_W; struct UnionFind { ll par[MAX_N]; /* 初期化 */ void init(int n) { for (int i = 0; i < n; i++) par[i] = i; } /* root(一番上)を返す */ int root(int x) { return ((x == par[x]) ? (x) : (par[x] = root(par[x]))); } /* yの下にxをぶら下げる */ void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; par[x] = y; } /* xとyのrootが同じであればtrueを返す */ bool same(int x, int y) { return root(x) == root(y); } }uf; // }}} int ans; #define int long long signed main() { cin.tie(0); ios::sync_with_stdio(false); UnionFind uf; int w = in(), h = in(); vector<pair<int, pair<bool, int> > > cost; for (int i = 0; i < w; i++){ int p = in(); cost.pb(mp(p, mp(true, i))); } for (int i = 0; i < h; i++){ int q = in(); cost.pb(mp(q, mp(false, i))); } h++; w++; uf.init(h * w); sort(ALL(cost)); for (int i = 0; i < h + w - 2; i++){ //cout << cost[i].first << endl; bool f = cost[i].se.fi; for (int j = 0; j < (f?w:h) + 1; ++j){ if (f){ if (!uf.same(cost[i].se.se * w + j + 1, (cost[i].se.se + 1) * w + j + 1)){ cout << cost[i].se.se * w + j + 1 << ":" << (cost[i].se.se + 1) * w + j + 1 << " " << cost[i].fi << endl; ans += cost[i].fi; uf.unite(cost[i].se.se * w + j + 1, (cost[i].se.se + 1) * w + j + 1); } } else { if (!uf.same(j * w + cost[i].se.se + 1, j * w + cost[i].se.se + 2)){ cout << j * w + cost[i].se.se + 1 << ":" << j * w + cost[i].se.se + 2 << " " << cost[i].fi << endl; ans += cost[i].fi; uf.unite(j * w + cost[i].se.se + 1, j * w + cost[i].se.se + 2); } } } } cout << ans << endl; }
/tmp/ccGSOFws.o: in function `main': a.cc:(.text+0x4e5): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGSOFws.o a.cc:(.text+0x4ed): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGSOFws.o a.cc:(.text+0x74a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGSOFws.o a.cc:(.text+0x752): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGSOFws.o a.cc:(.text+0x832): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccGSOFws.o collect2: error: ld returned 1 exit status
s951299853
p03972
C++
#include <bits/stdc++.h> /* Karen {{{ ___ ____ |_ ||_ _| | |_/ / ,--. _ .--. .---. _ .--. | __'. `'_\ : [ `/'`\]/ /__\\[ `.-. | _| | \ \_ // | |, | | | \__., | | | | |____||____|\'-;__/[___] '.__.'[___||__] }}} */ /* cpp template {{{*/ using namespace std; #define endl '\n' #define REP(i, n) for (int i = 0; i < (n); i++) #define REPS(i, a, n) for (int i = (a); i < (n); i++) #define RREP(i, n) for (int i = 1; i <= (n); i++) #define X real() #define Y imag() #define EQ(n,m) (abs((n)-(m)) < EPS) #define pb push_back #define mp make_pair #define fi first #define se second #define ALL(v) v.begin(), v.end() typedef double D; typedef long long ll; typedef long double lb; typedef complex<D> P; typedef vector<P> VP; typedef vector<int> vi; typedef vector<vector<int> > vii; typedef pair<int, int> pii; typedef pair<int, string> pis; typedef pair<string, int> psi; inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);} inline int in() {int x; std::cin >> x; return x;} template <typename T> void print(std::vector<T>& v, char c = ' ') { REP(i, v.size()) { if (i != 0) std::cout << c; std::cout << v[i]; } std::cout << endl; } template <typename T> void print(T x) { std::cout << x << '\n'; } /* }}} */ /* 定数 {{{*/ const ll MOD = 1e9 + 7; const ll INF = 1e9 + 9; const D EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; /* }}} */ // {{{ const ll MAX_H = 1e5, MAX_W = 1e5; const ll MAX_N = MAX_H * MAX_W; struct UnionFind { ll par[MAX_N]; /* 初期化 */ void init(int n) { for (int i = 0; i < n; i++) par[i] = i; } /* root(一番上)を返す */ int root(int x) { return ((x == par[x]) ? (x) : (par[x] = root(par[x]))); } /* yの下にxをぶら下げる */ void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; par[x] = y; } /* xとyのrootが同じであればtrueを返す */ bool same(int x, int y) { return root(x) == root(y); } }uf; // }}} int ans; #define int long long signed main() { cin.tie(0); ios::sync_with_stdio(false); int w = in(), h = in(); vector<pair<int, pair<bool, int> > > cost; for (int i = 0; i < w; i++){ int p = in(); cost.pb(mp(p, mp(true, i))); } for (int i = 0; i < h; i++){ int q = in(); cost.pb(mp(q, mp(false, i))); } h++; w++; uf.init(h * w); sort(ALL(cost)); for (int i = 0; i < h + w - 2; i++){ //cout << cost[i].first << endl; bool f = cost[i].se.fi; for (int j = 0; j < (f?w:h) + 1; ++j){ if (f){ if (!uf.same(cost[i].se.se * w + j + 1, (cost[i].se.se + 1) * w + j + 1)){ cout << cost[i].se.se * w + j + 1 << ":" << (cost[i].se.se + 1) * w + j + 1 << " " << cost[i].fi << endl; ans += cost[i].fi; uf.unite(cost[i].se.se * w + j + 1, (cost[i].se.se + 1) * w + j + 1); } } else { if (!uf.same(j * w + cost[i].se.se + 1, j * w + cost[i].se.se + 2)){ cout << j * w + cost[i].se.se + 1 << ":" << j * w + cost[i].se.se + 2 << " " << cost[i].fi << endl; ans += cost[i].fi; uf.unite(j * w + cost[i].se.se + 1, j * w + cost[i].se.se + 2); } } } } cout << ans << endl; return (0); }
/tmp/ccxPnRCF.o: in function `main': a.cc:(.text+0x395): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxPnRCF.o a.cc:(.text+0x39d): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxPnRCF.o a.cc:(.text+0x58a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxPnRCF.o a.cc:(.text+0x592): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxPnRCF.o a.cc:(.text+0x650): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccxPnRCF.o collect2: error: ld returned 1 exit status
s156559642
p03972
C++
#include <bits/stdc++.h> /* Karen {{{ ___ ____ |_ ||_ _| | |_/ / ,--. _ .--. .---. _ .--. | __'. `'_\ : [ `/'`\]/ /__\\[ `.-. | _| | \ \_ // | |, | | | \__., | | | | |____||____|\'-;__/[___] '.__.'[___||__] }}} */ /* cpp template {{{*/ using namespace std; #define endl '\n' #define REP(i, n) for (int i = 0; i < (n); i++) #define REPS(i, a, n) for (int i = (a); i < (n); i++) #define RREP(i, n) for (int i = 1; i <= (n); i++) #define X real() #define Y imag() #define EQ(n,m) (abs((n)-(m)) < EPS) #define pb push_back #define mp make_pair #define fi first #define se second #define ALL(v) v.begin(), v.end() typedef double D; typedef long long ll; typedef long double lb; typedef complex<D> P; typedef vector<P> VP; typedef vector<int> vi; typedef vector<vector<int> > vii; typedef pair<int, int> pii; typedef pair<int, string> pis; typedef pair<string, int> psi; inline bool inside(int y,int x,int H,int W){return(y>=0&&x>=0&&y<H&&x<W);} inline int in() {int x; std::cin >> x; return x;} template <typename T> void print(std::vector<T>& v, char c = ' ') { REP(i, v.size()) { if (i != 0) std::cout << c; std::cout << v[i]; } std::cout << endl; } template <typename T> void print(T x) { std::cout << x << '\n'; } /* }}} */ /* 定数 {{{*/ const ll MOD = 1e9 + 7; const ll INF = 1e9 + 9; const D EPS = 1e-9; const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}; const int dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; /* }}} */ // {{{ const ll MAX_H = 1e5, MAX_W = 1e5; const ll MAX_N = MAX_H * MAX_W; struct UnionFind { ll par[MAX_N]; /* 初期化 */ void init(int n) { for (int i = 0; i < n; i++) par[i] = i; } /* root(一番上)を返す */ int root(int x) { return ((x == par[x]) ? (x) : (par[x] = root(par[x]))); } /* yの下にxをぶら下げる */ void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; par[x] = y; } /* xとyのrootが同じであればtrueを返す */ bool same(int x, int y) { return root(x) == root(y); } }uf; // }}} int ans; #define int long long signed main() { cin.tie(0); ios::sync_with_stdio(false); int w = in(), h = in(); vector<pair<int, pair<bool, int> > > cost; for (int i = 0; i < w; i++){ int p = in(); cost.pb(mp(p, mp(true, i))); } for (int i = 0; i < h; i++){ int q = in(); cost.pb(mp(q, mp(false, i))); } h++; w++; uf.init(h * w); sort(ALL(cost)); for (int i = 0; i < h + w - 2; i++){ //cout << cost[i].first << endl; bool f = cost[i].se.fi; for (int j = 0; j < (f?w:h) + 1; ++j){ if (f){ if (!uf.same(cost[i].se.se * w + j + 1, (cost[i].se.se + 1) * w + j + 1)){ cout << cost[i].se.se * w + j + 1 << ":" << (cost[i].se.se + 1) * w + j + 1 << " " << cost[i].fi << endl; ans += cost[i].fi; uf.unite(cost[i].se.se * w + j + 1, (cost[i].se.se + 1) * w + j + 1); } } else { if (!uf.same(j * w + cost[i].se.se + 1, j * w + cost[i].se.se + 2)){ cout << j * w + cost[i].se.se + 1 << ":" << j * w + cost[i].se.se + 2 << " " << cost[i].fi << endl; ans += cost[i].fi; uf.unite(j * w + cost[i].se.se + 1, j * w + cost[i].se.se + 2); } } } } cout << ans << endl; }
/tmp/ccDyy3Rk.o: in function `main': a.cc:(.text+0x395): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccDyy3Rk.o a.cc:(.text+0x39d): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccDyy3Rk.o a.cc:(.text+0x58a): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccDyy3Rk.o a.cc:(.text+0x592): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccDyy3Rk.o a.cc:(.text+0x650): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccDyy3Rk.o collect2: error: ld returned 1 exit status
s161194516
p03972
C++
123123
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 123123 | ^~~~~~
s413866898
p03972
C++
#include <iostream> using namespace std; int main() { long W,H; int cost=0; int lastcost=-1; long long *P=new long long[W]; long long *Q=new long long[H]; cin >> W>>H; int **data = new int*[W+1]; for(int i=0;i<W+1;i++){ data[i] = new int [H+1]; } for(int i=0;i<W;i++){ cin >> P[i]; } for(int i=0;i<H;i++){ cin >> Q[i]; } for(int i=0;i<W+1;i++){ for(int c=0;c<H+1;c++){ data[i][c]=0; } } for(int ii=0;ii<W+1;ii++){ for(int cc=0;cc<H+1;cc++){ for(int i=0;i<W+1;i++){ for(int c=0;c<H+1;c++){ data[i][c]=0; } } data[ii][cc]=1; while(1){ int tmpi=-1; int tmpc=-1; long long tmpcost=100000001; int dir=0; for(int i=0;i<W+1;i++){ for(int c=0;c<H+1;c++){ if(data[i][c]==1){ if(i>0){ if(data[i-1][c]==0){ if(P[i-1]<tmpcost){tmpcost=P[i-1];dir=1;tmpi=i;tmpc=c;} } } if(i<W){ if(data[i+1][c]==0){ if(P[i]<tmpcost){tmpcost=P[i];dir=2;tmpi=i;tmpc=c;} } } if(c>0){ if(data[i][c-1]==0){ if(Q[c-1]<tmpcost){tmpcost=Q[c-1];dir=3;}tmpi=i;tmpc=c;} } } if(c<H){ if(data[i][c+1]==0){ if(Q[i]<tmpcost){tmpcost=Q[i];dir=4;tmpi=i;tmpc=c;} } } if(tmpcost!=100000001){ if(dir==1) data[tmpi-1][tmpc]=1; else if(dir==2)data[tmpi+1][tmpc]=1; else if(dir==3)data[tmpi][tmpc-1]=1; else if(dir==4)data[tmpi][tmpc+1]=1; cost+=tmpcost; tmpcost=100000001;dir=0; } } } } int check = 0; for(int i=0;i<W+1;i++){ for(int c=0;c<H+1;c++){ if(data[i][c]==0)check=1; } } if(check==0)break; } if(ii==0&&cc==0)lastcost=cost; else{ if(lastcost>cost)lastcost=cost; } //cout<<ii<<cc<<":"<<cost<<endl;/////////////////////////////// cost=0; } } cout<<lastcost<<endl; for(int i=0;i<W+1;i++){ delete[] data[i];data[i]=0; } delete [] data; return 0; }
a.cc: In function 'int main()': a.cc:102:17: error: 'cc' was not declared in this scope 102 | if(ii==0&&cc==0)lastcost=cost; | ^~ a.cc: At global scope: a.cc:112:3: error: 'cout' does not name a type 112 | cout<<lastcost<<endl; | ^~~~ a.cc:113:3: error: expected unqualified-id before 'for' 113 | for(int i=0;i<W+1;i++){ | ^~~ a.cc:113:15: error: 'i' does not name a type 113 | for(int i=0;i<W+1;i++){ | ^ a.cc:113:21: error: 'i' does not name a type 113 | for(int i=0;i<W+1;i++){ | ^ a.cc:116:3: error: expected unqualified-id before 'delete' 116 | delete [] data; | ^~~~~~ a.cc:117:3: error: expected unqualified-id before 'return' 117 | return 0; | ^~~~~~ a.cc:118:1: error: expected declaration before '}' token 118 | } | ^
s530576615
p03972
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a) ;i < (b) ;i++) #define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) int main(){ int w, h, p[100000], q[100000] ; cin >> w >> h ; rep(i, 0, w)cin>>p[i] ; rep(j, 0, h)cin>>q[j] ; long ans = 0, added = 0 ; sort(q,q+h,greater<int>()); sort(p,p+w,greater<int>()); int i = 0 ,j = 0 ; while(!(i >= w) && !(j >= h){ if (i < w && p[i] <= q[j]){ ans += (h + 1 - j) * long (p[i]) ; i++ ; }else{ ans += (w + 1 - i) * long (q[j]) ; j++ ; } } cout<<ans<<endl ; return 0 ; }
a.cc: In function 'int main()': a.cc:17:37: error: expected ')' before '{' token 17 | while(!(i >= w) && !(j >= h){ | ~ ^ | )
s618191537
p03972
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<cstring> #include<vector> #include<map> #include<list> #include<stack> #include<queue> #include<climits> //INT_MIN/MAX using namespace std; #define FOR(i,s,e) for(int (i)=(s);(i)<(e);(i)++) #define FORR(i,s,e) for(int (i)=(s);(i)>(e);(i)--) #define MOD 1000000007 #define llong long long #define debug(x) cout<<#x<<": "<<x<<endl int main() { cin.tie(0); ios_base::sync_with_stdio(false); int W,H; int p[100005], q[100005]; llong int ans = 0; cin >> W>>H; for (int i = 0; i < W; i++) { int num; cin >> num; p[i] = num; } llong int Hnum = 0; for (int i = 0; i < H; i++) { int num; cin >> num; q[i] = num; Hnum += num; } sort(p, p+W); llong int sum[100005]; sum[0] = 0; int t = 0; for (int i = 0; i < W; i++) { sum[i] = t + p[i];// t = sum[i]; } ans = Hnum*W+sum[W - 1]*(H+1); for (int i = 0; i < H; i++) { int it = *lower_bound(p.begin(), p.end(), q[i]); ans = ans-q[i]*it+sum[it]; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:57:33: error: request for member 'begin' in 'p', which is of non-class type 'int [100005]' 57 | int it = *lower_bound(p.begin(), p.end(), q[i]); | ^~~~~ a.cc:57:44: error: request for member 'end' in 'p', which is of non-class type 'int [100005]' 57 | int it = *lower_bound(p.begin(), p.end(), q[i]); | ^~~
s337059258
p03972
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; #define N 1000000001 #define inf 0x3f3f3f3f #define M 10001 vector<pair<int, int> > graph; int wei_x[M]; int wei_y[M]; int weight[N]; int visit[N]; int n, m; int dir[8] = {1, 0, 0, 1, -1, 0, 0, -1}; bool is_ok(int x, int y) { if (x >= 0 && x < n && y >= 0 && y < m && visit[x * n + y] == 0) return true; return false; } void update(int x, int y) { if (is_ok(x - 1, y + 0)) { if (weight[x * n + y] + wei_x[x - 1] < weight[(x - 1) * n + y + 0]) { weight[(x - 1) * n + y + 0] = weight[x * n + y] + wei_x[x - 1]; } } if (is_ok(x + 1, y + 0)) { if (weight[x * n + y] + wei_x[x] < weight[(x + 1) * n + y + 0]) { weight[(x + 1) * n + y + 0] = weight[x * n + y] + wei_x[x]; } } if (is_ok(x + 0, y - 1)) { if (weight[x * n + y] + wei_y[y - 1] < weight[(x + 0) * n + y - 1]) { weight[(x + 0) * n + y - 1] = weight[x * n + y] + wei_y[y - 1]; } } if (is_ok(x + 0, y + 1)) { if (weight[x * n + y] + wei_y[y] < weight[(x + 0) * n + y + 1]) { weight[(x + 0) * n + y + 1] = weight[x * n + y] + wei_y[y]; } } } int choose(int &x, int &y) { int min_v = inf; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (min_v > weight[i *n + j] && visit[i * n + j] == 0) { min_v = weight[i * n + j]; x = i; y = j; } } } return min_v; } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", &wei_x[i]); for (int j = 0; j < m; j++) scanf("%d", &wei_y[j]); n++; m++; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { weight[i * n + j] = inf; } } int vx = 0, vy = 0; int pre_x = vx; int pre_y = vy; weight[vx *n + vy] = 0; visit[vx * n + vy] = 1; update(vx, vy); int k = 1; int min_cos = 0; while (k < n * m) { int x, y; choose(x, y); if (pre_x + 1 == x) { min_cos += wei_x[pre_x]; } else if (pre_x = x + 1) { min_cos += wei_x[x]; } else if (pre_y + 1 == y) { min_cos = wei_y[pre_y]; } else if (y + 1 == pre_y) { min_cos = wei_y[y]; } pre_x = x; pre_y = y; visit[x * n + y] = 1; update(x, y); k++; } cout << min_cos << endl; return 0; }
/tmp/ccD0qqgR.o: in function `is_ok(int, int)': a.cc:(.text+0x12): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/ccD0qqgR.o /tmp/ccD0qqgR.o: in function `update(int, int)': a.cc:(.text+0x8d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x17e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x1c3): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccD0qqgR.o a.cc:(.text+0x1e9): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s915182696
p03972
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; #define N 1000000001 #define inf 0x3f3f3f3f #define M 10001 vector<pair<int, int> > graph; int wei_x[M]; int wei_y[M]; int weight[N]; int visit[N]; int n, m; int dir[8] = {1, 0, 0, 1, -1, 0, 0, -1}; bool is_ok(int x, int y) { if (x >= 0 && x < n && y >= 0 && y < m && visit[x * n + y] == 0) return true; return false; } void update(int x, int y) { if (is_ok(x - 1, y + 0)) { if (weight[x * n + y] + wei_x[x - 1] < weight[(x - 1) * n + y + 0]) { weight[(x - 1) * n + y + 0] = weight[x * n + y] + wei_x[x - 1]; } } if (is_ok(x + 1, y + 0)) { if (weight[x * n + y] + wei_x[x] < weight[(x + 1) * n + y + 0]) { weight[(x + 1) * n + y + 0] = weight[x * n + y] + wei_x[x]; } } if (is_ok(x + 0, y - 1)) { if (weight[x * n + y] + wei_y[y - 1] < weight[(x + 0) * n + y - 1]) { weight[(x + 0) * n + y - 1] = weight[x * n + y] + wei_y[y - 1]; } } if (is_ok(x + 0, y + 1)) { if (weight[x * n + y] + wei_y[y] < weight[(x + 0) * n + y + 1]) { weight[(x + 0) * n + y + 1] = weight[x * n + y] + wei_y[y]; } } } int choose(int &x, int &y) { int min_v = inf; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { if (min_v > weight[i *n + j] && visit[i * n + j] == 0) { min_v = weight[i * n + j]; x = i; y = j; } } } return min_v; } int main() { scanf("%d%d", &n, &m); for (int i = 0; i < n; i++) scanf("%d", &wei_x[i]); for (int j = 0; j < m; j++) scanf("%d", &wei_y[j]); n++; m++; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { weight[i * n + j] = inf; } } int vx = 0, vy = 0; int pre_x = vx; int pre_y = vy; weight[vx *n + vy] = 0; visit[vx * n + vy] = 1; update(vx, vy); int k = 1; int min_cos = 0; while (k < n * m) { int x, y; choose(x, y); if (pre_x + 1 == x) { min_cos += wei_x[pre_x]; } else if (pre_x = x + 1) { min_cos += wei_x[x]; } else if (pre_y + 1 == y) { min_cos = wei_y[pre_y]; } else if (y + 1 == pre_y) { min_cos = wei_y[y]; } pre_x = x; pre_y = y; visit[x * n + y] = 1; update(x, y); k++; } cout << min_cos << endl; return 0; }
/tmp/cc8KEjg6.o: in function `is_ok(int, int)': a.cc:(.text+0x12): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against symbol `m' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x2e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x4a): relocation truncated to fit: R_X86_64_PC32 against symbol `visit' defined in .bss section in /tmp/cc8KEjg6.o /tmp/cc8KEjg6.o: in function `update(int, int)': a.cc:(.text+0x8d): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0xd5): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0xfb): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x140): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x17e): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x1c3): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/cc8KEjg6.o a.cc:(.text+0x1e9): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s540678512
p03972
C
#include <stdio.h> #include <stdlib.h> int main() { double W,H; int intW,intH,p[100000001],q[100000001],i,j=0,sum=0; // 整数の入力 scanf("%lf %lf\n",&W,&H); intW = round(W); intH = rounf(H); for(i=0;i<intW;i++) scanf("%d\n",&p[i]); for(i=0;i<intH;i++) scanf("%d\n",&q[i]); for(i=0;i<intW;i++) sum++ = p[i]; for(i=0;i<intH;i++) j++ = q[i]; sum ++ = j * W for(i=0;i<W-1;i++){ for(j=0;j<H-1;j++){ if(q[j] > p[j]){ sum = sum - q[j] + p[j] } } } // 出力 printf("%d\n",sum); return 0; }
main.c: In function 'main': main.c:11:12: error: implicit declaration of function 'round' [-Wimplicit-function-declaration] 11 | intW = round(W); | ^~~~~ main.c:3:1: note: include '<math.h>' or provide a declaration of 'round' 2 | #include <stdlib.h> +++ |+#include <math.h> 3 | int main() main.c:11:12: warning: incompatible implicit declaration of built-in function 'round' [-Wbuiltin-declaration-mismatch] 11 | intW = round(W); | ^~~~~ main.c:11:12: note: include '<math.h>' or provide a declaration of 'round' main.c:12:12: error: implicit declaration of function 'rounf' [-Wimplicit-function-declaration] 12 | intH = rounf(H); | ^~~~~ main.c:21:31: error: lvalue required as left operand of assignment 21 | for(i=0;i<intW;i++) sum++ = p[i]; | ^ main.c:22:29: error: lvalue required as left operand of assignment 22 | for(i=0;i<intH;i++) j++ = q[i]; | ^ main.c:23:12: error: lvalue required as left operand of assignment 23 | sum ++ = j * W | ^ main.c:23:19: error: expected ';' before 'for' 23 | sum ++ = j * W | ^ | ; ...... 27 | for(i=0;i<W-1;i++){ | ~~~
s147702049
p03972
C++
#include <iostream> #include <cstdio> #include <vector> #include <algorithm> #include <cstring> using namespace std; #define rep(l,n) for(int l = 0; l < (n); l++) #define rep2(i,k,n) for(int i = (k); i < (n); i++) inline void readInt2(int *a, int *b) { int c, p = 0; char s[20] = ""; for(int i = 0; (c = getchar()) != '\n'; ++i) { if (c == ' ') { *a = atoi(s); strcpy(s, ""); p = i+1; continue; } else s[i] = c; } *b = atoi(s+p); } /*inline void readInt3(int *a, int *b, int *c) { int d, p = 0; char s[20] = ""; for(int i = 0; (d = getchar()) != '\n'; i++) { if(d == ' ') { if(p == 0) { *a = atoi(s); strcpy(s, ""); p = i+1; } else {*b = atoi(s+p); strcpy(s, ""); p = i+1; } } else s[i] = d; } *c = atoi(s+p); }*/ inline void readInt(int *a) { int c; char s[20] = ""; for (int i = 0; (c = getchar()) != '\n'; ++i) s[i] = c; *a = atoi(s); } int parent[1000000], rank[100000]; void uf_init(int n); void unite(int x, int y); bool same(int x, int y); int find(int x); // kruskal struct edge { int u, v, cost; }; bool comp(const edge &e1, const edge &e2) { return e1.cost < e2.cost; } vector<edge> v; edge es; int N, M; // 頂点数と辺の数 int kruskal() { int res = 0; uf_init(N); sort(v.begin(), v.end(), comp); rep(i,M) { //cout << v[i].u << " " << v[i].v << " " << v[i].cost << endl; edge e = v[i]; if (!same(e.u, e.v)) { //cout << e.u << " " << e.v << endl; unite(e.u, e.v); res += e.cost; } } return res; } // Union Find void uf_init(int n) { rep(i,n+1) { parent[i] = i; rank[i] = 0; } } int find(int x) { if (parent[x] == x) return x; else return parent[x] = find(parent[x]); } void unite(int x, int y) { x = find(x); y = find(y); if(x == y) return; if (rank[x] < rank[y]) parent[x] = y; else { parent[y] = x; if(rank[x] == rank[y]) rank[x]++; } } bool same(int x, int y) { return find(x) == find(y); } int main(void) { int H, W, p, q; readInt2(&W, &H); N = (W+1) * (H+1); //cout << W << " " << H << endl; for (int i = 0; i < W; i++) { readInt(&p); rep(j,H+1) { edge e; e.u = i+j*(W+1); e.v = i+j*(W+1)+1; e.cost = p; v.push_back(e); } } for (int i = 0; i < H; i++) { readInt(&q); rep(j,W+1) { edge e; e.u = i*(W+1)+j; e.v = i*(W+1)+(W+1)+j; e.cost = q; v.push_back(e); } } M = W*(H+1) + H*(W+1); /*for (int i = 0; i < M; i++) { cout << v[i].u << " " << v[i].v << " " << v[i].cost << endl; }*/ printf("%d\n",kruskal()); return 0; }
a.cc: In function 'void uf_init(int)': a.cc:73:31: error: reference to 'rank' is ambiguous 73 | rep(i,n+1) { parent[i] = i; rank[i] = 0; } | ^~~~ In file included from /usr/include/c++/14/bits/move.h:37, from /usr/include/c++/14/bits/exception_ptr.h:41, from /usr/include/c++/14/exception:166, from /usr/include/c++/14/ios:41, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:22: note: 'int rank [100000]' 36 | int parent[1000000], rank[100000]; | ^~~~ a.cc: In function 'void unite(int, int)': a.cc:83:7: error: reference to 'rank' is ambiguous 83 | if (rank[x] < rank[y]) parent[x] = y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:22: note: 'int rank [100000]' 36 | int parent[1000000], rank[100000]; | ^~~~ a.cc:83:17: error: reference to 'rank' is ambiguous 83 | if (rank[x] < rank[y]) parent[x] = y; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:22: note: 'int rank [100000]' 36 | int parent[1000000], rank[100000]; | ^~~~ a.cc:86:8: error: reference to 'rank' is ambiguous 86 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:22: note: 'int rank [100000]' 36 | int parent[1000000], rank[100000]; | ^~~~ a.cc:86:19: error: reference to 'rank' is ambiguous 86 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:22: note: 'int rank [100000]' 36 | int parent[1000000], rank[100000]; | ^~~~ a.cc:86:28: error: reference to 'rank' is ambiguous 86 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:36:22: note: 'int rank [100000]' 36 | int parent[1000000], rank[100000]; | ^~~~
s672601770
p03972
C++
#include <iostream> #include <vector> #include <iterator> using namespace std; #define MAX 100000 int W,H; int numW=0,numH=0; int result=0; int p[100000],q[100000]; bool pairCompare(const std::pair<float, int>& firstElem, const std::pair<float, int>& secondElem) { return firstElem.second < secondElem.second; } int main(){ vector<pair<int,int> > pq; cin >> W >> H; for(int i=0;i<W;i++){cin >> p[i];} for(int i=0;i<H;i++){cin >> q[i];} for(int i=0;i<W;i++){ pq.push_back(make_pair(i,p[i])); } for(int i=0;i<H;i++){ pq.push_back(make_pair(i+W,q[i])); } sort(begin(pq), end(pq), pairCompare); for(int i = 0; i < H+W;i++){ if(pq[i].first<W){ //cout << pq[i].second <<"$"<<(W+1-numW)<<endl; result += pq[i].second*(H+1-numH); numW++; } else{ //cout << pq[i].second <<"$"<<(H+1-numH)<<endl; result += pq[i].second*(W+1-numW); numH++; } } cout << result << endl; }
a.cc: In function 'int main()': a.cc:30:3: error: 'sort' was not declared in this scope; did you mean 'short'? 30 | sort(begin(pq), end(pq), pairCompare); | ^~~~ | short
s153097498
p03972
C++
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a) ;i < (b) ;i++) #define repr(i, a, b) for (int i = (b) - 1 ;i >= a ;i--) int main(){ int w, h, p[100000], q[100000] ; cin >> w >> h ; rep(i, 0, w)cin>>p[i] ; rep(j, 0, h)cin>>q[j] ; long ans = 0, added = 0 ; sort(q,q+h,greater<int>()); sort(p,p+w,greater<int>()); int i = 0 ;j = 0 ; while(i < w && j <= h){ if (i < w && p[i] <= q[j]){ ans += (w + 1 - j) * long (p[i]) ; i++ ; }else{ ans += (h + 1 - j) * long (q[i]) ; j++ ; } } cout<<ans<<endl ; return 0 ; }
a.cc: In function 'int main()': a.cc:15:20: error: 'j' was not declared in this scope 15 | int i = 0 ;j = 0 ; | ^