submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s922792404
p03995
Java
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.NoSuchElementException; public class Main { int R,C,N; int[] r,c,a; long[] min; ArrayList<Edge>[][] graph; boolean[][] used; int[][] b; private class Edge{ int t,w; public Edge(int t,int w){ this.t = t; this.w = w; } } public void dfs(int type,int pos,long weight){ if(used[type&1][pos])return; used[type&1][pos] = true; b[type&1][pos] = weight; min[type&1] = Math.min(min[type&1],weight); for(Edge e : graph[type&1][pos]){ dfs((type+1)&1,e.t,e.w - weight); } } public void solve() { R = nextInt(); C = nextInt(); N = nextInt(); r = new int[N]; c = new int[N]; a = new int[N]; graph = new ArrayList[2][]; graph[0] = new ArrayList[R]; graph[1] = new ArrayList[C]; for(int i = 0;i < R;i++)graph[0][i] = new ArrayList<Edge>(); for(int i = 0;i < C;i++)graph[1][i] = new ArrayList<Edge>(); for(int i = 0;i < N;i++){ r[i] = nextInt() - 1; c[i] = nextInt() - 1; a[i] = nextInt(); graph[0][r[i]].add(new Edge(c[i],a[i])); graph[1][c[i]].add(new Edge(r[i],a[i])); } used = new boolean[2][]; used[0] = new boolean[R]; used[1] = new boolean[C]; b = new int[2][]; b[0] = new int[R]; b[1] = new int[C]; min = new long[2]; for(int i = 0;i < N;i++){ if(used[0][r[i]] || used[1][c[i]])continue; min[0] = Long.MAX_VALUE; min[1] = Long.MAX_VALUE; dfs(0,r[i],0); if(min[0] + min[1] < 0){ out.println("No"); return; } } for(int i = 0;i < N;i++){ if(a[i] == b[0][r[i]] + b[1][c[i]])continue; out.println("No"); return ; } out.println("Yes"); } public static void main(String[] args) { out.flush(); new Main().solve(); out.close(); } /* Input */ private static final InputStream in = System.in; private static final PrintWriter out = new PrintWriter(System.out); private final byte[] buffer = new byte[2048]; private int p = 0; private int buflen = 0; private boolean hasNextByte() { if (p < buflen) return true; p = 0; try { buflen = in.read(buffer); } catch (IOException e) { e.printStackTrace(); } if (buflen <= 0) return false; return true; } public boolean hasNext() { while (hasNextByte() && !isPrint(buffer[p])) { p++; } return hasNextByte(); } private boolean isPrint(int ch) { if (ch >= '!' && ch <= '~') return true; return false; } private int nextByte() { if (!hasNextByte()) return -1; return buffer[p++]; } public String next() { if (!hasNext()) throw new NoSuchElementException(); StringBuilder sb = new StringBuilder(); int b = -1; while (isPrint((b = nextByte()))) { sb.appendCodePoint(b); } return sb.toString(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } }
Main.java:24: error: incompatible types: possible lossy conversion from long to int b[type&1][pos] = weight; ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s870849838
p03995
C++
#include<bits/stdc++.h> using namespace std; typedef long long int64; const int64 INF = 1LL << 58; int main() { int H, W, N; vector< pair< int, int > > g[200000]; bool v[200000] = {}; int64 cost[200000]; scanf("%d %d", &H, &W); scanf("%d", &N); while(N--) { int x, y, z; scanf("%d %d %d", &x, &y, &z); --x, --y; g[x].emplace_back(H + y, z); g[H + y].emplace_back(x, z); } for(int i = 0; i < H + W; i++) { if(v[i]) continue; queue< int > que; int L = INF, R = INF; que.emplace(i); v[i] = true; cost[i] = 0; while(!que.empty()) { int idx = que.front(); que.pop(); if(idx < H) L = min(L, cost[idx]); else R = min(R, cost[idx]); for(auto& e : g[idx]) { if(v[e.first]++) { if(cost[idx] + cost[e.first] != e.second) { puts("No"); return (0); } } else { que.emplace(e.first); cost[e.first] = e.second - cost[idx]; } } } if(L + R < 0) { puts("No"); return (0); } } puts("Yes"); }
a.cc: In function 'int main()': a.cc:29:13: warning: overflow in conversion from 'long long int' to 'int' changes value from '288230376151711744' to '0' [-Woverflow] 29 | int L = INF, R = INF; | ^~~ a.cc:29:22: warning: overflow in conversion from 'long long int' to 'int' changes value from '288230376151711744' to '0' [-Woverflow] 29 | int L = INF, R = INF; | ^~~ a.cc:37:26: error: no matching function for call to 'min(int&, int64&)' 37 | if(idx < H) L = min(L, cost[idx]); | ~~~^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:37:26: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'int64' {aka 'long long int'}) 37 | if(idx < H) L = min(L, cost[idx]); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:37:26: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 37 | if(idx < H) L = min(L, cost[idx]); | ~~~^~~~~~~~~~~~~~ a.cc:38:19: error: no matching function for call to 'min(int&, int64&)' 38 | else R = min(R, cost[idx]); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:38:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'int64' {aka 'long long int'}) 38 | else R = min(R, cost[idx]); | ~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:38:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 38 | else R = min(R, cost[idx]); | ~~~^~~~~~~~~~~~~~ a.cc:40:21: error: use of an operand of type 'bool' in 'operator++' is forbidden in C++17 40 | if(v[e.first]++) { | ~~~~~~~~~^
s782566455
p03995
C++
#include <string> #include <queue> #include <stack> #include <vector> #include <sstream> #include <algorithm> #include <deque> #include <set> #include <map> #include <unordered_set> #include <unordered_map> #include <list> #include <cstdio> #include <iostream> #include <cmath> #include <climits> #include <bitset> #include <functional> #include <numeric> #include <ctime> #include <cassert> #include <cstring> #include <fstream> const long long MAX = 1e17; using namespace std; struct Edge { int to; int cost; }; bool saiki(int now, long long num, bool istate, pair<long long, long long> &minpair) { if (istate) { if (tated[now]) { if (tate[now] != num) { return false; } return true; } tated[now] = true, tate[now] = num; minpair.first = min(minpair.first, num); for (auto &t : tateedge[now]) { if (!saiki(t.to, t.cost - num, false, minpair)) return false; } return true; } else { if (yokod[now]) { if (yoko[now] != num) { return false; } return true; } yokod[now] = true, yoko[now] = num; minpair.second = min(minpair.second, num); for (auto &t : yokoedge[now]) { if (!saiki(t.to, t.cost - num, true, minpair)) return false; } return true; } } int main() { int R, C; cin >> R >> C; int N; cin >> N; vector<int> r(N), c(N), a(N); for (int i = 0; i < N; i++) { cin >> r[i] >> c[i] >> a[i]; r[i]--, c[i]--; } vector<vector<Edge>> tateedge, yokoedge; vector<long long> tate, yoko; vector<bool> tated, yokod; tateedge.resize(R); yokoedge.resize(C); tate.resize(R); yoko.resize(R); tated.resize(R, false); yokod.resize(C, false); for (int i = 0; i < N; i++) { tateedge[r[i]].push_back({ c[i], a[i] }); yokoedge[c[i]].push_back({ r[i], a[i] }); } bool res = true; for (int i = 0; i < R; i++) { pair<long long, long long> minp{ MAX,MAX }; if (tated[i] || tateedge[i].empty()) continue; if (!saiki(i, -100, true, minp)) { res = false; break; } if (minp.first + minp.second < 0) { res = false; break; } } cout << (res ? "Yes" : "No") << endl; return 0; }
a.cc: In function 'bool saiki(int, long long int, bool, std::pair<long long int, long long int>&)': a.cc:40:21: error: 'tated' was not declared in this scope 40 | if (tated[now]) { | ^~~~~ a.cc:41:29: error: 'tate' was not declared in this scope; did you mean 'istate'? 41 | if (tate[now] != num) { | ^~~~ | istate a.cc:46:17: error: 'tated' was not declared in this scope 46 | tated[now] = true, tate[now] = num; | ^~~~~ a.cc:46:36: error: 'tate' was not declared in this scope; did you mean 'istate'? 46 | tated[now] = true, tate[now] = num; | ^~~~ | istate a.cc:48:32: error: 'tateedge' was not declared in this scope 48 | for (auto &t : tateedge[now]) { | ^~~~~~~~ a.cc:55:21: error: 'yokod' was not declared in this scope 55 | if (yokod[now]) { | ^~~~~ a.cc:56:29: error: 'yoko' was not declared in this scope 56 | if (yoko[now] != num) { | ^~~~ a.cc:61:17: error: 'yokod' was not declared in this scope 61 | yokod[now] = true, yoko[now] = num; | ^~~~~ a.cc:61:36: error: 'yoko' was not declared in this scope 61 | yokod[now] = true, yoko[now] = num; | ^~~~ a.cc:63:32: error: 'yokoedge' was not declared in this scope 63 | for (auto &t : yokoedge[now]) { | ^~~~~~~~
s149406181
p03995
C++
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <cmath> #include <queue> #include <stack> #include <set> #include <map> #include <sstream> #include <string> #define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() #define mod 1000000007 #define mp make_pair #define pb push_back typedef long long ll; using namespace std; template <typename T> inline void output(T a, int p = 0) { if(p) cout << fixed << setprecision(p) << a << "\n"; else cout << a << "\n"; } // end of template const ll inf = 1LL << 60; struct node{ int r, c; ll n; }; vector<ll> row, col; map<node, int> M; vector<vector<node>> GR, GC; void dfs(node nd){ int r = nd.r, c = nd.c; ll n = nd.n; // cout << r << "," << c << "," << n << endl; // cout << row[r] << "," << col[c] << endl; if(M[nd]) return; M[nd] = 1; if(row[r] == inf && col[c] == inf){ row[r] = n, col[c] = 0; } else if(row[r] == inf){ row[r] = n - col[c]; } else if(col[c] == inf){ col[c] = n - row[r]; } else return; for(node nr: GR[r]){ dfs(nr); } for(node nc: GC[c]){ dfs(nc); } } int main() { cin.tie(0); ios::sync_with_stdio(0); // source code int R, C, N; cin >> R >> C >> N; row.resize(R + 1, inf), col.resize(C + 1, inf); GR.resize(R + 1), GC.resize(C + 1); rep(i, N){ int r, c; ll a; cin >> r >> c >> a; GR[r].pb({r, c, a}); GC[c].pb({r, c, a}); } rep(i, R + 1){ if(GR[i].size()){ for(node nd: GR[i]){ dfs(nd); } } } rep(i, C + 1){ if(GC[i].size()){ for(node nd: GC[i]){ dfs(nd); } } } rep(i, R + 1){ for(node nd: GR[i]){ // cout << row[nd.r] << "," << col[nd.c] << "," << nd.n << endl; if(row[nd.r] + col[nd.c] != nd.n){ output("No"); return 0; } } } ll row_min = inf, col_min = inf; rep(i, R + 1){ row_min = min(row_min, row[i]); } rep(i, C + 1){ col_min = min(col_min, col[i]); } if(row_min + col_min < 0){ output("No"); } else{ output("Yes"); } return 0; }
In file included from /usr/include/c++/14/string:49, 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_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = node]': /usr/include/c++/14/bits/stl_map.h:511:32: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = node; _Tp = int; _Compare = std::less<node>; _Alloc = std::allocator<std::pair<const node, int> >; mapped_type = int; key_type = node]' 511 | if (__i == end() || key_comp()(__k, (*__i).first)) | ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ a.cc:45:12: required from here 45 | if(M[nd]) return; | ^ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const node' and 'const node') 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const node' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const node' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const node' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const node' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s116025063
p03995
C++
#include <iostream> #include <iomanip> #include <vector> #include <algorithm> #include <numeric> #include <functional> #include <cmath> #include <queue> #include <stack> #include <set> #include <map> #include <sstream> #include <string> #define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repd(i,0,n) #define all(x) (x).begin(),(x).end() #define mod 1000000007 #define inf 100000000000000000 #define mp make_pair #define pb push_back typedef long long ll; using namespace std; template <typename T> inline void output(T a, int p = 0) { if(p) cout << fixed << setprecision(p) << a << "\n"; else cout << a << "\n"; } // end of template struct node{ int r, c; ll n; }; vector<ll> row, col; vector<vector<node>> GR, GC; void dfs(node nd){ int r = nd.r, c = nd.c; ll n = nd.n; if(row[r] == inf && col[c] == inf){ row[r] = n, col[c] = 0; } else if(row[r] == inf){ row[r] = n - col[c]; } else if(col[c] == inf){ col[c] = n - row[r]; } else return; for(node nr: GR[r]){ dfs(nr); } for(node nc: GC[c]){ dfs(nc); } } int main() { cin.tie(0); ios::sync_with_stdio(0); // source code int R, C, N; cin >> R >> C >> N; row.resize(R + 1, inf), col.resize(C + 1, inf); GR.resize(R + 1), GC.resize(C + 1); rep(i, N){ int r, c, a; cin >> r >> c >> a; GR[r].pb({r, c, a}); GC[c].pb({r, c, a}); } rep(i, R + 1){ if(GR[i].size()){ for(node nd: GR[i]){ dfs(nd); } } } rep(i, C + 1){ if(GC[i].size()){ for(node nd: GC[i]){ dfs(nd); } } } rep(i, R + 1){ for(node nd: GR[i]){ if(row[nd.r] + col[nd.c] != nd.n){ output("No"); return 0; } } } int row_min = inf, col_min = inf; rep(i, R + 1){ row_min = min(row_min, row[i]); } rep(i, C + 1){ col_min = min(col_min, col[i]); } if(row_min + col_min < 0){ output("No"); } else{ output("Yes"); } return 0; }
a.cc: In function 'int main()': a.cc:18:13: warning: overflow in conversion from 'long int' to 'int' changes value from '100000000000000000' to '1569325056' [-Woverflow] 18 | #define inf 100000000000000000 | ^~~~~~~~~~~~~~~~~~ a.cc:101:19: note: in expansion of macro 'inf' 101 | int row_min = inf, col_min = inf; | ^~~ a.cc:18:13: warning: overflow in conversion from 'long int' to 'int' changes value from '100000000000000000' to '1569325056' [-Woverflow] 18 | #define inf 100000000000000000 | ^~~~~~~~~~~~~~~~~~ a.cc:101:34: note: in expansion of macro 'inf' 101 | int row_min = inf, col_min = inf; | ^~~ a.cc:103:22: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 103 | row_min = min(row_min, row[i]); | ~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:103:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 103 | row_min = min(row_min, row[i]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:103:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 103 | row_min = min(row_min, row[i]); | ~~~^~~~~~~~~~~~~~~~~ a.cc:106:22: error: no matching function for call to 'min(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 106 | col_min = min(col_min, col[i]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:106:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 106 | col_min = min(col_min, col[i]); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:106:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 106 | col_min = min(col_min, col[i]); | ~~~^~~~~~~~~~~~~~~~~
s653088788
p03995
C++
#include <cstdio> #include <cstdlib> #include <algorithm> #include <vector> #include <cstring> #include <set> #include <queue> #define SIZE 100005 #define INF 1000000000000005LL using namespace std; typedef long long int ll; typedef pair <int,int> P; typedef pair <P,int> PP; struct edge { int to,cost; edge(int to=0,int cost=0):to(to),cost(cost){} }; vector <edge> vec[SIZE]; vector <P> query[SIZE]; ll mn[SIZE]; ll dist[SIZE]; bool use[SIZE]; int dp[SIZE]; int main() { int r,c; scanf("%d %d",&r,&c); int n; scanf("%d",&n); for(int i=0;i<c;i++) mn[i]=INF; for(int i=0;i<n;i++) { int x,y,a; scanf("%d %d %d",&x,&y,&a); x--,y--; query[x].push_back(P(y,a)); mn[y]=min(mn[y],a); } for(int i=0;i<r;i++) { for(int j=0;j+1<query[i].size();j++) { P p=query[i][j],q=query[i][j+1]; vec[p.first].push_back(edge(q.first,q.second-p.second)); vec[q.first].push_back(edge(p.first,p.second-q.second)); } } for(int i=0;i<c;i++) dist[i]=INF; for(int i=0;i<c;i++) { if(!use[i]) { dist[i]=0; queue <int> que; que.push(i); ll all=0,all2=mn[i]; while(!que.empty()) { int v=que.front();que.pop(); use[v]=true; all=min(all,dist[v]); all2=min(all2,mn[v]-dist[v]); for(int j=0;j<vec[v].size();j++) { edge e=vec[v][j]; if(dist[e.to]==INF) { dist[e.to]=dist[v]+e.cost; que.push(e.to); } else if(dist[e.to]!=dist[v]+e.cost) { puts("No"); return 0; } } } //Xj=Xi+dist[j] //Xj=Xk+dist[j]-dist[k] //-> (Xk-dist[k])+all で 0未 があればやばい if(all2+all<0) { puts("No"); return 0; } } } puts("Yes"); return 0; }
a.cc: In function 'int main()': a.cc:41:26: error: no matching function for call to 'min(ll&, int&)' 41 | mn[y]=min(mn[y],a); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from a.cc:3: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:41:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 41 | mn[y]=min(mn[y],a); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:41:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 41 | mn[y]=min(mn[y],a); | ~~~^~~~~~~~~
s477454006
p03995
C++
#include <iostream> #include <queue> #include <map> #include <list> #include <vector> #include <string> #include <stack> #include <limits> #include <cassert> #include <fstream> #include <cstring> #include <cmath> #include <bitset> #include <iomanip> #include <algorithm> #include <functional> #include <cstdio> #include <ciso646> #include <set> #include <array> using namespace std; #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define inf 0x3f3f3f3f #define PB push_back #define MP make_pair #define ALL(a) (a).begin(),(a).end() #define SET(a,c) memset(a,c,sizeof a) #define CLR(a) memset(a,0,sizeof a) #define pii pair<int,int> #define pcc pair<char,char> #define pic pair<int,char> #define pci pair<char,int> #define VS vector<string> #define VI vector<int> #define DEBUG(x) cout<<#x<<": "<<x<<endl #define MIN(a,b) (a>b?b:a) #define MAX(a,b) (a>b?a:b) #define pi 2*acos(0.0) #define INFILE() freopen("in0.txt","r",stdin) #define OUTFILE()freopen("out0.txt","w",stdout) #define ll long long #define ull unsigned long long #define eps 1e-14 #define FST first #define SEC second #define SETUP cin.tie(0), ios::sync_with_stdio(false), cout << setprecision(15) namespace { struct input_returnner { int N; input_returnner(int N_ = 0) :N(N_) {} template<typename T> operator vector<T>() const { vector<T> res(N); for (auto &a : res) cin >> a; return std::move(res); } template<typename T> operator T() const { T res; cin >> res; return res; } template<typename T> T operator - (T right) { return T(input_returnner()) - right; } template<typename T> T operator + (T right) { return T(input_returnner()) + right; } template<typename T> T operator * (T right) { return T(input_returnner()) * right; } template<typename T> T operator / (T right) { return T(input_returnner()) / right; } template<typename T> T operator << (T right) { return T(input_returnner()) << right; } template<typename T> T operator >> (T right) { return T(input_returnner()) >> right; } }; template<typename T> input_returnner in() { return in<T>(); } input_returnner in() { return input_returnner(); } input_returnner in(int N) { return std::move(input_returnner(N)); } } void solve(); /// ---template--- signed main(void) { SETUP; solve(); return 0; } int dx[] = {1,0,-1,0}; int dy[] = {0,-1,0,1}; const ll INF = LLONG_MAX / 2 - 1; struct Edge { ll t; ll c; Edge(ll to, ll cost):t(to),c(cost){} Edge(){} }; vector<ll> weigh; ll R, C; bool DFS(ll node, vector<vector<Edge> >& edge, ll& xmin, ll& ymin) { for (auto &to : edge[node]) { if (weigh[to.t] == INF) { weigh[to.t] = to.c - weigh[node]; if (to.t < R) xmin = min(xmin, weigh[to.t]); else ymin = min(ymin, weigh[to.t]); if (not DFS(to.t, edge, xmin, ymin)) return false; } else { if (weigh[to.t] + weigh[node] != to.c) return false; } } return true; } void solve() { cin >> R >> C; ll N = in(); weigh.resize(R + C, INF); vector<vector<Edge> > edge(R+C); REP(i, N) { ll r, c, a; cin >> r >> c >> a; --r; --c; edge[r].emplace_back(R+c,a); edge[R+c].emplace_back(r, a); } bool res = true; ll xmin, ymin; REP(i, R + C) if(weigh[i] == INF and edge[i].size() > 0) { xmin = ymin = numeric_limits<int>::max(); weigh[i] = 0; if (not DFS(i,edge,xmin,ymin) or xmin+ymin < 0) { cout << "No" << endl; return; } } cout << "Yes" << endl; }
a.cc:82:16: error: 'LLONG_MAX' was not declared in this scope 82 | const ll INF = LLONG_MAX / 2 - 1; | ^~~~~~~~~ a.cc:20:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 19 | #include <set> +++ |+#include <climits> 20 | #include <array>
s741497154
p03995
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) #define FOR(i,k,n) for(int i=(k);i<(int)(n);++i) typedef long long int ll; using namespace std; int R, C, N; int wr[100001], wc[100001]; struct E{ int to, cost; E(int t, int c): to(t), cost(c) {}; }; vector<E> edge_r[100001], edge_c[100001]; int rmin, cmin; bool dfs(int v) { if(v < R) { rmin = min(rmin, wr[v]); REP(i, edge_r[v].size()) { E e = edge_r[v][i]; if(wc[e.to] != -1) { if(wr[v]+wc[e.to]!=e.cost) return false; } else { wc[e.to] = e.cost - wr[v]; if(!dfs(e.to+R)) return false; } } } else { v -= R; cmin = min(cmin, wc[v]); REP(i, edge_c[v].size()) { E e = edge_c[v][i]; if(wr[e.to] != -1) { if(wc[v]+wr[e.to]!=e.cost) return false; } else { wr[e.to] = e.cost - wc[v]; if(!dfs(e.to)) return false; } } } return true; } int main(void) { int tr, tc, ta; cin >> R >> C >> N; REP(i, R) wr[i] = -1; REP(i, C) wc[i] = -1; REP(i, N) { cin >> tr >> tc >> ta; tr--; tc--; edge_r[tr].push_back(E(tc, ta)); edge_c[tc].push_back(E(tr, ta)); } REP(i, R) { if(wr[i] != -1 || edge_r[i].size() == 0) continue; wr[i] = 0; rmin = numeric_limits<int>::max(); cmin = numeric_limits<int>::max(); if(!dfs(i) || rmin+cmin < 0) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }#include <bits/stdc++.h> #define REP(i,n) for(int i=0; i<(int)(n); ++i) #define FOR(i,k,n) for(int i=(k);i<(int)(n);++i) typedef long long int ll; using namespace std; int R, C, N; int wr[100001], wc[100001]; struct E{ int to, cost; E(int t, int c): to(t), cost(c) {}; }; vector<E> edge_r[100001], edge_c[100001]; int rmin, cmin; bool dfs(int v) { if(v < R) { rmin = min(rmin, wr[v]); REP(i, edge_r[v].size()) { E e = edge_r[v][i]; if(wc[e.to] != -1) { if(wr[v]+wc[e.to]!=e.cost) return false; } else { wc[e.to] = e.cost - wr[v]; if(!dfs(e.to+R)) return false; } } } else { v -= R; cmin = min(cmin, wc[v]); REP(i, edge_c[v].size()) { E e = edge_c[v][i]; if(wr[e.to] != -1) { if(wc[v]+wr[e.to]!=e.cost) return false; } else { wr[e.to] = e.cost - wc[v]; if(!dfs(e.to)) return false; } } } return true; } int main(void) { int tr, tc, ta; cin >> R >> C >> N; REP(i, R) wr[i] = -1; REP(i, C) wc[i] = -1; REP(i, N) { cin >> tr >> tc >> ta; tr--; tc--; edge_r[tr].push_back(E(tc, ta)); edge_c[tc].push_back(E(tr, ta)); } REP(i, R) { if(wr[i] != -1 || edge_r[i].size() == 0) continue; wr[i] = 0; rmin = numeric_limits<int>::max(); cmin = numeric_limits<int>::max(); if(!dfs(i) || rmin+cmin < 0) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
a.cc:73:2: error: stray '#' in program 73 | }#include <bits/stdc++.h> | ^ a.cc:73:3: error: 'include' does not name a type 73 | }#include <bits/stdc++.h> | ^~~~~~~ a.cc:81:5: error: redefinition of 'int R' 81 | int R, C, N; | ^ a.cc:9:5: note: 'int R' previously declared here 9 | int R, C, N; | ^ a.cc:81:8: error: redefinition of 'int C' 81 | int R, C, N; | ^ a.cc:9:8: note: 'int C' previously declared here 9 | int R, C, N; | ^ a.cc:81:11: error: redefinition of 'int N' 81 | int R, C, N; | ^ a.cc:9:11: note: 'int N' previously declared here 9 | int R, C, N; | ^ a.cc:82:5: error: redefinition of 'int wr [100001]' 82 | int wr[100001], wc[100001]; | ^~ a.cc:10:5: note: 'int wr [100001]' previously declared here 10 | int wr[100001], wc[100001]; | ^~ a.cc:82:17: error: redefinition of 'int wc [100001]' 82 | int wr[100001], wc[100001]; | ^~ a.cc:10:17: note: 'int wc [100001]' previously declared here 10 | int wr[100001], wc[100001]; | ^~ a.cc:84:8: error: redefinition of 'struct E' 84 | struct E{ | ^ a.cc:12:8: note: previous definition of 'struct E' 12 | struct E{ | ^ a.cc:88:11: error: redefinition of 'std::vector<E> edge_r [100001]' 88 | vector<E> edge_r[100001], edge_c[100001]; | ^~~~~~ a.cc:16:11: note: 'std::vector<E> edge_r [100001]' previously declared here 16 | vector<E> edge_r[100001], edge_c[100001]; | ^~~~~~ a.cc:88:27: error: redefinition of 'std::vector<E> edge_c [100001]' 88 | vector<E> edge_r[100001], edge_c[100001]; | ^~~~~~ a.cc:16:27: note: 'std::vector<E> edge_c [100001]' previously declared here 16 | vector<E> edge_r[100001], edge_c[100001]; | ^~~~~~ a.cc:89:5: error: redefinition of 'int rmin' 89 | int rmin, cmin; | ^~~~ a.cc:17:5: note: 'int rmin' previously declared here 17 | int rmin, cmin; | ^~~~ a.cc:89:11: error: redefinition of 'int cmin' 89 | int rmin, cmin; | ^~~~ a.cc:17:11: note: 'int cmin' previously declared here 17 | int rmin, cmin; | ^~~~ a.cc:91:6: error: redefinition of 'bool dfs(int)' 91 | bool dfs(int v) { | ^~~ a.cc:19:6: note: 'bool dfs(int)' previously defined here 19 | bool dfs(int v) { | ^~~ a.cc:120:5: error: redefinition of 'int main()' 120 | int main(void) { | ^~~~ a.cc:48:5: note: 'int main()' previously defined here 48 | int main(void) { | ^~~~
s115421015
p03995
C++
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cctype> #include <cstring> #include <ctime> #include <iterator> #include <bitset> #include <numeric> #include <list> #include <iomanip> #include <cassert> #include <array> #include <tuple> #include <initializer_list> #include <unordered_set> #include <unordered_map> #include <forward_list> using namespace std; using ll = long long; #define rep(j,n) for(int j = 0; j < (int)(n); ++j) #define int ll using pii = pair<int, int>; int h, w; int n; const int INF = 1e18; signed main() { cin.tie(0); ios::sync_with_stdio(0); while (cin >> h >> w >> n) { bool yes = true; vector<vector<pii>> hols((signed)h, {}), vers((signed)w, {}); vector<int> hol_min((signed)h, INF), ver_min((signed)w, INF); for (int i = 0; i < n; i++) { int ii, jj, a; cin >> ii >> jj; --ii; --jj; cin >> a; hols[ii].emplace_back(jj, a); vers[jj].emplace_back(ii, a); hol_min[ii] = min(hol_min[ii], a); ver_min[jj] = min(ver_min[jj], a); } vector<tuple<int, int, int>> hol_diff, ver_diff; for (int i = 0; i < h; i++) { sort(hols[i].begin(), hols[i].end()); } for (auto &hol : hols) { for (int i = 0; i < (int)hol.size() - 1; i++) { int j1 = hol[i].first; int j2 = hol[i + 1].first; int d = hol[i + 1].second - hol[i].second; hol_diff.emplace_back(j1, j2, d); } } for (int j = 0; j < w; j++) { sort(vers[j].begin(), vers[j].end()); } for (auto &ver : vers) { for (int j = 0; j < (int)ver.size() - 1; j++) { int i1 = ver[j].first; int i2 = ver[j + 1].first; int d = ver[j + 1].second - ver[j].second; ver_diff.emplace_back(i1, i2, d); } } sort(hol_diff.begin(), hol_diff.end()); sort(ver_diff.begin(), ver_diff.end()); vector<int> hol_rel(w + 1, -1); for (auto &t : hol_diff) { if (!yes) break; int j1, j2, d; tie(j1, j2, d) = t; assert(ver_min[j1] != INF); assert(ver_min[j2] != INF); if (hol_rel[j1] == -1) { hol_rel[j1] = ver_min[j1]; hol_rel[j2] = hol_rel[j1] + d; } if (hol_rel[j2] == -1) { hol_rel[j2] = hol_rel[j1] + d; } if (hol_rel[j1] + d != hol_rel[j2] || hol_rel[j1] < 0 || hol_rel[j2] < 0) { yes = false; } } vector<int> ver_rel(h + 1, -1); for (auto &t : hol_diff) { if (!yes) break; int i1, i2, d; tie(i1, i2, d) = t; assert(hol_min[i1] != INF); assert(hol_min[i2] != INF); if (ver_rel[i1] == -1) { ver_rel[i1] = hol_min[i1]; ver_rel[i1] = ver_rel[i1] + d; } if (ver_rel[i2] == -1) { ver_rel[i2] = ver_rel[i1] + d; } if (ver_rel[i1] + d != ver_rel[i2] || ver_rel[i1] < 0 || ver_rel[i2] < 0) { yes = false; } } cout << (yes ? "Yes" : "No") << endl; } }
a.cc: In function 'int main()': a.cc:55:47: error: call of overloaded 'vector(int, <brace-enclosed initializer list>)' is ambiguous 55 | vector<vector<pii>> hols((signed)h, {}), vers((signed)w, {}); | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:11: /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; value_type = std::vector<std::pair<long long int, long long int> >; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ a.cc:55:68: error: call of overloaded 'vector(int, <brace-enclosed initializer list>)' is ambiguous 55 | vector<vector<pii>> hols((signed)h, {}), vers((signed)w, {}); | ^ /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; value_type = std::vector<std::pair<long long int, long long int> >; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~
s210132357
p03995
C++
#include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <deque> #include <complex> #include <stack> #include <queue> #include <cstdio> #include <cctype> #include <cstring> #include <ctime> #include <iterator> #include <bitset> #include <numeric> #include <list> #include <iomanip> #include <cassert> #include <array> #include <tuple> #include <initializer_list> #include <unordered_set> #include <unordered_map> #include <forward_list> using namespace std; using ll = long long; #define rep(j,n) for(int j = 0; j < (int)(n); ++j) #define int ll using pii = pair<int, int>; int h, w; int n; const int INF = 1e18; signed main() { cin.tie(0); ios::sync_with_stdio(0); while (cin >> h >> w >> n) { bool yes = true; vector<vector<pii>> hols(h, {}), vers(w, {}); vector<int> hol_min(h, INF), ver_min(w, INF); for (int i = 0; i < n; i++) { int ii, jj, a; cin >> ii >> jj; --ii; --jj; cin >> a; hols[ii].emplace_back(jj, a); vers[jj].emplace_back(ii, a); hol_min[ii] = min(hol_min[ii], a); ver_min[jj] = min(ver_min[jj], a); } vector<tuple<int, int, int>> hol_diff, ver_diff; for (int i = 0; i < h; i++) { sort(hols[i].begin(), hols[i].end()); } for (auto &hol : hols) { for (int i = 0; i < (int)hol.size() - 1; i++) { int j1 = hol[i].first; int j2 = hol[i + 1].first; int d = hol[i + 1].second - hol[i].second; hol_diff.emplace_back(j1, j2, d); } } for (int j = 0; j < w; j++) { sort(vers[j].begin(), vers[j].end()); } for (auto &ver : vers) { for (int j = 0; j < (int)ver.size() - 1; j++) { int i1 = ver[j].first; int i2 = ver[j + 1].first; int d = ver[j + 1].second - ver[j].second; ver_diff.emplace_back(i1, i2, d); } } sort(hol_diff.begin(), hol_diff.end()); sort(ver_diff.begin(), ver_diff.end()); vector<int> hol_rel(w + 1, -1); for (auto &t : hol_diff) { if (!yes) break; int j1, j2, d; tie(j1, j2, d) = t; assert(ver_min[j1] != INF); assert(ver_min[j2] != INF); if (hol_rel[j1] == -1) { hol_rel[j1] = ver_min[j1]; hol_rel[j2] = hol_rel[j1] + d; } if (hol_rel[j2] == -1) { hol_rel[j2] = hol_rel[j1] + d; } if (hol_rel[j1] + d != hol_rel[j2] || hol_rel[j1] < 0 || hol_rel[j2] < 0) { yes = false; } } vector<int> ver_rel(h + 1, -1); for (auto &t : hol_diff) { if (!yes) break; int i1, i2, d; tie(i1, i2, d) = t; assert(hol_min[i1] != INF); assert(hol_min[i2] != INF); if (ver_rel[i1] == -1) { ver_rel[i1] = hol_min[i1]; ver_rel[i1] = ver_rel[i1] + d; } if (ver_rel[i2] == -1) { ver_rel[i2] = ver_rel[i1] + d; } if (ver_rel[i1] + d != ver_rel[i2] || ver_rel[i1] < 0 || ver_rel[i2] < 0) { yes = false; } } cout << (yes ? "Yes" : "No") << endl; } }
a.cc: In function 'int main()': a.cc:55:39: error: call of overloaded 'vector(ll&, <brace-enclosed initializer list>)' is ambiguous 55 | vector<vector<pii>> hols(h, {}), vers(w, {}); | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:11: /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; value_type = std::vector<std::pair<long long int, long long int> >; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ a.cc:55:52: error: call of overloaded 'vector(ll&, <brace-enclosed initializer list>)' is ambiguous 55 | vector<vector<pii>> hols(h, {}), vers(w, {}); | ^ /usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; value_type = std::vector<std::pair<long long int, long long int> >; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 569 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = std::vector<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::vector<std::pair<long long int, long long int> > >; size_type = long unsigned int; allocator_type = std::allocator<std::vector<std::pair<long long int, long long int> > >]' 556 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~
s948240875
p03995
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<pii,int> piii; typedef pair<ll,ll> pll; #define reps(i,f,n) for(int i = int(f); i <= int(n); i++) #define rep(i,n) reps(i,0,int(n)-1) #define rrep(i,n) for(int i = n-1; i >= 0; i--) #define all(x) (x).begin(),(x).end() #define X first #define Y second #define sz size() #define eb emplace_back #define pb push_back vector<pii> p[2][200000]; int u[2][200000]; int m[2]; const int INF=1000000000; bool dfs(int now, int to, int pos){ bool ret = true; rep(i, p[pos][to].sz){ int next = p[pos][to][i].X; int val = p[pos][to][i].Y; if(u[1-pos][next] == INF){ u[1-pos][next] = val-now; m[1-pos] = min(m[1-pos], u[1-pos][next]); ret &= dfs(u[1-pos][next], next, 1-pos); }else if(u[1-pos][next] != val-now){ return false; } } return ret; } int main(void){ int r,c,n; int x,y,a; cin >> r >> c; cin >> n; rep(i,n){ cin >> x >> y >> a; x--;y--; p[0][x].pb(make_pair(y,a));p[1][y].pb(make_pair(x,a)); } rep(i, r)u[0][i] = INF; rep(i, c)u[1][i] = INF; bool ret = true; bool r = true; rep(i,r){ if(u[0][i] == INF){ u[0][i] = 0; m[0] = 0;m[1] = INF; ret &= dfs(0, i, 0); if(m[0] + m[1] < 0)r = false; } } ret = true; rep(i,r){ rep(j, p[0][i].sz){ if( u[0][i] + u[1][p[0][i][j].X] == p[0][i][j].Y){ ret = false; } } } if(ret&r) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
a.cc: In function 'int main()': a.cc:60:8: error: conflicting declaration 'bool r' 60 | bool r = true; | ^ a.cc:46:7: note: previous declaration as 'int r' 46 | int r,c,n; | ^
s736212864
p03995
C++
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}}; #include <bits/stdc++.h> using namespace std; using i64 = long long; const i64 INF = 1e18; int R, C, N; const int MAX_V = 200010; vector<pair<int, i64>> adj[MAX_V]; bool used[MAX_V]; i64 weight[MAX_V]; void dfs(int cur_v, i64& minR, i64& minC) { used[cur_v] = true; for(const auto& e : adj[cur_v]) { int nxt_v; i64 cost tie(nxt_v, cost) = e; i64 w = cost - weight[cur_v]; if(used[nxt_v]) { if(w != weight[nxt_v]) minC = minR = -INF; continue; } weight[nxt_v] = w; if(nxt_v < R) minR = min(minR, w); else minC = min(minC, w); dfs(nxt_v, minR, minC); } } int main() { cin >> R >> C >> N; for(int _ : _in(N)) { int r, c; i64 x; cin >> r >> c >> x; --r; --c; c += R; adj[r].emplace_back(c, x); adj[c].emplace_back(r, x); } for(int i : _in(R)) if(!used[i]) { i64 minR = 0LL, minC = INF; weight[i] = 0LL; dfs(i, minR, minC); if(minC + minR < 0LL) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
a.cc: In function 'void dfs(int, i64&, i64&)': a.cc:18:9: error: expected initializer before 'tie' 18 | tie(nxt_v, cost) = e; | ^~~ a.cc:19:17: error: 'cost' was not declared in this scope; did you mean 'cosl'? 19 | i64 w = cost - weight[cur_v]; | ^~~~ | cosl
s260916677
p03995
C
//Task D /* Grid and Integers Magic Sum/REctangles */ #include <stdio.h> #include <stdlib.h> int main(){ int R, C; scanf("%d %d",&R,&C); int N; scanf("%d"&N); int r = 0; int c = 0; int a = 0; int** array = calloc(R,sizeof(int)); int x = 0; //generic counter while(x < C){ array[x] = calloc(C,sizeof(int)); x++; } x = 0; while(x < N){ scanf("%d %d %d",&r,&c,&a); array[r][c] = a; x++; } /* I want to see more cases (ie the soln/test cases) */ return EXIT_SUCCESS; }
main.c: In function 'main': main.c:13:15: error: invalid operands to binary & (have 'char *' and 'int') 13 | scanf("%d"&N); | ~~~~^ | | | char *
s621509649
p03995
C
//Task D /* Grid and Integers Magic Sum/REctangles */ #include <stdio.h> #include <stlib.h> int main(){ int R, C; scanf("%d %d",&R,&C); int N; scanf("%d"&N); int r = 0; int c = 0; int a = 0; int** array = calloc(R,sizeof(int)); int x = 0; //generic counter while(x < C){ array[x] = calloc(C,sizeof(int)); x++; } x = 0; while(x < N){ scanf("%d %d %d",&r,&c,&a); array[r][c] = a; x++; } /* I want to see more cases (ie the soln/test cases) */ return EXIT_SUCCESS; }
main.c:7:10: fatal error: stlib.h: No such file or directory 7 | #include <stlib.h> | ^~~~~~~~~ compilation terminated.
s230305528
p03995
C++
#include <bits/stdc++.h> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int, int> PII; typedef long long LL; typedef pair<LL, LL> PLL; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(), (a).rend() #define PB push_back #define EB emplace_back #define MP make_pair #define SZ(a) int((a).size()) #define SORT(c) sort((c).begin(),(c).end()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define FF first #define SS second template<class S, class T> istream& operator>>(istream& is, pair<S,T>& p){ return is >> p.FF >> p.SS; } const double EPS = 1e-10; const double PI = acos(-1.0); const LL MOD = 1e9+7; const LL INF = 1e15; int R, C, N; void dfs(auto& G, int u, int p, vector<LL>& xs, LL& mr, LL& mc){ if(u < R) mr = min(mr, xs[u]); else mc = min(mc, xs[u]); for(auto&& e: G[u]){ if(e.FF == p) continue; if(xs[e.FF] != INF) continue; xs[e.FF] = e.SS - xs[u]; dfs(G, e.FF, u, xs); } } int main(){ cin.tie(0); ios_base::sync_with_stdio(false); cin >> R >> C >> N; vector<vector<pair<int,LL>>> G(R+C); REP(i,N){ int r, c, x; cin >> r >> c >> x; --r, --c; G[r].EB(R+c, x); G[R+c].EB(r, x); } vector<LL> xs(R+C, INF); REP(i,R+C){ if(xs[i] == INF){ xs[i] = 0; LL mr = INF, mc = INF; dfs(G, i, -1, xs, mr, mc); if(mr+mc < 0){ cout << "No" << endl; return 0; } } } REP(i,R+C){ for(auto&& e: G[i]) if(e.SS != xs[i] + xs[e.FF]){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
a.cc:35:10: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 35 | void dfs(auto& G, int u, int p, vector<LL>& xs, LL& mr, LL& mc){ | ^~~~ a.cc: In instantiation of 'void dfs(auto:28&, int, int, std::vector<long long int>&, LL&, LL&) [with auto:28 = std::vector<std::vector<std::pair<int, long long int> > >; LL = long long int]': a.cc:64:7: required from here 64 | dfs(G, i, -1, xs, mr, mc); | ~~~^~~~~~~~~~~~~~~~~~~~~~ a.cc:42:12: error: no matching function for call to 'dfs(std::vector<std::vector<std::pair<int, long long int> > >&, int&, int&, std::vector<long long int>&)' 42 | dfs(G, e.FF, u, xs); | ~~~^~~~~~~~~~~~~~~~ a.cc:35:6: note: candidate: 'template<class auto:28> void dfs(auto:28&, int, int, std::vector<long long int>&, LL&, LL&)' 35 | void dfs(auto& G, int u, int p, vector<LL>& xs, LL& mr, LL& mc){ | ^~~ a.cc:35:6: note: candidate expects 6 arguments, 4 provided
s608238662
p03995
C++
#include <bits/stdc++.h> using namespace std; const long long inf = 1e17; const int MAX = 100010; int R, C, N; bool used[MAX + MAX]; long long val[MAX + MAX]; vector< tuple<int, long long> > G[MAX + MAX]; long long minr, minc; void dfsc(int c, long long a){ used[c] = true; minc = min( minc, a ); val[c] = a; for(int i = 0; i < G[c].size(); i++){ int r; long long b; tie(r,b) = G[c][i]; if( !used[r] ) dfsc( r, b - a ); } } void dfsr(int r, long long a){ used[r] = true; minr = min( minr, a ); val[r] = a; for(int i = 0; i < G[r].size(); i++){ int c; long long b; tie(c,b) = G[r][i]; if( !used[c] ) dfsc( c, b - a ); } } int r[MAX], c[MAX]; long long a[MAX]; int main(){ cin >> R >> C >> N; for(int i = 0; i < N; i++){ int h, w; long long v; cin >> h >> w >> v; G[ h ].emplace_back( MAX + w, v, i ); G[ MAX + w ].emplace_back( h, v, i ); r[i] = h; c[i] = MAX + w; a[i] = v; } bool ans = true; for(int i = 1; i <= R; i++){ minr = inf; minc = inf; if( ! used[i] ){ dfsr(i, 0); } if( minr + minc < 0 ) ans = false; } for(int i = 0; i < N; i++){ if(a[i] != val[ r[i] ] + val[ c[i] ]) ans = false; } if( ans ) cout << "Yes" << endl; else cout << "No" << endl; }
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/c++allocator.h:33, from /usr/include/c++/14/bits/allocator.h:46, 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:1: /usr/include/c++/14/bits/new_allocator.h: In instantiation of 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::tuple<int, long long int>; _Args = {int, long long int&, int&}; _Tp = std::tuple<int, long long int>]': /usr/include/c++/14/bits/alloc_traits.h:575:17: required from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = std::tuple<int, long long int>; _Args = {int, long long int&, int&}; _Tp = std::tuple<int, long long int>; allocator_type = std::allocator<std::tuple<int, long long int> >]' 575 | __a.construct(__p, std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:117:30: required from 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::emplace_back(_Args&& ...) [with _Args = {int, long long int&, int&}; _Tp = std::tuple<int, long long int>; _Alloc = std::allocator<std::tuple<int, long long int> >; reference = std::tuple<int, long long int>&]' 117 | _Alloc_traits::construct(this->_M_impl, this->_M_impl._M_finish, | ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 118 | std::forward<_Args>(__args)...); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:47:24: required from here 47 | G[ h ].emplace_back( MAX + w, v, i ); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/new_allocator.h:191:11: error: no matching function for call to 'std::tuple<int, long long int>::tuple(int, long long int&, int&)' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2323:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_explicitly_constructible<_U1, _U2>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, std::pair<_U1, _U2>&&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_explicitly_constructible<_U1, _U2>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2323 | tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) | ^~~~~ /usr/include/c++/14/tuple:2323:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2314:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_implicitly_constructible<_U1, _U2>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, std::pair<_U1, _U2>&&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_implicitly_constructible<_U1, _U2>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2314 | tuple(allocator_arg_t __tag, const _Alloc& __a, pair<_U1, _U2>&& __in) | ^~~~~ /usr/include/c++/14/tuple:2314:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'std::pair<_Tp1, _Tp2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2306:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_explicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, const std::pair<_U1, _U2>&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_explicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2306 | tuple(allocator_arg_t __tag, const _Alloc& __a, | ^~~~~ /usr/include/c++/14/tuple:2306:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2297:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_implicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, const std::pair<_U1, _U2>&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_implicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2297 | tuple(allocator_arg_t __tag, const _Alloc& __a, | ^~~~~ /usr/include/c++/14/tuple:2297:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'const std::pair<_Tp1, _Tp2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2290:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_explicitly_constructible<_U1, _U2>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, std::tuple<_U1, _U2>&&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_explicitly_constructible<_U1, _U2>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2290 | tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) | ^~~~~ /usr/include/c++/14/tuple:2290:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'std::tuple<_T1, _T2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2282:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_implicitly_constructible<_U1, _U2>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, std::tuple<_U1, _U2>&&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_implicitly_constructible<_U1, _U2>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2282 | tuple(allocator_arg_t __tag, const _Alloc& __a, tuple<_U1, _U2>&& __in) | ^~~~~ /usr/include/c++/14/tuple:2282:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'std::tuple<_T1, _T2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2273:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_explicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, const std::tuple<_U1, _U2>&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_explicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2273 | tuple(allocator_arg_t __tag, const _Alloc& __a, | ^~~~~ /usr/include/c++/14/tuple:2273:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'const std::tuple<_T1, _T2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2263:9: note: candidate: 'template<class _Alloc, class _U1, class _U2, typename std::enable_if<__is_implicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> > std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, const std::tuple<_U1, _U2>&) [with _U1 = _Alloc; _U2 = _U1; typename std::enable_if<std::_TupleConstraints<true, _T1, _T2>::__is_implicitly_constructible<const _U1&, const _U2&>(), bool>::type <anonymous> = _U2; _T1 = int; _T2 = long long int]' 2263 | tuple(allocator_arg_t __tag, const _Alloc& __a, | ^~~~~ /usr/include/c++/14/tuple:2263:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/new_allocator.h:191:11: note: mismatched types 'const std::tuple<_T1, _T2>' and 'int' 191 | { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/tuple:2257:9: note: candidate: 'template<class _Alloc> std::tuple<_T1, _T2>::tuple(std::allocator_arg_t, const _Alloc&, std::tuple<_T1, _T2>&&) [with _T1 = int; _T2 = long long int]' 2257 | tuple(allocator_arg_t __tag, const _Alloc& __a, tuple&& __in) | ^~~~~ /usr/include/c++/14/tuple:2257:9: note: template argumen
s786555998
p03995
C++
#include <iostream> #include <map> #define int long long using namespace std; int h, w; int n; int r, c, a; typedef pair<int, int> P; map<int, int> dict_r[100000]; map<int, int> dict_c[100000]; map<int, int>::iterator it, it2; bool solveH(int pre) { for (int i = 0; i < h; i++) { if (i == pre) continue; //i行目, pre行目を見て、[i][j]にも[pre][j]にも値があるようなjを列挙→固定値を求める int pnum = -1145141919; for (it = dict_r[pre].begin(); it != dict_r[pre].end(); it++) { //[pre][(*it).first]が存在するか? if (dict_r[i].find((*it).first) != dict_r[i].end()) { int num = dict_r[pre][(*it).first] - dict_r[i][(*it).first]; if (pnum >= 0 && pnum != num) { return false; } pnum = num; } } if (pnum != -1145141919) { for (it = dict_r[pre].begin(); it != dict_r[pre].end(); it++) { if ((*it).second - pnum < 0) { return false; } } for (it = dict_r[i].begin(); it != dict_r[i].end(); it++) { if ((*it).second + pnum < 0) { return false; } } } } return true; } bool solveW(int pre) { for (int i = 0; i < w; i++) { if (i == pre) continue; //i列目, pre列目を見て、[j][i]にも[j][pre]にも値があるようなjを列挙→固定値を求める int pnum = -1145141919; for (it = dict_c[pre].begin(); it != dict_c[pre].end(); it++) { //[pre][(*it).first]が存在するか? if (dict_c[i].find((*it).first) != dict_c[i].end()) { int num = dict_c[pre][(*it).first] - dict_c[i][(*it).first]; if (pnum >= 0 && pnum != num) { return false; } pnum = num; } } if (pnum != -1145141919) { for (it = dict_c[pre].begin(); it != dict_c[pre].end(); it++) { if ((*it).second - pnum < 0) { return false; } } for (it = dict_c[i].begin(); it != dict_c[i].end(); it++) { if ((*it).second + pnum < 0) { return false; } } } } return true; } signed main() { int i; cin >> h >> w; cin >> n; static int cnt_r[100000] = {0}; static int cnt_c[100000] = {0}; for (i = 0; i < n; i++) { cin >> r >> c >> a; r--; c--; dict_r[r].insert(P(c, a)); dict_c[c].insert(P(r, a)); cnt_r[r]++; cnt_c[c]++; } for (i = 0; i < h; i++) { if (cnt_r[i] * h <= n) break; } if (!solveH(i)) { cout << "No" << endl; return 0; } for (i = 0; i < w; i++) { if (cnt_c[i] * w <= n) break; } if (!solveW(i)) { cout << "No" << endl; return 0; } assert(0); cout << "Yes" << endl; return 0; }
a.cc: In function 'int main()': a.cc:89:9: error: 'assert' was not declared in this scope 89 | assert(0); | ^~~~~~ a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 2 | #include <map> +++ |+#include <cassert> 3 | #define int long long
s899059423
p03995
C++
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> #include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <set> #include <map> #include <numeric> #include <unordered_map> #include <unordered_set> #include <complex> //cin.sync_with_stdio(false); //streambuf using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<double, double> pdd; using vi = vector<int>; using vll = vector<ll>; using vpii = vector<pii>; using ti3 = tuple<int, int, int>; using vti3 = vector<ti3>; template<class T, class T2> using umap = unordered_map<T, T2>; template<class T> using uset = unordered_set<T>; template<class T> void cmin(T &a, const T&b) { if (a > b)a = b; } #define ALL(a) a.begin(),a.end() #define rep(i,a) for(int i=0;i<a;i++) #define rep1(i,a) for(int i=1;i<=a;i++) const ll mod = 1000000007; const int INF = numeric_limits<int>().max()/2; template <class T> #define int long long inline void hash_combine(size_t & seed, const T & v) { hash<T> hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } namespace std { template<typename S, typename T> struct hash<pair<S, T>> { inline size_t operator()(const pair<S, T> & v) const { size_t seed = 0; hash_combine(seed, v.first); hash_combine(seed, v.second); return seed; } }; // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t& seed, Tuple const& tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename ... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const& tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...> >::apply(seed, tt); return seed; } }; } umap<ti3, ll> memo; ll pow(ll base, ll i,ll mod) { ll a=1; while (i) { if (i & 1) { a *= base; a %= mod; } base *= base; base %= mod; i/=2; } return a; } class unionfind { vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う public: unionfind(int n) :par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); } int find(int x) { if (par[x] == x)return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); par[y] = x; size_[x] += size_[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return size_[find(x)]; } }; ll gcd(ll a, ll b) { while (b) { ll c = a%b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } int popcnt(unsigned long long a) { a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555); a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333); a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f); a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff); a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff); return (a & 0xffffffff) + (a >> 32); } singned main() { int r, c, n; cin >> r >> c >> n; vti3 a(n); vi vr(n), vc(n); rep(i, n) { int ri, ci, ai; cin >> ri >> ci >> ai; a[i] = make_tuple(ri, ci, ai); vr[i] = ri, vc[i] = ci; } sort(ALL(vr)); sort(ALL(vc)); vr.erase(unique(ALL(vr)), vr.end()); vc.erase(unique(ALL(vc)), vc.end()); rep(i, n) { int ri, ci, ai; tie(ri, ci, ai) = a[i]; ri = lower_bound(ALL(vr), ri) - vr.begin(); ci = lower_bound(ALL(vc), ci) - vc.begin(); a[i] = make_tuple(ri, ci, ai); } auto ac = a; sort(ALL(a)); sort(ALL(ac), [](const ti3 &a, const ti3 &b) {return (get<1>(a) == get<1>(b)) ? (get<0>(a) < get<0>(b)) : (get<1>(a) < get<1>(b)); }); vi dr(vr.size(),INF), dc(vc.size(),INF); uset<int> used; for (auto &x : ac) { if (!used.insert(get<0>(x)).second)continue; auto lit = lower_bound(ALL(a), make_tuple(get<0>(x) + 1, 0, 0)); auto it = lower_bound(ALL(a), x); int p1 = get<1>(*it); if (dc[p1] == INF)dc[p1] = 0; int as = get<2>(*it); for (it++; it != lit; it++) { int p2 = get<1>(*it); if (dc[p2] == INF)dc[p2] = get<2>(*it) - as; else if (dc[p2] != get<2>(*it) - as) { cout << "No" << endl; return 0; } } } used.erase(ALL(used)); for (auto &x : a) { if (!used.insert(get<1>(x)).second)continue; auto lit = lower_bound(ALL(ac), make_tuple(0,get<1>(x) + 1, 0), [](const ti3 &a, const ti3 &b) {return (get<1>(a) == get<1>(b)) ? (get<0>(a) < get<0>(b)) : (get<1>(a) < get<1>(b)); }); auto it = lower_bound(ALL(ac), x, [](const ti3 &a, const ti3 &b) {return (get<1>(a) == get<1>(b)) ? (get<0>(a) < get<0>(b)) : (get<1>(a) < get<1>(b)); }); int p1 = get<1>(*it); if (dr[p1] == INF)dr[p1] = 0; int as = get<2>(*it); for (it++; it != lit; it++) { int p2 = get<0>(*it); if (dr[p2] == INF)dr[p2] = get<2>(*it) - as; else if (dr[p2] != get<2>(*it) - as) { cout << "No" << endl; return 0; } } } int m; int min = INF; rep(i, dr.size()) { if (dr[i] < min)min = dr[i], m = i; } for (auto&x : a) { if (min - dr[get<0>(x)] + get<2>(x) < 0) { cout << "No" << endl; return 0; } } min = INF; rep(i, dc.size()) { if (dc[i] < min)min = dc[i], m = i; } for (auto&x : a) { if (min - dc[get<0>(x)] + get<2>(x) < 0) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
a.cc:143:1: error: 'singned' does not name a type; did you mean 'signed'? 143 | singned main() { | ^~~~~~~ | signed
s081702336
p03995
C++
#include <vector> #include <iostream> #include <utility> #include <algorithm> #include <string> #include <deque> #include <tuple> #include <queue> #include <functional> #include <cmath> #include <iomanip> #include <set> #include <map> #include <numeric> #include <unordered_map> #include <unordered_set> #include <complex> //cin.sync_with_stdio(false); //streambuf using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<double, double> pdd; using vi = vector<int>; using vll = vector<ll>; using vpii = vector<pii>; using ti3 = tuple<int, int, int>; using vti3 = vector<ti3>; template<class T, class T2> using umap = unordered_map<T, T2>; template<class T> using uset = unordered_set<T>; template<class T> void cmin(T &a, const T&b) { if (a > b)a = b; } #define ALL(a) a.begin(),a.end() #define rep(i,a) for(int i=0;i<a;i++) #define rep1(i,a) for(int i=1;i<=a;i++) const ll mod = 1000000007; const int INF = numeric_limits<int>().max()/2; template <class T> #define int long long inline void hash_combine(size_t & seed, const T & v) { hash<T> hasher; seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); } namespace std { template<typename S, typename T> struct hash<pair<S, T>> { inline size_t operator()(const pair<S, T> & v) const { size_t seed = 0; hash_combine(seed, v.first); hash_combine(seed, v.second); return seed; } }; // Recursive template code derived from Matthieu M. template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { HashValueImpl<Tuple, Index - 1>::apply(seed, tuple); hash_combine(seed, std::get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t& seed, Tuple const& tuple) { hash_combine(seed, std::get<0>(tuple)); } }; template <typename ... TT> struct hash<std::tuple<TT...>> { size_t operator()(std::tuple<TT...> const& tt) const { size_t seed = 0; HashValueImpl<std::tuple<TT...> >::apply(seed, tt); return seed; } }; } umap<ti3, ll> memo; ll pow(ll base, ll i,ll mod) { ll a=1; while (i) { if (i & 1) { a *= base; a %= mod; } base *= base; base %= mod; i/=2; } return a; } class unionfind { vector<int> par, rank, size_;//速度ではなくメモリ効率を考えるならrankのかわりにsizeを使う public: unionfind(int n) :par(n), rank(n), size_(n, 1) { iota(ALL(par), 0); } int find(int x) { if (par[x] == x)return x; return par[x] = find(par[x]); } void unite(int x, int y) { x = find(x), y = find(y); if (x == y)return; if (rank[x] < rank[y])swap(x, y); par[y] = x; size_[x] += size_[y]; if (rank[x] == rank[y])rank[x]++; } bool same(int x, int y) { return find(x) == find(y); } int size(int x) { return size_[find(x)]; } }; ll gcd(ll a, ll b) { while (b) { ll c = a%b; a = b; b = c; } return a; } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } int popcnt(unsigned long long a) { a = (a & 0x5555555555555555) + (a >> 1 & 0x5555555555555555); a = (a & 0x3333333333333333) + (a >> 2 & 0x3333333333333333); a = (a & 0x0f0f0f0f0f0f0f0f) + (a >> 4 & 0x0f0f0f0f0f0f0f0f); a = (a & 0x00ff00ff00ff00ff) + (a >> 8 & 0x00ff00ff00ff00ff); a = (a & 0x0000ffff0000ffff) + (a >> 16 & 0x0000ffff0000ffff); return (a & 0xffffffff) + (a >> 32); } int main() { int r, c, n; cin >> r >> c >> n; vti3 a(n); vi vr(n), vc(n); rep(i, n) { int ri, ci, ai; cin >> ri >> ci >> ai; a[i] = make_tuple(ri, ci, ai); vr[i] = ri, vc[i] = ci; } sort(ALL(vr)); sort(ALL(vc)); vr.erase(unique(ALL(vr)), vr.end()); vc.erase(unique(ALL(vc)), vc.end()); rep(i, n) { int ri, ci, ai; tie(ri, ci, ai) = a[i]; ri = lower_bound(ALL(vr), ri) - vr.begin(); ci = lower_bound(ALL(vc), ci) - vc.begin(); a[i] = make_tuple(ri, ci, ai); } auto ac = a; sort(ALL(a)); sort(ALL(ac), [](const ti3 &a, const ti3 &b) {return (get<1>(a) == get<1>(b)) ? (get<0>(a) < get<0>(b)) : (get<1>(a) < get<1>(b)); }); vi dr(vr.size(),INF), dc(vc.size(),INF); uset<int> used; for (auto &x : ac) { if (!used.insert(get<0>(x)).second)continue; auto lit = lower_bound(ALL(a), make_tuple(get<0>(x) + 1, 0, 0)); auto it = lower_bound(ALL(a), x); int p1 = get<1>(*it); if (dc[p1] == INF)dc[p1] = 0; int as = get<2>(*it); for (it++; it != lit; it++) { int p2 = get<1>(*it); if (dc[p2] == INF)dc[p2] = get<2>(*it) - as; else if (dc[p2] != get<2>(*it) - as) { cout << "No" << endl; return 0; } } } used.erase(ALL(used)); for (auto &x : a) { if (!used.insert(get<1>(x)).second)continue; auto lit = lower_bound(ALL(ac), make_tuple(0,get<1>(x) + 1, 0), [](const ti3 &a, const ti3 &b) {return (get<1>(a) == get<1>(b)) ? (get<0>(a) < get<0>(b)) : (get<1>(a) < get<1>(b)); }); auto it = lower_bound(ALL(ac), x, [](const ti3 &a, const ti3 &b) {return (get<1>(a) == get<1>(b)) ? (get<0>(a) < get<0>(b)) : (get<1>(a) < get<1>(b)); }); int p1 = get<1>(*it); if (dr[p1] == INF)dr[p1] = 0; int as = get<2>(*it); for (it++; it != lit; it++) { int p2 = get<0>(*it); if (dr[p2] == INF)dr[p2] = get<2>(*it) - as; else if (dr[p2] != get<2>(*it) - as) { cout << "No" << endl; return 0; } } } int m; int min = INF; rep(i, dr.size()) { if (dr[i] < min)min = dr[i], m = i; } for (auto&x : a) { if (min - dr[get<0>(x)] + get<2>(x) < 0) { cout << "No" << endl; return 0; } } min = INF; rep(i, dc.size()) { if (dc[i] < min)min = dc[i], m = i; } for (auto&x : a) { if (min - dc[get<0>(x)] + get<2>(x) < 0) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; }
cc1plus: error: '::main' must return 'int'
s205403411
p03995
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<int,pii> piii; #define rep(i,n) for(ll i=0;i<(ll)(n);i++) #define all(a) (a).begin(),(a).end() #define pb push_back #define INF (1e9+1) //#define INF (1LL<<59) struct edge{int to,cost;}; struct st{int pos,num;}; #define MAX_V 100000 int r,c; vector<edge> G[100000]; int f=false; void dfs(int cur, int d[MAX_V],map<piii,bool> &used){ for(auto &e : G[cur]){ int from=cur, to=e.to; if( used.count(make_pair( from,pii(to,e.cost) ))==0 ){ used[make_pair( from,pii(to,e.cost) )]=true; if(d[to]==INF){ d[to] = d[cur]+e.cost; if() dfs(to,d,used); }else { if(d[to] != d[cur]+e.cost)f=true; } } } } void solve(vector<pii> inp[100000]){ rep(i,r)sort(all(inp[i])); vector<int> less(MAX_V,INF); rep(i,r){ rep(j,inp[i].size()-1){ int from = inp[i][j].first; int to = inp[i][j+1].first; less[from] = min(less[from],inp[i][j].second); if(j==inp[i].size()-1) less[from] = min(less[from],inp[i][j].second); G[from].pb(edge{to ,inp[i][j+1].second-inp[i][j].second}); G[to ].pb(edge{from,-(inp[i][j+1].second-inp[i][j].second)}); } } int d[MAX_V]; map<piii,bool> used; rep(i,MAX_V)d[i] = INF; rep(i,MAX_V){ if(d[i]==INF){ dfs((int)i,d,used); } } } int main(){ cin>>r>>c; int n; cin>>n; vector<pii> inpy[MAX_V]; vector<pii> inpx[MAX_V]; rep(i,n){ int y,x,a; cin>>y>>x>>a; y--,x--; inpy[y].pb(pii(x,a)); inpx[x].pb(pii(y,a)); } solve(inpy); rep(i,r)G[i].clear(); solve(inpx); if(f)cout<<"No"<<endl; else cout<<"Yes"<<endl; }
a.cc: In function 'void dfs(int, int*, std::map<std::pair<int, std::pair<int, int> >, bool>&)': a.cc:31:36: error: expected primary-expression before ')' token 31 | if() | ^
s139184710
p03995
C++
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <sstream> #include <algorithm> #include <cstdlib> #include <map> #include <queue> #include <utility> #include <vector> #include <set> #include <memory.h> #include <iomanip> #include <bitset> #include <list> #include <stack> using namespace std; #define mod 1000000007 int main() { int r, c, n; cin >> r >> c >> n; vector<pair<int, int> > retsu(100001), gyou(100001); for(int i = 0; i < n; i++){ int rr, cc, a; cin >> rr >> cc >> a; retsu[rr].push_back(make_pair(cc, a)); gyou[cc].push_back(make_pair(rr, a)); } double retsusub = mod + 0.0, gyousub = mod + 0.0, retsufirst[10001], gyoufirst[10001]; for(int i = 1; i <= r; i++){ retsufirst[i] = mod; if(retsu[i].size() == 0) continue; sort(retsu[i].begin(), retsu[i].end()); for(int j = 1; j < retsu[i].size(); j++){ double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first); if(retsusub == mod){ retsusub = tmp; } if(retsusub != tmp || floor(retsusub) != retsusub){ cout << "No" << endl; return 0; } } if(retsusub != mod){ retsufirst[i] = retsu[i][0].second - (retsusub * (retsu[i][0].first - 1)); if(retsufirst[i] + retsusub * (r - 1) < 0){ cout << "No" << endl; return 0; } } } for(int i = 1; i <= c; i++){ // cout << i << endl; gyoufirst[i] = mod; if(gyou[i].size() == 0) continue; sort(gyou[i].begin(), gyou[i].end()); for(int j = 1; j < gyou[i].size(); j++){ double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first); // cout << tmp << endl; if(gyousub == mod){ // cout << "ho" << endl; gyousub = tmp; } // cout << gyousub << endl; if(gyousub != tmp || floor(gyousub) != gyousub){ cout << "No" << endl; return 0; } } if(retsusub != mod){ gyoufirst[i] = gyou[i][0].second - (gyousub * (gyou[i][0].first - 1)); if(gyoufirst[i] + gyousub * (c - 1) < 0){ cout << "No" << endl; return 0; } } } // cout << retsusub << " " << gyousub << endl; // cout << gyoufirst << " " << retsufirst << endl; if(gyoufirst[1] != mod && retsufirst[1] != mod && gyoufirst[1] != retsufirst[1]) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:19: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back' 31 | retsu[rr].push_back(make_pair(cc, a)); | ^~~~~~~~~ a.cc:32:18: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'push_back' 32 | gyou[cc].push_back(make_pair(rr, a)); | ^~~~~~~~~ a.cc:37:21: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size' 37 | if(retsu[i].size() == 0) continue; | ^~~~ a.cc:38:23: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'begin' 38 | sort(retsu[i].begin(), retsu[i].end()); | ^~~~~ a.cc:38:41: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'end' 38 | sort(retsu[i].begin(), retsu[i].end()); | ^~~ a.cc:39:37: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size' 39 | for(int j = 1; j < retsu[i].size(); j++){ | ^~~~ a.cc:40:43: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 40 | double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first); | ^ a.cc:40:64: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 40 | double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first); | ^ a.cc:40:91: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 40 | double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first); | ^ a.cc:40:111: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 40 | double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first); | ^ a.cc:51:37: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 51 | retsufirst[i] = retsu[i][0].second - (retsusub * (retsu[i][0].first - 1)); | ^ a.cc:51:71: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 51 | retsufirst[i] = retsu[i][0].second - (retsusub * (retsu[i][0].first - 1)); | ^ a.cc:61:20: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size' 61 | if(gyou[i].size() == 0) continue; | ^~~~ a.cc:62:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'begin' 62 | sort(gyou[i].begin(), gyou[i].end()); | ^~~~~ a.cc:62:39: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'end' 62 | sort(gyou[i].begin(), gyou[i].end()); | ^~~ a.cc:63:36: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'size' 63 | for(int j = 1; j < gyou[i].size(); j++){ | ^~~~ a.cc:64:42: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 64 | double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first); | ^ a.cc:64:62: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 64 | double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first); | ^ a.cc:64:88: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 64 | double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first); | ^ a.cc:64:107: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 64 | double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first); | ^ a.cc:77:35: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 77 | gyoufirst[i] = gyou[i][0].second - (gyousub * (gyou[i][0].first - 1)); | ^ a.cc:77:67: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} and 'int') 77 | gyoufirst[i] = gyou[i][0].second - (gyousub * (gyou[i][0].first - 1)); | ^
s496337793
p03995
C++
#include <iostream> #include <sstream> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <cassert> using namespace std; #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) #define pb(e) push_back(e) #define mp(a, b) make_pair(a, b) typedef long long ll; int main(){ int r,c; int n; scanf("%d %d",&r ,&c); int t[r][c]; rep(i,r){ rep(j,c){ t[i][j]=-1; } } scanf("%d", &n); rep(i,n){ int rr,cc,a; scanf("%d", &rr); scanf("%d", &cc); scanf("%d", &a); t[rr-1][cc-1] = a; } // ll mm=0; int a=0; rep(i,r-1){ rep(j,c-1){ if(t[i][j]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i][j]=t[i+1][j]+t[i][j+1]-t[i+1][j+1]; if(t[i][j]<0){printf("No\n");return 0;} } else if(t[i+1][j]==-1&&t[i][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i+1][j]= t[i][j]-t[i][j+1]+t[i+1][j+1]; if(t[i+1][j]<0){printf("No\n");return 0;} } else if(t[i][j+1]==-1&&t[i+1][j]!=-1&&t[i][j]!=-1&&t[i+1][j+1]!=-1){ t[i][j+1]= -t[i+1][j]+t[i][j]+t[i+1][j+1]; if(t[i][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ t[i+1][j+1]=t[i+1][j]+t[i][j+1]-t[i][j]; if(t[i+1][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]!=-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ if((t[i+1][j+1]+t[i][j])!=(t[i][j+1]+t[i+1][j])){printf("No\n");return 0;} } //if(mm>10000000){printf("Yes\n"); return 0;} } } printf("Yes\n"); return 0;
a.cc: In function 'int main()': a.cc:79:12: error: expected '}' at end of input 79 | return 0; | ^ a.cc:29:11: note: to match this '{' 29 | int main(){ | ^
s388754790
p03995
C
#include <stdio.h> #include <stdlib.h> #include <time.h> int main() { srand(time(0)); int R, C, N; scanf("%d%d%d", &R, &C, &N); int r, c, a; for( int i = 0; i < N; ++i ){ scanf("%d%d%d", &r, &c, &n); } if( rand() & 1 ) printf("Yes\n"); else printf("No\n"); return 0; }
main.c: In function 'main': main.c:16:34: error: 'n' undeclared (first use in this function) 16 | scanf("%d%d%d", &r, &c, &n); | ^ main.c:16:34: note: each undeclared identifier is reported only once for each function it appears in
s020734179
p03995
C++
#include <iostAream> #include <sstream> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <cassert> using namespace std; #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) #define pb(e) push_back(e) #define mp(a, b) make_pair(a, b) typedef long long ll; int main(){ int r,c; int n; scanf("%d %d",&r ,&c); int t[r][c]; rep(i,r){ rep(j,c){ t[i][j]=-1; } } scanf("%d", &n); rep(i,n){ int rr,cc,a; scanf("%d", &rr); scanf("%d", &cc); scanf("%d", &a); t[rr-1][cc-1] = a; } ll mm=0; int a=0; rep(i,r-1){ rep(j,c-1){ if(t[i][j]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i][j]=t[i+1][j]+t[i][j+1]-t[i+1][j+1]; if(t[i][j]<0){printf("No\n");return 0;} } else if(t[i+1][j]==-1&&t[i][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i+1][j]= t[i][j]-t[i][j+1]+t[i+1][j+1]; if(t[i+1][j]<0){printf("No\n");return 0;} } else if(t[i][j+1]==-1&&t[i+1][j]!=-1&&t[i][j]!=-1&&t[i+1][j+1]!=-1){ t[i][j+1]= -t[i+1][j]+t[i][j]+t[i+1][j+1]; if(t[i][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ t[i+1][j+1]=t[i+1][j]+t[i][j+1]-t[i][j]; if(t[i+1][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]!=-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ if((t[i+1][j+1]+t[i][j])!=(t[i][j+1]+t[i+1][j])){printf("No\n");return 0;} } if(mm>10000000){printf("Yes\n"); return 0;} } } printf("Yes\n"); return 0; }
a.cc:1:10: fatal error: iostAream: No such file or directory 1 | #include <iostAream> | ^~~~~~~~~~~ compilation terminated.
s559295599
p03995
C
#include <stdio.h> #include <stdlib.h> #include <time.h> using namespace std; int main() { srand(time(0)); int R, C, N; scanf("%d%d%d", &R, &C, &N); int r, c, a; for( int i = 0; i < N; ++i ){ scanf("%d%d%d", &r, &c, &n); } if( rand() & 1 ) printf("Yes\n"); else printf("No\n"); return 0; }
main.c:8:1: error: unknown type name 'using' 8 | using namespace std; | ^~~~~ main.c:8:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std' 8 | using namespace std; | ^~~ main.c: In function 'main': main.c:20:34: error: 'n' undeclared (first use in this function) 20 | scanf("%d%d%d", &r, &c, &n); | ^ main.c:20:34: note: each undeclared identifier is reported only once for each function it appears in
s633063188
p03995
C++
#include <iostAream> #include <sstream> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <cassert> using namespace std; #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) #define pb(e) push_back(e) #define mp(a, b) make_pair(a, b) typedef long long ll; int main(){ int r,c; int n; scanf("%d %d",&r ,&c); int t[r][c]; rep(i,r){ rep(j,c){ t[i][j]=-1; } } scanf("%d", &n); rep(i,n){ int rr,cc,a; scanf("%d", &rr); scanf("%d", &cc); scanf("%d", &a); t[rr-1][cc-1] = a; } ll mm=0; int a=0; rep(i,r-1){ rep(j,c-1){ if(t[i][j]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i][j]=t[i+1][j]+t[i][j+1]-t[i+1][j+1]; if(t[i][j]<0){printf("No\n");return 0;} } else if(t[i+1][j]==-1&&t[i][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i+1][j]= t[i][j]-t[i][j+1]+t[i+1][j+1]; if(t[i+1][j]<0){printf("No\n");return 0;} } else if(t[i][j+1]==-1&&t[i+1][j]!=-1&&t[i][j]!=-1&&t[i+1][j+1]!=-1){ t[i][j+1]= -t[i+1][j]+t[i][j]+t[i+1][j+1]; if(t[i][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ t[i+1][j+1]=t[i+1][j]+t[i][j+1]-t[i][j]; if(t[i+1][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]!=-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ if((t[i+1][j+1]+t[i][j])!=(t[i][j+1]+t[i+1][j])){printf("No\n");return 0;} } if(mm>10000000){printf("Yes\n"); return 0;} } } printf("Yes\n"); return 0; }
a.cc:1:10: fatal error: iostAream: No such file or directory 1 | #include <iostAream> | ^~~~~~~~~~~ compilation terminated.
s627307084
p03995
C++
#include <iostAream> #include <sstream> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <cassert> using namespace std; #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) #define pb(e) push_back(e) #define mp(a, b) make_pair(a, b) typedef long long ll; int main(){ int r,c; int n; scanf("%d %d",&r ,&c); int t[r][c]; rep(i,r){ rep(j,c){ t[i][j]=-1; } } scanf("%d", &n); rep(i,n){ int rr,cc,a; scanf("%d", &rr); scanf("%d", &cc); scanf("%d", &a); t[rr-1][cc-1] = a; } ll mm=0; int a=0; rep(i,r-1){ rep(j,c-1){ if(t[i][j]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i][j]=t[i+1][j]+t[i][j+1]-t[i+1][j+1]; if(t[i][j]<0){printf("No\n");return 0;} } else if(t[i+1][j]==-1&&t[i][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i+1][j]= t[i][j]-t[i][j+1]+t[i+1][j+1]; if(t[i+1][j]<0){printf("No\n");return 0;} } else if(t[i][j+1]==-1&&t[i+1][j]!=-1&&t[i][j]!=-1&&t[i+1][j+1]!=-1){ t[i][j+1]= -t[i+1][j]+t[i][j]+t[i+1][j+1]; if(t[i][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ t[i+1][j+1]=t[i+1][j]+t[i][j+1]-t[i][j]; if(t[i+1][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]!=-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ if((t[i+1][j+1]+t[i][j])!=(t[i][j+1]+t[i+1][j])){printf("No\n");return 0;} } if(mm>10000000){printf("Yes\n"); return 0;} } } printf("Yes\n"); return 0; }
a.cc:1:10: fatal error: iostAream: No such file or directory 1 | #include <iostAream> | ^~~~~~~~~~~ compilation terminated.
s251222357
p03995
C++
#!/usr/bin/ruby $m=Hash.new{|h,k|h[k]=[]} $memo={} def dfs(now,goal,d) v=$m[now] v.size.times{|i| if v[i][0]==goal&&v[i][1]!=d return false end if !$memo.has_key?(v[i][0]) $memo[v[i][0]]=1 if !dfs(v[i][0],goal,d-v[i][1]) return false end end } return true end r,c=gets.split.map(&:to_i) h=Hash.new{|h,k|h[k]=[]} w=Hash.new{|h,k|h[k]=[]} g=Hash.new{|h,k|h[k]=Hash.new{|h_,k_|h_[k_]=[]}} a=[] gets.to_i.times{ x,y,z=gets.split.map(&:to_i) x-=1 y-=1 a<<[x,y,z] g[x][y]=z h[x]<<[y,z] w[y]<<[x,z] } h.each{|k,v| y0=v[0][0] v.each{|y,z| $memo={} d=g[k][y0]-g[k][y] if !dfs(y0,y,d) puts 'No' exit end $m[y0]<<[y,d] $m[y]<<[y0,-d] } } $m=Hash.new{|h,k|h[k]=[]} w.each{|k,v| x0=v[0][0] v.each{|x,z| $memo={} d=g[x0][k]-g[x][k] if !dfs(x0,x,d) puts 'No' exit end $m[x0]<<[x,d] $m[x]<<[x0,-d] } } puts 'Yes'
a.cc:1:2: error: invalid preprocessing directive #! 1 | #!/usr/bin/ruby | ^ a.cc:40:30: warning: multi-character character constant [-Wmultichar] 40 | puts 'No' | ^~~~ a.cc:54:30: warning: multi-character character constant [-Wmultichar] 54 | puts 'No' | ^~~~ a.cc:61:6: warning: multi-character character constant [-Wmultichar] 61 | puts 'Yes' | ^~~~~ a.cc:2:1: error: '$m' does not name a type 2 | $m=Hash.new{|h,k|h[k]=[]} | ^~ a.cc:3:1: error: '$memo' does not name a type 3 | $memo={} | ^~~~~ a.cc:4:1: error: 'def' does not name a type 4 | def dfs(now,goal,d) | ^~~ a.cc:17:9: error: expected unqualified-id before 'return' 17 | return true | ^~~~~~ a.cc:22:1: error: 'w' does not name a type 22 | w=Hash.new{|h,k|h[k]=[]} | ^ a.cc:23:1: error: 'g' does not name a type 23 | g=Hash.new{|h,k|h[k]=Hash.new{|h_,k_|h_[k_]=[]}} | ^ a.cc:24:1: error: 'a' does not name a type 24 | a=[] | ^ a.cc:34:1: error: 'h' does not name a type 34 | h.each{|k,v| | ^ a.cc:47:1: error: '$m' does not name a type 47 | $m=Hash.new{|h,k|h[k]=[]} | ^~ a.cc:48:1: error: 'w' does not name a type 48 | w.each{|k,v| | ^ a.cc:61:1: error: 'puts' does not name a type 61 | puts 'Yes' | ^~~~
s791500419
p03995
C++
#include<bits/stdc++.h> using namespace std; #define int long long typedef long long int64; const int64 INF = 1LL << 58; int H, W, N; vector< int > y, x, c; int64 uku[100000], ku[100000]; map< pair< int, int >, int64 > hashed; map< pair< int, int >, int64 > hashed2; void E() { puts("No"); exit(0); } signed main() { cin >> H >> W; cin >> N; y.resize(N), x.resize(N), c.resize(N); vector< int > qs, qa; for(int i = 0; i < N; i++) { cin >> y[i] >> x[i] >> c[i]; --y[i], --x[i]; qs.push_back(y[i]); qa.push_back(x[i]); } sort(begin(qs), end(qs)); qs.erase(unique(begin(qs), end(qs)), end(qs)); sort(begin(qa), end(qa)); qa.erase(unique(begin(qa), end(qa)), end(qa)); for(int i = 0; i < N; i++) { x[i] = lower_bound(begin(qa), end(qa), x[i]) - begin(qa); y[i] = lower_bound(begin(ya), end(ya), y[i]) - begin(ya); hashed[{y[i], x[i]}] = c[i]; } vector< int > idx(y.size()); iota(begin(idx), end(idx), 0); sort(begin(idx), end(idx), [=](int a, int b) { return (make_pair(y[a], x[a]) < make_pair(y[b], x[b])); }); fill_n(uku, 100000, INF); for(int i = 1; i < N; i++) { int a = idx[i - 1], b = idx[i]; if(y[a] == y[b] && x[b] - x[a] == 1) { if(uku[x[a]] != INF && uku[x[a]] != c[b] - c[a]) E(); uku[x[a]] = c[b] - c[a]; } } for(int i = 0; i < N; i++) { if(x[i] - 1 >= 0) { if(uku[x[i] - 1] < INF) { int64 val = c[i] - uku[x[i] - 1]; if(val < 0) E(); if(hashed.count({y[i], x[i] - 1}) && hashed[{y[i], x[i] - 1}] != val) E(); hashed[{y[i], x[i] - 1}] = val; x.push_back(x[i] - 1); y.push_back(y[i]); c.push_back(val); } } if(x[i] + 1 < W) { if(uku[x[i]] < INF) { int64 val = c[i] + uku[x[i]]; if(val < 0) E(); if(hashed.count({y[i], x[i] + 1}) && hashed[{y[i], x[i] + 1}] != val) E(); hashed[{y[i], x[i] + 1}] = val; x.push_back(x[i] + 1); y.push_back(y[i]); c.push_back(val); } } } idx.resize(y.size()); iota(begin(idx), end(idx), 0); swap(x, y); swap(W, H); for(auto k : hashed) hashed2[{k.first.second, k.first.first}] = k.second; swap(hashed, hashed2); fill_n(uku, 100000, INF); sort(begin(idx), end(idx), [=](int a, int b) { return (make_pair(y[a], x[a]) < make_pair(y[b], x[b])); }); for(int i = 1; i < y.size(); i++) { int a = idx[i - 1], b = idx[i]; if(y[a] == y[b] && x[b] - x[a] == 1) { if(uku[x[a]] != INF && uku[x[a]] != c[b] - c[a]) E(); uku[x[a]] = c[b] - c[a]; } } for(int i = 0; i < y.size(); i++) { if(x[i] - 1 >= 0) { if(uku[x[i] - 1] < INF) { int64 val = c[i] - uku[x[i] - 1]; if(val < 0) E(); if(hashed.count({y[i], x[i] - 1}) && hashed[{y[i], x[i] - 1}] != val) E(); hashed[{y[i], x[i] - 1}] = val; } } if(x[i] + 1 < W) { if(uku[x[i]] < INF) { int64 val = c[i] + uku[x[i]]; if(val < 0) E(); if(hashed.count({y[i], x[i] + 1}) && hashed[{y[i], x[i] + 1}] != val) E(); hashed[{y[i], x[i] + 1}] = val; } } } throw (0); puts("Yes"); }
a.cc: In function 'int main()': a.cc:43:30: error: 'ya' was not declared in this scope; did you mean 'qa'? 43 | y[i] = lower_bound(begin(ya), end(ya), y[i]) - begin(ya); | ^~ | qa
s343998258
p03995
C++
#include <algorithm> #include <cstdio> #include <cstdlib> #include <cctype> #include <cmath> #include <iostream> #include <queue> #include <list> #include <stack> #include <map> #include <numeric> #include <set> #include <sstream> #include <string> #include <vector> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; int R, C; map< pair<int,int>, int> in; map< pair<int,int>, int> in2; bool check_local(int y1, int x1, int y2, int x2){ int a = (in.count(make_pair(y1,x1))>0)?in[make_pair(y1,x1)]:-1; int b = (in.count(make_pair(y1,x2))>0)?in[make_pair(y1,x2)]:-1; int c = (in.count(make_pair(y2,x1))>0)?in[make_pair(y2,x1)]:-1; int d = (in.count(make_pair(y2,x2))>0)?in[make_pair(y2,x2)]:-1; //cout << y << " " << x << endl; //cout << " " << a << " " << b << endl; //cout << " " << c << " " << d << endl; int minus = 0; if(a<0) minus++; if(b<0) minus++; if(c<0) minus++; if(d<0) minus++; if(minus == 0){ if(a+d == b+c) return true; else return false; } if(minus == 1){ if(a==-1){ if(b+c>=d){ in2[make_pair(y1,x1)] = b+c-d; return true; } else return false; } if(b==-1){ if(a+d>=c){ in2[make_pair(y1,x2)] = a+d-c; return true; } else return false; } if(c==-1){ if(a+d>=b){ in2[make_pair(y2,x1)] = a+d-b; return true; } else return false; } if(d==-1){ if(b+c>=a){ in2[make_pair(y2,x2)] = b+c-a; return true; } else return false; } } return true; } bool check2x2(){ FOR(it,in){ int y = (it->first).first; int x = (it->first).second; int a = it->second; //left-top if(y<R-1 && x<C-1){ if(!check_local(y,x,y+1,x+1)) return false; } //right-top if(y<R-1 && x>0){ if(!check_local(y,x-1,y+1,x)) return false; } //left-bottom if(y>0 && x<C-1){ if(!check_local(y-1,x,y,x+1)) return false; } //right-bottom if(y>0 && x>0){ if(!check_local(y-1,x-1,y,x)) return false; } } FOR(it1,in){ FOR(it2,in){ int y1 = (it1->first).first; int x1 = (it1->first).second; int y2 = (it2->first).first; int x2 = (it2->first).second; if(y<R-1 && x<C-1){ if(!check_local(y1,x1,y2,x2)) return false; } } } return true; } int main(){ ios::sync_with_stdio(false); int N; cin >> R >> C; cin >> N; rep(i,N){ int r, c, a; cin >> r >> c >> a; r--; c--; in[make_pair(r,c)] = a; } while(true){ if(!check2x2()){ cout << "No" << endl; return 0; } if(in2.size() == 0) break; FOR(it,in2){ in[it->first] = it->second; } in2.clear(); } cout << "Yes" << endl; return 0; }
a.cc: In function 'bool check2x2()': a.cc:110:10: error: 'y' was not declared in this scope; did you mean 'y2'? 110 | if(y<R-1 && x<C-1){ | ^ | y2 a.cc:110:19: error: 'x' was not declared in this scope; did you mean 'x2'? 110 | if(y<R-1 && x<C-1){ | ^ | x2
s273620741
p03995
C++
#include <stdio.h> #include <vector> #include <iostream> #include <string> #include <random> using namespace std; random_device rnd(2,0); int R; int C; int N; int rs; int cs; int as; bool dame=false; int main(){ scanf("%d %d %d",&R,&C,&N); vector< vector<int> > D(C, vector<int>(R, -1)); for(int i=0;i<R;i++){ for(int j=0;j<C;j++){ D[i][j]=-1; } } for(int i=0;i<N;i++){ scanf("%d %d %d",&rs,&cs,&as); //D[rs-1][cs-1]=as; } if(rnd()>1)cout<<"Yes"; else cout<<"No"; return 0; }
a.cc:9:22: error: no matching function for call to 'std::random_device::random_device(int, int)' 9 | random_device rnd(2,0); | ^ In file included from /usr/include/c++/14/random:48, from a.cc:5: /usr/include/c++/14/bits/random.h:1763:5: note: candidate: 'std::random_device::random_device(const std::string&)' 1763 | random_device(const std::string& __token) { _M_init(__token); } | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/random.h:1763:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/random.h:1760:5: note: candidate: 'std::random_device::random_device()' 1760 | random_device() { _M_init("default"); } | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/random.h:1760:5: note: candidate expects 0 arguments, 2 provided
s525697310
p03995
C++
#include <iostream> using namespace std; long long map[100000][100000]; int main(){ int R,C; int N; int black=0; int white=0; cin >> R >> C; cin >> N; for(int i=0;i<N;i++){ int r,c; cin >> r >> c; cin >> map[r][c]; for(int i=0;i<R-1;i++){ for(int j=0;j<C-1;j++){ if(map[i][j]+map[i+1][j+1] != map[i+1][j]+map[i][j+1]) cout << "No" << endl; } } cout << "Yes" << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:2: error: expected '}' at end of input 26 | } | ^ a.cc:7:11: note: to match this '{' 7 | int main(){ | ^
s728377569
p03995
C++
#include <cstdio> #include <iostream> #include <cmath> #include <cstring> #include <sstream> #include <algorithm> #include <cstdlib> #include <map> #include <queue> #include <utility> #include <vector> #include <set> #include <memory.h> #include <iomanip> #include <bitset> #include <list> #include <stack> using namespace std; #define mod 1000000007 int main() { int r, c, n; cin >> r >> c >> n; vector<pair<int, int> > retsu[100001], gyou[100001]; for(int i = 0; i < n; i++){ int r, c, a; cin >> r >> c >> a; retsu[r].push_back(make_pair(c, a)); gyou[c].push_back(make_pair(r, a)); } double retsusub = mod + 0.0, gyousub = mod + 0.0, retsufirst[10001], gyoufirst[10001]; for(int i = 1; i <= r; i++){ if(retsu[i].size() == 0) continue; retsufirst[i] = mod; sort(retsu[i].begin(), retsu[i].end()); for(int j = 1; j < retsu[i].size(); j++){ double tmp = (double)(retsu[i][j].second - retsu[i][j - 1].second) / (retsu[i][j].first - retsu[i][j - 1].first); if(retsusub == mod){ retsusub = tmp; } if(retsusub != tmp || floor(retsusub) != retsusub){ cout << "No" << endl; return 0; } } if(retsu[i].size() > 0){ retsufirst[i] = retsu[i][0].second - (retsusub * retsu[i][0].first - 1); if(retsufirst[i] + retsusub * (r - 1) < 0){ cout << "No" << endl; return 0; } } } for(int i = 1; i <= c; i++){ // cout << i << endl; if(gyou.size() == 0) continue; gyoufirst[i] = mod; sort(gyou[i].begin(), gyou[i].end()); for(int j = 1; j < gyou[i].size(); j++){ double tmp = (double)(gyou[i][j].second - gyou[i][j - 1].second) / (gyou[i][j].first - gyou[i][j - 1].first); // cout << tmp << endl; if(gyousub == mod){ // cout << "ho" << endl; gyousub = tmp; } // cout << gyousub << endl; if(gyousub != tmp || floor(gyousub) != gyousub){ cout << "No" << endl; return 0; } } if(gyou[i].size() > 0){ gyoufirst[i] = gyou[i][0].second - (gyousub * gyou[i][0].first - 1); if(gyoufirst[i] + gyousub * (c - 1) < 0){ cout << "No" << endl; return 0; } } } // cout << retsusub << " " << gyousub << endl; // cout << gyoufirst << " " << retsufirst << endl; if(gyoufirst[1] != mod && retsufirst[1] != mod && gyoufirst[1] != retsufirst[1]) cout << "No" << endl; else cout << "Yes" << endl; return 0; }
a.cc: In function 'int main()': a.cc:60:17: error: request for member 'size' in 'gyou', which is of non-class type 'std::vector<std::pair<int, int> > [100001]' 60 | if(gyou.size() == 0) continue; | ^~~~
s645647647
p03995
C++
/** * code generated by JHelper * More info: https://github.com/AlexeyDmitriev/JHelper * @author RiaD */ #include <iostream> #include <fstream> #include <iostream> #include <vector> #include <iterator> #include <string> #include <stdexcept> #ifndef SPCPPL_ASSERT #ifdef SPCPPL_DEBUG #define SPCPPL_ASSERT(condition) \ if(!(condition)) { \ throw std::runtime_error(std::string() + #condition + " in line " + std::to_string(__LINE__) + " in " + __PRETTY_FUNCTION__); \ } #else #define SPCPPL_ASSERT(condition) #endif #endif /** * Support decrementing and multi-passing, but not declared bidirectional(or even forward) because * it's reference type is not a reference. * * It doesn't return reference because * 1. Anyway it'll not satisfy requirement [forward.iterators]/6 * If a and b are both dereferenceable, then a == b if and only if *a and * b are bound to the same object. * 2. It'll not work with reverse_iterator that returns operator * of temporary which is temporary for this iterator * * Note, reverse_iterator is not guaranteed to work now too since it works only with bidirectional iterators, * but it's seems to work at least on my implementation. * * It's not really useful anywhere except iterating anyway. */ template <typename T> class IntegerIterator: public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> { public: explicit IntegerIterator(T value): value(value) { } IntegerIterator& operator++() { ++value; return *this; } IntegerIterator operator++(int) { IntegerIterator copy = *this; ++value; return copy; } IntegerIterator& operator--() { --value; return *this; } IntegerIterator operator--(int) { IntegerIterator copy = *this; --value; return copy; } T operator*() const { return value; } bool operator==(IntegerIterator rhs) const { return value == rhs.value; } bool operator!=(IntegerIterator rhs) const { return !(*this == rhs); } private: T value; }; template <typename T> class IntegerRange { public: IntegerRange(T begin, T end): begin_(begin), end_(end) { SPCPPL_ASSERT(begin <= end); } IntegerIterator<T> begin() const { return IntegerIterator<T>(begin_); } IntegerIterator<T> end() const { return IntegerIterator<T>(end_); } private: T begin_; T end_; }; template <typename T> class ReversedIntegerRange { typedef std::reverse_iterator<IntegerIterator<T>> IteratorType; public: ReversedIntegerRange(T begin, T end): begin_(begin), end_(end) { SPCPPL_ASSERT(begin >= end); } IteratorType begin() const { return IteratorType(IntegerIterator<T>(begin_)); } IteratorType end() const { return IteratorType(IntegerIterator<T>(end_)); } private: T begin_; T end_; }; template <typename T> IntegerRange<T> range(T to) { return IntegerRange<T>(0, to); } template <typename T> IntegerRange<T> range(T from, T to) { return IntegerRange<T>(from, to); } template <typename T> IntegerRange<T> inclusiveRange(T to) { return IntegerRange<T>(0, to + 1); } template <typename T> IntegerRange<T> inclusiveRange(T from, T to) { return IntegerRange<T>(from, to + 1); } template <typename T> ReversedIntegerRange<T> downrange(T from) { return ReversedIntegerRange<T>(from, 0); } template <typename T> ReversedIntegerRange<T> downrange(T from, T to) { return ReversedIntegerRange<T>(from, to); } template <typename T> ReversedIntegerRange<T> inclusiveDownrange(T from) { return ReversedIntegerRange<T>(from + 1, 0); } template <typename T> ReversedIntegerRange<T> inclusiveDownrange(T from, T to) { return ReversedIntegerRange<T>(from + 1, to); } using namespace std; class DA { public: void solve(std::istream& in, std::ostream& out) { #define int int64_t int n, m, e; in >> n >> m >> e; vector<int> vr(n); vector<int> vc(m); vector<vector<pair<int, int>>> gr(n); vector<vector<pair<int, int>>> gc(m); vector<int> ur(n), uc(m); for (int i: range(e)) { int a, b, x; in >> a >> b >> x; --a, --b, --x; gr[a].emplace_back(b, x); gr[b].emplace_back(a,x ); } function<pair<int, int>(int, int)> dr, dc; dr = [&](int a, int v) { pair<int, int> res = {vr[a], 1000000000000000000}; if (ur[a]) { if (vr[a] != v) { throw 1; } return res; } for (auto p: gr[a]) { auto x = dc(p.first, p.second - v); res.first = max(res.first, x.first); res.second = min(res.second, x.second); } return res; }; dc = [&](int a, int v) { pair<int, int> res = {-1000000000000000000, vc[a]}; if (uc[a]) { if (vc[a] != v) { throw 1; } return res; } for (auto p: gr[a]) { auto x = dr(p.first, p.second - v); res.first = max(res.first, x.first); res.second = min(res.second, x.second); } return res; }; for (int i: range(n)) { if (ur[i]) { continue; } try { auto x = dr(i, 0); if (x.first + x.second < 0) { throw 1; } } catch (...) { out << "No"; return; } } out << "Yes\n"; #undef int } }; int main() { std::ios_base::sync_with_stdio(false); DA solver; std::istream& in(std::cin); std::ostream& out(std::cout); in.tie(0); out << std::fixed; out.precision(20); solver.solve(in, out); return 0; }
a.cc:48:36: warning: 'template<class _Category, class _Tp, class _Distance, class _Pointer, class _Reference> struct std::iterator' is deprecated [-Wdeprecated-declarations] 48 | class IntegerIterator: public std::iterator<std::input_iterator_tag, T, std::ptrdiff_t, T*, T> { | ^~~~~~~~ In file included from /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66, from /usr/include/c++/14/string:47, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:7: /usr/include/c++/14/bits/stl_iterator_base_types.h:127:34: note: declared here 127 | struct _GLIBCXX17_DEPRECATED iterator | ^~~~~~~~ a.cc: In member function 'void DA::solve(std::istream&, std::ostream&)': a.cc:199:9: error: 'function' was not declared in this scope 199 | function<pair<int, int>(int, int)> dr, dc; | ^~~~~~~~ a.cc:15:1: note: 'std::function' is defined in header '<functional>'; this is probably fixable by adding '#include <functional>' 14 | #include <iterator> +++ |+#include <functional> 15 | a.cc:199:32: error: expected primary-expression before '(' token 199 | function<pair<int, int>(int, int)> dr, dc; | ^ a.cc:199:36: error: expected primary-expression before ',' token 199 | function<pair<int, int>(int, int)> dr, dc; | ^ a.cc:199:41: error: expected primary-expression before ')' token 199 | function<pair<int, int>(int, int)> dr, dc; | ^ a.cc:199:44: error: 'dr' was not declared in this scope; did you mean 'ur'? 199 | function<pair<int, int>(int, int)> dr, dc; | ^~ | ur a.cc:199:48: error: 'dc' was not declared in this scope; did you mean 'uc'? 199 | function<pair<int, int>(int, int)> dr, dc; | ^~ | uc
s733697458
p03995
C++
#<ll>include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define INF 1<<29 #define LINF LLONG_MAX/3 #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(v) (v).begin(),(v).end() #define all(v) (v).begin(),(v).end() #define debug(x) cerr<<#x<<":"<<x<<endl #define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl #define CININIT cin.tie(0),ios::sync_with_stdio(false) template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; ll R,C; ll N; vector<ll> r,c,a; int main(){ CININIT; cin>>R>>C>>N; r.resize(N); c.resize(N); a.resize(N); vector<int> needx,needy; rep(i,N){ cin>>r[i]>>c[i]>>a[i]; r[i]--; c[i]--; a[i]++; needx.emplace_back(r[i]); if(r[i]+1<R) needx.emplace_back(r[i]+1); if(r[i]-1>=0) needx.emplace_back(r[i]-1); needy.emplace_back(c[i]); if(c[i]+1<C) needy.emplace_back(c[i]+1); if(c[i]-1>=0) needy.emplace_back(c[i]-1); } sort(ALL(needx)); sort(ALL(needy)); needx.erase(unique(needx.begin(),needx.end()),needx.end()); needy.erase(unique(needy.begin(),needy.end()),needy.end()); vi rr(N),cc(N); vi aa(N); for(int i=0;i<N;i++){ rr[i] = find(all(needx),r[i]) - needx.begin(); cc[i] = find(all(needy),c[i]) - needy.begin(); aa[i] = a[i]; } ll RR = needx.size(); ll CC = needy.size(); if(RR==1 or CC==1){ cout << "Yes" << endl; return 0; } vector<vector<ll>> vec(RR,vector<ll>(CC,0)); for(int i=0;i<N;i++){ vec[rr[i]][cc[i]] = aa[i]; } __int128 hoge = RR*CC; hoge=100000000LL/hoge; if(hoge<1){ cout << "No" << endl; return 0; } if(RR*CC>10000000){ cout << "No" << endl; return 0; } auto beg(vec); /*{{{*/ ll counter = -1; while(true){ beg = vec; if(++counter==min<ll>(hoge,5)){ cout <<"No" << endl; return 0; } for(int i=0;i<RR-1;i++){ for(int j=0;j<CC-1;j++){ if(vec[i][j]>0){ ll sum1 = vec[i][j]+vec[i+1][j+1]; ll sum2 = vec[i+1][j]+vec[i][j+1]; if(vec[i+1][j]==0 and vec[i][j+1]==0) continue; if(sum1 == sum2) continue; if(vec[i+1][j+1]!=0){ if(sum2 > sum1){ cout <<"No" << endl; return 0; } } if(vec[i+1][j+1]==0 and vec[i+1][j]!=0 and vec[i][j+1]!=0){ vec[i+1][j+1] = sum2 - sum1; if(vec[i+1][j+1]<0){ cout << "No" << endl; return 0; } } if(vec[i+1][j]==0 and vec[i+1][j+1]>0 and vec[i][j+1]>0){ vec[i+1][j] == sum1 - sum2; if(vec[i+1][j]<0){ cout << "No" << endl; return 0; } } if(vec[i][j+1]==0 and vec[i+1][j+1]>0 and vec[i+1][j]>0){ vec[i][j+1] = sum1 -sum2; if(vec[i][j+1]<0){ cout << "No" << endl; return 0; } } if(vec[i+1][j]!=0 and vec[i][j+1]!=0){ if(sum1 > sum2){ cout << "No" << endl; return 0; }else{ if(vec[i+1][j]>0 and vec[i][j+1]==0){ vec[i][j+1] = sum1 - sum2; }else if(vec[i+1][j]==0 and vec[i][j+1]>0){ vec[i+1][j] = sum1 - sum2; } } } } if(vec[i][j]==0 and vec[i+1][j+1]>0 and vec[i][j+1]>0 and vec[i+1][j]>0){ vec[i][j] = vec[i+1][j] + vec[i][j+1] - vec[i+1][j+1]; if(vec[i][j] < 0){ cout <<"No" << endl; return 0; } } } } if(vec == beg){ break; } } /*}}}*/ // for(int i=0;i<RR;i++){ // cout << vec[i] << endl; // } cout << "Yes" << endl; }
a.cc:1:2: error: invalid preprocessing directive #< 1 | #<ll>include <bits/stdc++.h> | ^ a.cc:16:22: error: 'ostream' does not name a type 16 | template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } | ^~~~~~~ a.cc:20:9: error: 'pair' does not name a type 20 | typedef pair<int,int> pii; | ^~~~ a.cc:21:9: error: 'vector' does not name a type 21 | typedef vector<int> vi; | ^~~~~~ a.cc:22:9: error: 'vector' does not name a type 22 | typedef vector<vi> vvi; | ^~~~~~ a.cc:26:1: error: 'vector' does not name a type 26 | vector<ll> r,c,a; | ^~~~~~ a.cc: In function 'int main()': a.cc:15:17: error: 'cin' was not declared in this scope 15 | #define CININIT cin.tie(0),ios::sync_with_stdio(false) | ^~~ a.cc:29:5: note: in expansion of macro 'CININIT' 29 | CININIT; | ^~~~~~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | #<ll>include <bits/stdc++.h> a.cc:15:28: error: 'ios' has not been declared 15 | #define CININIT cin.tie(0),ios::sync_with_stdio(false) | ^~~ a.cc:29:5: note: in expansion of macro 'CININIT' 29 | CININIT; | ^~~~~~~ a.cc:31:5: error: 'r' was not declared in this scope 31 | r.resize(N); | ^ a.cc:32:5: error: 'c' was not declared in this scope 32 | c.resize(N); | ^ a.cc:33:5: error: 'a' was not declared in this scope 33 | a.resize(N); | ^ a.cc:34:5: error: 'vector' was not declared in this scope 34 | vector<int> needx,needy; | ^~~~~~ a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' +++ |+#include <vector> 1 | #<ll>include <bits/stdc++.h> a.cc:34:12: error: expected primary-expression before 'int' 34 | vector<int> needx,needy; | ^~~ a.cc:41:9: error: 'needx' was not declared in this scope 41 | needx.emplace_back(r[i]); | ^~~~~ a.cc:45:9: error: 'needy' was not declared in this scope 45 | needy.emplace_back(c[i]); | ^~~~~ a.cc:51:14: error: 'needx' was not declared in this scope 51 | sort(ALL(needx)); | ^~~~~ a.cc:11:17: note: in definition of macro 'ALL' 11 | #define ALL(v) (v).begin(),(v).end() | ^ a.cc:51:5: error: 'sort' was not declared in this scope; did you mean 'short'? 51 | sort(ALL(needx)); | ^~~~ | short a.cc:52:14: error: 'needy' was not declared in this scope 52 | sort(ALL(needy)); | ^~~~~ a.cc:11:17: note: in definition of macro 'ALL' 11 | #define ALL(v) (v).begin(),(v).end() | ^ a.cc:53:17: error: 'unique' was not declared in this scope 53 | needx.erase(unique(needx.begin(),needx.end()),needx.end()); | ^~~~~~ a.cc:57:5: error: 'vi' was not declared in this scope; did you mean 'void'? 57 | vi rr(N),cc(N); | ^~ | void a.cc:58:7: error: expected ';' before 'aa' 58 | vi aa(N); | ^~~ | ; a.cc:61:9: error: 'rr' was not declared in this scope 61 | rr[i] = find(all(needx),r[i]) - needx.begin(); | ^~ a.cc:61:17: error: 'find' was not declared in this scope 61 | rr[i] = find(all(needx),r[i]) - needx.begin(); | ^~~~ a.cc:62:9: error: 'cc' was not declared in this scope 62 | cc[i] = find(all(needy),c[i]) - needy.begin(); | ^~ a.cc:63:9: error: 'aa' was not declared in this scope 63 | aa[i] = a[i]; | ^~ a.cc:71:9: error: 'cout' was not declared in this scope 71 | cout << "Yes" << endl; | ^~~~ a.cc:71:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:71:26: error: 'endl' was not declared in this scope 71 | cout << "Yes" << endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | #<ll>include <bits/stdc++.h> a.cc:75:21: error: expected primary-expression before '>>' token 75 | vector<vector<ll>> vec(RR,vector<ll>(CC,0)); | ^~ a.cc:75:40: error: expected primary-expression before '>' token 75 | vector<vector<ll>> vec(RR,vector<ll>(CC,0)); | ^ a.cc:75:24: error: 'vec' was not declared in this scope 75 | vector<vector<ll>> vec(RR,vector<ll>(CC,0)); | ^~~ a.cc:77:13: error: 'rr' was not declared in this scope; did you mean 'RR'? 77 | vec[rr[i]][cc[i]] = aa[i]; | ^~ | RR a.cc:77:20: error: 'cc' was not declared in this scope; did you mean 'CC'? 77 | vec[rr[i]][cc[i]] = aa[i]; | ^~ | CC a.cc:77:29: error: 'aa' was not declared in this scope 77 | vec[rr[i]][cc[i]] = aa[i]; | ^~ a.cc:84:9: error: 'cout' was not declared in this scope 84 | cout << "No" << endl; | ^~~~ a.cc:84:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:84:25: error: 'endl' was not declared in this scope 84 | cout << "No" << endl; | ^~~~ a.cc:84:25: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:89:9: error: 'cout' was not declared in this scope 89 | cout << "No" << endl; | ^~~~ a.cc:89:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:89:25: error: 'endl' was not declared in this scope 89 | cout << "No" << endl; | ^~~~ a.cc:89:25: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:98:23: error: 'min' was not declared in this scope; did you mean 'main'? 98 | if(++counter==min<ll>(hoge,5)){ | ^~~ | main a.cc:98:29: error: expected primary-expression before '>' token 98 | if(++counter==min<ll>(hoge,5)){ | ^ a.cc:99:13: error: 'cout' was not declared in this scope 99 | cout <<"No" << endl; | ^~~~ a.cc:99:13: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:99:28: error: 'endl' was not declared in this scope 99 | cout <<"No" << endl; | ^~~~ a.cc:99:28: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:112:29: error: 'cout' was not declared in this scope 112 | cout <<"No" << endl; | ^~~~ a.cc:112:29: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:112:44: error: 'endl' was not declared in this scope 112 | cout <<"No" << endl; | ^~~~ a.cc:112:44: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:120:29: error: 'cout' was not declared in this scope 120 | cout << "No" << endl; | ^~~~ a.cc:120:29: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:120:45: error: 'endl' was not declared in this scope 120 | cout << "No" << endl; | ^~~~ a.cc:120:45: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:128:29: error: 'cout' was not declared in this scope 128 | cout << "No" << endl; | ^~~~ a.cc:128:29: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:128:45: error: 'endl' was not declared in this scope 128 | cout << "No" << endl; | ^~~~ a.cc:128:45: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:136:29: error: 'cout' was not declared in this scope 136 | cout << "No" << endl; | ^~~~ a.cc:136:29: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:136:46: error: 'endl' was not declared in this scope 136 | cout << "No" << endl; | ^~~~ a.cc:136:46: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:143:29: error: 'cout' was not declared in this scope 143 | cout << "No" << endl; | ^~~~ a.cc:143:29: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:143:45: error: 'endl' was not declared in this scope 143 | cout << "No" << endl; | ^~~~ a.cc:143:45: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:157:25: error: 'cout' was not declared in this scope 157 | cout <<"No" << endl; |
s669347761
p03995
C++
#include <iostream> #include <sstream> #include <string> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <cassert> using namespace std; #define all(c) (c).begin(), (c).end() #define iter(c) __typeof((c).begin()) #define cpresent(c, e) (find(all(c), (e)) != (c).end()) #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i) #define pb(e) push_back(e) #define mp(a, b) make_pair(a, b) typedef long long ll; int main(){ int r,c; int n; scanf("%d %d",&r ,&c); int t[r][c]; rep(i,r){ rep(j,c){ t[i][j]=-1; } } scanf("%d", &n); rep(i,n){ int rr,cc,a; scanf("%d", &rr); scanf("%d", &cc); scanf("%d", &a); t[rr-1][cc-1] = a; } int t=0; int a=0; rep(i,r-1){ rep(j,c-1){ if(t[i][j]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i][j]=t[i+1][j]+t[i][j+1]-t[i+1][j+1]; if(t[i][j]<0){printf("No\n");return 0;} } else if(t[i+1][j]==-1&&t[i][j]!=-1&&t[i][j+1]!=-1&&t[i+1][j+1]!=-1){ t[i+1][j]= t[i][j]-t[i][j+1]+t[i+1][j+1]; if(t[i+1][j]<0){printf("No\n");return 0;} } else if(t[i][j+1]==-1&&t[i+1][j]!=-1&&t[i][j]!=-1&&t[i+1][j+1]!=-1){ t[i][j+1]= -t[i+1][j]+t[i][j]+t[i+1][j+1]; if(t[i][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]==-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ t[i+1][j+1]=t[i+1][j]+t[i][j+1]-t[i][j]; if(t[i+1][j+1]<0){printf("No\n");return 0;} } else if(t[i+1][j+1]!=-1&&t[i+1][j]!=-1&&t[i][j+1]!=-1&&t[i][j]!=-1){ if((t[i+1][j+1]+t[i][j])!=(t[i][j+1]+t[i+1][j])){printf("No\n");return 0;} } if(t++>10000000){printf("Yes\n"); return 0;} } } printf("Yes\n"); return 0; }
a.cc: In function 'int main()': a.cc:50:7: error: conflicting declaration 'int t' 50 | int t=0; | ^ a.cc:34:7: note: previous declaration as 'int t [r][c]' 34 | int t[r][c]; | ^ a.cc:73:9: error: lvalue required as increment operand 73 | if(t++>10000000){printf("Yes\n"); return 0;} | ^
s388633914
p03995
C++
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define INF 1<<29 #define LINF LLONG_MAX/3 #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(v) (v).begin(),(v).end() #define all(v) (v).begin(),(v).end() #define debug(x) cerr<<#x<<":"<<x<<endl #define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl #define CININIT cin.tie(0),ios::sync_with_stdio(false) template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; ll R,C; ll N; vector<ll> r,c,a; int main(){ CININIT; cin>>R>>C>>N; r.resize(N); c.resize(N); a.resize(N); vector<int> needx,needy; rep(i,N){ cin>>r[i]>>c[i]>>a[i]; r[i]--; c[i]--; a[i]++; needx.emplace_back(r[i]); if(r[i]+1<R) needx.emplace_back(r[i]+1); if(r[i]-1>=0) needx.emplace_back(r[i]-1); needy.emplace_back(c[i]); if(c[i]+1<C) needy.emplace_back(c[i]+1); if(c[i]-1>=0) needy.emplace_back(c[i]-1); } sort(ALL(needx)); sort(ALL(needy)); needx.erase(unique(needx.begin(),needx.end()),needx.end()); needy.erase(unique(needy.begin(),needy.end()),needy.end()); vi rr(N),cc(N); vi aa(N); for(int i=0;i<N;i++){ rr[i] = find(all(needx),r[i]) - needx.begin(); cc[i] = find(all(needy),c[i]) - needy.begin(); aa[i] = a[i]; } ll RR = needx.size(); ll CC = needy.size(); if(RR==1 or CC==1){ cout << "Yes" << endl; return 0; } vector<vector<ll>> vec(RR,vector<ll>(CC,0)); for(int i=0;i<N;i++){ vec[rr[i]][cc[i]] = aa[i]; } __int128 hoge = RR*CC; hoge=100000000LL/hoge; if(hoge<1){ cout << "No" << endl; return 0; } if(RR**CC>10000000){ cout << "No" << endl; return 0; } auto beg(vec); /*{{{*/ ll counter = -1; while(true){ beg = vec; if(++counter==min<ll>(hoge,5)){ cout <<"No" << endl; return 0; } for(int i=0;i<RR-1;i++){ for(int j=0;j<CC-1;j++){ if(vec[i][j]>0){ ll sum1 = vec[i][j]+vec[i+1][j+1]; ll sum2 = vec[i+1][j]+vec[i][j+1]; if(vec[i+1][j]==0 and vec[i][j+1]==0) continue; if(sum1 == sum2) continue; if(vec[i+1][j+1]!=0){ if(sum2 > sum1){ cout <<"No" << endl; return 0; } } if(vec[i+1][j+1]==0 and vec[i+1][j]!=0 and vec[i][j+1]!=0){ vec[i+1][j+1] = sum2 - sum1; if(vec[i+1][j+1]<0){ cout << "No" << endl; return 0; } } if(vec[i+1][j]==0 and vec[i+1][j+1]>0 and vec[i][j+1]>0){ vec[i+1][j] == sum1 - sum2; if(vec[i+1][j]<0){ cout << "No" << endl; return 0; } } if(vec[i][j+1]==0 and vec[i+1][j+1]>0 and vec[i+1][j]>0){ vec[i][j+1] = sum1 -sum2; if(vec[i][j+1]<0){ cout << "No" << endl; return 0; } } if(vec[i+1][j]!=0 and vec[i][j+1]!=0){ if(sum1 > sum2){ cout << "No" << endl; return 0; }else{ if(vec[i+1][j]>0 and vec[i][j+1]==0){ vec[i][j+1] = sum1 - sum2; }else if(vec[i+1][j]==0 and vec[i][j+1]>0){ vec[i+1][j] = sum1 - sum2; } } } } if(vec[i][j]==0 and vec[i+1][j+1]>0 and vec[i][j+1]>0 and vec[i+1][j]>0){ vec[i][j] = vec[i+1][j] + vec[i][j+1] - vec[i+1][j+1]; if(vec[i][j] < 0){ cout <<"No" << endl; return 0; } } } } if(vec == beg){ break; } } /*}}}*/ // for(int i=0;i<RR;i++){ // cout << vec[i] << endl; // } cout << "Yes" << endl; }
a.cc: In function 'int main()': a.cc:88:11: error: invalid type argument of unary '*' (have 'll' {aka 'long long int'}) 88 | if(RR**CC>10000000){ | ^~~
s954415576
p03995
C++
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define INF 1<<29 #define LINF LLONG_MAX/3 #define MP make_pair #define PB push_back #define EB emplace_back #define ALL(v) (v).begin(),(v).end() #define all(v) (v).begin(),(v).end() #define debug(x) cerr<<#x<<":"<<x<<endl #define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl #define CININIT cin.tie(0),ios::sync_with_stdio(false) template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; } typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<vi> vvi; ll R,C; ll N; vector<ll> r,c,a; int main(){ CININIT; cin>>R>>C>>N; r.resize(N); c.resize(N); a.resize(N); vector<int> needx,needy; rep(i,N){ cin>>r[i]>>c[i]>>a[i]; r[i]--; c[i]--; a[i]++; needx.emplace_back(r[i]); if(r[i]+1<R) needx.emplace_back(r[i]+1); if(r[i]-1>=0) needx.emplace_back(r[i]-1); needy.emplace_back(c[i]); if(c[i]+1<C) needy.emplace_back(c[i]+1); if(c[i]-1>=0) needy.emplace_back(c[i]-1); } sort(ALL(needx)); sort(ALL(needy)); needx.erase(unique(needx.begin(),needx.end()),needx.end()); needy.erase(unique(needy.begin(),needy.end()),needy.end()); vi rr(N),cc(N); vi aa(N); for(int i=0;i<N;i++){ rr[i] = find(all(needx),r[i]) - needx.begin(); cc[i] = find(all(needy),c[i]) - needy.begin(); aa[i] = a[i]; } ll RR = needx.size(); ll CC = needy.size(); if(RR==1 or CC==1){ cout << "Yes" << endl; return 0; } vector<vector<ll>> vec(RR,vector<ll>(CC,0)); for(int i=0;i<N;i++){ vec[rr[i]][cc[i]] = aa[i]; } __int128 hoge = RR*CC; hoge=100000000LL/hoge; if(hoge<1){ cout << "No" << endl; return 0; } if(RR**CC>10000000){ cout << "No" << endl; return 0; } auto beg(vec); /*{{{*/ ll counter = -1; while(true){ beg = vec; if(++counter==10){ cout <<"No" << endl; return 0; } for(int i=0;i<RR-1;i++){ for(int j=0;j<CC-1;j++){ if(vec[i][j]>0){ ll sum1 = vec[i][j]+vec[i+1][j+1]; ll sum2 = vec[i+1][j]+vec[i][j+1]; if(vec[i+1][j]==0 and vec[i][j+1]==0) continue; if(sum1 == sum2) continue; if(vec[i+1][j+1]!=0){ if(sum2 > sum1){ cout <<"No" << endl; return 0; } } if(vec[i+1][j+1]==0 and vec[i+1][j]!=0 and vec[i][j+1]!=0){ vec[i+1][j+1] = sum2 - sum1; if(vec[i+1][j+1]<0){ cout << "No" << endl; return 0; } } if(vec[i+1][j]==0 and vec[i+1][j+1]>0 and vec[i][j+1]>0){ vec[i+1][j] == sum1 - sum2; if(vec[i+1][j]<0){ cout << "No" << endl; return 0; } } if(vec[i][j+1]==0 and vec[i+1][j+1]>0 and vec[i+1][j]>0){ vec[i][j+1] = sum1 -sum2; if(vec[i][j+1]<0){ cout << "No" << endl; return 0; } } if(vec[i+1][j]!=0 and vec[i][j+1]!=0){ if(sum1 > sum2){ cout << "No" << endl; return 0; }else{ if(vec[i+1][j]>0 and vec[i][j+1]==0){ vec[i][j+1] = sum1 - sum2; }else if(vec[i+1][j]==0 and vec[i][j+1]>0){ vec[i+1][j] = sum1 - sum2; } } } } if(vec[i][j]==0 and vec[i+1][j+1]>0 and vec[i][j+1]>0 and vec[i+1][j]>0){ vec[i][j] = vec[i+1][j] + vec[i][j+1] - vec[i+1][j+1]; if(vec[i][j] < 0){ cout <<"No" << endl; return 0; } } } } if(vec == beg){ break; } } /*}}}*/ // for(int i=0;i<RR;i++){ // cout << vec[i] << endl; // } cout << "Yes" << endl; }
a.cc: In function 'int main()': a.cc:88:11: error: invalid type argument of unary '*' (have 'll' {aka 'long long int'}) 88 | if(RR**CC>10000000){ | ^~~
s119725036
p03995
C++
#include <bits/stdc++.h> using namespace std; unordered_set<pair<int,int>> s; map<pair<int,int>,int> mp; map<pair<int,int>,int>::iterator map_find(pair<int,int> x){ auto y = mp.lower_bound(x); if(y != mp.upper_bound(x)){ return *y } return mp.end(); } int main(){ int r,c,c; cin >> r >> c; cin >> n; for(int i=0;i<n;i++){ int ri,ci,a; cin >> ri >> ci >> a; mp[make_pair(ri,ci)] = a; if(s.find(ri,ci) != s.end()) s.erase(s.find(ri,ci)); s.insert(make_pair(ri-1,ci)); s.insert(make_pair(ri+1,ci)); s.insert(make_pair(ri,ci-1)); s.insert(make_pair(ri,ci+1)); } for(auto x:s){ auto mp1 = map_find(make_pair(x.first-1,x.second-1)) auto mp2 = map_find(make_pair(x.first-1,x.second)) auto mp3 = map_find(make_pair(x.first-1,x.second+1)) auto mp4 = map_find(make_pair(x.first,x.second-1)) auto mp5 = map_find(make_pair(x.first,x.second+1)) auto mp6 = map_find(make_pair(x.first+1,x.second-1)) auto mp7 = map_find(make_pair(x.first+1,x.second)) auto mp8 = map_find(make_pair(x.first+1,x.second+1)) int cand = -1; if(mp1 != mp.end() && mp2 != mp.end() && mp4 != mp.end()){ int z = *mp4 + *mp2 - *mp1; if(cand != -1 && cand != z){ cout << "No" << endl; return 0; } cand = z; } if(mp2 != mp.end() && mp3 != mp.end() && mp5 != mp.end()){ int z = *mp2 + *mp5 - *mp3; if(cand != -1 && cand != z){ cout << "No" << endl; return 0; } cand = z; } if(mp4 != mp.end() && mp6 != mp.end() && mp7 != mp.end()){ int z = *mp4 + *mp7 - *mp6; if(cand != -1 && cand != z){ cout << "No" << endl; return 0; } cand = z; } if(mp5 != mp.end() && mp7 != mp.end() && mp8 != mp.end()){ int z = *mp5 + *mp7 - *mp8; if(cand != -1 && cand != z){ cout << "No" << endl; return 0; } cand = z; } } return 0; }
a.cc:5:30: error: use of deleted function 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' 5 | unordered_set<pair<int,int>> s; | ^ In file included from /usr/include/c++/14/unordered_set:41, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:189, from a.cc:1: /usr/include/c++/14/bits/unordered_set.h:142:7: note: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::pair<int, int>; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<int, int> >]' is implicitly deleted because the default definition would be ill-formed: 142 | unordered_set() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_set.h:142:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33, from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::pair<int, int> >; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<int, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<int, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<int, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<int, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<int, int>; _Value = std::pair<int, int>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::pair<int, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<int, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<int, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<int, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed: 1306 | struct _Hash_code_base | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1306:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<int, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable.h:539:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::pair<int, int>, std::pair<int, int>, std::__detail::_Identity, std::equal_to<std::pair<int, int> >, std::hash<std::pair<int, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__d
s985706593
p03995
Java
/* * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package java.util; import java.io.IOException; import java.io.InvalidObjectException; import java.io.Serializable; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.function.BiConsumer; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Function; /** * Hash table based implementation of the <tt>Map</tt> interface. This * implementation provides all of the optional map operations, and permits * <tt>null</tt> values and the <tt>null</tt> key. (The <tt>HashMap</tt> * class is roughly equivalent to <tt>Hashtable</tt>, except that it is * unsynchronized and permits nulls.) This class makes no guarantees as to * the order of the map; in particular, it does not guarantee that the order * will remain constant over time. * * <p>This implementation provides constant-time performance for the basic * operations (<tt>get</tt> and <tt>put</tt>), assuming the hash function * disperses the elements properly among the buckets. Iteration over * collection views requires time proportional to the "capacity" of the * <tt>HashMap</tt> instance (the number of buckets) plus its size (the number * of key-value mappings). Thus, it's very important not to set the initial * capacity too high (or the load factor too low) if iteration performance is * important. * * <p>An instance of <tt>HashMap</tt> has two parameters that affect its * performance: <i>initial capacity</i> and <i>load factor</i>. The * <i>capacity</i> is the number of buckets in the hash table, and the initial * capacity is simply the capacity at the time the hash table is created. The * <i>load factor</i> is a measure of how full the hash table is allowed to * get before its capacity is automatically increased. When the number of * entries in the hash table exceeds the product of the load factor and the * current capacity, the hash table is <i>rehashed</i> (that is, internal data * structures are rebuilt) so that the hash table has approximately twice the * number of buckets. * * <p>As a general rule, the default load factor (.75) offers a good * tradeoff between time and space costs. Higher values decrease the * space overhead but increase the lookup cost (reflected in most of * the operations of the <tt>HashMap</tt> class, including * <tt>get</tt> and <tt>put</tt>). The expected number of entries in * the map and its load factor should be taken into account when * setting its initial capacity, so as to minimize the number of * rehash operations. If the initial capacity is greater than the * maximum number of entries divided by the load factor, no rehash * operations will ever occur. * * <p>If many mappings are to be stored in a <tt>HashMap</tt> * instance, creating it with a sufficiently large capacity will allow * the mappings to be stored more efficiently than letting it perform * automatic rehashing as needed to grow the table. Note that using * many keys with the same {@code hashCode()} is a sure way to slow * down performance of any hash table. To ameliorate impact, when keys * are {@link Comparable}, this class may use comparison order among * keys to help break ties. * * <p><strong>Note that this implementation is not synchronized.</strong> * If multiple threads access a hash map concurrently, and at least one of * the threads modifies the map structurally, it <i>must</i> be * synchronized externally. (A structural modification is any operation * that adds or deletes one or more mappings; merely changing the value * associated with a key that an instance already contains is not a * structural modification.) This is typically accomplished by * synchronizing on some object that naturally encapsulates the map. * * If no such object exists, the map should be "wrapped" using the * {@link Collections#synchronizedMap Collections.synchronizedMap} * method. This is best done at creation time, to prevent accidental * unsynchronized access to the map:<pre> * Map m = Collections.synchronizedMap(new HashMap(...));</pre> * * <p>The iterators returned by all of this class's "collection view methods" * are <i>fail-fast</i>: if the map is structurally modified at any time after * the iterator is created, in any way except through the iterator's own * <tt>remove</tt> method, the iterator will throw a * {@link ConcurrentModificationException}. Thus, in the face of concurrent * modification, the iterator fails quickly and cleanly, rather than risking * arbitrary, non-deterministic behavior at an undetermined time in the * future. * * <p>Note that the fail-fast behavior of an iterator cannot be guaranteed * as it is, generally speaking, impossible to make any hard guarantees in the * presence of unsynchronized concurrent modification. Fail-fast iterators * throw <tt>ConcurrentModificationException</tt> on a best-effort basis. * Therefore, it would be wrong to write a program that depended on this * exception for its correctness: <i>the fail-fast behavior of iterators * should be used only to detect bugs.</i> * * <p>This class is a member of the * <a href="{@docRoot}/../technotes/guides/collections/index.html"> * Java Collections Framework</a>. * * @param <K> the type of keys maintained by this map * @param <V> the type of mapped values * * @author Doug Lea * @author Josh Bloch * @author Arthur van Hoff * @author Neal Gafter * @see Object#hashCode() * @see Collection * @see Map * @see TreeMap * @see Hashtable * @since 1.2 */ public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable { private static final long serialVersionUID = 362498820763181265L; /* * Implementation notes. * * This map usually acts as a binned (bucketed) hash table, but * when bins get too large, they are transformed into bins of * TreeNodes, each structured similarly to those in * java.util.TreeMap. Most methods try to use normal bins, but * relay to TreeNode methods when applicable (simply by checking * instanceof a node). Bins of TreeNodes may be traversed and * used like any others, but additionally support faster lookup * when overpopulated. However, since the vast majority of bins in * normal use are not overpopulated, checking for existence of * tree bins may be delayed in the course of table methods. * * Tree bins (i.e., bins whose elements are all TreeNodes) are * ordered primarily by hashCode, but in the case of ties, if two * elements are of the same "class C implements Comparable<C>", * type then their compareTo method is used for ordering. (We * conservatively check generic types via reflection to validate * this -- see method comparableClassFor). The added complexity * of tree bins is worthwhile in providing worst-case O(log n) * operations when keys either have distinct hashes or are * orderable, Thus, performance degrades gracefully under * accidental or malicious usages in which hashCode() methods * return values that are poorly distributed, as well as those in * which many keys share a hashCode, so long as they are also * Comparable. (If neither of these apply, we may waste about a * factor of two in time and space compared to taking no * precautions. But the only known cases stem from poor user * programming practices that are already so slow that this makes * little difference.) * * Because TreeNodes are about twice the size of regular nodes, we * use them only when bins contain enough nodes to warrant use * (see TREEIFY_THRESHOLD). And when they become too small (due to * removal or resizing) they are converted back to plain bins. In * usages with well-distributed user hashCodes, tree bins are * rarely used. Ideally, under random hashCodes, the frequency of * nodes in bins follows a Poisson distribution * (http://en.wikipedia.org/wiki/Poisson_distribution) with a * parameter of about 0.5 on average for the default resizing * threshold of 0.75, although with a large variance because of * resizing granularity. Ignoring variance, the expected * occurrences of list size k are (exp(-0.5) * pow(0.5, k) / * factorial(k)). The first values are: * * 0: 0.60653066 * 1: 0.30326533 * 2: 0.07581633 * 3: 0.01263606 * 4: 0.00157952 * 5: 0.00015795 * 6: 0.00001316 * 7: 0.00000094 * 8: 0.00000006 * more: less than 1 in ten million * * The root of a tree bin is normally its first node. However, * sometimes (currently only upon Iterator.remove), the root might * be elsewhere, but can be recovered following parent links * (method TreeNode.root()). * * All applicable internal methods accept a hash code as an * argument (as normally supplied from a public method), allowing * them to call each other without recomputing user hashCodes. * Most internal methods also accept a "tab" argument, that is * normally the current table, but may be a new or old one when * resizing or converting. * * When bin lists are treeified, split, or untreeified, we keep * them in the same relative access/traversal order (i.e., field * Node.next) to better preserve locality, and to slightly * simplify handling of splits and traversals that invoke * iterator.remove. When using comparators on insertion, to keep a * total ordering (or as close as is required here) across * rebalancings, we compare classes and identityHashCodes as * tie-breakers. * * The use and transitions among plain vs tree modes is * complicated by the existence of subclass LinkedHashMap. See * below for hook methods defined to be invoked upon insertion, * removal and access that allow LinkedHashMap internals to * otherwise remain independent of these mechanics. (This also * requires that a map instance be passed to some utility methods * that may create new nodes.) * * The concurrent-programming-like SSA-based coding style helps * avoid aliasing errors amid all of the twisty pointer operations. */ /** * The default initial capacity - MUST be a power of two. */ static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 /** * The maximum capacity, used if a higher value is implicitly specified * by either of the constructors with arguments. * MUST be a power of two <= 1<<30. */ static final int MAXIMUM_CAPACITY = 1 << 30; /** * The load factor used when none specified in constructor. */ static final float DEFAULT_LOAD_FACTOR = 0.75f; /** * The bin count threshold for using a tree rather than list for a * bin. Bins are converted to trees when adding an element to a * bin with at least this many nodes. The value must be greater * than 2 and should be at least 8 to mesh with assumptions in * tree removal about conversion back to plain bins upon * shrinkage. */ static final int TREEIFY_THRESHOLD = 8; /** * The bin count threshold for untreeifying a (split) bin during a * resize operation. Should be less than TREEIFY_THRESHOLD, and at * most 6 to mesh with shrinkage detection under removal. */ static final int UNTREEIFY_THRESHOLD = 6; /** * The smallest table capacity for which bins may be treeified. * (Otherwise the table is resized if too many nodes in a bin.) * Should be at least 4 * TREEIFY_THRESHOLD to avoid conflicts * between resizing and treeification thresholds. */ static final int MIN_TREEIFY_CAPACITY = 64; /** * Basic hash bin node, used for most entries. (See below for * TreeNode subclass, and in LinkedHashMap for its Entry subclass.) */ static class Node<K,V> implements Map.Entry<K,V> { final int hash; final K key; V value; Node<K,V> next; Node(int hash, K key, V value, Node<K,V> next) { this.hash = hash; this.key = key; this.value = value; this.next = next; } public final K getKey() { return key; } public final V getValue() { return value; } public final String toString() { return key + "=" + value; } public final int hashCode() { return Objects.hashCode(key) ^ Objects.hashCode(value); } public final V setValue(V newValue) { V oldValue = value; value = newValue; return oldValue; } public final boolean equals(Object o) { if (o == this) return true; if (o instanceof Map.Entry) { Map.Entry<?,?> e = (Map.Entry<?,?>)o; if (Objects.equals(key, e.getKey()) && Objects.equals(value, e.getValue())) return true; } return false; } } /* ---------------- Static utilities -------------- */ /** * Computes key.hashCode() and spreads (XORs) higher bits of hash * to lower. Because the table uses power-of-two masking, sets of * hashes that vary only in bits above the current mask will * always collide. (Among known examples are sets of Float keys * holding consecutive whole numbers in small tables.) So we * apply a transform that spreads the impact of higher bits * downward. There is a tradeoff between speed, utility, and * quality of bit-spreading. Because many common sets of hashes * are already reasonably distributed (so don't benefit from * spreading), and because we use trees to handle large sets of * collisions in bins, we just XOR some shifted bits in the * cheapest possible way to reduce systematic lossage, as well as * to incorporate impact of the highest bits that would otherwise * never be used in index calculations because of table bounds. */ static final int hash(Object key) { int h; return (key == null) ? 0 : (h = key.hashCode()) ^ (h >>> 16); } /** * Returns x's Class if it is of the form "class C implements * Comparable<C>", else null. */ static Class<?> comparableClassFor(Object x) { if (x instanceof Comparable) { Class<?> c; Type[] ts, as; Type t; ParameterizedType p; if ((c = x.getClass()) == String.class) // bypass checks return c; if ((ts = c.getGenericInterfaces()) != null) { for (int i = 0; i < ts.length; ++i) { if (((t = ts[i]) instanceof ParameterizedType) && ((p = (ParameterizedType)t).getRawType() == Comparable.class) && (as = p.getActualTypeArguments()) != null && as.length == 1 && as[0] == c) // type arg is c return c; } } } return null; } /** * Returns k.compareTo(x) if x matches kc (k's screened comparable * class), else 0. */ @SuppressWarnings({"rawtypes","unchecked"}) // for cast to Comparable static int compareComparables(Class<?> kc, Object k, Object x) { return (x == null || x.getClass() != kc ? 0 : ((Comparable)k).compareTo(x)); } /** * Returns a power of two size for the given target capacity. */ static final int tableSizeFor(int cap) { int n = cap - 1; n |= n >>> 1; n |= n >>> 2; n |= n >>> 4; n |= n >>> 8; n |= n >>> 16; return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1; } /* ---------------- Fields -------------- */ /** * The table, initialized on first use, and resized as * necessary. When allocated, length is always a power of two. * (We also tolerate length zero in some operations to allow * bootstrapping mechanics that are currently not needed.) */ transient Node<K,V>[] table; /** * Holds cached entrySet(). Note that AbstractMap fields are used * for keySet() and values(). */ transient Set<Map.Entry<K,V>> entrySet; /** * The number of key-value mappings contained in this map. */ transient int size; /** * The number of times this HashMap has been structurally modified * Structural modifications are those that change the number of mappings in * the HashMap or otherwise modify its internal structure (e.g., * rehash). This field is used to make iterators on Collection-views of * the HashMap fail-fast. (See ConcurrentModificationException). */ transient int modCount; /** * The next size value at which to resize (capacity * load factor). * * @serial */ // (The javadoc description is true upon serialization. // Additionally, if the table array has not been allocated, this // field holds the initial array capacity, or zero signifying // DEFAULT_INITIAL_CAPACITY.) int threshold; /** * The load factor for the hash table. * * @serial */ final float loadFactor; /* ---------------- Public operations -------------- */ /** * Constructs an empty <tt>HashMap</tt> with the specified initial * capacity and load factor. * * @param initialCapacity the initial capacity * @param loadFactor the load factor * @throws IllegalArgumentException if the initial capacity is negative * or the load factor is nonpositive */ public HashMap(int initialCapacity, float loadFactor) { if (initialCapacity < 0) throw new IllegalArgumentException("Illegal initial capacity: " + initialCapacity); if (initialCapacity > MAXIMUM_CAPACITY) initialCapacity = MAXIMUM_CAPACITY; if (loadFactor <= 0 || Float.isNaN(loadFactor)) throw new IllegalArgumentException("Illegal load factor: " + loadFactor); this.loadFactor = loadFactor; this.threshold = tableSizeFor(initialCapacity); } /** * Constructs an empty <tt>HashMap</tt> with the specified initial * capacity and the default load factor (0.75). * * @param initialCapacity the initial capacity. * @throws IllegalArgumentException if the initial capacity is negative. */ public HashMap(int initialCapacity) { this(initialCapacity, DEFAULT_LOAD_FACTOR); } /** * Constructs an empty <tt>HashMap</tt> with the default initial capacity * (16) and the default load factor (0.75). */ public HashMap() { this.loadFactor = DEFAULT_LOAD_FACTOR; // all other fields defaulted } /** * Constructs a new <tt>HashMap</tt> with the same mappings as the * specified <tt>Map</tt>. The <tt>HashMap</tt> is created with * default load factor (0.75) and an initial capacity sufficient to * hold the mappings in the specified <tt>Map</tt>. * * @param m the map whose mappings are to be placed in this map * @throws NullPointerException if the specified map is null */ public HashMap(Map<? extends K, ? extends V> m) { this.loadFactor = DEFAULT_LOAD_FACTOR; putMapEntries(m, false); } /** * Implements Map.putAll and Map constructor * * @param m the map * @param evict false when initially constructing this map, else * true (relayed to method afterNodeInsertion). */ final void putMapEntries(Map<? extends K, ? extends V> m, boolean evict) { int s = m.size(); if (s > 0) { if (table == null) { // pre-size float ft = ((float)s / loadFactor) + 1.0F; int t = ((ft < (float)MAXIMUM_CAPACITY) ? (int)ft : MAXIMUM_CAPACITY); if (t > threshold) threshold = tableSizeFor(t); } else if (s > threshold) resize(); for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) { K key = e.getKey(); V value = e.getValue(); putVal(hash(key), key, value, false, evict); } } } /** * Returns the number of key-value mappings in this map. * * @return the number of key-value mappings in this map */ public int size() { return size; } /** * Returns <tt>true</tt> if this map contains no key-value mappings. * * @return <tt>true</tt> if this map contains no key-value mappings */ public boolean isEmpty() { return size == 0; } /** * Returns the value to which the specified key is mapped, * or {@code null} if this map contains no mapping for the key. * * <p>More formally, if this map contains a mapping from a key * {@code k} to a value {@code v} such that {@code (key==null ? k==null : * key.equals(k))}, then this method returns {@code v}; otherwise * it returns {@code null}. (There can be at most one such mapping.) * * <p>A return value of {@code null} does not <i>necessarily</i> * indicate that the map contains no mapping for the key; it's also * possible that the map explicitly maps the key to {@code null}. * The {@link #containsKey containsKey} operation may be used to * distinguish these two cases. * * @see #put(Object, Object) */ public V get(Object key) { Node<K,V> e; return (e = getNode(hash(key), key)) == null ? null : e.value; } /** * Implements Map.get and related methods * * @param hash hash for key * @param key the key * @return the node, or null if none */ final Node<K,V> getNode(int hash, Object key) { Node<K,V>[] tab; Node<K,V> first, e; int n; K k; if ((tab = table) != null && (n = tab.length) > 0 && (first = tab[(n - 1) & hash]) != null) { if (first.hash == hash && // always check first node ((k = first.key) == key || (key != null && key.equals(k)))) return first; if ((e = first.next) != null) { if (first instanceof TreeNode) return ((TreeNode<K,V>)first).getTreeNode(hash, key); do { if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) return e; } while ((e = e.next) != null); } } return null; } /** * Returns <tt>true</tt> if this map contains a mapping for the * specified key. * * @param key The key whose presence in this map is to be tested * @return <tt>true</tt> if this map contains a mapping for the specified * key. */ public boolean containsKey(Object key) { return getNode(hash(key), key) != null; } /** * Associates the specified value with the specified key in this map. * If the map previously contained a mapping for the key, the old * value is replaced. * * @param key key with which the specified value is to be associated * @param value value to be associated with the specified key * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt>. * (A <tt>null</tt> return can also indicate that the map * previously associated <tt>null</tt> with <tt>key</tt>.) */ public V put(K key, V value) { return putVal(hash(key), key, value, false, true); } /** * Implements Map.put and related methods * * @param hash hash for key * @param key the key * @param value the value to put * @param onlyIfAbsent if true, don't change existing value * @param evict if false, the table is in creation mode. * @return previous value, or null if none */ final V putVal(int hash, K key, V value, boolean onlyIfAbsent, boolean evict) { Node<K,V>[] tab; Node<K,V> p; int n, i; if ((tab = table) == null || (n = tab.length) == 0) n = (tab = resize()).length; if ((p = tab[i = (n - 1) & hash]) == null) tab[i] = newNode(hash, key, value, null); else { Node<K,V> e; K k; if (p.hash == hash && ((k = p.key) == key || (key != null && key.equals(k)))) e = p; else if (p instanceof TreeNode) e = ((TreeNode<K,V>)p).putTreeVal(this, tab, hash, key, value); else { for (int binCount = 0; ; ++binCount) { if ((e = p.next) == null) { p.next = newNode(hash, key, value, null); if (binCount >= TREEIFY_THRESHOLD - 1) // -1 for 1st treeifyBin(tab, hash); break; } if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) break; p = e; } } if (e != null) { // existing mapping for key V oldValue = e.value; if (!onlyIfAbsent || oldValue == null) e.value = value; afterNodeAccess(e); return oldValue; } } ++modCount; if (++size > threshold) resize(); afterNodeInsertion(evict); return null; } /** * Initializes or doubles table size. If null, allocates in * accord with initial capacity target held in field threshold. * Otherwise, because we are using power-of-two expansion, the * elements from each bin must either stay at same index, or move * with a power of two offset in the new table. * * @return the table */ final Node<K,V>[] resize() { Node<K,V>[] oldTab = table; int oldCap = (oldTab == null) ? 0 : oldTab.length; int oldThr = threshold; int newCap, newThr = 0; if (oldCap > 0) { if (oldCap >= MAXIMUM_CAPACITY) { threshold = Integer.MAX_VALUE; return oldTab; } else if ((newCap = oldCap << 1) < MAXIMUM_CAPACITY && oldCap >= DEFAULT_INITIAL_CAPACITY) newThr = oldThr << 1; // double threshold } else if (oldThr > 0) // initial capacity was placed in threshold newCap = oldThr; else { // zero initial threshold signifies using defaults newCap = DEFAULT_INITIAL_CAPACITY; newThr = (int)(DEFAULT_LOAD_FACTOR * DEFAULT_INITIAL_CAPACITY); } if (newThr == 0) { float ft = (float)newCap * loadFactor; newThr = (newCap < MAXIMUM_CAPACITY && ft < (float)MAXIMUM_CAPACITY ? (int)ft : Integer.MAX_VALUE); } threshold = newThr; @SuppressWarnings({"rawtypes","unchecked"}) Node<K,V>[] newTab = (Node<K,V>[])new Node[newCap]; table = newTab; if (oldTab != null) { for (int j = 0; j < oldCap; ++j) { Node<K,V> e; if ((e = oldTab[j]) != null) { oldTab[j] = null; if (e.next == null) newTab[e.hash & (newCap - 1)] = e; else if (e instanceof TreeNode) ((TreeNode<K,V>)e).split(this, newTab, j, oldCap); else { // preserve order Node<K,V> loHead = null, loTail = null; Node<K,V> hiHead = null, hiTail = null; Node<K,V> next; do { next = e.next; if ((e.hash & oldCap) == 0) { if (loTail == null) loHead = e; else loTail.next = e; loTail = e; } else { if (hiTail == null) hiHead = e; else hiTail.next = e; hiTail = e; } } while ((e = next) != null); if (loTail != null) { loTail.next = null; newTab[j] = loHead; } if (hiTail != null) { hiTail.next = null; newTab[j + oldCap] = hiHead; } } } } } return newTab; } /** * Replaces all linked nodes in bin at index for given hash unless * table is too small, in which case resizes instead. */ final void treeifyBin(Node<K,V>[] tab, int hash) { int n, index; Node<K,V> e; if (tab == null || (n = tab.length) < MIN_TREEIFY_CAPACITY) resize(); else if ((e = tab[index = (n - 1) & hash]) != null) { TreeNode<K,V> hd = null, tl = null; do { TreeNode<K,V> p = replacementTreeNode(e, null); if (tl == null) hd = p; else { p.prev = tl; tl.next = p; } tl = p; } while ((e = e.next) != null); if ((tab[index] = hd) != null) hd.treeify(tab); } } /** * Copies all of the mappings from the specified map to this map. * These mappings will replace any mappings that this map had for * any of the keys currently in the specified map. * * @param m mappings to be stored in this map * @throws NullPointerException if the specified map is null */ public void putAll(Map<? extends K, ? extends V> m) { putMapEntries(m, true); } /** * Removes the mapping for the specified key from this map if present. * * @param key key whose mapping is to be removed from the map * @return the previous value associated with <tt>key</tt>, or * <tt>null</tt> if there was no mapping for <tt>key</tt>. * (A <tt>null</tt> return can also indicate that the map * previously associated <tt>null</tt> with <tt>key</tt>.) */ public V remove(Object key) { Node<K,V> e; return (e = removeNode(hash(key), key, null, false, true)) == null ? null : e.value; } /** * Implements Map.remove and related methods * * @param hash hash for key * @param key the key * @param value the value to match if matchValue, else ignored * @param matchValue if true only remove if value is equal * @param movable if false do not move other nodes while removing * @return the node, or null if none */ final Node<K,V> removeNode(int hash, Object key, Object value, boolean matchValue, boolean movable) { Node<K,V>[] tab; Node<K,V> p; int n, index; if ((tab = table) != null && (n = tab.length) > 0 && (p = tab[index = (n - 1) & hash]) != null) { Node<K,V> node = null, e; K k; V v; if (p.hash == hash && ((k = p.key) == key || (key != null && key.equals(k)))) node = p; else if ((e = p.next) != null) { if (p instanceof TreeNode) node = ((TreeNode<K,V>)p).getTreeNode(hash, key); else { do { if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) { node = e; break; } p = e; } while ((e = e.next) != null); } } if (node != null && (!matchValue || (v = node.value) == value || (value != null && value.equals(v)))) { if (node instanceof TreeNode) ((TreeNode<K,V>)node).removeTreeNode(this, tab, movable); else if (node == p) tab[index] = node.next; else p.next = node.next; ++modCount; --size; afterNodeRemoval(node); return node; } } return null; } /** * Removes all of the mappings from this map. * The map will be empty after this call returns. */ public void clear() { Node<K,V>[] tab; modCount++; if ((tab = table) != null && size > 0) { size = 0; for (int i = 0; i < tab.length; ++i) tab[i] = null; } } /** * Returns <tt>true</tt> if this map maps one or more keys to the * specified value. * * @param value value whose presence in this map is to be tested * @return <tt>true</tt> if this map maps one or more keys to the * specified value */ public boolean containsValue(Object value) { Node<K,V>[] tab; V v; if ((tab = table) != null && size > 0) { for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) { if ((v = e.value) == value || (value != null && value.equals(v))) return true; } } } return false; } /** * Returns a {@link Set} view of the keys contained in this map. * The set is backed by the map, so changes to the map are * reflected in the set, and vice-versa. If the map is modified * while an iteration over the set is in progress (except through * the iterator's own <tt>remove</tt> operation), the results of * the iteration are undefined. The set supports element removal, * which removes the corresponding mapping from the map, via the * <tt>Iterator.remove</tt>, <tt>Set.remove</tt>, * <tt>removeAll</tt>, <tt>retainAll</tt>, and <tt>clear</tt> * operations. It does not support the <tt>add</tt> or <tt>addAll</tt> * operations. * * @return a set view of the keys contained in this map */ public Set<K> keySet() { Set<K> ks = keySet; if (ks == null) { ks = new KeySet(); keySet = ks; } return ks; } final class KeySet extends AbstractSet<K> { public final int size() { return size; } public final void clear() { HashMap.this.clear(); } public final Iterator<K> iterator() { return new KeyIterator(); } public final boolean contains(Object o) { return containsKey(o); } public final boolean remove(Object key) { return removeNode(hash(key), key, null, false, true) != null; } public final Spliterator<K> spliterator() { return new KeySpliterator<>(HashMap.this, 0, -1, 0, 0); } public final void forEach(Consumer<? super K> action) { Node<K,V>[] tab; if (action == null) throw new NullPointerException(); if (size > 0 && (tab = table) != null) { int mc = modCount; for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) action.accept(e.key); } if (modCount != mc) throw new ConcurrentModificationException(); } } } /** * Returns a {@link Collection} view of the values contained in this map. * The collection is backed by the map, so changes to the map are * reflected in the collection, and vice-versa. If the map is * modified while an iteration over the collection is in progress * (except through the iterator's own <tt>remove</tt> operation), * the results of the iteration are undefined. The collection * supports element removal, which removes the corresponding * mapping from the map, via the <tt>Iterator.remove</tt>, * <tt>Collection.remove</tt>, <tt>removeAll</tt>, * <tt>retainAll</tt> and <tt>clear</tt> operations. It does not * support the <tt>add</tt> or <tt>addAll</tt> operations. * * @return a view of the values contained in this map */ public Collection<V> values() { Collection<V> vs = values; if (vs == null) { vs = new Values(); values = vs; } return vs; } final class Values extends AbstractCollection<V> { public final int size() { return size; } public final void clear() { HashMap.this.clear(); } public final Iterator<V> iterator() { return new ValueIterator(); } public final boolean contains(Object o) { return containsValue(o); } public final Spliterator<V> spliterator() { return new ValueSpliterator<>(HashMap.this, 0, -1, 0, 0); } public final void forEach(Consumer<? super V> action) { Node<K,V>[] tab; if (action == null) throw new NullPointerException(); if (size > 0 && (tab = table) != null) { int mc = modCount; for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) action.accept(e.value); } if (modCount != mc) throw new ConcurrentModificationException(); } } } /** * Returns a {@link Set} view of the mappings contained in this map. * The set is backed by the map, so changes to the map are * reflected in the set, and vice-versa. If the map is modified * while an iteration over the set is in progress (except through * the iterator's own <tt>remove</tt> operation, or through the * <tt>setValue</tt> operation on a map entry returned by the * iterator) the results of the iteration are undefined. The set * supports element removal, which removes the corresponding * mapping from the map, via the <tt>Iterator.remove</tt>, * <tt>Set.remove</tt>, <tt>removeAll</tt>, <tt>retainAll</tt> and * <tt>clear</tt> operations. It does not support the * <tt>add</tt> or <tt>addAll</tt> operations. * * @return a set view of the mappings contained in this map */ public Set<Map.Entry<K,V>> entrySet() { Set<Map.Entry<K,V>> es; return (es = entrySet) == null ? (entrySet = new EntrySet()) : es; } final class EntrySet extends AbstractSet<Map.Entry<K,V>> { public final int size() { return size; } public final void clear() { HashMap.this.clear(); } public final Iterator<Map.Entry<K,V>> iterator() { return new EntryIterator(); } public final boolean contains(Object o) { if (!(o instanceof Map.Entry)) return false; Map.Entry<?,?> e = (Map.Entry<?,?>) o; Object key = e.getKey(); Node<K,V> candidate = getNode(hash(key), key); return candidate != null && candidate.equals(e); } public final boolean remove(Object o) { if (o instanceof Map.Entry) { Map.Entry<?,?> e = (Map.Entry<?,?>) o; Object key = e.getKey(); Object value = e.getValue(); return removeNode(hash(key), key, value, true, true) != null; } return false; } public final Spliterator<Map.Entry<K,V>> spliterator() { return new EntrySpliterator<>(HashMap.this, 0, -1, 0, 0); } public final void forEach(Consumer<? super Map.Entry<K,V>> action) { Node<K,V>[] tab; if (action == null) throw new NullPointerException(); if (size > 0 && (tab = table) != null) { int mc = modCount; for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) action.accept(e); } if (modCount != mc) throw new ConcurrentModificationException(); } } } // Overrides of JDK8 Map extension methods @Override public V getOrDefault(Object key, V defaultValue) { Node<K,V> e; return (e = getNode(hash(key), key)) == null ? defaultValue : e.value; } @Override public V putIfAbsent(K key, V value) { return putVal(hash(key), key, value, true, true); } @Override public boolean remove(Object key, Object value) { return removeNode(hash(key), key, value, true, true) != null; } @Override public boolean replace(K key, V oldValue, V newValue) { Node<K,V> e; V v; if ((e = getNode(hash(key), key)) != null && ((v = e.value) == oldValue || (v != null && v.equals(oldValue)))) { e.value = newValue; afterNodeAccess(e); return true; } return false; } @Override public V replace(K key, V value) { Node<K,V> e; if ((e = getNode(hash(key), key)) != null) { V oldValue = e.value; e.value = value; afterNodeAccess(e); return oldValue; } return null; } @Override public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) { if (mappingFunction == null) throw new NullPointerException(); int hash = hash(key); Node<K,V>[] tab; Node<K,V> first; int n, i; int binCount = 0; TreeNode<K,V> t = null; Node<K,V> old = null; if (size > threshold || (tab = table) == null || (n = tab.length) == 0) n = (tab = resize()).length; if ((first = tab[i = (n - 1) & hash]) != null) { if (first instanceof TreeNode) old = (t = (TreeNode<K,V>)first).getTreeNode(hash, key); else { Node<K,V> e = first; K k; do { if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) { old = e; break; } ++binCount; } while ((e = e.next) != null); } V oldValue; if (old != null && (oldValue = old.value) != null) { afterNodeAccess(old); return oldValue; } } V v = mappingFunction.apply(key); if (v == null) { return null; } else if (old != null) { old.value = v; afterNodeAccess(old); return v; } else if (t != null) t.putTreeVal(this, tab, hash, key, v); else { tab[i] = newNode(hash, key, v, first); if (binCount >= TREEIFY_THRESHOLD - 1) treeifyBin(tab, hash); } ++modCount; ++size; afterNodeInsertion(true); return v; } public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { if (remappingFunction == null) throw new NullPointerException(); Node<K,V> e; V oldValue; int hash = hash(key); if ((e = getNode(hash, key)) != null && (oldValue = e.value) != null) { V v = remappingFunction.apply(key, oldValue); if (v != null) { e.value = v; afterNodeAccess(e); return v; } else removeNode(hash, key, null, false, true); } return null; } @Override public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) { if (remappingFunction == null) throw new NullPointerException(); int hash = hash(key); Node<K,V>[] tab; Node<K,V> first; int n, i; int binCount = 0; TreeNode<K,V> t = null; Node<K,V> old = null; if (size > threshold || (tab = table) == null || (n = tab.length) == 0) n = (tab = resize()).length; if ((first = tab[i = (n - 1) & hash]) != null) { if (first instanceof TreeNode) old = (t = (TreeNode<K,V>)first).getTreeNode(hash, key); else { Node<K,V> e = first; K k; do { if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) { old = e; break; } ++binCount; } while ((e = e.next) != null); } } V oldValue = (old == null) ? null : old.value; V v = remappingFunction.apply(key, oldValue); if (old != null) { if (v != null) { old.value = v; afterNodeAccess(old); } else removeNode(hash, key, null, false, true); } else if (v != null) { if (t != null) t.putTreeVal(this, tab, hash, key, v); else { tab[i] = newNode(hash, key, v, first); if (binCount >= TREEIFY_THRESHOLD - 1) treeifyBin(tab, hash); } ++modCount; ++size; afterNodeInsertion(true); } return v; } @Override public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) { if (value == null) throw new NullPointerException(); if (remappingFunction == null) throw new NullPointerException(); int hash = hash(key); Node<K,V>[] tab; Node<K,V> first; int n, i; int binCount = 0; TreeNode<K,V> t = null; Node<K,V> old = null; if (size > threshold || (tab = table) == null || (n = tab.length) == 0) n = (tab = resize()).length; if ((first = tab[i = (n - 1) & hash]) != null) { if (first instanceof TreeNode) old = (t = (TreeNode<K,V>)first).getTreeNode(hash, key); else { Node<K,V> e = first; K k; do { if (e.hash == hash && ((k = e.key) == key || (key != null && key.equals(k)))) { old = e; break; } ++binCount; } while ((e = e.next) != null); } } if (old != null) { V v; if (old.value != null) v = remappingFunction.apply(old.value, value); else v = value; if (v != null) { old.value = v; afterNodeAccess(old); } else removeNode(hash, key, null, false, true); return v; } if (value != null) { if (t != null) t.putTreeVal(this, tab, hash, key, value); else { tab[i] = newNode(hash, key, value, first); if (binCount >= TREEIFY_THRESHOLD - 1) treeifyBin(tab, hash); } ++modCount; ++size; afterNodeInsertion(true); } return value; } @Override public void forEach(BiConsumer<? super K, ? super V> action) { Node<K,V>[] tab; if (action == null) throw new NullPointerException(); if (size > 0 && (tab = table) != null) { int mc = modCount; for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) action.accept(e.key, e.value); } if (modCount != mc) throw new ConcurrentModificationException(); } } @Override public void replaceAll(BiFunction<? super K, ? super V, ? extends V> function) { Node<K,V>[] tab; if (function == null) throw new NullPointerException(); if (size > 0 && (tab = table) != null) { int mc = modCount; for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) { e.value = function.apply(e.key, e.value); } } if (modCount != mc) throw new ConcurrentModificationException(); } } /* ------------------------------------------------------------ */ // Cloning and serialization /** * Returns a shallow copy of this <tt>HashMap</tt> instance: the keys and * values themselves are not cloned. * * @return a shallow copy of this map */ @SuppressWarnings("unchecked") @Override public Object clone() { HashMap<K,V> result; try { result = (HashMap<K,V>)super.clone(); } catch (CloneNotSupportedException e) { // this shouldn't happen, since we are Cloneable throw new InternalError(e); } result.reinitialize(); result.putMapEntries(this, false); return result; } // These methods are also used when serializing HashSets final float loadFactor() { return loadFactor; } final int capacity() { return (table != null) ? table.length : (threshold > 0) ? threshold : DEFAULT_INITIAL_CAPACITY; } /** * Save the state of the <tt>HashMap</tt> instance to a stream (i.e., * serialize it). * * @serialData The <i>capacity</i> of the HashMap (the length of the * bucket array) is emitted (int), followed by the * <i>size</i> (an int, the number of key-value * mappings), followed by the key (Object) and value (Object) * for each key-value mapping. The key-value mappings are * emitted in no particular order. */ private void writeObject(java.io.ObjectOutputStream s) throws IOException { int buckets = capacity(); // Write out the threshold, loadfactor, and any hidden stuff s.defaultWriteObject(); s.writeInt(buckets); s.writeInt(size); internalWriteEntries(s); } /** * Reconstitute the {@code HashMap} instance from a stream (i.e., * deserialize it). */ private void readObject(java.io.ObjectInputStream s) throws IOException, ClassNotFoundException { // Read in the threshold (ignored), loadfactor, and any hidden stuff s.defaultReadObject(); reinitialize(); if (loadFactor <= 0 || Float.isNaN(loadFactor)) throw new InvalidObjectException("Illegal load factor: " + loadFactor); s.readInt(); // Read and ignore number of buckets int mappings = s.readInt(); // Read number of mappings (size) if (mappings < 0) throw new InvalidObjectException("Illegal mappings count: " + mappings); else if (mappings > 0) { // (if zero, use defaults) // Size the table using given load factor only if within // range of 0.25...4.0 float lf = Math.min(Math.max(0.25f, loadFactor), 4.0f); float fc = (float)mappings / lf + 1.0f; int cap = ((fc < DEFAULT_INITIAL_CAPACITY) ? DEFAULT_INITIAL_CAPACITY : (fc >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : tableSizeFor((int)fc)); float ft = (float)cap * lf; threshold = ((cap < MAXIMUM_CAPACITY && ft < MAXIMUM_CAPACITY) ? (int)ft : Integer.MAX_VALUE); @SuppressWarnings({"rawtypes","unchecked"}) Node<K,V>[] tab = (Node<K,V>[])new Node[cap]; table = tab; // Read the keys and values, and put the mappings in the HashMap for (int i = 0; i < mappings; i++) { @SuppressWarnings("unchecked") K key = (K) s.readObject(); @SuppressWarnings("unchecked") V value = (V) s.readObject(); putVal(hash(key), key, value, false, false); } } } /* ------------------------------------------------------------ */ // iterators abstract class HashIterator { Node<K,V> next; // next entry to return Node<K,V> current; // current entry int expectedModCount; // for fast-fail int index; // current slot HashIterator() { expectedModCount = modCount; Node<K,V>[] t = table; current = next = null; index = 0; if (t != null && size > 0) { // advance to first entry do {} while (index < t.length && (next = t[index++]) == null); } } public final boolean hasNext() { return next != null; } final Node<K,V> nextNode() { Node<K,V>[] t; Node<K,V> e = next; if (modCount != expectedModCount) throw new ConcurrentModificationException(); if (e == null) throw new NoSuchElementException(); if ((next = (current = e).next) == null && (t = table) != null) { do {} while (index < t.length && (next = t[index++]) == null); } return e; } public final void remove() { Node<K,V> p = current; if (p == null) throw new IllegalStateException(); if (modCount != expectedModCount) throw new ConcurrentModificationException(); current = null; K key = p.key; removeNode(hash(key), key, null, false, false); expectedModCount = modCount; } } final class KeyIterator extends HashIterator implements Iterator<K> { public final K next() { return nextNode().key; } } final class ValueIterator extends HashIterator implements Iterator<V> { public final V next() { return nextNode().value; } } final class EntryIterator extends HashIterator implements Iterator<Map.Entry<K,V>> { public final Map.Entry<K,V> next() { return nextNode(); } } /* ------------------------------------------------------------ */ // spliterators static class HashMapSpliterator<K,V> { final HashMap<K,V> map; Node<K,V> current; // current node int index; // current index, modified on advance/split int fence; // one past last index int est; // size estimate int expectedModCount; // for comodification checks HashMapSpliterator(HashMap<K,V> m, int origin, int fence, int est, int expectedModCount) { this.map = m; this.index = origin; this.fence = fence; this.est = est; this.expectedModCount = expectedModCount; } final int getFence() { // initialize fence and size on first use int hi; if ((hi = fence) < 0) { HashMap<K,V> m = map; est = m.size; expectedModCount = m.modCount; Node<K,V>[] tab = m.table; hi = fence = (tab == null) ? 0 : tab.length; } return hi; } public final long estimateSize() { getFence(); // force init return (long) est; } } static final class KeySpliterator<K,V> extends HashMapSpliterator<K,V> implements Spliterator<K> { KeySpliterator(HashMap<K,V> m, int origin, int fence, int est, int expectedModCount) { super(m, origin, fence, est, expectedModCount); } public KeySpliterator<K,V> trySplit() { int hi = getFence(), lo = index, mid = (lo + hi) >>> 1; return (lo >= mid || current != null) ? null : new KeySpliterator<>(map, lo, index = mid, est >>>= 1, expectedModCount); } public void forEachRemaining(Consumer<? super K> action) { int i, hi, mc; if (action == null) throw new NullPointerException(); HashMap<K,V> m = map; Node<K,V>[] tab = m.table; if ((hi = fence) < 0) { mc = expectedModCount = m.modCount; hi = fence = (tab == null) ? 0 : tab.length; } else mc = expectedModCount; if (tab != null && tab.length >= hi && (i = index) >= 0 && (i < (index = hi) || current != null)) { Node<K,V> p = current; current = null; do { if (p == null) p = tab[i++]; else { action.accept(p.key); p = p.next; } } while (p != null || i < hi); if (m.modCount != mc) throw new ConcurrentModificationException(); } } public boolean tryAdvance(Consumer<? super K> action) { int hi; if (action == null) throw new NullPointerException(); Node<K,V>[] tab = map.table; if (tab != null && tab.length >= (hi = getFence()) && index >= 0) { while (current != null || index < hi) { if (current == null) current = tab[index++]; else { K k = current.key; current = current.next; action.accept(k); if (map.modCount != expectedModCount) throw new ConcurrentModificationException(); return true; } } } return false; } public int characteristics() { return (fence < 0 || est == map.size ? Spliterator.SIZED : 0) | Spliterator.DISTINCT; } } static final class ValueSpliterator<K,V> extends HashMapSpliterator<K,V> implements Spliterator<V> { ValueSpliterator(HashMap<K,V> m, int origin, int fence, int est, int expectedModCount) { super(m, origin, fence, est, expectedModCount); } public ValueSpliterator<K,V> trySplit() { int hi = getFence(), lo = index, mid = (lo + hi) >>> 1; return (lo >= mid || current != null) ? null : new ValueSpliterator<>(map, lo, index = mid, est >>>= 1, expectedModCount); } public void forEachRemaining(Consumer<? super V> action) { int i, hi, mc; if (action == null) throw new NullPointerException(); HashMap<K,V> m = map; Node<K,V>[] tab = m.table; if ((hi = fence) < 0) { mc = expectedModCount = m.modCount; hi = fence = (tab == null) ? 0 : tab.length; } else mc = expectedModCount; if (tab != null && tab.length >= hi && (i = index) >= 0 && (i < (index = hi) || current != null)) { Node<K,V> p = current; current = null; do { if (p == null) p = tab[i++]; else { action.accept(p.value); p = p.next; } } while (p != null || i < hi); if (m.modCount != mc) throw new ConcurrentModificationException(); } } public boolean tryAdvance(Consumer<? super V> action) { int hi; if (action == null) throw new NullPointerException(); Node<K,V>[] tab = map.table; if (tab != null && tab.length >= (hi = getFence()) && index >= 0) { while (current != null || index < hi) { if (current == null) current = tab[index++]; else { V v = current.value; current = current.next; action.accept(v); if (map.modCount != expectedModCount) throw new ConcurrentModificationException(); return true; } } } return false; } public int characteristics() { return (fence < 0 || est == map.size ? Spliterator.SIZED : 0); } } static final class EntrySpliterator<K,V> extends HashMapSpliterator<K,V> implements Spliterator<Map.Entry<K,V>> { EntrySpliterator(HashMap<K,V> m, int origin, int fence, int est, int expectedModCount) { super(m, origin, fence, est, expectedModCount); } public EntrySpliterator<K,V> trySplit() { int hi = getFence(), lo = index, mid = (lo + hi) >>> 1; return (lo >= mid || current != null) ? null : new EntrySpliterator<>(map, lo, index = mid, est >>>= 1, expectedModCount); } public void forEachRemaining(Consumer<? super Map.Entry<K,V>> action) { int i, hi, mc; if (action == null) throw new NullPointerException(); HashMap<K,V> m = map; Node<K,V>[] tab = m.table; if ((hi = fence) < 0) { mc = expectedModCount = m.modCount; hi = fence = (tab == null) ? 0 : tab.length; } else mc = expectedModCount; if (tab != null && tab.length >= hi && (i = index) >= 0 && (i < (index = hi) || current != null)) { Node<K,V> p = current; current = null; do { if (p == null) p = tab[i++]; else { action.accept(p); p = p.next; } } while (p != null || i < hi); if (m.modCount != mc) throw new ConcurrentModificationException(); } } public boolean tryAdvance(Consumer<? super Map.Entry<K,V>> action) { int hi; if (action == null) throw new NullPointerException(); Node<K,V>[] tab = map.table; if (tab != null && tab.length >= (hi = getFence()) && index >= 0) { while (current != null || index < hi) { if (current == null) current = tab[index++]; else { Node<K,V> e = current; current = current.next; action.accept(e); if (map.modCount != expectedModCount) throw new ConcurrentModificationException(); return true; } } } return false; } public int characteristics() { return (fence < 0 || est == map.size ? Spliterator.SIZED : 0) | Spliterator.DISTINCT; } } /* ------------------------------------------------------------ */ // LinkedHashMap support /* * The following package-protected methods are designed to be * overridden by LinkedHashMap, but not by any other subclass. * Nearly all other internal methods are also package-protected * but are declared final, so can be used by LinkedHashMap, view * classes, and HashSet. */ // Create a regular (non-tree) node Node<K,V> newNode(int hash, K key, V value, Node<K,V> next) { return new Node<>(hash, key, value, next); } // For conversion from TreeNodes to plain nodes Node<K,V> replacementNode(Node<K,V> p, Node<K,V> next) { return new Node<>(p.hash, p.key, p.value, next); } // Create a tree bin node TreeNode<K,V> newTreeNode(int hash, K key, V value, Node<K,V> next) { return new TreeNode<>(hash, key, value, next); } // For treeifyBin TreeNode<K,V> replacementTreeNode(Node<K,V> p, Node<K,V> next) { return new TreeNode<>(p.hash, p.key, p.value, next); } /** * Reset to initial default state. Called by clone and readObject. */ void reinitialize() { table = null; entrySet = null; keySet = null; values = null; modCount = 0; threshold = 0; size = 0; } // Callbacks to allow LinkedHashMap post-actions void afterNodeAccess(Node<K,V> p) { } void afterNodeInsertion(boolean evict) { } void afterNodeRemoval(Node<K,V> p) { } // Called only from writeObject, to ensure compatible ordering. void internalWriteEntries(java.io.ObjectOutputStream s) throws IOException { Node<K,V>[] tab; if (size > 0 && (tab = table) != null) { for (int i = 0; i < tab.length; ++i) { for (Node<K,V> e = tab[i]; e != null; e = e.next) { s.writeObject(e.key); s.writeObject(e.value); } } } } /* ------------------------------------------------------------ */ // Tree bins /** * Entry for Tree bins. Extends LinkedHashMap.Entry (which in turn * extends Node) so can be used as extension of either regular or * linked node. */ static final class TreeNode<K,V> extends LinkedHashMap.Entry<K,V> { TreeNode<K,V> parent; // red-black tree links TreeNode<K,V> left; TreeNode<K,V> right; TreeNode<K,V> prev; // needed to unlink next upon deletion boolean red; TreeNode(int hash, K key, V val, Node<K,V> next) { super(hash, key, val, next); } /** * Returns root of tree containing this node. */ final TreeNode<K,V> root() { for (TreeNode<K,V> r = this, p;;) { if ((p = r.parent) == null) return r; r = p; } } /** * Ensures that the given root is the first node of its bin. */ static <K,V> void moveRootToFront(Node<K,V>[] tab, TreeNode<K,V> root) { int n; if (root != null && tab != null && (n = tab.length) > 0) { int index = (n - 1) & root.hash; TreeNode<K,V> first = (TreeNode<K,V>)tab[index]; if (root != first) { Node<K,V> rn; tab[index] = root; TreeNode<K,V> rp = root.prev; if ((rn = root.next) != null) ((TreeNode<K,V>)rn).prev = rp; if (rp != null) rp.next = rn; if (first != null) first.prev = root; root.next = first; root.prev = null; } assert checkInvariants(root); } } /** * Finds the node starting at root p with the given hash and key. * The kc argument caches comparableClassFor(key) upon first use * comparing keys. */ final TreeNode<K,V> find(int h, Object k, Class<?> kc) { TreeNode<K,V> p = this; do { int ph, dir; K pk; TreeNode<K,V> pl = p.left, pr = p.right, q; if ((ph = p.hash) > h) p = pl; else if (ph < h) p = pr; else if ((pk = p.key) == k || (k != null && k.equals(pk))) return p; else if (pl == null) p = pr; else if (pr == null) p = pl; else if ((kc != null || (kc = comparableClassFor(k)) != null) && (dir = compareComparables(kc, k, pk)) != 0) p = (dir < 0) ? pl : pr; else if ((q = pr.find(h, k, kc)) != null) return q; else p = pl; } while (p != null); return null; } /** * Calls find for root node. */ final TreeNode<K,V> getTreeNode(int h, Object k) { return ((parent != null) ? root() : this).find(h, k, null); } /** * Tie-breaking utility for ordering insertions when equal * hashCodes and non-comparable. We don't require a total * order, just a consistent insertion rule to maintain * equivalence across rebalancings. Tie-breaking further than * necessary simplifies testing a bit. */ static int tieBreakOrder(Object a, Object b) { int d; if (a == null || b == null || (d = a.getClass().getName(). compareTo(b.getClass().getName())) == 0) d = (System.identityHashCode(a) <= System.identityHashCode(b) ? -1 : 1); return d; } /** * Forms tree of the nodes linked from this node. * @return root of tree */ final void treeify(Node<K,V>[] tab) { TreeNode<K,V> root = null; for (TreeNode<K,V> x = this, next; x != null; x = next) { next = (TreeNode<K,V>)x.next; x.left = x.right = null; if (root == null) { x.parent = null; x.red = false; root = x; } else { K k = x.key; int h = x.hash; Class<?> kc = null; for (TreeNode<K,V> p = root;;) { int dir, ph; K pk = p.key; if ((ph = p.hash) > h) dir = -1; else if (ph < h) dir = 1; else if ((kc == null && (kc = comparableClassFor(k)) == null) || (dir = compareComparables(kc, k, pk)) == 0) dir = tieBreakOrder(k, pk); TreeNode<K,V> xp = p; if ((p = (dir <= 0) ? p.left : p.right) == null) { x.parent = xp; if (dir <= 0) xp.left = x; else xp.right = x; root = balanceInsertion(root, x); break; } } } } moveRootToFront(tab, root); } /** * Returns a list of non-TreeNodes replacing those linked from * this node. */ final Node<K,V> untreeify(HashMap<K,V> map) { Node<K,V> hd = null, tl = null; for (Node<K,V> q = this; q != null; q = q.next) { Node<K,V> p = map.replacementNode(q, null); if (tl == null) hd = p; else tl.next = p; tl = p; } return hd; } /** * Tree version of putVal. */ final TreeNode<K,V> putTreeVal(HashMap<K,V> map, Node<K,V>[] tab, int h, K k, V v) { Class<?> kc = null; boolean searched = false; TreeNode<K,V> root = (parent != null) ? root() : this; for (TreeNode<K,V> p = root;;) { int dir, ph; K pk; if ((ph = p.hash) > h) dir = -1; else if (ph < h) dir = 1; else if ((pk = p.key) == k || (k != null && k.equals(pk))) return p; else if ((kc == null && (kc = comparableClassFor(k)) == null) || (dir = compareComparables(kc, k, pk)) == 0) { if (!searched) { TreeNode<K,V> q, ch; searched = true; if (((ch = p.left) != null && (q = ch.find(h, k, kc)) != null) || ((ch = p.right) != null && (q = ch.find(h, k, kc)) != null)) return q; } dir = tieBreakOrder(k, pk); } TreeNode<K,V> xp = p; if ((p = (dir <= 0) ? p.left : p.right) == null) { Node<K,V> xpn = xp.next; TreeNode<K,V> x = map.newTreeNode(h, k, v, xpn); if (dir <= 0) xp.left = x; else xp.right = x; xp.next = x; x.parent = x.prev = xp; if (xpn != null) ((TreeNode<K,V>)xpn).prev = x; moveRootToFront(tab, balanceInsertion(root, x)); return null; } } } /** * Removes the given node, that must be present before this call. * This is messier than typical red-black deletion code because we * cannot swap the contents of an interior node with a leaf * successor that is pinned by "next" pointers that are accessible * independently during traversal. So instead we swap the tree * linkages. If the current tree appears to have too few nodes, * the bin is converted back to a plain bin. (The test triggers * somewhere between 2 and 6 nodes, depending on tree structure). */ final void removeTreeNode(HashMap<K,V> map, Node<K,V>[] tab, boolean movable) { int n; if (tab == null || (n = tab.length) == 0) return; int index = (n - 1) & hash; TreeNode<K,V> first = (TreeNode<K,V>)tab[index], root = first, rl; TreeNode<K,V> succ = (TreeNode<K,V>)next, pred = prev; if (pred == null) tab[index] = first = succ; else pred.next = succ; if (succ != null) succ.prev = pred; if (first == null) return; if (root.parent != null) root = root.root(); if (root == null || root.right == null || (rl = root.left) == null || rl.left == null) { tab[index] = first.untreeify(map); // too small return; } TreeNode<K,V> p = this, pl = left, pr = right, replacement; if (pl != null && pr != null) { TreeNode<K,V> s = pr, sl; while ((sl = s.left) != null) // find successor s = sl; boolean c = s.red; s.red = p.red; p.red = c; // swap colors TreeNode<K,V> sr = s.right; TreeNode<K,V> pp = p.parent; if (s == pr) { // p was s's direct parent p.parent = s; s.right = p; } else { TreeNode<K,V> sp = s.parent; if ((p.parent = sp) != null) { if (s == sp.left) sp.left = p; else sp.right = p; } if ((s.right = pr) != null) pr.parent = s; } p.left = null; if ((p.right = sr) != null) sr.parent = p; if ((s.left = pl) != null) pl.parent = s; if ((s.parent = pp) == null) root = s; else if (p == pp.left) pp.left = s; else pp.right = s; if (sr != null) replacement = sr; else replacement = p; } else if (pl != null) replacement = pl; else if (pr != null) replacement = pr; else replacement = p; if (replacement != p) { TreeNode<K,V> pp = replacement.parent = p.parent; if (pp == null) root = replacement; else if (p == pp.left) pp.left = replacement; else pp.right = replacement; p.left = p.right = p.parent = null; } TreeNode<K,V> r = p.red ? root : balanceDeletion(root, replacement); if (replacement == p) { // detach TreeNode<K,V> pp = p.parent; p.parent = null; if (pp != null) { if (p == pp.left) pp.left = null; else if (p == pp.right) pp.right = null; } } if (movable) moveRootToFront(tab, r); } /** * Splits nodes in a tree bin into lower and upper tree bins, * or untreeifies if now too small. Called only from resize; * see above discussion about split bits and indices. * * @param map the map * @param tab the table for recording bin heads * @param index the index of the table being split * @param bit the bit of hash to split on */ final void split(HashMap<K,V> map, Node<K,V>[] tab, int index, int bit) { TreeNode<K,V> b = this; // Relink into lo and hi lists, preserving order TreeNode<K,V> loHead = null, loTail = null; TreeNode<K,V> hiHead = null, hiTail = null; int lc = 0, hc = 0; for (TreeNode<K,V> e = b, next; e != null; e = next) { next = (TreeNode<K,V>)e.next; e.next = null; if ((e.hash & bit) == 0) { if ((e.prev = loTail) == null) loHead = e; else loTail.next = e; loTail = e; ++lc; } else { if ((e.prev = hiTail) == null) hiHead = e; else hiTail.next = e; hiTail = e; ++hc; } } if (loHead != null) { if (lc <= UNTREEIFY_THRESHOLD) tab[index] = loHead.untreeify(map); else { tab[index] = loHead; if (hiHead != null) // (else is already treeified) loHead.treeify(tab); } } if (hiHead != null) { if (hc <= UNTREEIFY_THRESHOLD) tab[index + bit] = hiHead.untreeify(map); else { tab[index + bit] = hiHead; if (loHead != null) hiHead.treeify(tab); } } } /* ------------------------------------------------------------ */ // Red-black tree methods, all adapted from CLR static <K,V> TreeNode<K,V> rotateLeft(TreeNode<K,V> root, TreeNode<K,V> p) { TreeNode<K,V> r, pp, rl; if (p != null && (r = p.right) != null) { if ((rl = p.right = r.left) != null) rl.parent = p; if ((pp = r.parent = p.parent) == null) (root = r).red = false; else if (pp.left == p) pp.left = r; else pp.right = r; r.left = p; p.parent = r; } return root; } static <K,V> TreeNode<K,V> rotateRight(TreeNode<K,V> root, TreeNode<K,V> p) { TreeNode<K,V> l, pp, lr; if (p != null && (l = p.left) != null) { if ((lr = p.left = l.right) != null) lr.parent = p; if ((pp = l.parent = p.parent) == null) (root = l).red = false; else if (pp.right == p) pp.right = l; else pp.left = l; l.right = p; p.parent = l; } return root; } static <K,V> TreeNode<K,V> balanceInsertion(TreeNode<K,V> root, TreeNode<K,V> x) { x.red = true; for (TreeNode<K,V> xp, xpp, xppl, xppr;;) { if ((xp = x.parent) == null) { x.red = false; return x; } else if (!xp.red || (xpp = xp.parent) == null) return root; if (xp == (xppl = xpp.left)) { if ((xppr = xpp.right) != null && xppr.red) { xppr.red = false; xp.red = false; xpp.red = true; x = xpp; } else { if (x == xp.right) { root = rotateLeft(root, x = xp); xpp = (xp = x.parent) == null ? null : xp.parent; } if (xp != null) { xp.red = false; if (xpp != null) { xpp.red = true; root = rotateRight(root, xpp); } } } } else { if (xppl != null && xppl.red) { xppl.red = false; xp.red = false; xpp.red = true; x = xpp; } else { if (x == xp.left) { root = rotateRight(root, x = xp); xpp = (xp = x.parent) == null ? null : xp.parent; } if (xp != null) { xp.red = false; if (xpp != null) { xpp.red = true; root = rotateLeft(root, xpp); } } } } } } static <K,V> TreeNode<K,V> balanceDeletion(TreeNode<K,V> root, TreeNode<K,V> x) { for (TreeNode<K,V> xp, xpl, xpr;;) { if (x == null || x == root) return root; else if ((xp = x.parent) == null) { x.red = false; return x; } else if (x.red) { x.red = false; return root; } else if ((xpl = xp.left) == x) { if ((xpr = xp.right) != null && xpr.red) { xpr.red = false; xp.red = true; root = rotateLeft(root, xp); xpr = (xp = x.parent) == null ? null : xp.right; } if (xpr == null) x = xp; else { TreeNode<K,V> sl = xpr.left, sr = xpr.right; if ((sr == null || !sr.red) && (sl == null || !sl.red)) { xpr.red = true; x = xp; } else { if (sr == null || !sr.red) { if (sl != null) sl.red = false; xpr.red = true; root = rotateRight(root, xpr); xpr = (xp = x.parent) == null ? null : xp.right; } if (xpr != null) { xpr.red = (xp == null) ? false : xp.red; if ((sr = xpr.right) != null) sr.red = false; } if (xp != null) { xp.red = false; root = rotateLeft(root, xp); } x = root; } } } else { // symmetric if (xpl != null && xpl.red) { xpl.red = false; xp.red = true; root = rotateRight(root, xp); xpl = (xp = x.parent) == null ? null : xp.left; } if (xpl == null) x = xp; else { TreeNode<K,V> sl = xpl.left, sr = xpl.right; if ((sl == null || !sl.red) && (sr == null || !sr.red)) { xpl.red = true; x = xp; } else { if (sl == null || !sl.red) { if (sr != null) sr.red = false; xpl.red = true; root = rotateLeft(root, xpl); xpl = (xp = x.parent) == null ? null : xp.left; } if (xpl != null) { xpl.red = (xp == null) ? false : xp.red; if ((sl = xpl.left) != null) sl.red = false; } if (xp != null) { xp.red = false; root = rotateRight(root, xp); } x = root; } } } } } /** * Recursive invariant check */ static <K,V> boolean checkInvariants(TreeNode<K,V> t) { TreeNode<K,V> tp = t.parent, tl = t.left, tr = t.right, tb = t.prev, tn = (TreeNode<K,V>)t.next; if (tb != null && tb.next != t) return false; if (tn != null && tn.prev != t) return false; if (tp != null && t != tp.left && t != tp.right) return false; if (tl != null && (tl.parent != t || tl.hash > t.hash)) return false; if (tr != null && (tr.parent != t || tr.hash < t.hash)) return false; if (t.red && tl != null && tl.red && tr != null && tr.red) return false; if (tl != null && !checkInvariants(tl)) return false; if (tr != null && !checkInvariants(tr)) return false; return true; } } }
Main.java:26: error: package exists in another module: java.base package java.util; ^ Main.java:137: error: class HashMap is public, should be declared in a file named HashMap.java public class HashMap<K,V> extends AbstractMap<K,V> ^ Main.java:137: error: cannot find symbol public class HashMap<K,V> extends AbstractMap<K,V> ^ symbol: class AbstractMap Main.java:138: error: cannot find symbol implements Map<K,V>, Cloneable, Serializable { ^ symbol: class Map Main.java:278: error: package Map does not exist static class Node<K,V> implements Map.Entry<K,V> { ^ Main.java:401: error: cannot find symbol transient Set<Map.Entry<K,V>> entrySet; ^ symbol: class Set location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:401: error: package Map does not exist transient Set<Map.Entry<K,V>> entrySet; ^ Main.java:487: error: cannot find symbol public HashMap(Map<? extends K, ? extends V> m) { ^ symbol: class Map location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:499: error: cannot find symbol final void putMapEntries(Map<? extends K, ? extends V> m, boolean evict) { ^ symbol: class Map location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:783: error: cannot find symbol public void putAll(Map<? extends K, ? extends V> m) { ^ symbol: class Map location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:904: error: cannot find symbol public Set<K> keySet() { ^ symbol: class Set location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:955: error: cannot find symbol public Collection<V> values() { ^ symbol: class Collection location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1004: error: cannot find symbol public Set<Map.Entry<K,V>> entrySet() { ^ symbol: class Set location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1004: error: package Map does not exist public Set<Map.Entry<K,V>> entrySet() { ^ Main.java:1799: error: package LinkedHashMap does not exist static final class TreeNode<K,V> extends LinkedHashMap.Entry<K,V> { ^ Main.java:913: error: cannot find symbol final class KeySet extends AbstractSet<K> { ^ symbol: class AbstractSet location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:916: error: cannot find symbol public final Iterator<K> iterator() { return new KeyIterator(); } ^ symbol: class Iterator location: class HashMap<K,V>.KeySet where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:921: error: cannot find symbol public final Spliterator<K> spliterator() { ^ symbol: class Spliterator location: class HashMap<K,V>.KeySet where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:964: error: cannot find symbol final class Values extends AbstractCollection<V> { ^ symbol: class AbstractCollection location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:967: error: cannot find symbol public final Iterator<V> iterator() { return new ValueIterator(); } ^ symbol: class Iterator location: class HashMap<K,V>.Values where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:969: error: cannot find symbol public final Spliterator<V> spliterator() { ^ symbol: class Spliterator location: class HashMap<K,V>.Values where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1009: error: cannot find symbol final class EntrySet extends AbstractSet<Map.Entry<K,V>> { ^ symbol: class AbstractSet location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1009: error: package Map does not exist final class EntrySet extends AbstractSet<Map.Entry<K,V>> { ^ Main.java:1012: error: cannot find symbol public final Iterator<Map.Entry<K,V>> iterator() { ^ symbol: class Iterator location: class HashMap<K,V>.EntrySet where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1012: error: package Map does not exist public final Iterator<Map.Entry<K,V>> iterator() { ^ Main.java:1032: error: cannot find symbol public final Spliterator<Map.Entry<K,V>> spliterator() { ^ symbol: class Spliterator location: class HashMap<K,V>.EntrySet where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1032: error: package Map does not exist public final Spliterator<Map.Entry<K,V>> spliterator() { ^ Main.java:1035: error: package Map does not exist public final void forEach(Consumer<? super Map.Entry<K,V>> action) { ^ Main.java:1460: error: cannot find symbol implements Iterator<K> { ^ symbol: class Iterator location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1465: error: cannot find symbol implements Iterator<V> { ^ symbol: class Iterator location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1470: error: cannot find symbol implements Iterator<Map.Entry<K,V>> { ^ symbol: class Iterator location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1470: error: package Map does not exist implements Iterator<Map.Entry<K,V>> { ^ Main.java:1471: error: package Map does not exist public final Map.Entry<K,V> next() { return nextNode(); } ^ Main.java:1515: error: cannot find symbol implements Spliterator<K> { ^ symbol: class Spliterator location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1587: error: cannot find symbol implements Spliterator<V> { ^ symbol: class Spliterator location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1658: error: cannot find symbol implements Spliterator<Map.Entry<K,V>> { ^ symbol: class Spliterator location: class HashMap<K,V> where K,V are type-variables: K extends Object declared in class HashMap V extends Object declared in class HashMap Main.java:1658: error: package Map does not exist implements Spliterator<Map.Entry<K,V>> { ^ Main.java:1671: error: package Map does not exist public void forEachRemaining(Consumer<? super Map.Entry<K,V>> action) { ^ Main.java:1700: error: package Map does not exist public boolean tryAdvance(Consumer<? super Map.Entry<K,V>> action) { ^ Main.java:296: error: cannot find symbol return Objects.hashCode(key) ^ Objects.hashCode(value); ^ symbol: variable Objects location: class Node<K,V> where K,V are type-variables: K extends Object declared in class Node V extends Object declared in class Node Main.java:296: error: cannot find symbol return Objects.hashCode(key) ^ Objects.hashCode(value); ^ symbol: variable Objects location: class Node<K,V> where K,V are type-variables: K extends Object declared in class Node V extends Object declared in class Node Main.java:308: error: package Map does not exist if (o instanceof Map.Entry) { ^ Main.java:309: error: package Map does not exist Map.Entry<?,?> e = (Map.Entry<?,?>)o; ^ Main.java:309: error: package Map does not exist Map.Entry<?,?> e = (Map.Entry<?,?>)o; ^ Main.java:310: error: cannot find symbol
s801656428
p03995
C++
#include <iostream> #include <cstring> #include <random> using namespace std; int map[100001][100001]; int main() { memset(map, -1, (unsigned long long)100001 * (unsigned long long)100001); int R, C, N; cin >> R >> C >> N; for(int i = 0; i < N; i++) { int r, c, a; cin >> r >> c >> a; map[r - 1][c - 1] = a; } bool flag = true; for(int i = 0; i < R; i++) { for(int j = 0; j < C; j++) { if(map[i][j] == -1) continue; int n = i + 1; while(n < R) { if(map[n][j] != -1) break; n++; } if(map[n][j] == -1) continue; int m = j + 1; while(m < C) { if(map[i][m] != -1) break; m++; } if(map[i][m] == -1) break; if(map[n][m] == -1) { map[n][m] = map[n][j] + map[i][m] - map[i][j]; if(map[n][m] < 0) { flag = false; break; } else { if(map[n][m] != map[n][j] + map[i][m] - map[i][j]) { flag = false; break; } } } } if(!flag) break; } if(flag) { random_device rnd(); if(rnd() % 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else cout << "No" << endl; }
a.cc: In function 'int main()': a.cc:58:22: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 58 | random_device rnd(); | ^~ a.cc:58:22: note: remove parentheses to default-initialize a variable 58 | random_device rnd(); | ^~ | -- a.cc:58:22: note: or replace parentheses with braces to value-initialize a variable a.cc:59:14: error: no match for 'operator%' (operand types are 'std::random_device' and 'int') 59 | if(rnd() % 2) { | ~~~~~ ^ ~ | | | | | int | std::random_device
s153186978
p03995
C++
#include <iostream> #include <cstring> #include <random> using namespace std; int map[100001][100001]; int main() { //memset(map, -1, 100001 * 100001); int R, C, N; cin >> R >> C >> N; for(int i = 0; i < N; i++) { int r, c, a; cin >> r >> c >> a; map[r - 1][c - 1] = a; } bool flag = true; for(int i = 0; i < R; i++) { for(int j = 0; j < C; j++) { if(map[i][j] == -1) continue; int n = i + 1; while(n < R) { if(map[n][j] != -1) break; n++; } if(map[n][j] == -1) continue; int m = j + 1; while(m < C) { if(map[i][m] != -1) break; m++; } if(map[i][m] == -1) break; if(map[n][m] == -1) { map[n][m] = map[n][j] + map[i][m] - map[i][j]; if(map[n][m] < 0) { flag = false; break; } else { if(map[n][m] != map[n][j] + map[i][m] - map[i][j]) { flag = false; break; } } } } if(!flag) break; } if(flag) { random_device rnd(); if(rnd() % 2) { cout << "Yes" << endl; } else { cout << "No" << endl; } } else cout << "No" << endl; }
a.cc: In function 'int main()': a.cc:58:22: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 58 | random_device rnd(); | ^~ a.cc:58:22: note: remove parentheses to default-initialize a variable 58 | random_device rnd(); | ^~ | -- a.cc:58:22: note: or replace parentheses with braces to value-initialize a variable a.cc:59:14: error: no match for 'operator%' (operand types are 'std::random_device' and 'int') 59 | if(rnd() % 2) { | ~~~~~ ^ ~ | | | | | int | std::random_device
s271778310
p03995
C++
#define _USE_MATH_DEFINES #include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstdio> #include <climits> #include <cstdlib> #include <vector> #include <queue> #include <unordered_map> #include <iomanip> using namespace std; #define ALL(a) (a).begin(),(a).end() #define FOR(i,a,b) for (int i=(a);i<(b);i++) #define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--) #define REP(i,n) for (int i=0;i<(n);i++) #define RREP(i,n) for (int i=(n)-1;i>=0;i--) #define INF (INT_MAX/3) #define PSB push_back #define PN 1000000007 typedef long long LL; //#define int long long //booooooooooooost //#include <boost/multiprecision/cpp_int.hpp> //#include <boost/multiprecision/cpp_dec_float.hpp> //namespace mp = boost::multiprecision; //多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100) LL inv_mod(LL a, LL m) { LL b, x, u, q, tmp; b = m; x = 1; u = 0; while (b > 0) { q = a / b; tmp = u; u = x - q * u; x = tmp; tmp = b; b = a - q * b; a = tmp; } return (x < 0) ? m + x : x; } typedef struct{ int r; int c; int a; } po; signed main() { auto f = [](po x, po y){ if (x.r == y.r) return x.c < y.c; else return x.r < y.r; }; auto g = [](po x, po y){ if (x.c == y.c) return x.r < y.r; else return x.c < y.c; }; int R, C, N; vector<po> arr; cin >> R >> C >> N; REP(i, N) { int r, c, a; cin >> r >> c >> a; arr.PSB(po{ r, c, a }); } sort(ALL(arr), f); int ff = 0, ll = 0; FOR(i, 1, N) { if (arr[i].r == arr[i - 1].r) ++ll; else { int mvalue = min_element(arr.begin() + ff, arr.begin() + ll + 1, [](po x, po y){return x.a < y.a; })->a; FOR(j, ff, ll + 1) arr[j].a -= mvalue; ++ll; ff = ll; } } int mvalue = min_element(arr.begin() + ff, arr.begin() + ll + 1, [](po x, po y){return x.a < y.a; })->a; FOR(j, ff, ll + 1) arr[j].a -= mvalue; sort(ALL(arr), g); ff = 0; ll = 0; FOR(i, 1, N) { if (arr[i].c == arr[i - 1].c) ++ll; else { int mvalue = min_element(arr.begin() + ff, arr.begin() + ll + 1, [](po x, po y){return x.a < y.a; })->a; FOR(j, ff, ll + 1) arr[j].a -= mvalue; ++ll; ff = ll; } } mvalue = min_element(arr.begin() + ff, arr.begin() + ll + 1, [](po x, po y){return x.a < y.a; })->a; FOR(j, ff, ll + 1) arr[j].a -= mvalue; bool flag = true; int cou = 0; REP(i, N) { if (arr[i].a != 0) { flag = false; ++cou; } } if (cout > 1) flag = true; cout << (flag ? "Yes" : "No") << endl; return 0; }
a.cc: In function 'int main()': a.cc:108:28: error: no match for 'operator>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int') 108 | } if (cout > 1) flag = true; | ~~~~ ^ ~ | | | | | int | std::ostream {aka std::basic_ostream<char>} a.cc:108:28: note: candidate: 'operator>(int, int)' (built-in) 108 | } if (cout > 1) flag = true; | ~~~~~^~~ a.cc:108:28: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int' 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:2: /usr/include/c++/14/bits/stl_iterator.h:462:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 462 | operator>(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:462:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 507 | operator>(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:507:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1714 | operator>(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1714:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1774 | operator>(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1774:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>' 108 | } if (cout > 1) flag = true; | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1058:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1058 | operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1058:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>' 108 | } if (cout > 1) flag = true; | ^ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:695:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 695 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:695:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/string_view:702:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 702 | operator> (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:702:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/string_view:710:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 710 | operator> (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:710:5: note: template argument deduction/substitution failed: a.cc:108:30: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/bits/basic_string.h:3915:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3915 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3915:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/bits/basic_string.h:3929:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3929 | operator>(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3929:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 108 | } if (cout > 1) flag = true; | ^ /usr/include/c++/14/bits/basic_string.h:3942:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator>(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3942 | operator>(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3942:5: note: template argument deduction/substitution failed: a.cc:108:30: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>' 108 | } if (cout > 1) flag = true; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68: /usr/include/c++/14/tuple:2619:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator>(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)' 2619 | operator>(const tuple<_TElements...>& __t, | ^~~~~~~~ /usr/include/c++/14/tuple:2619:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::tuple<_UTypes ...>' 108 | } if (cout > 1) flag = true; | ^ In file included from /usr/include/c++/14/vector:66, from a.cc:9: /usr/include/c++/14/bits/stl_vector.h:2102:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)' 2102 | operator>(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:2102:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::vector<_Tp, _Alloc>' 108 | } if (cout > 1) flag = true; | ^ In file included from /usr/include/c++/14/deque:66, from /usr/include/c++/14/queue:62, from a.cc:10: /usr/include/c++/14/bits/stl_deque.h:2349:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator>(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)' 2349 | operator>(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_deque.h:2349:5: note: template argument deduction/substitution failed: a.cc:108:30: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::deque<_Tp, _Alloc>' 108 | } if (cout > 1) flag = true; | ^ In file included from /usr/include/c++/14/queue:66: /usr/include/c++/14/bits/stl_queue.h:411:5: note: candidate: 'template<class _Tp, class
s427950074
p03995
C++
#include <iostream> #include <random> using namespace std; int map[100001][100001]; int main() { memset(map, -1, 100001 * 100001); int R, C, N; cin >> R >> C >> N; for(int i = 0; i < N; i++) { int r, c, a; cin >> r >> c >> a; map[r - 1][c - 1] = a; } bool flag = true; for(int i = 0; i < R; i++) { for(int j = 0; j < C; j++) { if(map[i][j] == -1) continue; int n = i + 1; while(n < R) { if(map[n][j] != -1) break; n++; } if(map[n][j] == -1) continue; int m = j + 1; while(m < C) { if(map[i][m] != -1) break; m++; } if(map[i][m] == -1) continue; if(map[n][m] == -1) { map[n][m] = map[n][j] + map[i][m] - map[i][j]; if(map[n][m] < 0) { flag = false; break; } else { if(map[n][m] != map[n][j] + map[i][m] - map[i][j]) { flag = false; break; } } } } if(!flag) break; } if(flag) cout << "Yes" << endl; else cout << "No" << endl; }
a.cc: In function 'int main()': a.cc:8:26: warning: integer overflow in expression of type 'int' results in '1410265409' [-Woverflow] 8 | memset(map, -1, 100001 * 100001); | ~~~~~~~^~~~~~~~ a.cc:8:3: error: 'memset' was not declared in this scope 8 | memset(map, -1, 100001 * 100001); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <random> +++ |+#include <cstring> 3 |
s697722642
p03995
C++
1000000000000000000
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1000000000000000000 | ^~~~~~~~~~~~~~~~~~~
s503009349
p03995
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<array> #include<bitset> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstring> #include<functional> #include<limits> #include<list> #include<map> #include<numeric> #include<set> #include<stack> #include<string> #include<sstream> #include<unordered_map> #include<queue> #include<vector> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; #define rep(i,A,b) for(int i=(A);i<(b);i++) #define rrep(i,A,b) for(int i=(b)-1;i>=(A);i--) #define all(A) (A).begin(),(A).end() #define dump(o) {cerr<<#o<<" "<<o<<endl;} #define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;} #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL const int MOD = 1e9 + 7; #define MAX 100010 signed main() { int R; cin >> R; int C; cin >> C; int N; cin >> N; static int a[3][MAX] = {}; fill(a[0], a[3], -1); int prevr = 0; bool flag = true; queue<int> Q; rep(i, 0, N) { int r, c, A; cin >> r >> c >> A; a[r % 3][c] = A; if (r >= 2) { Q.push(c); Q.push(c + 1); } if (prevr < r&&r >= 3) { while (!Q.empty()) { int j = Q.front(); Q.pop(); int cnt = 0; int x = a[(r - 2) % 3][j - 1], y = a[(r - 2) % 3][j], z = a[(r - 1) % 3][j - 1], w = a[(r - 1) % 3][j]; if (x == -1)cnt++; if (y == -1)cnt++; if (z == -1)cnt++; if (w == -1)cnt++; if (cnt >= 3)continue; if (cnt == 2) { if (z != -1 && r >= 3) { if (a[(r - 3) % 3][j] != -1 || a[(r - 3) % 3][j - 1] != -1)continue; if (w - z != a[(r - 3) % 3][j] - a[(r - 3) % 3][j - 1]) { flag = false; i = N; break; } } if (y != -1 && j >= 3) { if (a[(r - 2) % 3][j - 2] != -1 || a[(r - 1) % 3][j - 2] != -1)continue; if (w - z != a[(r - 2) % 3][j - 2] - a[(r - 1) % 3][j - 2]) { flag = false; i = N; break; } } continue; } if (cnt == 1) { bool flag2 = false; if (x == -1 && z + y - w >= 0) { flag2 = true; a[(r - 2) % 3][j - 1] = z + y - w; } if (y == -1 && x + w - z >= 0) { flag2 = true; a[(r - 2) % 3][j] = x + w - z; } if (z == -1 && x + w - y >= 0) { flag2 = true; a[(r - 1) % 3][j - 1] = x + w - y; } if (w == -1 && z + y - x >= 0) { flag2 = true; a[(r - 1) % 3][j] = z + y - x; Q.push(j + 1); } if (!flag2) { flag = false; i = N; break; } } if (cnt == 0) { if (x + w != y + z) { flag = false; i = N; break; } } } } } if (flag) { while (!Q.empty()) { int j = Q.front(); Q.pop(); int cnt = 0; int x = a[(R + 1 - 2) % 3][j - 1], y = a[(R + 1 - 2) % 3][j], z = a[(R + 1 - 1) % 3][j - 1], w = a[(R + 1 - 1) % 3][j]; if (x == -1)cnt++; if (y == -1)cnt++; if (z == -1)cnt++; if (w == -1)cnt++; if (cnt >= 3)continue; if (cnt == 2) { if (z != -1 && r >= 3) { if (a[(r - 3) % 3][j] != -1 || a[(r - 3) % 3][j - 1] != -1)continue; if (w - z != a[(r - 3) % 3][j] - a[(r - 3) % 3][j - 1]) { flag = false; i = N; break; } } if (y != -1 && j >= 3) { if (a[(r - 2) % 3][j - 2] != -1 || a[(r - 1) % 3][j - 2] != -1)continue; if (w - z != a[(r - 2) % 3][j - 2] - a[(r - 1) % 3][j - 2]) { flag = false; i = N; break; } } continue; } if (cnt == 1) { bool flag2 = false; if (x == -1 && z + y - w >= 0) { flag2 = true; a[(R + 1 - 2) % 3][j - 1] = z + y - w; } if (y == -1 && x + w - z >= 0) { flag2 = true; a[(R + 1 - 2) % 3][j] = x + w - z; } if (z == -1 && x + w - y >= 0) { flag2 = true; a[(R + 1 - 1) % 3][j - 1] = x + w - y; } if (w == -1 && z + y - x >= 0) { flag2 = true; a[(R + 1 - 1) % 3][j] = z + y - x; Q.push(j + 1); } if (!flag2) { flag = false; break; } } if (cnt == 0) { if (x + w != y + z) { flag = false; break; } } } } if (flag)cout << "Yes" << endl; else cout << "No" << endl; return 0; }
a.cc: In function 'int main()': a.cc:113:48: error: 'r' was not declared in this scope 113 | if (z != -1 && r >= 3) { | ^ a.cc:115:113: error: 'i' was not declared in this scope 115 | if (w - z != a[(r - 3) % 3][j] - a[(r - 3) % 3][j - 1]) { flag = false; i = N; break; } | ^ a.cc:118:48: error: 'r' was not declared in this scope 118 | if (a[(r - 2) % 3][j - 2] != -1 || a[(r - 1) % 3][j - 2] != -1)continue; | ^ a.cc:119:57: error: 'r' was not declared in this scope 119 | if (w - z != a[(r - 2) % 3][j - 2] - a[(r - 1) % 3][j - 2]) { flag = false; i = N; break; } | ^ a.cc:119:117: error: 'i' was not declared in this scope 119 | if (w - z != a[(r - 2) % 3][j - 2] - a[(r - 1) % 3][j - 2]) { flag = false; i = N; break; } | ^
s080196962
p03995
C
#include<stdio.h> #define RMAX 100001 #define CMAX 100001 #define NMAX 100000 unsigned long a[RMAX][CMAX], isfilled[RMAX][CMAX]; int r[NMAX], c[NMAX]; int main(void){ long i, j; long R, C, N, anow; scanf("%ld", &R); scanf("%ld", &C); scanf("%ld", &N); for(i = 0; i < N; i++){ scanf("%ld", &(r[i])); scanf("%ld", &(c[i])); scanf("%ld", &anow); a[r[i]][c[i]] = anow; isfilled[r[i]][c[i]] = 1; } for(i = 0; i < N - 1; i++){ for(j = i + 1; j < N; j++){ if(r[i] == r[j] || c[i] == c[j]) continue; switch(isfilled[r[i]][c[i]] + isfilled[r[i]][c[j]] + isfilled[r[j]][c[i]] + isfilled[r[j]][c[j]]){ case 4: if(a[r[i]][c[i]] + a[r[j]][c[j]] != a[r[j]][c[i]] + a[r[i]][c[j]]) goto no; break; case 3: if(!isfilled[r[i]][c[i]] || !isfilled[r[j]][c[j]]){ if(a[r[i]][c[i]] + a[r[j]][c[j]] > a[r[j]][c[i]] + a[r[i]][c[j]]) goto no; }else{ if(a[r[i]][c[i]] + a[r[j]][c[j]] < a[r[j]][c[i]] + a[r[i]][c[j]]) goto no; } break; } } } if(1){ printf("Yes"); }else{ no: printf("No"); } return 0; }
/tmp/ccucahyJ.o: in function `main': main.c:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0xa2): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0xee): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x13f): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x155): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x176): relocation truncated to fit: R_X86_64_PC32 against symbol `isfilled' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x1d8): relocation truncated to fit: R_X86_64_PC32 against symbol `r' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x1f6): relocation truncated to fit: R_X86_64_PC32 against symbol `c' defined in .bss section in /tmp/ccucahyJ.o main.c:(.text+0x20c): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s153039256
p03995
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <utility> using namespace std; int main() { int R,C,N; cin >> R >> C; cin >> N; int a[R][C]; for(int i=0;i<R;i++) { for(int j=0;j<C;j++) { a[i][j]=-1; } } int r,c,num; int sum = 0; for(int i=0;i<N;i++) { cin >> r << c << num; a[r][c] = num; sum += num; sum%=2; } /* for(int i=0;i<R;i++) { for(int j=0;j<C;i++) { if(a[i][j]!=-1 && ) { if() } } }*/ if(sum%2==0) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:26: error: no match for 'operator<<' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'int') 22 | cin >> r << c << num; | ~~~~~~~~ ^~ ~ | | | | | int | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} a.cc:22:26: note: candidate: 'operator<<(int, int)' (built-in) 22 | cin >> r << c << num; | ~~~~~~~~~^~~~ a.cc:22:26: note: no known conversion for argument 1 from 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} to 'int' In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ In file included from /usr/include/c++/14/bits/memory_resource.h:38, from /usr/include/c++/14/string:68: /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:22:21: note: cannot convert 'std::cin.std::basic_istream<char>::operator>>(r)' (type 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'}) to type 'std::byte' 22 | cin >> r << c << num; | ~~~~^~~~ In file included from /usr/include/c++/14/bits/ios_base.h:46: /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 22 | cin >> r << c << num; | ^ /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:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ 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 argument deduction/substitution failed: a.cc:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>' 22 | cin >> r << c << num; | ^ /usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)' 671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed: a.cc:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 22 | cin >> r << c << num; | ^ /usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)' 684 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:684:5: note: template argument deduction/substitution failed: a.cc:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 22 | cin >> r << c << num; | ^ /usr/include/c++/14/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)' 689 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s) | ^~~~~~~~ /usr/include/c++/14/ostream:689:5: note: template argument deduction/substitution failed: a.cc:22:29: note: 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>' 22 | cin >> r << c << num; | ^ /usr/include/c++/14/ostream:810:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)' 810 | opera
s825921587
p03995
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; template<typename T> using Graph = vector<vector<T>>; #define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, a) REP(i, 0, a) #define EACH(i, a) for (auto i: a) #define ITR(x, a) for (__typeof(a.begin()) x = a.begin(); x != a.end(); x++) #define ALL(a) (a.begin()), (a.end()) #define HAS(a, x) (a.find(x) != a.end()) #define endl '\n' #define mp(a, b) make_pair(a, b) int N; int R, C; vector<pair<int, int>> A; map<pair<int, int>, ll> M; bool is_inside(int r, int c) { return (0 <= r && r < R && 0 <= c && c < C); } bool calc_cell(int vr, int vc, int pr, int pc, int r1, int c1, int r2, int c2) { pair<int, int> vp = mp(vr, vc), pp = mp(pr, pc), p1 = mp(r1, c1), p2 = mp(r2, c2); if (HAS(M, vp)) { if (HAS(M, pp) && HAS(M, p1) && HAS(M, p2)) { return (M[vp] + M[pp] == M[p1] + M[p2]); } } else { if (HAS(M, pp) && HAS(M, p1) && HAS(M, p2)) { ll va = M[p1] + M[p2] - M[pp]; if (va < 0) return false; A.push_back(vp); M[vp] = va; } return true; } } bool check_cell(int r1, int c1, int r2, int c2, int r3, int c3, int r4, int r4) { if (is_inside(r1, c1) && is_inside(r2, c2) && is_inside(r3, c3) && is_inside(r4, r4)) { pair<int, int> p1 = mp(r1, c1), p2 = mp(r2, c2), p3 = mp(r3, c3), p4 = mp(r4, c4); if (HAS(M, p1) && HAS(M, p2) && HAS(M, p3) && HAS(M, p4)) { return (M[p1] - M[p2] == M[p3] - M[p4]); } } return true; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> R >> C; cin >> N; rep(i, N) { int r, c, a; cin >> r >> c >> a; r--; c--; A.push_back(make_pair(r, c)); M[mp(r, c)] = a; } bool ok = true; for (int i = 0; i < A.size(); i++) { int r = A[i].first, c = A[i].second; ll a = M[mp(r, c)]; int r1 = r - 1, c1 = c - 1; int r2 = r - 1, c2 = c; int r3 = r - 1, c3 = c + 1; int r4 = r, c4 = c - 1; int r5 = r, c5 = c + 1; int r6 = r + 1, c6 = c - 1; int r7 = r + 1, c7 = c; int r8 = r + 1, c8 = c + 1; // up left if (is_inside(r1, c1)) { ok = calc_cell(r1, c1, r, c, r2, c2, r4, c4) && calc_cell(r2, c2, r4, c4, r1, c1, r, c) && calc_cell(r4, c4, r2, c2, r1, c1, r, c); if (!ok) break; } //cout << "ul" << endl; // up right if (is_inside(r3, c3)) { ok = calc_cell(r3, c3, r, c, r2, c2, r5, c5) && calc_cell(r2, c2, r5, c5, r, c, r3, c3) && calc_cell(r5, c5, r2, c2, r, c, r3, c3); if (!ok) break; } //cout << "ur" << endl; // down left if (is_inside(r6, c6)) { ok = calc_cell(r6, c6, r, c, r4, c4, r7, c7) && calc_cell(r4, c4, r7, c7, r, c, r6, c6) && calc_cell(r7, c7, r4, c4, r, c, r6, c6); if (!ok) break; } //cout << "dl" << endl; // down right if (is_inside(r8, c8)) { ok = calc_cell(r8, c8, r, c, r5, c5, r7, c7) && calc_cell(r5, c5, r7, c7, r, c, r8, c8) && calc_cell(r7, c7, r5, c5, r, c, r8, c8); if (!ok) break; } //cout << "dr" << endl; ok = check_cell(r, c, r4, c4, r + 2, c, r + 2, c - 1) && check_cell(r, c, r4, c4, r - 2, c, r - 2, c - 1) && check_cell(r, c, r5, c5, r + 2, c, r + 2, c + 1) && check_cell(r, c, r5, c5, r - 2, c, r - 2, c + 1) && check_cell(r, c, r2, c2, r, c + 2, r + 1, c + 2) && check_cell(r, c, r2, c2, r, c - 2, r + 1, c - 2) && check_cell(r, c, r7, c7, r, c + 2, r - 1, c + 2) && check_cell(r, c, r7, c7, r, c - 2, r - 1, c - 2); if (!ok) break; } cout << (ok ? "Yes":"No") << endl; }
a.cc:41:77: error: redefinition of 'int r4' 41 | bool check_cell(int r1, int c1, int r2, int c2, int r3, int c3, int r4, int r4) { | ~~~~^~ a.cc:41:69: note: 'int r4' previously declared here 41 | bool check_cell(int r1, int c1, int r2, int c2, int r3, int c3, int r4, int r4) { | ~~~~^~ a.cc: In function 'bool check_cell(...)': a.cc:43:83: error: 'c4' was not declared in this scope; did you mean 'p4'? 43 | pair<int, int> p1 = mp(r1, c1), p2 = mp(r2, c2), p3 = mp(r3, c3), p4 = mp(r4, c4); | ^~ a.cc:13:31: note: in definition of macro 'mp' 13 | #define mp(a, b) make_pair(a, b) | ^ a.cc: In function 'bool calc_cell(int, int, int, int, int, int, int, int)': a.cc:39:1: warning: control reaches end of non-void function [-Wreturn-type] 39 | } | ^
s405111242
p03995
C++
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) using namespace std; const string YES = "Yes"; const string NO = "No"; struct Data { int x,y; bool operator < ( const Data& data ) const { if( x != data.x ) return x < data.x; return y < data.y; } bool operator == (const Data& data) const { return x == data.x && y == data.y; } }; int H,W,N; int dx[] = {1,0,-1,0}; int dy[] = {0,1,0,-1}; inline bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; } bool check(map<Data,int> &mp,int x,int y,int a) { rep(i,4) { int x2 = x + dx[i] * 2 , y2 = y + dy[i] * 2; if( !isValid(x2,y2) ) continue; int x3 = x + dx[(i+1)%4] * 2, y3 = y + dy[(i+1)%4] * 2; if( !isValid(x3,y3) ) continue; if( !mp.count((Data){x2,y2}) ) continue; if( !mp.count((Data){x3,y3}) ) continue; int x4 = x + dx[i] * 2 + dx[(i+1)%4] * 2; int y4 = y + dy[i] * 2 + dy[(i+1)%4] * 2; if( mp.count((Data){x4,y4}) ) { int a2 = mp[(Data){x4,y4}]; if( ( a + a2 ) != ( mp[(Data){x2,y2}] + mp[(Data){x3,y3}] ) ) return false; } } return true; } int main(){ scanf(" %d %d",&H,&W); scanf(" %d",&N); map<Data,int> mp; rep(i,N) { int x,y,a; scanf(" %d %d %d",&y,&x,&a); --x, --y; mp[(Data){x,y}] = a; } bool update = true; int cnt = 0; while( update ) { ++cnt; if( cnt >= 100 ) { cout << NO << endl; return 0: } update = false; map<Data,int> next; for(map<Data,int>::iterator it = mp.begin();it!=mp.end();++it) { int x = (it->first).x; int y = (it->first).y; int a = it->second; if( !check(mp,x,y,a) ) { cout << NO << endl; return 0; } //cout << x << "," << y << " = " << a <<endl; rep(i,4) { int x2 = x + dx[i], y2 = y + dy[i]; if( !isValid(x2,y2) ) continue; int x3 = x + dx[(i+1)%4], y3 = y + dy[(i+1)%4]; if( !isValid(x3,y3) ) continue; if( !mp.count((Data){x2,y2}) ) continue; if( !mp.count((Data){x3,y3}) ) continue; int x4 = x + dx[i] + dx[(i+1)%4]; int y4 = y + dy[i] + dy[(i+1)%4]; if( mp.count((Data){x4,y4}) ) { int v1 = a + mp[(Data){x4,y4}]; int v2 = mp[(Data){x2,y2}] + mp[(Data){x3,y3}]; if( v1 != v2 ) { cout << NO << endl; return 0; } } else { int v1 = a; int v2 = mp[(Data){x2,y2}] + mp[(Data){x3,y3}]; if( v2 - v1 < 0 ) { cout << NO << endl; return 0; } next[(Data){x4,y4}] = v2 - v1; update = true; } } if( update ) break; } for(map<Data,int>::iterator it = next.begin();it!=next.end();++it) { int x = (it->first).x; int y = (it->first).y; int a = it->second; mp[(Data){x,y}] = a; } } cout << YES << endl; return 0; }
a.cc: In function 'int main()': a.cc:61:52: error: expected ';' before ':' token 61 | if( cnt >= 100 ) { cout << NO << endl; return 0: } | ^ | ; a.cc:61:52: error: expected primary-expression before ':' token
s605980415
p03995
C++
/* * Created by KeigoOgawa */ #include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <map> #include <set> #include <cassert> #include <cmath> typedef long long ll; #define INF (int)1e10 #define EPS 1e-10 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n) - 1; i >= 0; i--) #define MIN(a, b) (a > b ? b : a) #define MAX(a, b) (a > b ? a : b) #define debug(x) cout << #x << ": " << x << endl #define all(a) (a).begin(), (a).end() using namespace std; typedef unsigned long long ull; typedef pair<int, int> PII; int R, C, N; int a[100000][100000] = {INF}; bool check() { REP(i, C - 1) { REP(j, R - 1) { int lu = a[i][j], ld = a[i + 1][j], ru = a[i][j + 1], rd = a[i + 1][j + 1]; if (lu < INF && ld < INF && ru < INF && rd < INF) { if (lu + rd != ld + ru || lu < 0 || rd < 0 || ld < 0 || ru < 0) { return false; } } } } return true; } bool ume3() { REP(i, C - 1) { REP(j, R - 1) { int lu = a[i][j], ld = a[i + 1][j], ru = a[i][j + 1], rd = a[i + 1][j + 1]; if (lu == INF && ld < INF && ru < INF && rd < INF) { lu = (ru + ld) - rd; if (lu < 0) return false; a[i][j] = lu; } if (lu < INF && ld == INF && ru < INF && rd < INF) { ld = (lu + rd) - ru; if (ld < 0) return false; a[i + 1][j] = ld; } if (lu < INF && ld < INF && ru == INF && rd < INF) { ru = (lu + rd) - ld; if (ru < 0) return false; a[i][j+1] = ru; } if (lu < INF && ld < INF && ru < INF && rd == INF) { rd = (ru + ld) - lu; if (rd < 0) return false; a[i + 1][j + 1] = rd; } } } return true; } void solve() { // 4 kakunin if (!check()) { cout << "No" << endl; return; } // 3 ume if (!ume3()) { cout << "No" << endl; return; } if (!check()) { cout << "No" << endl; return; } cout << "Yes" << endl; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> R >> C >> N; REP(i, N) { ll r, c, aa; cin >> r >> c >> aa; r--; c--; a[r][c] = aa; } solve(); return 0; }
g++: internal compiler error: File size limit exceeded signal terminated program as Please submit a full bug report, with preprocessed source (by using -freport-bug). See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
s249653508
p03995
C++
/* * Created by KeigoOgawa */ #include <cstdio> #include <iostream> #include <algorithm> #include <queue> #include <map> #include <set> #include <cassert> #include <cmath> typedef long long ll; #define INF (ll)1e10 #define EPS 1e-10 #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--) #define REP(i, n) for (int i = 0; i < (n); i++) #define RREP(i, n) for (int i = (n) - 1; i >= 0; i--) #define MIN(a, b) (a > b ? b : a) #define MAX(a, b) (a > b ? a : b) #define debug(x) cout << #x << ": " << x << endl #define all(a) (a).begin(), (a).end() using namespace std; typedef unsigned long long ull; typedef pair<int, int> PII; ll R, C, N; ll a[100000][100000] = {INF}; bool check() { REP(i, C - 1) { REP(j, R - 1) { int lu = a[i][j], ld = a[i + 1][j], ru = a[i][j + 1], rd = a[i + 1][j + 1]; if (lu < INF && ld < INF && ru < INF && rd < INF) { if (lu + rd != ld + ru || lu < 0 || rd < 0 || ld < 0 || ru < 0) { return false; } } } } return true; } bool ume3() { REP(i, C - 1) { REP(j, R - 1) { ll lu = a[i][j], ld = a[i + 1][j], ru = a[i][j + 1], rd = a[i + 1][j + 1]; if (lu == INF && ld < INF && ru < INF && rd < INF) { lu = (ru + ld) - rd; if (lu < 0) return false; a[i][j] = lu; } if (lu < INF && ld == INF && ru < INF && rd < INF) { ld = (lu + rd) - ru; if (ld < 0) return false; a[i + 1][j] = ld; } if (lu < INF && ld < INF && ru == INF && rd < INF) { ru = (lu + rd) - ld; if (ru < 0) return false; a[i][j+1] = ru; } if (lu < INF && ld < INF && ru < INF && rd == INF) { rd = (ru + ld) - lu; if (rd < 0) return false; a[i + 1][j + 1] = rd; } } } return true; } void solve() { // 4 kakunin if (!check()) { cout << "No" << endl; return; } // 3 ume if (!ume3()) { cout << "No" << endl; return; } if (!check()) { cout << "No" << endl; return; } cout << "Yes" << endl; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); cin >> R >> C >> N; REP(i, N) { ll r, c, aa; cin >> r >> c >> aa; r--; c--; a[r][c] = aa; } solve(); return 0; }
g++: internal compiler error: File size limit exceeded signal terminated program as Please submit a full bug report, with preprocessed source (by using -freport-bug). See <file:///usr/share/doc/gcc-14/README.Bugs> for instructions.
s360565983
p03995
C++
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <complex> #include <string> #include <vector> #include <list> #include <deque> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <functional> #include <utility> #include <algorithm> #include <numeric> #include <typeinfo> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <ctime> #define INF 10000000007LL using namespace std; typedef long long ll; typedef pair<ll,ll> P; int R,C,N; int r[100001],c[100001]; ll a[100001]; vector<P> xid[100001],yid[100001]; vector<P> xlimit[100001]; vector<P> ylimit[100001]; ll mini[100001],mini2[100001]; bool checked[100001]; ll dist[100001]; bool flag=true; vector<int> route; ll dmini; void dfs(int v,ll s){ dist[v]=s; checked[v]=true; dmini=min(dmini,dist[v]); route.push_back(v); for(int i=0;i<xlimit[v].size();i++){ P p=xlimit[v][i]; if(!checked[p.first]){ dfs(p.first,s+p.second); }else if(dist[v]+p.second!=dist[p.first])flag=false; } } void dfs2(int v,ll s){ dist[v]=s; checked[v]=true; for(int i=0;i<ylimit[v].size();i++){ P p=ylimit[v][i]; if(!checked[p.first]){ dfs2(p.first,s+p.second); }else if(dist[v]+p.second!=dist[p.first])flag=false; } } int main(void){ scanf("%d%d%d",&R,&C,&N); for(int i=0;i<max(C,R);i++){ mini[i]=INF; mini2[i]=INF; } for(int i=0;i<N;i++){ scanf("%d%d%lld",&r[i],&c[i],&a[i]); r[i]--; c[i]--; xid[r[i]].push_back(P(c[i],a[i])); yid[c[i]].push_back(P(r[i],a[i])); mini[c[i]]=min(mini[c[i]],a[i]); mini2[r[i]]=min(mini2[r[i]],a[i]); } for(int i=0;i<R;i++){ if(xid[i].size()<=1)continue; int f=xid[i][0].first; for(int j=1;j<xid[i].size();j++){ int t=xid[i][j].first; ll c=xid[i][0].second-xid[i][j].second; xlimit[f].push_back(P(t,-c)); xlimit[t].push_back(P(f,c)); if(mini[f]-c<0)flag=false; if(mini[t]+c<0)flag=false; } } for(int i=0;i<C;i++){ if(yid[i].size()<=1)continue; int f=yid[i][0].first; for(int j=1;j<yid[i].size();j++){ int t=yid[i][j].first; ll c=yid[i][0].second-yid[i][j].second; ylimit[f].push_back(P(t,-c)); ylimit[t].push_back(P(f,c)); if(mini2[f]-c<0)flag=false; if(mini2[t]+c<0)flag=false; } } for(int i=0;i<R;i++){ if(!checked[i]){ dmini=INF; dfs(i,0); for(int j=0;j<route.size();j++){ if(mini[route[j]]-(dist[route[j]]-dmini)<0)flag=false; } route.clear(); } } memset(checked,false,sizeof(checked)); memset(dist,0,sizeof(dist)); for(int i=0;i<C;i++){ if(!checked[i]){ dmini=INF; dfs2(i,0); for(int j=0;j<route.size();j++){ if(mini[route[j]]-(dist[route[j]]-dmini)<0)flag=false; } route.clear(); } printf("%s\n",flag?"Yes":"No"); return 0; }
a.cc: In function 'int main()': a.cc:132:2: error: expected '}' at end of input 132 | } | ^ a.cc:68:15: note: to match this '{' 68 | int main(void){ | ^
s337501851
p03995
C++
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <complex> #include <string> #include <vector> #include <list> #include <deque> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <functional> #include <utility> #include <algorithm> #include <numeric> #include <typeinfo> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <ctime> #define INF 1000000007LL using namespace std; typedef long long ll; typedef pair<ll,ll> P; int R,C,N; int r[100001],c[100001]; ll a[100001]; vector<P> xid[100001],yid[100001]; vector<P> xlimit[100001]; vector<P> ylimit[100001]; ll mini[100001],mini2[100001]; bool checked[100001]; ll dist[100001]; bool flag=true; vector<int> route; ll dmini; void dfs(int v,ll s){ dist[v]=s; checked[v]=true; dmini=min(dmini,dist[v]); route.push_back(v); for(int i=0;i<xlimit[v].size();i++){ P p=xlimit[v][i]; if(!checked[p.first]){ dfs(p.first,s+p.second); }else if(dist[v]+p.second!=dist[p.first])flag=false; } } void dfs2(int v,ll s){ dist[v]=s; checked[v]=true; for(int i=0;i<ylimit[v].size();i++){ P p=ylimit[v][i]; if(!checked[p.first]){ dfs2(p.first,s+p.second); }else if(dist[v]+p.second!=dist[p.first])flag=false; } } int main(void){ scanf("%d%d%d",&R,&C,&N); for(int i=0;i<max(C,R);i++){ mini[i]=INF; mini2[i]=INF; } for(int i=0;i<N;i++){ scanf("%d%d%lld",&r[i],&c[i],&a[i]); r[i]--; c[i]--; xid[r[i]].push_back(P(c[i],a[i])); yid[c[i]].push_back(P(r[i],a[i])); mini[c[i]]=min(mini[c[i]],a[i]); mini2[r[i]]=min(mini2[r[i]],a[i]); } for(int i=0;i<R;i++){ if(xid[i].size()<=1)continue; int f=xid[i][0].first; for(int j=1;j<xid[i].size();j++){ int t=xid[i][j].first; ll c=xid[i][0].second-xid[i][j].second; xlimit[f].push_back(P(t,-c)); xlimit[t].push_back(P(f,c)); if(mini[f]-c<0)flag=false; if(mini[t]+c<0)flag=false; } } for(int i=0;i<C;i++){ if(yid[i].size()<=1)continue; int f=yid[i][0].first; for(int j=1;j<yid[i].size();j++){ int t=yid[i][j].first; ll c=yid[i][0].second-yid[i][j].second; ylimit[f].push_back(P(t,-c)); ylimit[t].push_back(P(f,c)); if(mini2[f]-c<0)flag=false; if(mini2[t]+c<0)flag=false; } } for(int i=0;i<R;i++){ if(!checked[i]){ dmini=INF; dfs(i,0); for(int j=0;j<route.size();j++){ if(mini[route[j]]-(dist[route[j]]-dmini)<0)flag=false; } route.clear(); } } memset(checked,false,sizeof(checked)); memset(dist,0,sizeof(dist)); for(int i=0;i<C;i++){ if(!checked[i]){ dfs2(i,0); } printf("%s\n",flag?"Yes":"No"); return 0; }
a.cc: In function 'int main()': a.cc:127:2: error: expected '}' at end of input 127 | } | ^ a.cc:68:15: note: to match this '{' 68 | int main(void){ | ^
s406772947
p03995
C++
#include <cstdio> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <cmath> #include <string> #include <map> #include <unordered_map> #include <queue> using namespace std; typedef long long LL; const int dx[] = {0, 1, 1, 0}; const int dy[] = {0, 1, 0, 1}; int data[100005][100005]; int val[100005][100005]; int r, c; int n; queue<pair<int, int> > Q; void check(int x, int y) { val[x][y] -= 1; if (x > 0) { val[x - 1][y] -= 1; if (val[x - 1][y] == 1) { Q.push(make_pair(x - 1, y)); } } if (y > 0) { val[x][y - 1] -= 1; if (val[x][y - 1] == 1) { Q.push(make_pair(x, y - 1)); } } if (x > 0 && y > 0) { val[x - 1][y - 1] -= 1; if (val[x - 1][y - 1] == 1) { Q.push(make_pair(x - 1, y - 1)); } } } int main() { scanf("%d %d", &r, &c); scanf("%d", &n); for (int i = 0; i < r; i += 1) { for (int j = 0; j < c; j += 1) { data[i][j] = -1; val[i][j] = 4; } } for (int i = 0; i < n; i += 1) { int x, y, a; scanf("%d %d %d", &x, &y, &a); x -= 1; y -= 1; data[x][y] = a; check(x, y); } while (!Q.empty()) { int x = Q.front().first, y = Q.front().second; Q.pop(); int pos = -1, flag = 0; for (int i = 0; i < 4; i += 1) { if (data[x + dx[i]][y + dy[i]] == -1) { pos = i; flag += 1; } } if (flag != 1) { if (data[x][y] + data[x + 1][y + 1] != data[x][y + 1] + data[x + 1][y]) { printf("NO\n"); return 0; } } if (pos == 0) { data[x][y] = data[x + 1][y] + data[x][y + 1] - data[x + 1][y + 1]; if (data[x][y] < 0) { printf("NO\n"); return 0; } check(x, y); } else if (pos == 1) { data[x + 1][y + 1] = data[x + 1][y] + data[x][y + 1] - data[x][y]; if (data[x + 1][y + 1] < 0) { printf("NO\n"); return 0; } check(x + 1, y + 1); } else if (pos == 2) { data[x + 1][y] = data[x][y] + data[x + 1][y + 1] - data[x][y + 1]; if (data[x + 1][y] < 0) { printf("NO\n"); return 0; } check(x + 1, y); } else { data[x][y + 1] = data[x][y] + data[x + 1][y + 1] - data[x + 1][y]; if (data[x][y + 1] < 0) { printf("NO\n"); return 0; } check(x, y + 1); } } for (int i = 0; i < r; i += 1) { for (int j = 0; j < c; j += 1) { if (val[i][j] == 0) { if (data[i][j] + data[i + 1][j + 1] != data[i][j + 1] + data[i + 1][j]) { printf("NO\n"); return 0; } } } } printf("YES\n"); return 0; }
a.cc: In function 'int main()': a.cc:55:7: error: reference to 'data' is ambiguous 55 | data[i][j] = -1; | ^~~~ In file included from /usr/include/c++/14/vector:69, from a.cc:5: /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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:64:5: error: reference to 'data' is ambiguous 64 | data[x][y] = a; | ^~~~ /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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:72:11: error: reference to 'data' is ambiguous 72 | if (data[x + dx[i]][y + dy[i]] == -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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:78:11: error: reference to 'data' is ambiguous 78 | if (data[x][y] + data[x + 1][y + 1] != data[x][y + 1] + data[x + 1][y]) { | ^~~~ /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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:78:24: error: reference to 'data' is ambiguous 78 | if (data[x][y] + data[x + 1][y + 1] != data[x][y + 1] + data[x + 1][y]) { | ^~~~ /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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:78:46: error: reference to 'data' is ambiguous 78 | if (data[x][y] + data[x + 1][y + 1] != data[x][y + 1] + data[x + 1][y]) { | ^~~~ /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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:78:63: error: reference to 'data' is ambiguous 78 | if (data[x][y] + data[x + 1][y + 1] != data[x][y + 1] + data[x + 1][y]) { | ^~~~ /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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:84:7: error: reference to 'data' is ambiguous 84 | data[x][y] = data[x + 1][y] + data[x][y + 1] - data[x + 1][y + 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:21:5: note: 'int data [100005][100005]' 21 | int data[100005][100005]; | ^~~~ a.cc:84:20: error: reference to 'data' is ambiguous 84 | data[x][y] = data[x + 1][y] + data[x][y + 1] - data[x + 1][y + 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])' 3
s023753027
p03995
C++
#include <cstdio> #include <vector> #include <map> using namespace std; using pii=pair<int, int>; using ppi=pair<pii, int>; using mpi=map<pii, int>; static const int di[]={-1, -1, 1, 1}, dj[]={-1, 1, -1, 1}; bool is_valid(const ppi &item, mpi &dict, mpi &extdict) { int i=item.first.first, j=item.first.second; int a=item.second; for (int k=0; k<4; ++k) { int I=i+di[k], J=j+dj[k]; int fcount=0; int matched=0; if (dict.find(pii(I, J)) != dict.end()) ++fcount, matched|=1; if (dict.find(pii(I, j)) != dict.end()) ++fcount, matched|=2; if (dict.find(pii(i, J)) != dict.end()) ++fcount, matched|=4; if (fcount <= 1) continue; if (fcount == 2) { int b=0; pii blank; if (matched == 6) { b = dict[pii(I, j)]+dict[pii(i, J)]-a; blank = pii(I, J); } else if (matched == 3) { b = a+dict[pii(I, J)]-dict[pii(I, j)]; blank = pii(i, J); } else if (matched == 5) { b = a+dict[pii(I, J)]-dict[pii(i, J)]; blank = pii(I, j); } if (b < 0) { return false; } else if (extdict.find(blank)!=extdict.end() && extdict[blank]!=b) { return false; } else { extdict[blank] = b; } } else { if (dict[pii(I, J)]+a != dict[pii(I, j)]+dict[pii(i, J)]) return false; } } return true; } int main() { int R, C, N; scanf("%d %d %d", &R, &C, &N); mpi dict; for (int i=0; i<N; ++i) { int r, c, a; scanf("%d %d %d", &r, &c, &a); dict[pii(r, c)] = a; } mpi extdict; for (auto item: dict) { if (!is_valid(item, dict, extdict)) { printf("No\n"); return 0; } } for (auto item: extdict) { if (dict.find(item.first)!=dict.end()&&find[item.first]!=item.second) { printf("No\n"); return 0; } dict[item.first] = item.second; } mpi extdict2; for (auto item: extdict) { if (!is_valid(item, dict, extdict2)) { printf("No\n"); return 0; } } printf("Yes\n"); return 0; }
a.cc: In function 'int main()': a.cc:78:48: error: 'find' was not declared in this scope 78 | if (dict.find(item.first)!=dict.end()&&find[item.first]!=item.second) { | ^~~~
s976032224
p03995
C++
#include <stdio.h> #include <vector> #include <iostream> #include <string> using namespace std; int R; int C; int N; int rs; int cs; long int as; bool dame=false; int po(char o){ return (int)o; } int main(){ scanf("%d %d %d",&R,&C,&N); vector< vector<int> > D(C, vector<int>(R, -1)); for(i=0;i<R && dame==false;i++){ for(int j=0;j<C;j++){ D[i][j]=-1; } } for(long long int i=0;i<N;i++){ scanf("%d %d %ld",&rs,&cs,&as); D[rs-1][cs-1]=as; } for(int i=0;i<R-1 && dame==false;i++){ for(int j=0;j<C-1;j++){ if(D[i][j]!=-1 && D[i][j+1]!=-1 && D[i+1][j]!=-1 && D[i+1][j+1]!=-1){ if(D[i][j]+D[i+1][j+1] != D[i+1][j]+D[i][j+1])dame=true; } if(D[i][j]!=-1 && D[i][j+1]!=-1 && D[i+1][j]!=-1 ){ D[i+1][j+1]= D[i+1][j]+D[i][j+1]-D[i][j]; if(D[i+1][j+1]<0)dame=true; } if(D[i][j]!=-1 && D[i][j+1]!=-1 && D[i+1][j+1]!=-1 ){ D[i+1][j]=D[i][j]+D[i+1][j+1] - D[i][j+1]; if(D[i+1][j]<0)dame=true; } if(D[i][j]!=-1 && D[i+1][j]!=-1 && D[i+1][j+1]!=-1){ D[i][j+1]=D[i][j]+D[i+1][j+1] - D[i+1][j]; if(D[i][j+1]<0)dame=true; } if(D[i][j+1]!=-1 && D[i+1][j]!=-1 && D[i+1][j+1]!=-1){ D[i][j]= D[i+1][j]+D[i][j+1]-D[i+1][j+1]; if(D[i][j]<0)dame=true; } } } if(dame==false)cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:28:13: error: 'i' was not declared in this scope 28 | for(i=0;i<R && dame==false;i++){ | ^
s278036005
p03995
C++
#include <bits/stdc++.h> using namespace std; using LL = long long int; int vx[4] = {-1, -1, +1, +1}; int vy[4] = {-1, +1, -1, +1}; int main(){ int R, C, N; cin >> R >> C >> N; vector<int> r(N), c(N), a(N); vector<vector<LL>> state(R+2, vector<LL>(C+2, -1)), cond(R+2, vector<LL>(C+2, -1)); for(int i = 0; i < N; i++){ cin >> r[i] >> c[i] >> a[i]; state[r[i]][c[i]] = a[i]; } for(int i = 0; i < N; i++){ for(int j = 0; j < 4; j++){ int x = r[i] + vx[j]; int y = c[i] + vy[j]; if(state[x][y] == -1){ if(state[x][c[i]] != -1 && state[r[i]][y] != -1){ state[x][y] = state[x][c[i]] + state[r[i]][y] - a[i]; if(state[x][y] < 0){ cout << "No" << endl; return 0 } }else if(cond[x][y] == -1){ cond[x][y] = a[i] % 2; }else if(cond[x][y] != a[i] % 2){ cout << "No" << endl; return 0 } }else{ if(state[x][c[i]] != -1 && state[r[i]][y] != -1){ if(a[i] + state[x][y] != state[x][c[i]] + state[r[i]][y]){ cout << "No" << endl; return 0 } }else if(state[x][c[i]] != -1){ state[r[i]][y] = a[i] + state[x][y] - state[x][c[i]]; if(state[r[i]][y] < 0){ cout << "No" << endl; return 0 } }else if(state[r[i]][y] != -1){ state[x][c[i]] = a[i] + state[x][y] - state[r[i]][y]; if(state[r[i]][y] < 0){ cout << "No" << endl; return 0 } } } } } cout << "Yes" << endl; return 0; }
a.cc: In function 'int main()': a.cc:26:57: error: expected ';' before '}' token 26 | return 0 | ^ | ; 27 | } | ~ a.cc:32:49: error: expected ';' before '}' token 32 | return 0 | ^ | ; 33 | } | ~ a.cc:38:57: error: expected ';' before '}' token 38 | return 0 | ^ | ; 39 | } | ~ a.cc:44:57: error: expected ';' before '}' token 44 | return 0 | ^ | ; 45 | } | ~ a.cc:50:57: error: expected ';' before '}' token 50 | return 0 | ^ | ; 51 | } | ~
s050313018
p03995
C++
#include <iostream> using namespace std; int R, C, N; int r[100000], c[100000], a[100000]; int field[100000][100000]; bool filled[100000][100000]; const int dx[] = {1, 1, -1, -1}; const int dy[] = {1, -1, 1, -1}; bool isIllegal(int i) { int ri = r[i]; int ci = c[i]; int ai = a[i]; for (int j = 0; j < 4; j++) { int y = ri + dy[j]; int x = ci + dx[j]; if (x < 0 || C <= x || y < 0 || R <= y) continue; int cnt = 1 + filled[ri][x] + filled[y][ci] + filled[y][x]; if (cnt <= 2) continue; if (cnt == 4) { if (ai + field[y][x] != field[ri][x] + field[y][ci]) { return true; } } else if (!filled[ri][x]) { int temp = ai + field[y][x] - field[y][ci]; if (temp < 0) return true; field[ri][x] = temp; filled[ri][x] = true; } else if (!filled[y][ci]) { int temp = ai + field[y][x] - field[ri][x]; if (temp < 0) return true; field[y][ci] = temp; filled[y][ci] = true; } else if (!filled[y][x]) { int temp = field[ri][x] + field[y][ci] - ai; if (temp < 0) return true; field[y][x] = temp; filled[y][x] = true; } } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> R >> C >> N; for (int i = 0; i < N; i++) { cin >> r[i] >> c[i] >> a[i]; r[i]--; c[i]--; field[r[i]][c[i]] = a[i]; filled[r[i]][c[i]] = true; } for (int i = 0; i < N; i++) { if (isIllegal(i)) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
/tmp/ccyafRfv.o: in function `isIllegal(int)': a.cc:(.text+0xe9): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x138): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x2c7): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x2ee): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x3b0): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x3d7): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o a.cc:(.text+0x491): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o /tmp/ccyafRfv.o: in function `main': a.cc:(.text+0x6a7): relocation truncated to fit: R_X86_64_PC32 against symbol `filled' defined in .bss section in /tmp/ccyafRfv.o collect2: error: ld returned 1 exit status
s996351935
p03995
C++
#include<bits/stdc++.h> #define f first #define s second using namespace std; typedef long long ll; typedef pair<int,int> P; int main(){ int R,C,n; pair<P,int> o[100000]; map<P,int> mp; cin>>R>>C; cin>>n; for(int i=0;i<n;i++){ cin>>o[i].f.f>>o[i].f.s>>o[i].s; mp[o[i]]=o[i].s; } sort(o,o+n); bool f=1; for(int i=0;i<n;i++){ int a=o[i].s,b=-1,c=-1,d=-1; if(mp.find(P(o[i].f.f+1,o[i].f.s))!=mp.end())b=mp[P(o[i].f.f+1,o[i].f.s)]; if(mp.find(P(o[i].f.f,o[i].f.s+1))!=mp.end())c=mp[P(o[i].f.f,o[i].f.s+1)]; if(mp.find(P(o[i].f.f+1,o[i].f.s+1))!=mp.end())d=mp[P(o[i].f.f+1,o[i].f.s+1)]; if(c==-1&&b>=0&&d>=0){ if(a+d-b<0)f=0; mp[P(o[i].f.f,o[i].f.s+1)]=a+d-b; } if(b==-1&&d>=0&&c>=0){ if(a+d-c<0)f=0; mp[P(o[i].f.f+1,o[i].f.s)]=a+d-c; } if(d==-1&&b>=0&&c>=0){ if(b+c-a<0)f=0; mp[P(o[i].f.f+1,o[i].f.s+1)]=b+c-a; } if(f)cout<<"Yes"<<endl; else cout<<"No"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:15:7: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'std::pair<std::pair<int, int>, int>') 15 | mp[o[i]]=o[i].s; | ^ In file included from /usr/include/c++/14/map:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:1: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'std::pair<std::pair<int, int>, int>' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s061918420
p03995
C++
#include <cstdio> #include <numeric> #include <iostream> #include <vector> #include <set> #include <cstring> #include <string> #include <map> #include <cmath> #include <ctime> #include <algorithm> #include <bitset> #include <queue> #include <sstream> #include <deque> using namespace std; #define mp make_pair #define pb push_back #define rep(i,n) for(int i = 0; i < (n); i++) #define re return #define fi first #define se second #define sz(x) ((int) (x).size()) #define all(x) (x).begin(), (x).end() #define sqrt(x) sqrt(abs(x)) #define y0 y3487465 #define y1 y8687969 #define fill(x,y) memset(x,y,sizeof(x)) #define prev PREV #define next NEXT typedef vector<int> vi; typedef long long ll; typedef long double ld; typedef double D; typedef pair<int, int> ii; typedef vector<ii> vii; typedef vector<string> vs; typedef vector<vi> vvi; template<class T> T abs(T x) { re x > 0 ? x : -x; } template<class T> inline T sqr (T x) { re x * x; } #define filename "" const int N = 100000; int n; int m; vector<pair<ii, int> > v; ll row[N]; ll col[N]; int setrow[N]; int setcol[N]; int wasrow[N]; int wascol[N]; int needrow[N]; int needcol[N]; vi urow, ucol; vii vrow[N]; vii vcol[N]; ll cor; int setcor; int q; vector<pair<ll, ll> > w; int gocol (int x, ll y); int gorow (int x, ll y) { // cerr << x << " " << y << endl; if (wasrow[x] && row[x] != y) re 0; if (wasrow[x]) re 1; urow.pb (x); wasrow[x] = 1; row[x] = y; for (int i = 0; i < sz (vrow[x]); i++) if (!gocol (vrow[x][i].fi, vrow[x][i].se - y)) re 0; re 1; } int gocol (int x, ll y) { // cerr << x << " " << y << endl; if (wascol[x] && col[x] != y) re 0; if (wascol[x]) re 1; ucol.pb (x); wascol[x] = 1; col[x] = y; for (int i = 0; i < sz (vcol[x]); i++) if (!gorow (vcol[x][i].fi, vcol[x][i].se - y)) re 0; re 1; } int main () { scanf ("%d%d%d", &n, &m, &q); for (int i = 0; i < q; i++) { int a, b, c; scanf ("%d%d%d", &a, &b, &c); a--; b--; if (a == 0 && b == 0) { setcor = 1; cor = c; } else if (a == 0) { setcol[b] = 1; needcol[b] = c; } else if (b == 0) { setrow[a] = 1; needrow[a] = c; } else { vrow[a].pb (mp (b, c)); vcol[b].pb (mp (a, c)); } } for (int i = 1; i < n; i++) if (!wasrow[i] && setrow[i]) { urow.clear (); ucol.clear (); if (!gorow (i, needrow[i])) { printf ("No\n"); re 0; } for (int j = 0; j < sz (urow); j++) { int k = urow[j]; if (setrow[k] && needrow[k] != row[k]) { printf ("No\n"); re 0; } } for (int j = 0; j < sz (ucol); j++) { int k = ucol[j]; if (setcol[k]) { if (setcor) { if (needcol[k] != col[k] + cor) { printf ("No\n"); re 0; } } else { setcor = 1; cor = needcol[k] - col[k]; } } } ll minrow = 1e18, mincol = 1e18; for (int j = 0; j < sz (urow); j++) minrow = min (minrow, row[urow[j]]); for (int j = 0; j < sz (ucol); j++) mincol = min (mincol, col[ucol[j]]); w.pb (mp (minrow, mincol)); } for (int i = 1; i < m; i++) if (!wascol[i] && setcol[i]) { urow.clear (); ucol.clear (); if (!gocol (i, col[i])) { printf ("No\n"); re 0; } for (int j = 0; j < sz (ucol); j++) { int k = ucol[j]; if (setcol[k] && needcol[k] != col[k]) { printf ("No\n"); re 0; } } for (int j = 0; j < sz (urow); j++) { int k = urow[j]; if (setrow[k]) { if (setcor) { if (needrow[k] != row[k] + cor) { printf ("No\n"); re 0; } } else { setcor = 1; cor = needrow[k] - row[k]; } } } ll minrow = 1e18, mincol = 1e18; for (int j = 0; j < sz (urow); j++) minrow = min (minrow, row[urow[j]]); for (int j = 0; j < sz (ucol); j++) mincol = min (mincol, col[ucol[j]]); w.pb (mp (mincol, minrow)); } for (int i = 1; i < n; i++) if (!wasrow[i]) { urow.clear (); ucol.clear (); if (!gorow (i, 0)) { printf ("No\n"); re 0; } ll minrow = 1e18, mincol = 1e18; for (int j = 0; j < sz (urow); j++) minrow = min (minrow, row[urow[j]]); for (int j = 0; j < sz (ucol); j++) mincol = min (mincol, col[ucol[j]]); w.pb (mp (minrow, mincol)); } for (int i = 1; i < m; i++) if (!wascol[i]) { urow.clear (); ucol.clear (); if (!gocol (i, 0)) { printf ("No\n"); re 0; } ll minrow = 1e18, mincol = 1e18; for (int j = 0; j < sz (urow); j++) minrow = min (minrow, row[urow[j]]); for (int j = 0; j < sz (ucol); j++) mincol = min (mincol, col[ucol[j]]); w.pb (mp (minrow, mincol)); } if (setcor && cor < 0) { printf ("No\n"); re 0; } if (setcor) { for (int i = 0; i < sz (w); i++) { w[i].se += cor; if (w[i].fi < 0 || w[i].se < 0) { printf ("No\n"); re 0; } } } else { for (int i = 0; i < sz (w); i++) if (w[i].fi + w[i].se < 0) { printf ("No\n"); re 0; } } } printf ("Yes\n"); return 0; }
a.cc:231:16: error: expected constructor, destructor, or type conversion before '(' token 231 | printf ("Yes\n"); | ^ a.cc:232:9: error: expected unqualified-id before 'return' 232 | return 0; | ^~~~~~ a.cc:233:1: error: expected declaration before '}' token 233 | } | ^
s997082990
p03996
C++
#include <cmath> #include <cassert> #include <functional> #include <algorithm> template <typename T> class SegmentTree { using FuncType = std::function<T(const T&, const T&)>; private: T* val_p_m; const T init_val_m; const int size_m; const int rank_m; const FuncType func_m; T Query_rec(int range_left, int range_right, int node_index, int node_range_left, int node_range_right); bool Is_valid_index(int index); public: SegmentTree(int size, const T& init_val, const FuncType& func); void Update(int pos, const T& val); T Query(int range_left, int range_right); }; template<typename T> T SegmentTree<T>::Query_rec(int range_left, int range_right, int node_index, int node_range_left, int node_range_right) { if (node_range_right <= range_left || range_right <= node_range_left) return init_val_m; if (range_left <= node_range_left && node_range_right <= range_right) return val_p_m[node_index]; int node_range_mid = (node_range_left + node_range_right) / 2; const T val_left = Query_rec(range_left, range_right, node_index * 2, node_range_left, node_range_mid); const T val_right = Query_rec(range_left, range_right, node_index * 2 + 1, node_range_mid, node_range_right); return func_m(val_left, val_right); } template<typename T> inline bool SegmentTree<T>::Is_valid_index(int index) { return index >= 0 && index < size_m; } template<typename T> SegmentTree<T>::SegmentTree(int size, const T& init_val, const FuncType& func) : init_val_m(init_val), size_m(size), rank_m((int)std::log2(size) + 1), func_m(func) { val_p_m = new T[1 << rank_m]; fill(val_p_m + (1 << (rank_m - 1)), val_p_m + (1 << rank_m), init_val_m); for (int i = (1 << (rank_m - 1)) - 1; i >= 1; --i) { val_p_m[i] = func_m(val_p_m[i * 2], val_p_m[i * 2 + 1]); } } template<typename T> void SegmentTree<T>::Update(int pos, const T& val) { assert(Is_valid_index(pos)); int i = pos + (1 << (rank_m - 1)); val_p_m[i] = val; while (i > 1) { i /= 2; val_p_m[i] = func_m(val_p_m[i * 2], val_p_m[i * 2 + 1]); } } template<typename T> T SegmentTree<T>::Query(int range_left, int range_right) { assert(Is_valid_index(range_left)); assert(Is_valid_index(range_right - 1)); return Query_rec(range_left, range_right, 1, 0, 1 << (rank_m - 1)); } template<typename T> class Max { public: const T& operator()(const T& a, const T& b) const { return std::max<T>(a, b); } }; template<typename T> class Min { public: const T& operator()(const T& a, const T& b) const { return std::min<T>(a, b); } }; //#include "IntMod.h" //typedef IntMod<1000000007> MInt; #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <list> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <iomanip> #include <sstream> #include <numeric> #include <array> #include <bitset> using namespace std; #define REP(i,a,n) for(int i = (a); i < (int)(n); ++i) #define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i) #define EPS 0.0001 #define INF 0x3FFFFFFF #define INFLL 0x3FFFFFFF3FFFFFFF #define INFD 1.0e+308 #define FLOAT setprecision(16) typedef long long LL; typedef unsigned long long ULL; typedef pair<LL, LL> PP; template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; } template <class T, class U> ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; } template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); } template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); } // all_of #if 1 #include <unordered_set> #include <unordered_map> template<typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先 #endif //#include "Union_Find.h" int N, M, Q; int A[100000]; vector<PP> seq; int idxs[100000]; set<int> Set; int main() { cin >> N >> M >> Q; REP(i, 0, Q) { cin >> A[i]; --A[i]; } Fill(idxs, -1); SegmentTree<int> S(M, INF, Min<int>()); REPM(i, Q, 0) { int idx = idxs[A[i]]; if (idx == -1) { seq.push_back(PP(A[i], 1)); idxs[A[i]] = seq.size() - 1; S.Update(idxs[A[i]], 1); } else { int mn = idx == 0 ? INF : S.Query(0, idx); if (seq[idx].second != mn && seq[idx].second != N) { ++seq[idx].second; S.Update(idx, seq[idx].second); } } } REP(i, 0, M) { Set.insert(i); } bool ok = true; for (PP p : seq) { if (p.second == N) { Set.erase(p.first); } else { if (*Set.begin() != p.first) { ok = false; break; } Set.erase(p.first); } } cout << (ok ? "Yes" : "No") << endl; return 0; }
a.cc: In instantiation of 'SegmentTree<T>::SegmentTree(int, const T&, const FuncType&) [with T = int; FuncType = std::function<int(const int&, const int&)>]': a.cc:160:39: required from here 160 | SegmentTree<int> S(M, INF, Min<int>()); | ^ a.cc:48:13: error: 'fill' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive] 48 | fill(val_p_m + (1 << (rank_m - 1)), val_p_m + (1 << rank_m), init_val_m); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86, from a.cc:4: /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' declared here, later in the translation unit 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~
s186414743
p03996
C++
#ifndef __UNION_FIND_H__0004__ #define __UNION_FIND_H__0004__ class UnionFindTree { int whole_size_m; int* parent_p_m; // 根である場合は自分自身の添え字を入れる int* rank_p_m; int* size_p_m; // 集合のサイズ(根に大きさを書く) bool Is_valid_index(int index); int Root_of_rec(int index); public: UnionFindTree(int whole_size); ~UnionFindTree(); int Root_of(int index); void Unite(int index_l, int index_r); bool Are_together(int index_l, int index_r); int Size_of_set(int index); }; #include <cassert> #include <functional> #include <algorithm> template <typename T> class SegmentTree { using FuncType = std::function<T(const T&, const T&)>; private: T* val_p_m; const T init_val_m; const int size_m; const int rank_m; const FuncType func_m; T Query_rec(int range_left, int range_right, int node_index, int node_range_left, int node_range_right); bool Is_valid_index(int index); public: SegmentTree(int size, const T& init_val, const FuncType& func); void Update(int pos, const T& val); T Query(int range_left, int range_right); }; template<typename T> T SegmentTree<T>::Query_rec(int range_left, int range_right, int node_index, int node_range_left, int node_range_right) { if (node_range_right <= range_left || range_right <= node_range_left) return init_val_m; if (range_left <= node_range_left && node_range_right <= range_right) return val_p_m[node_index]; int node_range_mid = (node_range_left + node_range_right) / 2; const T val_left = Query_rec(range_left, range_right, node_index * 2, node_range_left, node_range_mid); const T val_right = Query_rec(range_left, range_right, node_index * 2 + 1, node_range_mid, node_range_right); return func_m(val_left, val_right); } template<typename T> inline bool SegmentTree<T>::Is_valid_index(int index) { return index >= 0 && index < size_m; } template<typename T> SegmentTree<T>::SegmentTree(int size, const T& init_val, const FuncType& func) : init_val_m(init_val), size_m(size), rank_m((int)std::log2(size) + 1), func_m(func) { val_p_m = new T[1 << rank_m]; fill(val_p_m + (1 << (rank_m - 1)), val_p_m + (1 << rank_m), init_val_m); for (int i = (1 << (rank_m - 1)) - 1; i >= 1; --i) { val_p_m[i] = func_m(val_p_m[i * 2], val_p_m[i * 2 + 1]); } } template<typename T> void SegmentTree<T>::Update(int pos, const T& val) { assert(Is_valid_index(pos)); int i = pos + (1 << (rank_m - 1)); val_p_m[i] = val; while (i > 1) { i /= 2; val_p_m[i] = func_m(val_p_m[i * 2], val_p_m[i * 2 + 1]); } } template<typename T> T SegmentTree<T>::Query(int range_left, int range_right) { assert(Is_valid_index(range_left)); assert(Is_valid_index(range_right - 1)); return Query_rec(range_left, range_right, 1, 0, 1 << (rank_m - 1)); } template<typename T> class Max { public: const T& operator()(const T& a, const T& b) const { return max<T>(a, b); } }; template<typename T> class Min { public: const T& operator()(const T& a, const T& b) const { return min<T>(a, b); } }; #endif //#include "IntMod.h" //typedef IntMod<1000000007> MInt; #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <list> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <iomanip> #include <sstream> #include <numeric> #include <array> #include <bitset> using namespace std; #define REP(i,a,n) for(int i = (a); i < (int)(n); ++i) #define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i) #define EPS 0.0001 #define INF 0x3FFFFFFF #define INFLL 0x3FFFFFFF3FFFFFFF #define INFD 1.0e+308 #define FLOAT setprecision(16) typedef long long LL; typedef unsigned long long ULL; typedef pair<LL, LL> PP; template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; } template <class T, class U> ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; } template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); } template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); } // all_of #if 1 #include <unordered_set> #include <unordered_map> template<typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先 #endif int N, M, Q; int A[100000]; vector<PP> seq; int idxs[100000]; set<int> Set; int main() { cin >> N >> M >> Q; REP(i, 0, Q) { cin >> A[i]; --A[i]; } Fill(idxs, -1); SegmentTree<int> S(M, INF, Min<int>()); REPM(i, Q, 0) { int idx = idxs[A[i]]; if (idx == -1) { seq.push_back(PP(A[i], 1)); idxs[A[i]] = seq.size() - 1; S.Update(idxs[A[i]], 1); } else { int mn = idx == 0 ? INF : S.Query(0, idx); if (seq[idx].second != mn && seq[idx].second != N) { ++seq[idx].second; S.Update(idx, seq[idx].second); } } } REP(i, 0, M) { Set.insert(i); } bool ok = true; for (PP p : seq) { if (p.second == N) { Set.erase(p.first); } else { if (*Set.begin() != p.first) { ok = false; break; } Set.erase(p.first); } } cout << (ok ? "Yes" : "No") << endl; return 0; }
a.cc: In constructor 'SegmentTree<T>::SegmentTree(int, const T&, const FuncType&)': a.cc:65:64: error: 'log2' is not a member of 'std' 65 | : init_val_m(init_val), size_m(size), rank_m((int)std::log2(size) + 1), func_m(func) { | ^~~~ a.cc: In member function 'const T& Max<T>::operator()(const T&, const T&) const': a.cc:99:24: error: 'max' was not declared in this scope; did you mean 'std::max'? 99 | return max<T>(a, b); | ^~~ | std::max In file included from /usr/include/c++/14/algorithm:61, from a.cc:24: /usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:99:29: error: expected primary-expression before '>' token 99 | return max<T>(a, b); | ^ a.cc: In member function 'const T& Min<T>::operator()(const T&, const T&) const': a.cc:107:24: error: 'min' was not declared in this scope; did you mean 'std::min'? 107 | return min<T>(a, b); | ^~~ | std::min /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ a.cc:107:29: error: expected primary-expression before '>' token 107 | return min<T>(a, b); | ^ a.cc: In instantiation of 'SegmentTree<T>::SegmentTree(int, const T&, const FuncType&) [with T = int; FuncType = std::function<int(const int&, const int&)>]': a.cc:180:39: required from here 180 | SegmentTree<int> S(M, INF, Min<int>()); | ^ a.cc:68:13: error: 'fill' was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation 68 | fill(val_p_m + (1 << (rank_m - 1)), val_p_m + (1 << rank_m), init_val_m); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:191:1: note: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' declared here, later in the translation unit 191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~
s021907420
p03996
C++
//#include "IntMod.h" //typedef IntMod<1000000007> MInt; #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <list> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <iomanip> #include <sstream> #include <numeric> #include <array> #include <bitset> using namespace std; #define REP(i,a,n) for(int i = (a); i < (int)(n); ++i) #define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i) #define EPS 0.0001 #define INF 0x3FFFFFFF #define INFLL 0x3FFFFFFF3FFFFFFF #define INFD 1.0e+308 #define FLOAT setprecision(16) typedef long long LL; typedef unsigned long long ULL; typedef pair<LL, LL> PP; template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; } template <class T, class U> ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; } template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); } template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); } // all_of #if 1 #include <unordered_set> #include <unordered_map> template<typename T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先 #endif #include "Union_Find.h" int N, M, Q; int A[100000]; vector<PP> seq; int idxs[100000]; set<int> Set; int main() { cin >> N >> M >> Q; REP(i, 0, Q) { cin >> A[i]; --A[i]; } Fill(idxs, -1); SegmentTree<int> S(M, INF, Min<int>()); REPM(i, Q, 0) { int idx = idxs[A[i]]; if (idx == -1) { seq.push_back(PP(A[i], 1)); idxs[A[i]] = seq.size() - 1; S.Update(idxs[A[i]], 1); } else { int mn = idx == 0 ? INF : S.Query(0, idx); if (seq[idx].second != mn && seq[idx].second != N) { ++seq[idx].second; S.Update(idx, seq[idx].second); } } } REP(i, 0, M) { Set.insert(i); } bool ok = true; for (PP p : seq) { if (p.second == N) { Set.erase(p.first); } else { if (*Set.begin() != p.first) { ok = false; break; } Set.erase(p.first); } } cout << (ok ? "Yes" : "No") << endl; return 0; }
a.cc:54:10: fatal error: Union_Find.h: No such file or directory 54 | #include "Union_Find.h" | ^~~~~~~~~~~~~~ compilation terminated.
s115258363
p03996
C++
/+ dub.sdl: name "A" dependency "dcomp" version=">=0.4.0" +/ import std.stdio, std.algorithm, std.conv; // import dcomp.scanner; // import dcomp.container.deque; int main() { auto sc = new Scanner(stdin); int n, m, q; int[] a; sc.read(n, m, q, a); bool solve() { int[] co, idx = new int[m]; idx[] = -1; int l = 0; foreach_reverse (d; a) { d--; int u = idx[d]; if (u == -1) { u = idx[d] = co.length.to!int; co ~= 0; } if (u && co[u-1] == co[u]) { return false; } co[u]++; if (co[u] == n) { l++; idx[d] = -1; } } foreach (i; 0..m) { if (idx[i] == -1) continue; if (idx[i]-l != i) return false; } return true; } if (solve()) { writeln("Yes"); } else { writeln("No"); } return 0; } /* IMPORT /home/yosupo/Program/dcomp/source/dcomp/container/deque.d */ // module dcomp.container.deque; struct Deque(T) { import core.exception : RangeError; import core.memory : GC; import std.range : ElementType, isInputRange; import std.traits : isImplicitlyConvertible; struct Payload { T *d; size_t st, length, cap; @property bool empty() const { return length == 0; } alias opDollar = length; ref inout(T) opIndex(size_t i) inout { version(assert) if (length <= i) throw new RangeError(); return d[(st+i >= cap) ? (st+i-cap) : st+i]; } private void expand() { import std.algorithm : max; assert(length == cap); auto nc = max(4L, 2*cap); T* nd = cast(T*)GC.malloc(nc * T.sizeof); foreach (i; 0..length) { nd[i] = this[i]; } d = nd; st = 0; cap = nc; } void insertFront(T v) { if (length == cap) expand(); if (st == 0) st += cap; st--; length++; this[0] = v; } void insertBack(T v) { if (length == cap) expand(); length++; this[length-1] = v; } void removeFront() { assert(!empty, "Deque.removeFront: Deque is empty"); st++; length--; if (st == cap) st = 0; } void removeBack() { assert(!empty, "Deque.removeBack: Deque is empty"); length--; } } struct RangeT(A) { alias T = typeof(*(A.p)); alias E = typeof(A.p.d[0]); T *p; size_t a, b; @property bool empty() const { return b <= a; } @property size_t length() const { return b-a; } @property RangeT save() { return RangeT(p, a, b); } @property RangeT!(const A) save() const { return typeof(return)(p, a, b); } alias opDollar = length; @property ref inout(E) front() inout { return (*p)[a]; } @property ref inout(E) back() inout { return (*p)[b-1]; } void popFront() { version(assert) if (empty) throw new RangeError(); a++; } void popBack() { version(assert) if (empty) throw new RangeError(); b--; } ref inout(E) opIndex(size_t i) inout { return (*p)[i]; } RangeT opSlice() { return this.save; } RangeT opSlice(size_t i, size_t j) { version(assert) if (i > j || a + j > b) throw new RangeError(); return typeof(return)(p, a+i, a+j); } RangeT!(const A) opSlice() const { return this.save; } RangeT!(const A) opSlice(size_t i, size_t j) const { version(assert) if (i > j || a + j > b) throw new RangeError(); return typeof(return)(p, a+i, a+j); } } alias Range = RangeT!Deque; alias ConstRange = RangeT!(const Deque); alias ImmutableRange = RangeT!(immutable Deque); Payload *p; private void I() { if (!p) p = new Payload(); } private void C() const { assert(p, "this deque is not init"); } //some value this(U)(U[] values...) if (isImplicitlyConvertible!(U, T)) {I; p = new Payload(); foreach (v; values) { insertBack(v); } } //range this(Range)(Range r) if (isInputRange!Range && isImplicitlyConvertible!(ElementType!Range, T) && !is(Range == T[])) {I; p = new Payload(); foreach (v; r) { insertBack(v); } } @property bool empty() const { return (!p || p.empty); } @property size_t length() const { return (p ? p.length : 0); } alias opDollar = length; ref inout(T) opIndex(size_t i) inout {C; return (*p)[i]; } ref inout(T) front() inout {C; return (*p)[0]; } ref inout(T) back() inout {C; return (*p)[$-1]; } void insertFront(T v) {I; p.insertFront(v); } void insertBack(T v) {I; p.insertBack(v); } void removeFront() {C; p.removeFront(); } void removeBack() {C; p.removeBack(); } Range opSlice() {I; return Range(p, 0, length); } } unittest { import std.algorithm : equal; import std.range.primitives : isRandomAccessRange; import std.container.util : make; auto q = make!(Deque!int); assert(isRandomAccessRange!(typeof(q[]))); //insert,remove assert(equal(q[], new int[](0))); q.insertBack(1); assert(equal(q[], [1])); q.insertBack(2); assert(equal(q[], [1, 2])); q.insertFront(3); assert(equal(q[], [3, 1, 2]) && q.front == 3); q.removeFront; assert(equal(q[], [1, 2]) && q.length == 2); q.insertBack(4); assert(equal(q[], [1, 2, 4]) && q.front == 1 && q.back == 4 && q[$-1] == 4); q.insertFront(5); assert(equal(q[], [5, 1, 2, 4])); //range assert(equal(q[][1..3], [1, 2])); assert(equal(q[][][][], q[])); //const range const auto rng = q[]; assert(rng.front == 5 && rng.back == 4); //reference type auto q2 = q; q2.insertBack(6); q2.insertFront(7); assert(equal(q[], q2[]) && q.length == q2.length); //construct with make auto a = make!(Deque!int)(1, 2, 3); auto b = make!(Deque!int)([1, 2, 3]); assert(equal(a[], b[])); } unittest { Deque!int a; Deque!int b; a.insertFront(2); assert(b.length == 0); } unittest { import std.algorithm : equal; import std.range : iota; Deque!int a; foreach (i; 0..100) { a.insertBack(i); } assert(equal(a[], iota(100))); } /* IMPORT /home/yosupo/Program/dcomp/source/dcomp/scanner.d */ // module dcomp.scanner; class Scanner { import std.stdio : File; import std.conv : to; import std.range : front, popFront, array, ElementType; import std.array : split; import std.traits : isSomeChar, isStaticArray, isArray; import std.algorithm : map; File f; this(File f) { this.f = f; } string[] buf; private bool succ() { while (!buf.length) { if (f.eof) return false; buf = f.readln.split; } return true; } private bool readSingle(T)(ref T x) { if (!succ()) return false; static if (isArray!T) { alias E = ElementType!T; static if (isSomeChar!E) { //string or char[10] etc x = buf.front; buf.popFront; } else { static if (isStaticArray!T) { //static assert(buf.length == T.length); } x = buf.map!(to!E).array; buf.length = 0; } } else { x = buf.front.to!T; buf.popFront; } return true; } int read(T, Args...)(ref T x, auto ref Args args) { if (!readSingle(x)) return 0; static if (args.length == 0) { return 1; } else { return 1 + read(args); } } } unittest { import std.path : buildPath; import std.file : tempDir; import std.algorithm : equal; import std.stdio : File; string fileName = buildPath(tempDir, "kyuridenanmaida.txt"); auto fout = File(fileName, "w"); fout.writeln("1 2 3"); fout.writeln("ab cde"); fout.writeln("1.0 1.0 2.0"); fout.close; Scanner sc = new Scanner(File(fileName, "r")); int a; int[2] b; char[2] c; string d; double e; double[] f; sc.read(a, b, c, d, e, f); assert(a == 1); assert(equal(b[], [2, 3])); assert(equal(c[], "ab")); assert(equal(d, "cde")); assert(e == 1.0); assert(equal(f, [1.0, 2.0])); }
a.cc:37:21: error: too many decimal points in number 37 | foreach (i; 0..m) { | ^~~~ a.cc:63:9: error: stray '@' in program 63 | @property bool empty() const { return length == 0; } | ^ a.cc:74:25: error: too many decimal points in number 74 | foreach (i; 0..length) { | ^~~~~~~~~ a.cc:105:9: error: stray '@' in program 105 | @property bool empty() const { return b <= a; } | ^ a.cc:106:9: error: stray '@' in program 106 | @property size_t length() const { return b-a; } | ^ a.cc:107:9: error: stray '@' in program 107 | @property RangeT save() { return RangeT(p, a, b); } | ^ a.cc:108:9: error: stray '@' in program 108 | @property RangeT!(const A) save() const { | ^ a.cc:112:9: error: stray '@' in program 112 | @property ref inout(E) front() inout { return (*p)[a]; } | ^ a.cc:113:9: error: stray '@' in program 113 | @property ref inout(E) back() inout { return (*p)[b-1]; } | ^ a.cc:160:5: error: stray '@' in program 160 | @property bool empty() const { return (!p || p.empty); } | ^ a.cc:161:5: error: stray '@' in program 161 | @property size_t length() const { return (p ? p.length : 0); } | ^ a.cc:196:22: error: too many decimal points in number 196 | assert(equal(q[][1..3], [1, 2])); | ^~~~ a.cc:225:17: error: too many decimal points in number 225 | foreach (i; 0..100) { | ^~~~~~ a.cc:1:1: error: expected unqualified-id before '/' token 1 | /+ dub.sdl: | ^ a.cc: In function 'int main()': a.cc:12:19: error: expected type-specifier before 'Scanner' 12 | auto sc = new Scanner(stdin); | ^~~~~~~ a.cc:14:8: error: structured binding declaration cannot have type 'int' 14 | int[] a; | ^~ a.cc:14:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto' a.cc:14:8: error: empty structured binding declaration a.cc:14:11: error: expected initializer before 'a' 14 | int[] a; | ^ a.cc:15:22: error: 'a' was not declared in this scope 15 | sc.read(n, m, q, a); | ^ a.cc:17:15: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 17 | bool solve() { | ^~ a.cc:17:15: note: remove parentheses to default-initialize a variable 17 | bool solve() { | ^~ | -- a.cc:17:15: note: or replace parentheses with braces to value-initialize a variable a.cc:17:18: error: a function-definition is not allowed here before '{' token 17 | bool solve() { | ^ a.cc:44:9: error: 'solve' was not declared in this scope 44 | if (solve()) { | ^~~~~ a.cc:45:9: error: 'writeln' was not declared in this scope 45 | writeln("Yes"); | ^~~~~~~ a.cc:47:9: error: 'writeln' was not declared in this scope 47 | writeln("No"); | ^~~~~~~ a.cc: At global scope: a.cc:54:15: error: variable 'Deque T' has initializer but incomplete type 54 | struct Deque(T) { | ^ a.cc:55:5: error: 'import' was not declared in this scope 55 | import core.exception : RangeError; | ^~~~~~ a.cc:55:12: error: expected '}' before 'core' 55 | import core.exception : RangeError; | ^~~~ a.cc:54:17: note: to match this '{' 54 | struct Deque(T) { | ^ a.cc:55:12: error: expected ',' or ';' before 'core' 55 | import core.exception : RangeError; | ^~~~ a.cc:56:5: error: 'import' does not name a type 56 | import core.memory : GC; | ^~~~~~ a.cc:56:5: note: C++20 'import' only available with '-fmodules-ts' a.cc:57:5: error: 'import' does not name a type 57 | import std.range : ElementType, isInputRange; | ^~~~~~ a.cc:57:5: note: C++20 'import' only available with '-fmodules-ts' a.cc:58:5: error: 'import' does not name a type 58 | import std.traits : isImplicitlyConvertible; | ^~~~~~ a.cc:58:5: note: C++20 'import' only available with '-fmodules-ts' a.cc:61:9: error: 'T' does not name a type 61 | T *d; | ^ a.cc:62:9: error: 'size_t' does not name a type 62 | size_t st, length, cap; | ^~~~~~ a.cc:1:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | /+ dub.sdl: a.cc:63:10: error: 'property' does not name a type 63 | @property bool empty() const { return length == 0; } | ^~~~~~~~ a.cc:64:9: error: 'alias' does not name a type 64 | alias opDollar = length; | ^~~~~ a.cc:65:9: error: 'ref' does not name a type 65 | ref inout(T) opIndex(size_t i) inout { | ^~~ a.cc:69:16: error: expected ':' before 'void' 69 | private void expand() { | ^~~~~ | : a.cc:79:26: error: 'T' is not a type 79 | void insertFront(T v) { | ^ a.cc:85:25: error: 'T' is not a type 85 | void insertBack(T v) { | ^ a.cc:99:6: error: expected ';' after struct definition 99 | } | ^ | ; a.cc: In member function 'void Payload::expand()': a.cc:70:13: error: 'import' was not declared in this scope 70 | import std.algorithm : max; | ^~~~~~ a.cc:71:20: error: 'length' was not declared in this scope 71 | assert(length == cap); | ^~~~~~ a.cc:71:30: error: 'cap' was not declared in this scope 71 | assert(length == cap); | ^~~ a.cc:71:13: error: 'assert' was not declared in this scope 71 | assert(length == cap); | ^~~~~~ a.cc:1:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' +++ |+#include <cassert> 1 | /+ dub.sdl: a.cc:72:23: error: 'max' was not declared in this scope 72 | auto nc = max(4L, 2*cap); | ^~~ a.cc:73:16: error: 'nd' was not declared in this scope 73 | T* nd = cast(T*)GC.malloc(nc * T.sizeof); | ^~ a.cc:73:28: error: expected primary-expression before ')' token 73 | T* nd = cast(T*)GC.malloc(nc * T.sizeof); | ^ a.cc:73:21: error: 'cast' was not declared in this scope 73 | T* nd = cast(T*)GC.malloc(nc * T.sizeof); | ^~~~ a.cc:74:22: error: 'i' was not declared in this scope 74 | foreach (i; 0..length) { | ^ a.cc:77:13: error: 'd' was not declared in this scope 77 | d = nd; st = 0; cap = nc; | ^ a.cc:77:21: error: 'st' was not declared in this scope; did you mean 'std'? 77 | d = nd; st = 0; cap = nc; | ^~ | std a.cc: In member function 'void Payload::insertFront(int)': a.cc:80:17: error: 'length' was not declared in this scope 80 | if (length == cap) expand(); | ^~~~~~ a.cc:80:27: error: 'cap' was not declared in this scope 80 | if (length == cap) expand(); | ^~~ a.cc:81:17: error: 'st' was not declared in this scope; did you mean 'std'? 81 | if (st == 0) st += cap; | ^~ | std a.cc:81:32: error: 'cap' was not declared in this scope 81 | if (st == 0) st += cap; | ^~~ a.cc:82:13: error: 'st' was not declared in this scope; did you mean 'std'? 82 | st--; length++; | ^~ | std a.cc:82:19: error: 'length' was not declared in this scope 82 | st--; length++; | ^~~~~~ a.cc:83:23: error: no match for 'operator=' (operand types are 'Payload' and 'int') 83 | this[0] = v; | ^ a.cc:60:12: note: candidate: 'constexpr Payload& Payload::operator=(const Payload&)' 60 | struct Payload { | ^~~~~~~ a.cc:60:12: note: no known conversion for argument 1 from 'int' to 'const Payload&' a.cc:60:12: note: candidate: 'constexpr Payload& Payload::operator=(Payload&&)' a.cc:60:12: note: no known conversion for argument 1 from 'int' to 'Payload&&' a.cc: In member function 'void Payload::insertBack(int)': a.cc:86:17: error: 'length' was not declared in this scope 86 | if (length == cap) expand(); | ^~~~~~ a.cc:86:27: error: 'cap' was not declared in this scope 86 | if (length == cap) expand(); | ^~~ a.cc:87:13: error: 'length' was not declared in this scope 87 | length++; | ^~~~~~ a.cc: In member function 'void Payload::removeFront()': a.cc:91:21: error: 'empty' was not declared in this scope 91 | assert(!empty, "Deque.removeFront: Deque is empty"); | ^~~~~ a.cc:91:13: error: 'assert' was not declared in this scope 91 | assert(!empty, "Deque.removeFront: Deque is empty"); | ^~~~~~ a.cc:91:13: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' a.cc:92:13: error: 'st' was not declared in this scope; did you mean 'std'? 92 | st++; length--; | ^~ | std a.cc:92:19: error: 'length' was not declared in this scope 92 | st++; length--; | ^~~~~~ a.cc:93:23: error: 'cap' was not declared in this scope 93 | if (st == cap) st = 0; | ^~~ a.cc: In member function 'void Payload::r
s771165398
p03996
C++
#include <iostream> #include <vector> using namespace std; int main(){ int n, m; cin >> n >> m; int q; cin >> q; vector<int> a(q); for(int i = 0; i < q; i++){ cin >> a[i]; a[i]--; } vector<int> b(m); vector<int> pos(m); vector<int> freq(m + 1); freq[0] = n; freq[m] = 0; int known = 0; for(int it = q - 1; it >= 0; it--){ int i = a[it]; if(pos[i] = -1){ b[known] = i; pos[i] = known; freq[known]--; known++; freq[known]++; continue; } if(freq[pos[i]] > 0){ freq[pos[i]]--; freq[pos[i] + 1]++; } } int first = -1; for(int i = 0; i <= m; i++){ if(freq[i] !=0){ first = i; break; } } vector<int> all; for(int i = first; i < known; i++){ all.push_back(b[i]); } for(int i = 0; i < m; i++){ if(pos[i] == -1){ all.push_back(i); } } sort(all.begin(), all.end()); for(int i = first; i < known; i++){ if(all[i - first] != a[i]){ cout << "No"; return 0; } } cout << "Yes"; }
a.cc: In function 'int main()': a.cc:55:2: error: 'sort' was not declared in this scope; did you mean 'short'? 55 | sort(all.begin(), all.end()); | ^~~~ | short
s443864370
p03996
C++
#include <iostream> #include <vector> int main(){ int n, m; cin >> n >> m; int q; cin >> q; vector<int> a(q); for(int i = 0; i < q; i++){ cin >> a[i]; a[i]--; } vector<int> b(m); vector<int> pos(m); vector<int> freq(m + 1); int known = 0; for(int it = q - 1; it >= 0; it--){ int i = a[it]; if(pos[i] = -1){ b[known] = i; pos[i] = known; freq[known]--; known++; freq[known]++; continue; } if(freq[pos[i]] > 0){ freq[pos[i]]--; freq[pos[i] + 1]++; } } int first = -1; for(int i = 0; i <= m; i++){ if(freq[i] !=0){ first = -1; break; } } vector<int> all; for(int i = first; i < known; i++){ all.push_back(b[i]); } for(int i = 0; i < m; i++){ if(pos[i] == -1){ all.push_back(i); } } for(int i = first; i < known; i++){ if(all[i - first] != a[i]){ cout << "No"; return 0; } } cout << "Yes"; }
a.cc: In function 'int main()': a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 6 | cin >> n >> m; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:9:3: error: 'vector' was not declared in this scope 9 | vector<int> a(q); | ^~~~~~ a.cc:9:3: note: suggested alternatives: In file included from /usr/include/c++/14/vector:66, from a.cc:2: /usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector' 428 | class vector : protected _Vector_base<_Tp, _Alloc> | ^~~~~~ /usr/include/c++/14/vector:93:13: note: 'std::pmr::vector' 93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>; | ^~~~~~ a.cc:9:10: error: expected primary-expression before 'int' 9 | vector<int> a(q); | ^~~ a.cc:11:12: error: 'a' was not declared in this scope 11 | cin >> a[i]; | ^ a.cc:15:10: error: expected primary-expression before 'int' 15 | vector<int> b(m); | ^~~ a.cc:16:10: error: expected primary-expression before 'int' 16 | vector<int> pos(m); | ^~~ a.cc:17:10: error: expected primary-expression before 'int' 17 | vector<int> freq(m + 1); | ^~~ a.cc:21:13: error: 'a' was not declared in this scope 21 | int i = a[it]; | ^ a.cc:22:8: error: 'pos' was not declared in this scope 22 | if(pos[i] = -1){ | ^~~ a.cc:23:7: error: 'b' was not declared in this scope 23 | b[known] = i; | ^ a.cc:25:7: error: 'freq' was not declared in this scope; did you mean 'free'? 25 | freq[known]--; | ^~~~ | free a.cc:30:8: error: 'freq' was not declared in this scope; did you mean 'free'? 30 | if(freq[pos[i]] > 0){ | ^~~~ | free a.cc:30:13: error: 'pos' was not declared in this scope 30 | if(freq[pos[i]] > 0){ | ^~~ a.cc:38:8: error: 'freq' was not declared in this scope; did you mean 'free'? 38 | if(freq[i] !=0){ | ^~~~ | free a.cc:44:10: error: expected primary-expression before 'int' 44 | vector<int> all; | ^~~ a.cc:46:6: error: 'all' was not declared in this scope; did you mean 'atoll'? 46 | all.push_back(b[i]); | ^~~ | atoll a.cc:46:20: error: 'b' was not declared in this scope 46 | all.push_back(b[i]); | ^ a.cc:49:8: error: 'pos' was not declared in this scope 49 | if(pos[i] == -1){ | ^~~ a.cc:50:7: error: 'all' was not declared in this scope; did you mean 'atoll'? 50 | all.push_back(i); | ^~~ | atoll a.cc:55:8: error: 'all' was not declared in this scope; did you mean 'atoll'? 55 | if(all[i - first] != a[i]){ | ^~~ | atoll a.cc:55:26: error: 'a' was not declared in this scope 55 | if(all[i - first] != a[i]){ | ^ a.cc:56:7: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 56 | cout << "No"; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:60:3: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 60 | cout << "Yes"; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s533345409
p03996
C++
#include <cstdio> #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <string> #include <iostream> #include <cmath> #include <string> #include <map> #include <unordered_map> #include <queue> #include <climits> using namespace std; typedef pair<int, int> PII; const int M = 100005; int n, m, q; int a[M]; bool used[M]; int cnt[M], ord[M]; vector<int> seq; void add(int x) { if (!used[x]) { int f = seq.size(); used[x] = true; ord[x] = f; if (cnt[i] > 0) { cnt[i] -= 1; cnt[i + 1] += 1; } seq.push_back(x); } else { int k = ord[x]; if (cnt[i] > 0) { cnt[i] -= 1; cnt[i + 1] += 1; } } } int main() { cin >> n >> m >> q; for (int i = 0; i < q; i += 1) { cin >> a[i]; a[i] -= 1; } reverse(a, a + q); cnt[0] = n; for (int i = 0; i < q; i += 1) add(a[i]); for (int i = 0; i < m; i += 1) if (!used[i]) seq.push_back(i); int sh = 0; while (!cnt[sh]) sh += 1; auto alt = seq; sort(alt.begin() + sh, alt.end()); if (alt == seq) { cout << "Yes\n"; } else { cout << "No\n"; } }
a.cc: In function 'void add(int)': a.cc:33:13: error: 'i' was not declared in this scope 33 | if (cnt[i] > 0) { | ^ a.cc:40:13: error: 'i' was not declared in this scope 40 | if (cnt[i] > 0) { | ^
s024824754
p03996
C++
#include <Windows.h> #include <stdio.h> const int max0=100010; int n,m,a,i; int count[max0],data[max0],ans[max0],top; int dic[max0],p1; bool had[max0],wrong; int main() { scanf("%d%d%d",&n,&m,&a); for(i=0;i<a;i++) scanf("%d",&data[i]); p1=-1; for(i=a-1;i>=0;i--) if(had[data[i]]==0){ had[data[i]]=1,ans[top++]=data[i]; if(data[i]==1)p1=top; } //printf("!%d %d %d\n",top,ans[1],p1); if(p1!=-1) { for(i=p1;i<top;i++) if(ans[i]!=i-p1+2)break; if(i==top)top=p1-1; } //printf("!%d\n",top); for(i=top-1;i>=1;i--)dic[ans[i]]=ans[i-1]; for(i=a-1;i>=0;i--){ count[data[i]]++; if(dic[data[i]]!=0) if(count[data[i]]>count[dic[data[i]]]) count[data[i]]=count[dic[data[i]]]; } if(top!=0&&count[ans[top-1]]<n)printf("No\n"); else printf("Yes\n"); return 0; }
a.cc:1:10: fatal error: Windows.h: No such file or directory 1 | #include <Windows.h> | ^~~~~~~~~~~ compilation terminated.
s191321391
p03996
C++
#include<stdio.h>   int main() { puts("Yes"); }
a.cc:2:1: error: extended character   is not valid in an identifier 2 |   | ^ a.cc:2:1: error: '\U000000a0' does not name a type 2 |   | ^
s084003445
p03996
C++
//ProblemE.cpp #include <iostream> static std::istream & ip = std::cin; static std::ostream & op = std::cout; #if OJ_MYPC #include <ojio.h> #endif #ifndef OPENOJIO #define OPENOJIO #endif #if 1 || DEFINE /***************************************************************/ typedef unsigned long long u64; typedef long long s64; typedef unsigned uint; #define ABS(x) ((x) > 0 ? (x) : -(x)) #define MIN(x, y) ((x) < (y) ? (x) : (y)) #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define MIN3(x, y, z) MIN(x, MIN(y, z)) #define MAX3(x, y, z) MAX(x, MAX(y, z)) #define FillZero(arr) memset(arr, 0, sizeof(arr)); /***************************************************************/ #endif //1 || DEFINE #include <string> #include <vector> #include <map> #include <set> #include <bitset> #include <queue> #include <stack> #include <utility> #include <algorithm> #include <iomanip> #include <cstring> #include <cmath> #include <cstdio> //001 //op << setfill('0') << setw(3) << setiosflags(ios::right) << 1; //op << fixed << setprecision(20); using namespace std; //ProblemE.cpp #define MAXN 100010 #define MAXM 100010 #define MAXQ 100010 int main(int argc, char* argv[]) { OPENOJIO; int n, m, q; static int a[MAXQ]; ip >> n >> m >> q; for (int i = 1; i <= q; ++i) ip >> a[i]; static bool used[MAXM]; for (int i = 1; i <= m; ++i) used[i] = false; int last[MAXM]; int ilast = 1; for (int i = q; i >= 1; --i) { if (used[a[i]]) continue; last[ilast++] = a[i]; used[a[i]] = true; } for (int i = 1; i <= m; ++i) { if (used[i]) continue; last[ilast++] = i; } int mii[MAXM]; for (int i = 1; i <= m; ++i) mii[last[i]] = i; static int cl[MAXM]; for (int i = 1; i <= m; ++i) cl[i] = 0; cl[0] = n; for (int i = q; i >= 1; --i) { int index = mii[a[i]]; if (cl[index - 1] > 0) { --cl[index - 1]; ++cl[index]; } } bool rst = true; for (int i = 0; i < m; ++i) { if (cl[i] == 0) continue; for (int j = i + 1; j < m; ++j) { if (last[j] > last[j + 1]) { rst = false; break; } } break; } bool rst = cl[m] == n; op << (rst ? "Yes" : "No") << endl; return 0; } /***************************************************************/
a.cc: In function 'int main(int, char**)': a.cc:124:14: error: redeclaration of 'bool rst' 124 | bool rst = cl[m] == n; | ^~~ a.cc:112:14: note: 'bool rst' previously declared here 112 | bool rst = true; | ^~~
s366794380
p03996
C++
#include<stdio.h> #include<vector> using namespace std; int N,M,Q,MIN; int a[111111]; int LST[111111]; vector<int> pos[111111]; bool valid[111111]; struct Node{ int prev,next; int val; } node[111111]; int head,tail,Z; int pnt[111111],cnt_bad; int nodelen; int bit[111111]; int lowbit(int x){ return x&-x; } void add(int x){ while(x <= M){ bit[x]++; x+=lowbit(x); } } int query(int x){ int r=0; while(x){ r+=bit[x]; x-=lowbit(x); } return r; } bool chk2(){ if(node[head].next == -1)return true; int start = node[node[head].next].val; int end = node[tail].val; return end - start + 1 == nodelen + query(end) - query(start+1); } bool chk(){ cnt_bad = 0; for(int i=1; i<=M; i++) valid[i] = true; head = tail = ++Z; node[Z].prev = -1; node[Z].next = -1; node[Z].val = 0; nodelen = 0; for(int i=1; i<=M; i++) if(!pos[i].empty()){ if(tail != head){ if(pos[node[tail].val].back() < pos[i].back()) cnt_bad++; } ++Z; node[Z].prev = tail; node[Z].next = -1; node[Z].val = i; pnt[i] = Z; node[tail].next = Z; tail = Z; nodelen++; } memset(bit,0,sizeof(bit)); MIN = 1; for(int i=Q; i>=1; i--){ if(!valid[a[i]])continue; int x = a[i]; if(x == MIN){ if(cnt_bad == 0 && chk2())return true; } int sz = (int)pos[x].size(), ct = 1; for(int j=sz-1; j>=0; j--){ if(pos[x][j] < LST[ct]){ LST[ct] = pos[x][j]; ++ct; if(ct > N) break; } } if(ct <= N) return false; valid[x] = false; int p = pnt[x]; int prev_pnt = node[p].prev; int next_pnt = node[p].next; if(prev_pnt != head && pos[node[prev_pnt].val].back() < pos[x].back())cnt_bad--; if(next_pnt != -1 && pos[x].back() < pos[node[next_pnt].val].back())cnt_bad--; if(prev_pnt != head && next_pnt != -1 && pos[node[prev_pnt].val].back() < pos[node[next_pnt].val].back())cnt_bad++; node[prev_pnt].next = next_pnt; if(next_pnt!=-1)node[next_pnt].prev = prev_pnt; if(tail == p) tail = prev_pnt; nodelen--; add(x); while(MIN <= M && !valid[MIN])MIN++; } return true; } int main(){ scanf("%d%d%d",&N,&M,&Q); for(int i=1; i<=Q; i++){ scanf("%d",&a[i]); pos[a[i]].push_back(i); } for(int i=1; i<=N; i++) LST[i] = 123456789; puts(chk()?"Yes":"No"); return 0; }
a.cc: In function 'bool chk()': a.cc:72:9: error: 'memset' was not declared in this scope 72 | memset(bit,0,sizeof(bit)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<vector> +++ |+#include <cstring> 3 | using namespace std;
s559363418
p03996
C++
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<math.h> #include<map> #define rep(i,n,m) for(int i=n;i<(int)(m);i++) using namespace std; int main() { int n,m,q; cin >>n>>m>>q; vector<int>num(q); rep(i,0,q){ cin>>num[i]; } if(m%2==)cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:21:13: error: expected primary-expression before ')' token 21 | if(m%2==)cout<<"Yes"<<endl; | ^
s898106174
p03996
C++
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<math.h> #include<map> #define rep(i,n,m) for(int i=n;i<(int)(m);i++) using namespace std; int main() { int n,m,q; cin >>>n>>m>>q; vector<int>num(q); rep(i,0,q){ cin>>num[i]; } if(m%2==)cout<<"Yes"<<endl; else cout<<"No"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:15:7: error: expected primary-expression before '>' token 15 | cin >>>n>>m>>q; | ^ a.cc:21:9: error: expected primary-expression before ')' token 21 | if(m%2==)cout<<"Yes"<<endl; | ^
s859362914
p03996
C++
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,M,Q; int A[101010]; int did[101010]; int index[101010]; vector<int> V; int num[101010]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>M>>Q; FOR(i,Q) { cin>>A[i]; did[A[i]]++; if(did[A[i]]==1) { index[A[i]]=V.size(); V.push_back(A[i]); } } if(1LL*V.size()*M>Q) return _P("No\n"); num[0]=M; for(i=Q-1;i>=0;i--) { if(num[index[A[i]]]) { num[index[A[i]]]--; num[index[A[i]]+1]++; } } if(num[V.size()]==M) _P("Yes\n"); else _P("No\n"); } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); solve(); return 0; }
a.cc:18:17: error: 'int index [101010]' redeclared as different kind of entity 18 | int index[101010]; | ^ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'void solve()': a.cc:30:30: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 30 | index[A[i]]=V.size(); | ^ a.cc:37:29: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 37 | if(num[index[A[i]]]) { | ^ a.cc:38:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 38 | num[index[A[i]]]--; | ^ a.cc:39:34: error: invalid types '<unresolved overloaded function type>[int]' for array subscript 39 | num[index[A[i]]+1]++; | ^
s726966931
p03996
C++
d'd
a.cc:1:2: warning: missing terminating ' character 1 | d'd | ^ a.cc:1:2: error: missing terminating ' character 1 | d'd | ^~ a.cc:1:1: error: 'd' does not name a type 1 | d'd | ^
s080634462
p03996
C++
#include <stdio.h> int main(){ int n,m,q; int a[100000]; int x[100000]; int i,j; int ans; scanf("%d %d",&n,&m); scanf("%d",&q); for(i=0;i<n;++i){ x[i]=0; } for(i=0;i<n;++i){ ++x[a[i]]; } ans=1; if(x[a[n-1]]<n){ ans=0; } printf("%s\n",(flag?"Yes":"No")); return 0; }
a.cc: In function 'int main()': a.cc:26:19: error: 'flag' was not declared in this scope 26 | printf("%s\n",(flag?"Yes":"No")); | ^~~~
s815092153
p03996
Java
import java.util.*; public class Main3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int numArrays = sc.nextInt(); int upperLimit = sc.nextInt(); int[][] arr = new int[numArrays][upperLimit]; for (int i = 0; i < numArrays; i++) { for (int j = 0; j < upperLimit; j++) { arr[i][j] = j+1; } } int numOps = sc.nextInt(); int[] ops = new int[numOps]; for (int i = 0; i < numOps; i++) { ops[i] = sc.nextInt(); } if (possible(arr, numArrays, upperLimit, ops)) System.out.println("Yes"); else System.out.println("No"); // moveFront(ops, arr); // print(arr, numArrays, upperLimit); // for checking } public static boolean possible(int[][] arr, int numArrays, int upperLimit, int[] ops) { return true; } public static void moveFront(int[] ops, int[][] arr) { for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length; j++) { if (arr[i][j] == ops[i]) { int[][] newArr = clone(arr); newArr[i][j] = ops[i]; } } } } public static int[][] clone(int[][] arr) { int[][] newArr = new int[arr.length][arr[0].length]; // clone the arr for (int i = 0; i < arr.length; i++) { for (int j = 0; j < arr[i].length-1; j++) { newArr[i][j+1] = arr[i][j]; } } return newArr; } public static void print(int[][] arr, int numArrays, int upperLimit) { for (int i = 0; i < numArrays; i++) { System.out.print("("); for (int j = 0; j < upperLimit; j++) { System.out.print(arr[i][j]); if (j != upperLimit-1) System.out.print(","); } System.out.println(")"); } } }
Main.java:3: error: class Main3 is public, should be declared in a file named Main3.java public class Main3 { ^ 1 error
s311026284
p03996
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> P; #define EACH(i,a) for (auto& i : a) #define FOR(i,a,b) for (ll i=(a);i<(b);i++) #define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--) #define REP(i,n) for (ll i=0;i<(n);i++) #define RREP(i,n) for (ll i=(n)-1;i>=0;i--) #define debug(x) cout<<#x<<": "<<x<<endl #define pb push_back #define ALL(a) (a).begin(),(a).end() const ll linf = 1e18; const ll inf = 1e9; const double eps = 1e-12; const double pi = acos(-1); template<typename T> istream& operator>>(istream& is, vector<T>& vec) { EACH(x,vec) is >> x; return is; } template<typename T> ostream& operator<<(ostream& os, vector<T>& vec) { REP(i,vec.size()) { if (i) os << " "; os << vec[i]; } return os; } template<typename T> ostream& operator<<(ostream& os, vector< vector<T> >& vec) { REP(i,vec.size()) { if (i) os << endl; os << vec[i]; } return os; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll n, m; cin >> n >> m; ll Q; cin >> Q; vector<ll> a(Q); cin >> a; REP(i, Q) a[i]--; vector<ll> seq = [&]() { set<ll> used; vector<ll> res; RREP(i, Q) { if (used.count(a[i]) == 0) { res.pb(a[i]); used.insert(a[i]); } } REP(i, m) if ( used.count(i) == 0 ) res.pb(i); return res; }(); assert(seq.size() == m); { set<ll> s; REP(i, m) s.insert(seq[i]); assert(s.size() == m); } vector<ll> rseq(m); REP(i, m) rseq[seq[i]] = i; vector<ll> cnt(m+1, 0); cnt[0] = n; int skipped = 0; RREP(i, Q) { ll pos = rseq[a[i]]; if (cnt[pos] > 0) --cnt[pos], ++cnt[pos+1]; else ++skipped; } ll def = 1; RREP(i, m-1) { if (seq[i+1] > seq[i]) ++def; } if (skipped > 0 && cnt[m] == 0 && cnt[m-1] == 0) { ans = false; } // cout << seq << endl; // cout << cnt << endl; // cout << def << endl; bool ans = true; REP(i, m) { if (cnt[i] > 0 && i+def < m) ans = false; } if (ans) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
a.cc: In function 'int main()': a.cc:80:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 80 | ans = false; | ^~~ | abs
s061163242
p03996
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> P; #define EACH(i,a) for (auto& i : a) #define FOR(i,a,b) for (ll i=(a);i<(b);i++) #define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--) #define REP(i,n) for (ll i=0;i<(n);i++) #define RREP(i,n) for (ll i=(n)-1;i>=0;i--) #define debug(x) cout<<#x<<": "<<x<<endl #define pb push_back #define ALL(a) (a).begin(),(a).end() const ll linf = 1e18; const ll inf = 1e9; const double eps = 1e-12; const double pi = acos(-1); template<typename T> istream& operator>>(istream& is, vector<T>& vec) { EACH(x,vec) is >> x; return is; } template<typename T> ostream& operator<<(ostream& os, vector<T>& vec) { REP(i,vec.size()) { if (i) os << " "; os << vec[i]; } return os; } template<typename T> ostream& operator<<(ostream& os, vector< vector<T> >& vec) { REP(i,vec.size()) { if (i) os << endl; os << vec[i]; } return os; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll n, m; cin >> n >> m; ll Q; cin >> Q; vector<ll> a(Q); cin >> a; REP(i, Q) a[i]--; vector<ll> seq = [&]() { set<ll> used; vector<ll> res; RREP(i, Q) { if (used.count(a[i]) == 0) { res.pb(a[i]); used.insert(a[i]); } } REP(i, m) if ( used.count(i) == 0 ) res.pb(i); return res; }(); assert(seq.size() == m); { set<ll> s; REP(i, m) s.insert(seq[i]); assert(s.size() == m); } vector<ll> rseq(m); REP(i, m) rseq[seq[i]] = i; vector<ll> cnt(m+1, 0); cnt[0] = n; int skipped = 0; RREP(i, Q) { ll pos = rseq[a[i]]; if (cnt[pos] > 0) --cnt[pos], ++cnt[pos+1]; else ++skipped; } ll def = 1; RREP(i, m-1) { if (seq[i+1] > seq[i]) ++def; } if (skipped > 0 && cnt[m] == 0) { ans = false; } // cout << seq << endl; // cout << cnt << endl; // cout << def << endl; bool ans = true; REP(i, m) { if (cnt[i] > 0 && i+def < m) ans = false; } if (ans) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
a.cc: In function 'int main()': a.cc:80:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 80 | ans = false; | ^~~ | abs
s258419930
p03996
C++
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() #define pb push_back #define fs first #define sc second #define show(x) cout << #x << " = " << x << endl #define chmin(x,y) x=min(x,y) #define chmax(x,y) x=max(x,y) using namespace std; template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";} template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;} const int MN=100000; int N,M,Q,a[MN]; bool done[MN]; //value done? int its[MN]; //where iterate? set<int> v2ps[MN]; int top; bool okalone(int num,int I){ if(num!=top) return 0; for(int it=I;it<Q&&num<M;it++){ int v=a[it]; if(done[v]) continue; if(v>num) return 0; if(a[it]==num){ num++; while(num<M&&done[num]) num++; } } return (num==M); } bool solve(){ cin>>N>>M>>Q; if(N==1) return 1; rep(i,Q) cin>>a[Q-1-i],a[Q-1-i]--; rep(i,Q) v2ps[a[i]].insert(i); while(true){ int I=its[0]; for(;I<Q;I++){ if(!done[a[I]]) break; } if(I==Q){ return 1; } int v=a[I]; // show(I); // show(v); if(okalone(v,I)) return 1; set<int>& st=v2ps[v]; rep(i,N){ auto it=st.lower_bound(its[i]); if(it==st.end()) return 0; its[i]=*it; st.erase(it); } done[v]=1; if(top==v){ while(top<M&&done[top]) top++ } } assert(false); } int main(){ if(solve()) puts("Yes"); else puts("No"); }
a.cc: In function 'bool solve()': a.cc:61:54: error: expected ';' before '}' token 61 | while(top<M&&done[top]) top++ | ^ | ; 62 | } | ~
s342458356
p03996
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> P; #define EACH(i,a) for (auto& i : a) #define FOR(i,a,b) for (ll i=(a);i<(b);i++) #define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--) #define REP(i,n) for (ll i=0;i<(n);i++) #define RREP(i,n) for (ll i=(n)-1;i>=0;i--) #define debug(x) cout<<#x<<": "<<x<<endl #define pb push_back #define ALL(a) (a).begin(),(a).end() const ll linf = 1e18; const ll inf = 1e9; const double eps = 1e-12; const double pi = acos(-1); template<typename T> istream& operator>>(istream& is, vector<T>& vec) { EACH(x,vec) is >> x; return is; } template<typename T> ostream& operator<<(ostream& os, vector<T>& vec) { REP(i,vec.size()) { if (i) os << " "; os << vec[i]; } return os; } template<typename T> ostream& operator<<(ostream& os, vector< vector<T> >& vec) { REP(i,vec.size()) { if (i) os << endl; os << vec[i]; } return os; } int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); ll n, m; cin >> n >> m; ll Q; cin >> Q; vector<ll> a(Q); cin >> a; REP(i, Q) a[i]--; vector<ll> seq = [&]() { set<ll> used; vector<ll> pos(m); REP(i, Q) { used.insert(a[i]); pos[a[i]] = i; } vector<P> temp; REP(i, m) if (used.count(i) > 0) temp.pb({-pos[i], i}); sort( ALL(temp) ); vector<ll> res; REP(i, temp.size()) { res.pb(temp[i].second); } REP(i, m) if ( used.count(i) == 0 ) res.pb(i); return res; }(); assert(seq.size() == m); { set<ll> s; RPE(i, m) s.insert(seq[i]); assert(s.size() == m); } vector<ll> rseq(m); REP(i, m) rseq[seq[i]] = i; vector<ll> cnt(m+1, 0); cnt[0] = n; RREP(i, Q) { ll pos = rseq[a[i]]; if (cnt[pos] > 0) --cnt[pos], ++cnt[pos+1]; } ll def = 1; RREP(i, m-1) { if (seq[i+1] > seq[i]) ++def; } cout << seq << endl; cout << cnt << endl; cout << def << endl; bool ans = true; REP(i, m) { if (cnt[i] > 0 && i+def < m) ans = false; } if (ans) { cout << "Yes" << endl; } else { cout << "No" << endl; } }
a.cc: In function 'int main()': a.cc:70:22: error: 'i' was not declared in this scope 70 | { set<ll> s; RPE(i, m) s.insert(seq[i]); assert(s.size() == m); } | ^ a.cc:70:18: error: 'RPE' was not declared in this scope; did you mean 'REP'? 70 | { set<ll> s; RPE(i, m) s.insert(seq[i]); assert(s.size() == m); } | ^~~ | REP
s287857036
p03996
C++
/*N M Q a1 a2 … aQ*/ #include <iostream> #include <string> #include <algorithm> #include <vector> #include <utility> using namespace std; int main() { int N,M,Q; cin >> N >> M; cin >> Q; int a[M]; int sum =0; for(int i=0;i<M;i++) { cin >> a[i]; sum+=a[i]; } string s; cin >> s; cin >> K; if(sum%2==0) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:24:16: error: 'K' was not declared in this scope 24 | cin >> K; | ^
s713209570
p03996
C++
#define FNAME "" #include <bits/stdc++.h> #define hash padjf9srpi #define y0 sdkfaslhagaklsldk #define y1 aasdfasdfasdf #define yn askfhwqriuperikldjk #define j1 assdgsdgasghsf #define tm sdfjahlfasfh #define lr asgasgash #define pb push_back #define mp make_pair #define forn(i, n) for (int i = 0; i < (n); i++) #define fornr(i, n) for (int i = (n) - 1; i >= 0; i--) #define forab(i, a, b) for (int i = (a); i < (b); i++) #define gcd __gcd #define all(a) (a).begin(), (a).end() #ifdef _WIN32 #define I64 "%I64d" #else #define I64 "%lld" #endif using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; typedef pair <int, int> pii; typedef vector <int> vi; template <class T> T sqr(const T &a) {return a * a;} const int MAXN = 2e5 + 100; set <int> Set[MAXN]; int n, m, q, a[MAXN], was[MAXN], pos[MAXN]; vi order; int main() { #ifdef LOCAL freopen(FNAME".in", "r", stdin); freopen(FNAME".out", "w", stdout); #endif scanf("%d%d%d", &n, &m, &q); forab(i, 1, n) Set[0].insert(i); forn(i, q) { scanf("%d", &a[i]); } fornr(i, q) { if (!was[a[i]]) { was[a[i]] = 1; pos[a[i]] = (int) order.size(); order.pb(a[i]); } else { int p = pos[a[i]]; if (Set[p].size()) { Set[p + 1].insert(*Set[p].begin()); Set[p].erase(Set[p].begin()); } } } int okPos = order.size(); int firstFail = (int) order.size(); forn(i, (int) order.size) if (Set[i].size()) { firstFail = i; break; } forn(i, (int) order.size()) { if (order[i] == 1) { int kek = 1; int last = 1; if (firstFail < i) continue; forab(j, i, (int) order.size()) { // printf("j=%d order=%d last=%d was=%d\n", j, order[j], last, was[last]); while (order[j] > last && was[last]) last++; // printf("j=%d order=%d last=%d\n", j, order[j], last); if (order[j] != last) kek = 0; last++; } if (kek) okPos = i; break; } } /* for (int i: order) printf("%d ", i); printf("\n%d\n", okPos);*/ int ok = 1; forn(i, okPos) { // printf("%d\n", (int) Set[i].size()); if (Set[i].size()) ok = 0; } puts(ok ? "Yes" : "No"); }
a.cc: In function 'int main()': a.cc:70:29: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?) 70 | forn(i, (int) order.size) | ~~~~~~^~~~ a.cc:14:41: note: in definition of macro 'forn' 14 | #define forn(i, n) for (int i = 0; i < (n); i++) | ^
s041068325
p03996
C++
#include <algorithm> #include <cmath> #include <cstdlib> #include <cstdio> #include <iostream> #include <map> #include <set> #include <utility> #include <vector> using namespace std; int main(){ int N, M; scanf("%d%d", &N, &M); int Q; scanf("%d", &Q); map<int,vector<int> > am; vector<int> av; for (int i = 0; i < Q; i++){ int temp; scanf("%d", &temp); av.push_back(temp); if (am.find(temp) == am.end()){ am[temp] = vector<int>(); } am[temp].push_back(i); } map<int,vector<int> > amc(am); int temp = av[av.size()-1]; int tempindex = av.size()-1; vector<int> used(Q, 0); int minw = N; vector<int> result; int counter = 1; while(amc.size() > 0){ if (temp != 1)){ minw = min(minw, (int)amc[temp].size()); } for (int i = 0; i < amc[temp].size(); i++){ used[amc[temp][i]] = 1; } amc.erase(temp); while(used[tempindex] == 1){ tempindex--; } result.push_back(temp); temp = av[tempindex]; counter++; } if (minw == N){ cout << "Yes" << endl; }else{ for (int i = 0; i < result.size(); i++){ if (result[i] == (i+1)){ continue; }else{ cout << "No" << endl; return 0; } } cout << "Yes" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:37:19: error: expected primary-expression before ')' token 37 | if (temp != 1)){ | ^
s601815963
p03996
C++
#ifndef __clang__ #pragma GCC optimize ("-O3") #endif #ifdef ONLINE_JUDGE #define NDEBUG 1 #endif #define _GLIBCXX_USE_CXX11_ABI 0 #include <stdio.h> #include <bits/stdc++.h> #define DESTRUCT2(p, a, b) \ auto a = get<0>(p); \ auto b = get<1>(p); #define DESTRUCT3(p, a, b, c) \ auto a = get<0>(p); \ auto b = get<1>(p); \ auto c = get<2>(p); #define DESTRUCT4(p, a, b, c, d) \ auto a = get<0>(p); \ auto b = get<1>(p); \ auto c = get<2>(p); \ auto d = get<3>(p); #define FOR(i, n) for(lli i = 0; i < (lli)(n); ++i) #define FORU(i, j, k) for(lli i = (j); i <= (lli)(k); ++i) #define FORD(i, j, k) for(lli i = (j); i >= (lli)(k); --i) #define SQ(x) ((x)*(x)) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define mp make_pair #define mt make_tuple #define pb push_back #define eb emplace_back using namespace std; template<typename... As> struct tpl : public std::tuple<As...> { using std::tuple<As...>::tuple; template<typename T = tuple<As...> > typename tuple_element<0, T>::type const& x() const { return get<0>(*this); } template<typename T = tuple<As...> > typename tuple_element<0, T>::type& x() { return get<0>(*this); } template<typename T = tuple<As...> > typename tuple_element<1, T>::type const& y() const { return get<1>(*this); } template<typename T = tuple<As...> > typename tuple_element<1, T>::type& y() { return get<1>(*this); } template<typename T = tuple<As...> > typename tuple_element<2, T>::type const& z() const { return get<2>(*this); } template<typename T = tuple<As...> > typename tuple_element<2, T>::type& z() { return get<2>(*this); } template<typename T = tuple<As...> > typename tuple_element<3, T>::type const& w() const { return get<3>(*this); } template<typename T = tuple<As...> > typename tuple_element<3, T>::type& w() { return get<3>(*this); } }; using lli = long long int; using llu = long long unsigned; using pii = tpl<lli, lli>; using piii = tpl<lli, lli, lli>; using piiii = tpl<lli, lli, lli, lli>; using vi = vector<lli>; using vii = vector<pii>; using viii = vector<piii>; using vvi = vector<vi>; using vvii = vector<vii>; using vviii = vector<viii>; template<class T> using min_queue = priority_queue<T, vector<T>, greater<T> >; template<class T> using max_queue = priority_queue<T>; template<size_t... I> struct my_index_sequence { using type = my_index_sequence; static constexpr array<size_t, sizeof...(I)> value = { {I}... }; }; namespace my_index_sequence_detail { template<typename I, typename J> struct concat; template<size_t... I, size_t... J> struct concat<my_index_sequence<I...>, my_index_sequence<J...> > : my_index_sequence<I..., (sizeof...(I)+J)...> { }; template<size_t N> struct make_index_sequence : concat<typename make_index_sequence<N/2>::type, typename make_index_sequence<N-N/2>::type>::type { }; template <> struct make_index_sequence<0> : my_index_sequence<>{}; template <> struct make_index_sequence<1> : my_index_sequence<0>{}; } template<class... A> using my_index_sequence_for = typename my_index_sequence_detail::make_index_sequence<sizeof...(A)>::type; template<class T, size_t... I> void print_tuple(ostream& s, T const& a, my_index_sequence<I...>){ using swallow = int[]; (void)swallow{0, (void(s << (I == 0? "" : ", ") << get<I>(a)), 0)...}; } template<class T> ostream& print_collection(ostream& s, T const& a){ s << '['; for(auto it = begin(a); it != end(a); ++it){ s << *it; if(it != prev(end(a))) s << " "; } return s << ']'; } template<class... A> ostream& operator<<(ostream& s, tpl<A...> const& a){ s << '('; print_tuple(s, a, my_index_sequence_for<A...>{}); return s << ')'; } template<class... A> ostream& operator<<(ostream& s, tuple<A...> const& a){ s << '('; print_tuple(s, a, my_index_sequence_for<A...>{}); return s << ')'; } template<class A, class B> ostream& operator<<(ostream& s, pair<A, B> const& a){ return s << "(" << get<0>(a) << ", " << get<1>(a) << ")"; } template<class T, size_t I> ostream& operator<<(ostream& s, array<T, I> const& a) { return print_collection(s, a); } template<class T> ostream& operator<<(ostream& s, vector<T> const& a) { return print_collection(s, a); } template<class T, class U> ostream& operator<<(ostream& s, multimap<T, U> const& a) { return print_collection(s, a); } template<class T> ostream& operator<<(ostream& s, multiset<T> const& a) { return print_collection(s, a); } template<class T, class U> ostream& operator<<(ostream& s, map<T, U> const& a) { return print_collection(s, a); } template<class T> ostream& operator<<(ostream& s, set<T> const& a) { return print_collection(s, a); } namespace std { namespace { template <class T> inline void hash_combine(size_t& seed, T const& v) { seed ^= hash<T>()(v) + 0x9e3779b9 + (seed<<6) + (seed>>2); } template <class Tuple, size_t Index = tuple_size<Tuple>::value - 1> struct HashValueImpl { static void apply(size_t& seed, Tuple const& tuple) { HashValueImpl<Tuple, Index-1>::apply(seed, tuple); hash_combine(seed, get<Index>(tuple)); } }; template <class Tuple> struct HashValueImpl<Tuple, 0> { static void apply(size_t& seed, Tuple const& tuple) { hash_combine(seed, get<0>(tuple)); } }; } template <typename ... TT> struct hash<tuple<TT...>> { size_t operator()(tuple<TT...> const& tt) const { size_t seed = 0; HashValueImpl<tuple<TT...> >::apply(seed, tt); return seed; } }; template <typename ... TT> struct hash<tpl<TT...>> { size_t operator()(tpl<TT...> const& tt) const { size_t seed = 0; HashValueImpl<tuple<TT...> >::apply(seed, tt); return seed; } }; } int read_positive(){ char c; int x=0; do { c = getchar(); } while(c<'0' || c>'9'); while(c>='0'&&c<='9') { x=10*x+(c-'0'); c = getchar(); } return x; } //------------------------------------------------------------------------------ int main(int, char**){ ios::sync_with_stdio(0); cin.tie(0); int n, m, q; cin >> n >> m >> q; vi A(q); FOR(i, q) { cin >> A[i]; A[i]-=1; } vi E(m); vi S; FORD(i, q-1, 0) if(!E[A[i]]) { E[A[i]] = 1; S.pb(A[i]); } bool remEnd=endV<=S.size(); int endV = S.back(); if(endV <= S.size()) FOR(i, endV+1) if(S[S.size()-1-i] != endV-i) remEnd = 0; if(remEnd) S.resize(S.size()-endV); if(S.empty()) goto ok; assert(false); ok:; cout << "Yes" << endl; return 0; fail:; cout << "No" << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:217:15: error: 'endV' was not declared in this scope 217 | bool remEnd=endV<=S.size(); int endV = S.back(); | ^~~~
s762830949
p03997
C++
#include<stdio.h> #include<iostream> #include<string> #include<vector> #include<map> #include<algorithm> #include<cmath> #include<bitset> #define Vsort(a) sort(a.begin(), a.end()) #define Vreverse(a) reverse(a.begin(), a.end()) #define Srep(n) for(int i = 0; i < (n); i++) #define Lrep(i,a,n) for(int i = (a); i < (n); i++) #define Brep(n) for(int bit = 0; bit < (1<<n); bit++) #define rep2nd(n,m) Srep(n) Lrep(j,0,m) #define vi vector<int> #define vi64 vector<int64_t> #define vvi vector<vector<int>> #define vvi64 vector<vector<int64_t>> #define P pair<int,int> #define F first #define S second using namespace std; int main(){ int a,b,h; cin >> a >> b >> h; cout << (a + b) * h / 2 }
a.cc: In function 'int main()': a.cc:29:26: error: expected ';' before '}' token 29 | cout << (a + b) * h / 2 | ^ | ; 30 | } | ~
s649805796
p03997
C++
#include <iostream> using namespace std; int main(){ int a; cin >> a; int b: cin >> b; int h; cin >> h; cout << (a+b)*h/2; }
a.cc: In function 'int main()': a.cc:7:8: error: found ':' in nested-name-specifier, expected '::' 7 | int b: | ^ | :: a.cc:7:7: error: 'b' has not been declared 7 | int b: | ^ a.cc:8:7: error: qualified-id in declaration before '>>' token 8 | cin >> b; | ^~ a.cc:11:14: error: 'b' was not declared in this scope 11 | cout << (a+b)*h/2; | ^
s063836662
p03997
C++
#include <iostream> using namespace std; int main(){ int a; cin >> a; int b; cin >> b; int h; cin >> h; cout << (a+b)*h/2 }
a.cc: In function 'int main()': a.cc:12:20: error: expected ';' before '}' token 12 | cout << (a+b)*h/2 | ^ | ; 13 | } | ~
s276807819
p03997
C++
#include <iostream> using namespace std; int main(){ int a; cin >> a; int b; cin >> b; int h; cin >> h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:12:16: error: expected ';' before 'h' 12 | cout << (a+b)h/2 << endl; | ^ | ;
s581821095
p03997
C++
#include <iostream> using namespace std; int main(){ int a.b.h; cin >> a; cin >> b; cin >> h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected initializer before '.' token 6 | int a.b.h; | ^ a.cc:7:9: error: 'a' was not declared in this scope 7 | cin >> a; | ^ a.cc:8:9: error: 'b' was not declared in this scope 8 | cin >> b; | ^ a.cc:9:9: error: 'h' was not declared in this scope 9 | cin >> h; | ^
s056423713
p03997
C++
#include <iostream> using namespace std; int main(){ int a.b.h; cin >> a; cin >> b; cin >> c; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected initializer before '.' token 6 | int a.b.h; | ^ a.cc:7:9: error: 'a' was not declared in this scope 7 | cin >> a; | ^ a.cc:8:9: error: 'b' was not declared in this scope 8 | cin >> b; | ^ a.cc:9:9: error: 'c' was not declared in this scope 9 | cin >> c; | ^
s204920491
p03997
C++
#include <iostream> using namespace std; int main(){ int a.b.h; cin << a << b << h << endl; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected initializer before '.' token 6 | int a.b.h; | ^ a.cc:7:10: error: 'a' was not declared in this scope 7 | cin << a << b << h << endl; | ^ a.cc:7:15: error: 'b' was not declared in this scope 7 | cin << a << b << h << endl; | ^ a.cc:7:20: error: 'h' was not declared in this scope 7 | cin << a << b << h << endl; | ^
s547065019
p03997
C++
#include <iostream> using namespace std; int main(){ int a.b.h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected initializer before '.' token 6 | int a.b.h; | ^ a.cc:7:12: error: 'a' was not declared in this scope 7 | cout << (a+b)h/2 << endl; | ^ a.cc:7:14: error: 'b' was not declared in this scope 7 | cout << (a+b)h/2 << endl; | ^
s766018016
p03997
C++
#include <iostream> using namespace std; int main(){ int a.b.h; cin >> a,b,h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected initializer before '.' token 6 | int a.b.h; | ^ a.cc:7:11: error: 'a' was not declared in this scope 7 | cin >> a,b,h; | ^ a.cc:7:13: error: 'b' was not declared in this scope 7 | cin >> a,b,h; | ^ a.cc:7:15: error: 'h' was not declared in this scope 7 | cin >> a,b,h; | ^
s908631265
p03997
C++
#include <iostream> using namespace std; int main(){ int a.b.h; cin >> a,b,h; cout << (a+b)*h/2 << endl; }
a.cc: In function 'int main()': a.cc:6:7: error: expected initializer before '.' token 6 | int a.b.h; | ^ a.cc:7:11: error: 'a' was not declared in this scope 7 | cin >> a,b,h; | ^ a.cc:7:13: error: 'b' was not declared in this scope 7 | cin >> a,b,h; | ^ a.cc:7:15: error: 'h' was not declared in this scope 7 | cin >> a,b,h; | ^
s665735894
p03997
C++
#include <iostream> using namespace std; int main(){ int a,b,h; cin >> a >> endl >> b >> endl >> h >> endl; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:7:12: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and '<unresolved overloaded function type>') 7 | cin >> a >> endl >> b >> endl >> h >> endl; | ~~~~~~~~~^~~~~~~ In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'} 352 | operator>>(__streambuf_type* __sb);
s830366583
p03997
C++
#include <iostream> using namespace std; int main(){ int a,b,h; cin >> a; cin >> b; cin >> h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:10:16: error: expected ';' before 'h' 10 | cout << (a+b)h/2 << endl; | ^ | ;
s414752987
p03997
C++
#include <iostream> using namespace std; int main(){ int a,b,h; cin >> a,b,h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:8:16: error: expected ';' before 'h' 8 | cout << (a+b)h/2 << endl; | ^ | ;
s569077995
p03997
C++
#include <iostream> using namespace std; int main(){ int a,b,h; cin >> a,b,h; cout << (a+b)h/2 << endl; }
a.cc: In function 'int main()': a.cc:8:16: error: expected ';' before 'h' 8 | cout << (a+b)h/2 << endl; | ^ | ;