submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s578439541 | p03855 | C++ | #include "pch.h"
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
#define ll long long
int gcd(int x, int y) {
if (y == 0)return x;
return gcd(y, x%y);
}
int lcm(int x, int y) {
return x / gcd(x, y)*y;
}
bool prime(int x) {
for (int i = 2; i <= sqrt(x); i++) {
if (x%i == 0)return false;
}
return true;
}
int kai(int x) {
if (x == 1)return 1;
return kai(x - 1)*x;
}
int mod_pow(int x, int y, int moder) {
int res = 1;
while (y > 0) {
if (y & 1)res = res * x%moder;
x = x * x%moder;
y >>= 1;
}
return res;
}
class Union_Find {
private:
int par[200010], rankk[200010];
public:
void init(int n) {
rep(i, n) {
par[i] = i;
rankk[i] = 0;
}
}
int find(int x) {
if (par[x] == x)return x;
else {
return par[x] = find(par[x]);
}
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y)return;
if (rankk[x] < rankk[y]) {
par[x] = y;
}
else {
par[y] = x;
if (rankk[x] == rankk[y])rankk[x]++;
}
}
bool same(int x, int y) {
return find(x) == find(y);
}
};
int n, k, l, p[100010], q[100010], a[100010], b[100010];
map<pair<int, int>, int> mp;
signed main() {
cin >> n >> k >> l;
Union_Find ta, mu;
ta.init(n + 1);
mu.init(n + 1);
rep(i, k) {
cin >> p[i] >> q[i];
ta.unite(p[i], q[i]);
}
rep(i, l) {
cin >> a[i] >> b[i];
mu.unite(a[i], b[i]);
}
for (int i = 1; i <= n; i++) {
mp[make_pair(ta.find(i), mu.find(i))]++;
}
for (int i = 1; i <= n; i++) {
if (i == n) {
cout << mp[make_pair(ta.find(i), mu.find(i))] << endl;
return 0;
}
else cout << mp[make_pair(ta.find(i), mu.find(i))] << " ";
}
}
| a.cc:1:10: fatal error: pch.h: No such file or directory
1 | #include "pch.h"
| ^~~~~~~
compilation terminated.
|
s036480910 | p03855 | C++ | #include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;
#include<vector>
template<typename T>
class UnionFind
{
public:
vector<T> parent;
vector<T> sz;
UnionFind(T n):parent(n),sz(n)
{
for(int i=0;i<n;i++)
parent[i]=i;
for(int i=0;i<n;i++)
sz[i]=1;
}
void unite(T a,T b)
{
a=root(a);
b=root(b);
if(a==b)return;
if(a>b)swap(a,b);
sz[a]+=sz[b];
sz[b]=0;
parent[b]=a;
return;
}
T root(T n)
{
if(parent[n]==n)
return n;
else
{
T ret=root(parent[n]);
parent[n]=ret;
return ret;
}
}
T size(T n)
{
return sz[root(n)];
}
};
int main()
{
int N,K,L;
cin >> N >> K >> L;
UnionFind<int> uf0(N);
UnionFind<int> uf2(N);
for(int i=0;i<K;i++)
{
int p,q;
cin >> p >> q;
uf1.unite(p-1,q-1);
}
for(int i=0;i<L;i++)
{
int r,s;
cin >> r >> s;
if(uf1.root(r-1)==uf1.root(s-1))
uf2.unite(r-1,s-1);
}
for(int i=0;i<N;i++)
{
cout << uf2.size(uf2.root(i));
if(i!=N-1)
cout << " ";
}
cout << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:64:17: error: 'uf1' was not declared in this scope; did you mean 'uf2'?
64 | uf1.unite(p-1,q-1);
| ^~~
| uf2
a.cc:70:20: error: 'uf1' was not declared in this scope; did you mean 'uf2'?
70 | if(uf1.root(r-1)==uf1.root(s-1))
| ^~~
| uf2
|
s625794791 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl
#define rep(i, n) REP(i, 0, n) // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define invrep(i, n) for(int i = (n)-1; i >= 0; i--) // n-1, n-2, ..., 0
#define invREP(i, x, n) for(int i = (n)-1; i >= (x; i--) // n-1, n-2, ..., x
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define PB push_back
#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
class UnionFind{
public:
vector<int> uni;
UnionFind(int s) : uni(s, -1) { }
//頂点aが所属するグループを調べる
int root(int a)
{
if (uni[a] < 0) return a;
return uni[a] = root(uni[a]);
}
//頂点aと頂点bを繋ぐ。もともと同じグループの時falseを返す
bool connect(int a,int b)
{
a = root(a);
b = root(b);
if (a == b) return false;
if (uni[a] > uni[b])
{
a ^= b;
b ^= a;
a ^= b;
}
uni[a] = uni[a] + uni[b];
uni[b] = a;
return true;
}
//頂点a,bが同じグループであるかを調べる
bool isConnect(int a,int b)
{
return root(a) == root(b);
}
//頂点aを含むグループの頂点数を調べる
int size(int a)
{
return -uni[root(a)];
}
};
int N, K, L;
int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
int a[3*10e5], b[3*10e5];
int main(){
cin >> N >> K >> L;
map<pi, int> mp;
UnionFind ufk(N), ufl(N);
rep(i, K){
cin >> p[i] >> q[i];
p[i]--; q[i]--;
ufk.connect(p[i], q[i]);
}
rep(i, L){
cin >> r[i] >> s[i];
r[i]--; s[i]--;
ufl.connect(r[i], s[i]);
}
rep(i, N){
a[i] = ufk.root(i);
b[i] = ufl.root(i);
mp[make_pair(a[i], b[i])]++;
}
rep(i, N){
cout << mp[make_pair(a[i], b[i])] << " \n"[i == N - 1];
}
} | a.cc:89:8: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
a.cc:89:8: error: could not convert '((double)2 * 1.0e+6)' from 'double' to 'long unsigned int'
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
| |
| double
a.cc:89:8: error: size of array 'p' has non-integral type 'double'
a.cc:89:19: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
a.cc:89:19: error: could not convert '((double)2 * 1.0e+6)' from 'double' to 'long unsigned int'
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
| |
| double
a.cc:89:19: error: size of array 'q' has non-integral type 'double'
a.cc:89:30: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
a.cc:89:30: error: could not convert '((double)2 * 1.0e+6)' from 'double' to 'long unsigned int'
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
| |
| double
a.cc:89:30: error: size of array 'r' has non-integral type 'double'
a.cc:89:41: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
a.cc:89:41: error: could not convert '((double)2 * 1.0e+6)' from 'double' to 'long unsigned int'
89 | int p[2*10e5], q[2*10e5], r[2*10e5], s[2*10e5];
| ~^~~~~
| |
| double
a.cc:89:41: error: size of array 's' has non-integral type 'double'
a.cc:90:8: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
90 | int a[3*10e5], b[3*10e5];
| ~^~~~~
a.cc:90:8: error: could not convert '((double)3 * 1.0e+6)' from 'double' to 'long unsigned int'
90 | int a[3*10e5], b[3*10e5];
| ~^~~~~
| |
| double
a.cc:90:8: error: size of array 'a' has non-integral type 'double'
a.cc:90:19: error: conversion from 'double' to 'long unsigned int' in a converted constant expression
90 | int a[3*10e5], b[3*10e5];
| ~^~~~~
a.cc:90:19: error: could not convert '((double)3 * 1.0e+6)' from 'double' to 'long unsigned int'
90 | int a[3*10e5], b[3*10e5];
| ~^~~~~
| |
| double
a.cc:90:19: error: size of array 'b' has non-integral type 'double'
|
s618318388 | p03855 | C++ | #include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
// Manages Union-Find Forest.
class UnionFindForest {
std::vector<int> parent_;
std::vector<int> rank_;
std::vector<int> size_;
public:
// Initialize forest.
// parent_[i]=i, rank_[i]=0, size_[i]=1.
UnionFindForest(const int &n);
// Get the number of the root of the node q.
int Root(const int &q);
// Return true if the roots of x and y is same.
bool IsSame(const int &x, const int &y);
// Unite the tree x and tree y.
void Unite(int x, int y);
// Get the number of nodes which are the same group as node q.
int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
parent_.resize(n);
rank_.resize(n);
size_.resize(n);
for (int i = 0; i < n; i++) {
parent_[i] = i;
rank_[i] = 0;
size_[i] = 1;
}
}
int UnionFindForest::Size(const int &q) {
return size_[Root(q)];
}
int UnionFindForest::Root(const int &q) {
if (parent_[q] == q) {
return q;
} else {
return parent_[q] = Root(parent_[q]);
}
}
bool UnionFindForest::IsSame(const int &x, const int &y) {
return Root(x) == Root(y);
}
void UnionFindForest::Unite(int x, int y) {
x = Root(x);
y = Root(y);
if (x == y) return;
if (rank_[x] < rank_[y]) {
parent_[x] = y;
size_[y] += size_[x];
size_[x] = 0;
} else {
parent_[y] = x;
size_[x] += size_[y];
size_[y] = 0;
if (rank_[x] == rank_[y]) rank_[x]++;
}
}
struct Node {
int root_road;
int root_rail;
const bool operator==(const Node &a) {
if (root_rail == a.root_rail && root_road == a.root_road) {
return true;
} else {
return false;
}
}
const bool operator<(const Node &a) {
if (root_road == a.root_road) {
return root_rail < a.root_rail;
} else {
return root_road < a.root_road;
}
}
const bool operator>(const Node &a) {
if (root_road == a.root_road) {
return root_rail > a.root_rail;
} else {
return root_road > a.root_road;
}
}
};
int main(void) {
cout << std::fixed << std::setprecision(10);
cin.tie(0);
std::ios::sync_with_stdio(false);
int n, k, l;
cin >> n >> k >> l;
std::unordered_set<int> road_connection[200001], rail_connection[200001];
for (int i = 0; i < k; i++) {
int p, q;
cin >> p >> q;
road_connection[p].insert(q);
road_connection[q].insert(p);
}
for (int i = 0; i < l; i++) {
int p, q;
cin >> p >> q;
rail_connection[p].insert(q);
rail_connection[q].insert(p);
}
UnionFindForest uf_road(n + 1);
for (int i = 1; i <= n; i++) {
for (auto x : road_connection[i]) {
uf_road.Unite(i, x);
}
}
UnionFindForest uf_rail(n + 1);
for (int i = 1; i <= n; i++) {
for (auto x : rail_connection[i]) {
uf_rail.Unite(i, x);
}
}
std::multiset<Node> set;
for (int i = 1; i <= n; i++) {
Node node;
node.root_rail = uf_rail.Root(i);
node.root_road = uf_road.Root(i);
set.insert(node);
}
for (int i = 1; i <= n; i++) {
Node node;
node.root_rail = uf_rail.Root(i);
node.root_road = uf_road.Root(i);
cout << set.count(node) << " ";
}
cout << endl;
return 0;
}
| In file included from /usr/include/c++/14/bits/refwrap.h:39,
from /usr/include/c++/14/deque:67,
from a.cc:3:
/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_tree.h:2147:32: required from 'std::pair<std::_Rb_tree_node_base*, std::_Rb_tree_node_base*> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_equal_pos(const key_type&) [with _Key = Node; _Val = Node; _KeyOfValue = std::_Identity<Node>; _Compare = std::less<Node>; _Alloc = std::allocator<Node>; key_type = Node]'
2147 | __x = _M_impl._M_key_compare(__k, _S_key(__x)) ?
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:2196:4: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_equal(_Arg&&) [with _Arg = const Node&; _Key = Node; _Val = Node; _KeyOfValue = std::_Identity<Node>; _Compare = std::less<Node>; _Alloc = std::allocator<Node>; iterator = std::_Rb_tree<Node, Node, std::_Identity<Node>, std::less<Node>, std::allocator<Node> >::iterator]'
2196 | = _M_get_insert_equal_pos(_KeyOfValue()(__v));
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h:505:36: required from 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::insert(const value_type&) [with _Key = Node; _Compare = std::less<Node>; _Alloc = std::allocator<Node>; iterator = std::_Rb_tree<Node, Node, std::_Identity<Node>, std::less<Node>, std::allocator<Node> >::const_iterator; value_type = Node]'
505 | { return _M_t._M_insert_equal(__x); }
| ~~~~~~~~~~~~~~~~~~~~^~~~~
a.cc:144:15: required from here
144 | set.insert(node);
| ~~~~~~~~~~^~~~~~
/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; }
| ~~~~^~~~~
a.cc:89:14: note: candidate: 'const bool Node::operator<(const Node&)' (near match)
89 | const bool operator<(const Node &a) {
| ^~~~~~~~
a.cc:89:14: note: passing 'const Node*' as 'this' argument discards qualifiers
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045: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::pair<_T1, _T2>'
405 | { return __x < __y; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/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; }
| ~~~~^~~~~
In file included from /usr/include/c++/14/deque:66:
/usr/include/c++/14/bits/stl_deque.h:2334:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)'
2334 | operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:2334: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::deque<_Tp, _Alloc>'
405 | { return __x < __y; }
| ~~~~^~~~~
|
s416919084 | p03855 | C++ | #include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
// Manages Union-Find Forest.
class UnionFindForest {
std::vector<int> parent_;
std::vector<int> rank_;
std::vector<int> size_;
public:
// Initialize forest.
// parent_[i]=i, rank_[i]=0, size_[i]=1.
UnionFindForest(const int &n);
// Get the number of the root of the node q.
int Root(const int &q);
// Return true if the roots of x and y is same.
bool IsSame(const int &x, const int &y);
// Unite the tree x and tree y.
void Unite(int x, int y);
// Get the number of nodes which are the same group as node q.
int Size(const int &q);
};
UnionFindForest::UnionFindForest(const int &n) {
parent_.resize(n);
rank_.resize(n);
size_.resize(n);
for (int i = 0; i < n; i++) {
parent_[i] = i;
rank_[i] = 0;
size_[i] = 1;
}
}
int UnionFindForest::Size(const int &q) {
return size_[Root(q)];
}
int UnionFindForest::Root(const int &q) {
if (parent_[q] == q) {
return q;
} else {
return parent_[q] = Root(parent_[q]);
}
}
bool UnionFindForest::IsSame(const int &x, const int &y) {
return Root(x) == Root(y);
}
void UnionFindForest::Unite(int x, int y) {
x = Root(x);
y = Root(y);
if (x == y) return;
if (rank_[x] < rank_[y]) {
parent_[x] = y;
size_[y] += size_[x];
size_[x] = 0;
} else {
parent_[y] = x;
size_[x] += size_[y];
size_[y] = 0;
if (rank_[x] == rank_[y]) rank_[x]++;
}
}
struct Node {
int root_road;
int root_rail;
const bool operator==(const Node &a) {
if (root_rail == a.root_rail && root_road == a.root_road) {
return true;
} else {
return false;
}
}
const bool operator<(const Node &a) {
if (root_road == a.root_road) {
return root_rail < a.root_rail;
} else {
return root_road < a.root_road;
}
}
const bool operator>(const Node &a) {
if (root_road == a.root_road) {
return root_rail > a.root_rail;
} else {
return root_road > a.root_road;
}
}
};
int main(void) {
cout << std::fixed << std::setprecision(10);
cin.tie(0);
std::ios::sync_with_stdio(false);
int n, k, l;
cin >> n >> k >> l;
std::unordered_set<int> road_connection[200001], rail_connection[200001];
for (int i = 0; i < k; i++) {
int p, q;
cin >> p >> q;
road_connection[p].insert(q);
road_connection[q].insert(p);
}
for (int i = 0; i < l; i++) {
int p, q;
cin >> p >> q;
rail_connection[p].insert(q);
rail_connection[q].insert(p);
}
UnionFindForest uf_road(n + 1);
for (int i = 1; i <= n; i++) {
for (auto x : road_connection[i]) {
uf_road.Unite(i, x);
}
}
UnionFindForest uf_rail(n + 1);
for (int i = 1; i <= n; i++) {
for (auto x : rail_connection[i]) {
uf_rail.Unite(i, x);
}
}
std::unordered_multiset<Node> set;
for (int i = 1; i <= n; i++) {
Node node;
node.root_rail = uf_rail.Root(i);
node.root_road = uf_road.Root(i);
set.insert(node);
}
for (int i = 1; i <= n; i++) {
Node node;
node.root_rail = uf_rail.Root(i);
node.root_road = uf_road.Root(i);
cout << set.count(node) << " ";
}
cout << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:139:33: error: use of deleted function 'std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset() [with _Value = Node; _Hash = std::hash<Node>; _Pred = std::equal_to<Node>; _Alloc = std::allocator<Node>]'
139 | std::unordered_multiset<Node> set;
| ^~~
In file included from /usr/include/c++/14/unordered_set:41,
from a.cc:9:
/usr/include/c++/14/bits/unordered_set.h:1009:7: note: 'std::unordered_multiset<_Value, _Hash, _Pred, _Alloc>::unordered_multiset() [with _Value = Node; _Hash = std::hash<Node>; _Pred = std::equal_to<Node>; _Alloc = std::allocator<Node>]' is implicitly deleted because the default definition would be ill-formed:
1009 | unordered_multiset() = default;
| ^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_set.h: At global scope:
/usr/include/c++/14/bits/unordered_set.h:1009:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = Node; _Value = Node; _Alloc = std::allocator<Node>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Node>; _Hash = std::hash<Node>; _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, false>]'
In file included from /usr/include/c++/14/bits/unordered_set.h:33:
/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 = Node; _Value = Node; _Alloc = std::allocator<Node>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Node>; _Hash = std::hash<Node>; _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, false>]' 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 = Node; _Value = Node; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Node>; _Hash = std::hash<Node>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, false>]'
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 = Node; _Value = Node; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<Node>; _Hash = std::hash<Node>; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, false>]' 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 = Node; _Value = Node; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<Node>; _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<Node>]':
/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<Node>::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/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/iomanip:42,
from a.cc:4:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<Node>::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<Node, 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 = Node; 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 = Node; 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 = Node; _Value = Node; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<Node>; _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<Node>, true>::~_Hashtable_ebo_helper()'
/usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<Node>, 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<Node>::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<Node>::~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 = Node; 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<Node, Node, std::__detail::_Identity, std::hash<Node>, 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<Node, Node, std::__detail::_Identity, std::hash<Node>, 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<Node>, 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<Node, Node, std::__detail::_Identity, std::equal_to<Node>, std::hash<Node>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, false> >::~_Hashtable_base()'
/usr/include/c++/14/bits/hashtable_policy.h:1688:12: note: 'std::__detail::_Hashtable_base<Node, Node, std::__detail::_Identity, std::equal_to<Node>, std::hash<Node>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, false> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed:
1688 | struct _Hashtable_base
| ^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/hashtable_policy.h:1688:12: error: use of deleted function 'std::__detail::_Hash_code_base<Node, Node, std::__detail::_Identity, std::hash<Node>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
/usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'constexpr std::_En |
s687824487 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
class UnionFind{
public:
vector<ll> par;
vector<ll> rank;
vector<ll> size;
UnionFind(ll n){
for(int i = 0; i < n; i++){
par.push_back(i);
rank.push_back(0);
size.push_back(1);
}
}
ll find(ll x){
if(x == par[x])
return x;
else
return par[x] = find(par[x]);
}
void unite(ll x, ll y){
x = find(x);
y = find(y);
if(x == y) return;
if(rank[x] < rank[y]){
par[x] = y;
size[y] += size[x];
}
else{
par[y] = x;
size[x] += size[y];
if(rank[x] == rank[y]) rank[x]++;
}
}
bool same(llnt x, ll y){
return find(x) == find(y);
}
ll get_size(ll x){
return size[find(x)];
}
};
vector<ll> RL[300100];
vector<ll> TL[300100];
bool isvisit[300100];
UnionFind road(300100);
UnionFind train(300100);
UnionFind ans(300100);
void dfs(int v){
isvisit[v] = true;
for(int i = 0; i < RL[v].size(); i++){
int next = RL[v][i];
if(isvisit[next]) continue;
road.unite(v, next);
dfs(next);
}
}
void dfs3(int v){
isvisit[v] = true;
for(int i = 0; i < TL[v].size(); i++){
int next = TL[v][i];
if(isvisit[next]) continue;
train.unite(v, next);
dfs(next);
}
}
void dfs2(int v){
isvisit[v] = true;
for(int i = 0; i < TL[v].size(); i++){
int next = TL[v][i];
if(isvisit[next]) continue;
if(!road.same(v, next)) continue;
ans.unite(v, next);
dfs2(next);
}
}
int main(){
ll N, K, L;
cin >> N >> K >> L;
REP(i,K){
ll p, q;
cin >> p >> q;
p--, q--;
RL[p].push_back(q);
RL[q].push_back(p);
}
REP(i,L){
ll r, s;
cin >> r >> s;
r--, s--;
TL[r].push_back(s);
TL[s].push_back(r);
}
for(int i = 0; i < N; i++){
if(isvisit[i]) continue;
dfs(i);
}
fill(isvisit, isvisit+N, false);
for(int i = 0; i < N; i++){
if(isvisit[i]) continue;
dfs3(i);
}
//fill(isvisit, isvisit+N, false);
//for(int i = 0; i < N; i++){
// if(isvisit[i]) continue;
// dfs2(i);
//}
map<pair<ll, ll>, ll> ma;
for(int i = 0; i < N; i++){
auto p = make_pair(road.find(i), train.find(i));
ma[p]++;
}
for(int i = 0; i < N; i++){
auto p = make_pair(road.find(i), train.find(i));
//cout << ma[p] << " ";
printf("%lld ", ma[p]);
}
printf("\n");
return 0;
}
| a.cc:46:19: error: 'llnt' has not been declared
46 | bool same(llnt x, ll y){
| ^~~~
|
s400087380 | p03855 | C++ | #include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;
struct UF
{
long num;
vector<long> par;
vector<long> rank;
UF(long n): num(n) {
par.resize(n);
rank.resize(n);
long i;
for(i=0; i<n; i++) {
par[i]=i; rank[i]=1;
}
}
long find(long x) {
if(x==par[x]) return x;
return par[x] = find(par[x]);
}
void unite(long x, long y) {
x=find(x);
y=find(y);
if(x==y) return;
if(rank[x]<rank[y]) {
par[x]=y;
}
else {
par[y]=x;
if(rank[x]==rank[y]) rank[x]++;
}
}
bool same(long x, long y) {
return find(x)==find(y);
}
long ngroup() {
long count=0;
long i;
for(i=0; i<num; i++) {
if(par[i]==i) count++;
}
return count;
}
};
int main(int argc, char* argv[])
{
long n, k, l;
scanf("%ld%ld%ld", &n, &k, &l);
UF uf0(n);
UF uf1(n);
long i;
for(i=0; i<k; i++) {
long x, y;
scanf("%ld%ld", &x, &y);
uf0.unite(x-1, y-1);
}
for(i=0; i<l; i++) {
long x, y;
scanf("%ld%ld", &x, &y);
uf1.unite(x-1, y-1);
}
map<pair<long, long>, long> zz;
for(i=0; i<n; i++) {
zz[make_pair(uf0.find(i), uf1.find(i)]++;
}
for(i=0; i<n; i++) {
printf("%ld", zz[make_pair(uf0.find(i), uf1.find(i))]);
if(i==n-1) printf("\n");
else printf(" ");
}
return 0;
}
| a.cc: In function 'int main(int, char**)':
a.cc:92:46: error: expected ')' before ']' token
92 | zz[make_pair(uf0.find(i), uf1.find(i)]++;
| ~ ^
| )
|
s984039724 | p03855 | Java | import java.util.Arrays;
import java.util.Scanner;
public class ABC049D_ {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int L = sc.nextInt();
DJSet road = new DJSet(N+1);
DJSet rail = new DJSet(N+1);
for (int i = 0; i < K; i++) {
int p = sc.nextInt();
int q = sc.nextInt();
road.union(p, q);
}
for (int i = 0; i < L; i++) {
int r = sc.nextInt();
int s = sc.nextInt();
rail.union(r, s);
}
StringBuilder sb = new StringBuilder();
int[] con = new int[N+1];
for (int i = 1; i <= N; i++) {
con[i] += 1;
for (int j = i+1; j <= N ; j++) {
if(road.same(i, j) && rail.same(i, j)){
con[i]++;
con[j]++;
}
}
sb.append(con[i]);
if(i < N) sb.append(" ");
}
System.out.println(sb.toString());
sc.close();
}
}
class DJSet {
// 親を保持する。根は負の数を持つ。(負の数の場合、絶対値がその集合のrank)
public int[] upper;
public DJSet(int n){
upper = new int[n];
Arrays.fill(upper, -1);
}
/*
* 要素xが含まれる集合のrootを求める.
* rootを求める過程で経路圧縮しrootが親になるようにする.
*/
public int root(int x){
return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
}
/*
* 要素xと要素yが同じ集合か判定する.
*/
public boolean same(int x, int y){
return root(x) == root(y);
}
/*
* 要素xと要素yを含むそれぞれの集合を合併する.
* 要素数の多い集合のrootを残し、少ないほうのrootをその下に合併する.
*/
public boolean union(int x, int y){
x = root(x);
y = root(y);
if(x != y){
if(upper[y] < upper[x]){
int t = x;
x = y;
y = t;
}
upper[x] += upper[y];
upper[y] = x;
}
return x == y;
}
/*
* 集合の数を数える.
*/
public int count(){
int c = 0;
for(int u :upper){
if(u < 0) c++;
}
return c;
}
}
| Main.java:4: error: class ABC049D_ is public, should be declared in a file named ABC049D_.java
public class ABC049D_ {
^
1 error
|
s290781325 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
template <>
struct hash<pair<int, int>> {
size_t operator()(const pair<int, int>& p) const {
return hash<int>()(p.first) + hash<int>()(p.second);
}
};
class UnionFind {
public:
explicit UnionFind(int n) : vec(n + 1), rank(n + 1) {
for (int i = 0; i <= n; ++i) {
vec[i] = i;
rank[i] = 0;
}
}
int find(int x) const {
if (x == vec[x]) return x;
return vec[x] = find(vec[x]);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) return;
if (rank[x] < rank[y]) {
vec[x] = y;
} else {
vec[y] = x;
if (rank[x] == rank[y]) rank[x]++;
}
return;
}
bool same(int x, int y) const { return find(x) == find(y); }
void dump() const {
for (size_t i = 1; i < vec.size(); ++i) {
if (1 < i) cout << ", ";
cout << vec[i];
}
cout << "\n";
}
mutable vector<int> vec;
mutable vector<int> rank;
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k, l;
cin >> n >> k >> l;
UnionFind roads(n), rails(n);
for (int i = 0; i < k; ++i) {
int p, q;
cin >> p >> q;
p--;
q--;
roads.unite(p, q);
}
for (int i = 0; i < l; ++i) {
int r, s;
cin >> r >> s;
r--;
s--;
rails.unite(r, s);
}
unordered_map<pair<int, int>, int> connects;
for (int i = 0; i < n; ++i) {
auto p = make_pair(roads.vec[i], rails.vec[i]);
connects[p]++;
}
for (int i = 0; i < n; ++i) {
if (0 < i) cout << " ";
cout << connects[make_pair(roads.vec[i], rails.vec[i])];
}
cout << "\n";
}
| a.cc:5:8: error: explicit specialization of 'template<class _Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive]
5 | struct hash<pair<int, int>> {
| ^~~~~~~~~~~~~~~~~~~~
|
s608380321 | p03855 | C++ | #include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>father;
#define twy(x,y) father[make_pair(x,y)]
#define M 200001
int k1[M],k2[M];
int n,k,l,p,q,r,s;
int find1(int x)
{
return k1[x]==x?k1[x]:k1[x]=find(k1[x]);
}
int find2(int x)
{
return k2[x]==x?k2[x]:k2[x]=find(k2[x]);
}
void kkk1(int x,int y)
{
int kx=find1(x);
int ky=find1(y);
if(kx!=ky)k1[kx]=ky;
}void kkk2(int x,int y)
{
int kx=find2(x);
int ky=find2(y);
if(kx!=ky)k2[kx]=ky;
}
int main(){
scanf("%d%d%d",&n,&k,&l);
for(int i=1;i<=n;i++)k1[i]=k2[i]=i;
for(int i=1;i<=k;i++)
{
scanf("%d%d",&p,&q);
kkk1(p,q);
}
for(int i=1;i<=l;i++)
{
scanf("%d%d",&r,&s);
kkk2(r,s);
}
for(int i=1;i<=n;i++)
{
find1(i);
find1(i);
}
for(int i=1;i<=n;i++)
twy(k1[i],k2[i])++;
for(int i=1;i<=n;i++)
printf("%d ",twy(k1[i],k2[i]));
return 0;
} | a.cc: In function 'int find1(int)':
a.cc:10:37: error: no matching function for call to 'find(int&)'
10 | return k1[x]==x?k1[x]:k1[x]=find(k1[x]);
| ~~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
3842 | find(_InputIterator __first, _InputIterator __last,
| ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided
In file included from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
a.cc: In function 'int find2(int)':
a.cc:14:37: error: no matching function for call to 'find(int&)'
14 | return k2[x]==x?k2[x]:k2[x]=find(k2[x]);
| ~~~~^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)'
3842 | find(_InputIterator __first, _InputIterator __last,
| ^~~~
/usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
| ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided
|
s501599138 | p03855 | C++ | #include<bits/stdc++.h>
using namespace std;
map<pair<int,int>,int>father;
#define twy(x,y) father[make_pair(x,y)]
#define M 200001
int k1[M],k2[M];
int n,k,l,p,q,r,s;
int find1(int x)
{
return p1[x]==x?p1[x]:p1[x]=find(p1[x]);
}
int find2(int x)
{
return p1[x]==x?p1[x]:p1[x]=find(p1[x]);
}
void kkk1(int x,int y)
{
int kx=find1(x);
int ky=find1(y);
if(kx!=ky)k1[kx]=ky;
}void kkk2(int x,int y)
{
int kx=find2(x);
int ky=find2(y);
if(kx!=ky)k2[kx]=ky;
}
int main(){
scanf("%d%d%d",&n,&k,&l);
for(int i=1;i<=n;i++)k1[i]=k2[i]=i;
for(int i=1;i<=k;i++)
{
scanf("%d%d",&p,&q);
kkk1(p,q);
}
for(int i=1;i<=l;i++)
{
scanf("%d%d",&r,&s);
kkk2(r,s);
}
for(int i=1;i<=n;i++)
{
find1(i);
find1(i);
}
for(int i=1;i<=n;i++)
twy(k1[i],k2[i])++;
for(int i=1;i<=n;i++)
printf("%d ",twy(k1[i],k2[i]));
return 0;
} | a.cc: In function 'int find1(int)':
a.cc:10:12: error: 'p1' was not declared in this scope; did you mean 'y1'?
10 | return p1[x]==x?p1[x]:p1[x]=find(p1[x]);
| ^~
| y1
a.cc: In function 'int find2(int)':
a.cc:14:12: error: 'p1' was not declared in this scope; did you mean 'y1'?
14 | return p1[x]==x?p1[x]:p1[x]=find(p1[x]);
| ^~
| y1
|
s138850192 | p03855 | C++ | #include <iostream>
#include <map>
using namespace std;
const int N=200000+10;
const int INF=10000000;
int p1[N],p2[N];
map<pair<int,int>,int>m;
inline int find(int x,int *p){
return p[x]==x?x:p[x]=find(p[x],p);
}
int main()
{
int n,k,l;
int x,y;
cin>>n>>k>>l;
for(int i=1;i<=n;i++)
p1[i]=i,p2[i]=i;
for(int i=1;i<=k;i++){
cin>>x>>y;
if(find(x,p1)!=find(y,p1)){
p1[find(x,p1)]=find(y,p1);
}
}
for(int i=1;i<=l;i++){
cin>>x>>y;
if(find(x,p2)!=find(y,p2)){
p2[find(x,p2)]=find(y,p2);
}
}
for(int i=1;i<=n;i++){
if(find(x,p1)!=find(y,p1)){
p1[find(x,p1)]=find(y,p1);
}
if(find(x,p2)!=find(y,p2)){
p2[find(x,p2)]=find(y,p2);
}
}
for(int i=1;i<=n;i++)
m[make_pair(p1[i],p2[i])]++;
for(int i=1;i<=n;i++)
cout<<m[make_pair(p1[i],p2[i])])<<' ';
cout<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:41:40: error: expected ';' before ')' token
41 | cout<<m[make_pair(p1[i],p2[i])])<<' ';
| ^
| ;
|
s225345303 | p03855 | C++ | #include <iostream>
#include <map>
using namespace std;
const int N=200000+10;
const int INF=10000000;
int p1[N],p2[N];
map<pair<int,int>,int>m;
inline int find(int x,int *p){
return p[x]==x?x:p[x]=find(p[x],p);
}
int main()
{
int n,k,l;
int x,y;
cin>>n>>k>>l;
for(int i=1;i<=n;i++)
p1[i]=i,p2[i]=i;
for(int i=1;i<=k;i++){
cin>>x>>y;
if(find(x,p1)!=find(y,p1)){
p1[find(x,p1)]=find(y,p1);
}
}
for(int i=1;i<=l;i++){
scanf("%d%d,",&x,&y);
if(find(x,p2)!=find(y,p2)){
p2[find(x,p2)]=find(y,p2);
}
}
for(int i=1;i<=n;i++){
if(find(x,p1)!=find(y,p1)){
p1[find(x,p1)]=find(y,p1);
}
if(find(x,p2)!=find(y,p2)){
p2[find(x,p2)]=find(y,p2);
}
}
for(int i=1;i<=n;i++)
m[make_pair(p1[i],p2[i])]++;
for(int i=1;i<=n;i++)
cout<<m[make_pair(p1[i],p2[i])])<<' ';
cout<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:41:40: error: expected ';' before ')' token
41 | cout<<m[make_pair(p1[i],p2[i])])<<' ';
| ^
| ;
|
s812411257 | p03855 | C++ | #include <iostream>
#include <map>
using namespace std;
const int N=200000+10;
const int INF=10000000;
int p1[N],p2[N];
map<pair<int,int>,int>m;
inline int find(int x,int *p){
return p[x]==x?x:p[x]=find(p[x],p);
}
int main()
{
int n,k,l;
int x,y;
cin>>n>>k>>l;
for(int i=1;i<=n;i++)
p1[i]=i,p2[i]=i;
for(int i=1;i<=k;i++){
cin>>x>>y;
if(find(x,p1)!=find(y,p1)){
p1[find(x,p1)]=find(y,p1);
}
}
for(int i=1;i<=l;i++){
scanf("%d%d,",&x,&y);
if(find(x,p2)!=find(y,p2)){
p2[find(x,p2)]=find(y,p2);
}
}
for(int i=1;i<=n;i++){
if(find(x,p1)!=find(y,p1)){
p1[find(x,p1)]=find(y,p1);
}
if(find(x,p2)!=find(y,p2)){
p2[find(x,p2)]=find(y,p2);
}
}
for(int i=1;i<=n;i++)
m[make_pair(p1[i],p2[i])]++;
for(int i=1;i<=n;i++)
cout<<m[make_pair(p1[i],p2[i])])<<' ';
cout<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:41:40: error: expected ';' before ')' token
41 | cout<<m[make_pair(p1[i],p2[i])])<<' ';
| ^
| ;
|
s915908331 | p03855 | C++ | #include<bits/stdc++.h> using namespace std; const int N=1e6+5; struct node{ int t,next; }e[N]; int head[N],cnt; void init(){ memset(head,-1,sizeof(head)); cnt=0; } void add(int u,int v){ e[cnt]=node{v,head[u]}; head[u]=cnt++; } int fa[N]; int father(int x){return x==fa[x]?x:fa[x]=father(fa[x]);} int join(int x,int y){x=father(x);y=father(y);if(x!=y)fa[x]=y;} void initfa(int n){for(int i=1;i<=n;i++)fa[i]=i;} int vis[N],ans[N]; void dfs1(int u,int tag,map<int,int>&M) //块计数 { if(vis[u]==tag)return; vis[u]=tag; M[father(u)]++; for(int i=head[u];~i;i=e[i].next) { dfs1(e[i].t,tag,M); } } void dfs2(int u,int tag,map<int,int>&M) { if(vis[u]==tag)return; vis[u]=tag; ans[u]+=M[father(u)]; for(int i=head[u];~i;i=e[i].next) { dfs2(e[i].t,tag,M); } } int main() { int n,k,L,u,v; scanf("%d%d%d",&n,&k,&L); init(); initfa(n); while(k--){ scanf("%d%d",&u,&v); join(u,v); } while(L--){ scanf("%d%d",&u,&v); add(u,v); add(v,u); } memset(vis,0,sizeof(vis)); for(int i=1;i<=n;i++) if(!vis[i]) { map<int,int>M; dfs1(i,i,M); dfs2(i,-i,M); } for(int i=1;i<=n;i++) printf("%d%c",ans[i],i<n?' ':'\n'); } | a.cc:1:25: warning: extra tokens at end of #include directive
1 | #include<bits/stdc++.h> using namespace std; const int N=1e6+5; struct node{ int t,next; }e[N]; int head[N],cnt; void init(){ memset(head,-1,sizeof(head)); cnt=0; } void add(int u,int v){ e[cnt]=node{v,head[u]}; head[u]=cnt++; } int fa[N]; int father(int x){return x==fa[x]?x:fa[x]=father(fa[x]);} int join(int x,int y){x=father(x);y=father(y);if(x!=y)fa[x]=y;} void initfa(int n){for(int i=1;i<=n;i++)fa[i]=i;} int vis[N],ans[N]; void dfs1(int u,int tag,map<int,int>&M) //块计数 { if(vis[u]==tag)return; vis[u]=tag; M[father(u)]++; for(int i=head[u];~i;i=e[i].next) { dfs1(e[i].t,tag,M); } } void dfs2(int u,int tag,map<int,int>&M) { if(vis[u]==tag)return; vis[u]=tag; ans[u]+=M[father(u)]; for(int i=head[u];~i;i=e[i].next) { dfs2(e[i].t,tag,M); } } int main() { int n,k,L,u,v; scanf("%d%d%d",&n,&k,&L); init(); initfa(n); while(k--){ scanf("%d%d",&u,&v); join(u,v); } while(L--){ scanf("%d%d",&u,&v); add(u,v); add(v,u); } memset(vis,0,sizeof(vis)); for(int i=1;i<=n;i++) if(!vis[i]) { map<int,int>M; dfs1(i,i,M); dfs2(i,-i,M); } for(int i=1;i<=n;i++) printf("%d%c",ans[i],i<n?' ':'\n'); }
| ^~~~~
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s049534667 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
class UnionFind {
private:
vector<int> parent;
vector<int> height;
vector<int> m_size;
public:
UnionFind(int size_) : parent(size_), height(size_, 0), m_size(size_, 1) {
for (int i = 0; i < size_; ++i) parent[i] = i;
}
void init(int size_) {
parent.resize(size_);
height.resize(size_, 0);
m_size.resize(size_, 0);
for (int i = 0; i < size_; ++i) parent[i] = i;
}
int find(int x) {
if (parent[x] == x) return x;
return parent[x] = find(parent[x]);
}
void unite(int x, int y) {
x = find(x);
y = find(y);
if (x == y) return;
int t = size(x) + size(y);
m_size[x] = m_size[y] = t;
if (height[x] < height[y]) parent[x] = y;
else parent[y] = x;
if (height[x] == height[y]) ++height[x];
}
bool same(int x, int y) {
return find(x) == find(y);
}
int size(int x) {
if (parent[x] == x) return m_size[x];
return size(parent[x] = find(parent[x]));
}
};
int N,K,L;
int p[200000],q[200000],r[200000],s[200000];
int a[300000],b[300000];
map<pair<int, int>, int> mp;
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
// ifstream in("input.txt");
// cin.rdbuf(in.rdbuf());
cin >> N >> K >> L;
UnionFind ufk(N);
UnionFind ufl(N);
for(i = 0;i < K;i++){
cin >> p[i] >> q[i];
p[i]--;q[i]--;
ufk.unite(p[i], q[i]);
}
for(i = 0;i < L;i++){
cin >> r[i] >> s[i];
r[i]--;s[i]--;
ufl.unite(r[i], s[i]);
}
for(i = 0;i < N;i++){
a[i]=ufk.find(i);
b[i]=ufl.find(i);
mp[make_pair(a[i], b[i])]++;
}
for(i = 0;i < N;i++){
cout<< mp[make_pair(a[i], b[i])] <<" \n"[i==N-1];
}
return 0;
} | a.cc: In function 'int main()':
a.cc:57:7: error: 'i' was not declared in this scope
57 | for(i = 0;i < K;i++){
| ^
a.cc:62:7: error: 'i' was not declared in this scope
62 | for(i = 0;i < L;i++){
| ^
a.cc:67:7: error: 'i' was not declared in this scope
67 | for(i = 0;i < N;i++){
| ^
a.cc:72:7: error: 'i' was not declared in this scope
72 | for(i = 0;i < N;i++){
| ^
|
s424262750 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N= 1<<5+7;
const int INF=INT_MAX;
int pre1[MAXN],pre2[MAXN];
int finds(int x,int *pre)
{
return pre[x] == x? pre[x]:pre[x] = finds(pre[x],pre);
}
void join(int x,int y,int *pre)
{
int px = finds(x,pre);
int py = finds(y,pre);
if( px!=py)
{
pre[px] = py;
}
}
int main()
{
int n,k,l;
cin>>n>>k>>l;
for(int i = 1;i<=n;i++)
pre1[i] = i,pre2[i] = i;
for(int i = 1;i<=k;i++)
{
int x,y;
cin>>x>>y;
join(x,y,pre1);
}
for(int i = 1;i<=l;i++)
{
int x,y;
cin>>x>>y;
join(x,y,pre2);
}
for(int i = 1;i<=n;i++)
{
finds(i,pre1);
finds(i,pre2);
}
map<pair<int,int>,int> mp;
for(int i = 1;i<=n;i++)
{
mp[make_pair(pre1[i],pre2[i])] ++;
}
for(int i = 1;i<=n;i++)
{
cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
}
cout<<endl;
}
| a.cc:5:10: error: 'MAXN' was not declared in this scope
5 | int pre1[MAXN],pre2[MAXN];
| ^~~~
a.cc:5:21: error: 'MAXN' was not declared in this scope
5 | int pre1[MAXN],pre2[MAXN];
| ^~~~
a.cc: In function 'int main()':
a.cc:24:9: error: 'pre1' was not declared in this scope
24 | pre1[i] = i,pre2[i] = i;
| ^~~~
a.cc:24:21: error: 'pre2' was not declared in this scope
24 | pre1[i] = i,pre2[i] = i;
| ^~~~
a.cc:29:18: error: 'pre1' was not declared in this scope
29 | join(x,y,pre1);
| ^~~~
a.cc:35:18: error: 'pre2' was not declared in this scope
35 | join(x,y,pre2);
| ^~~~
a.cc:39:17: error: 'pre1' was not declared in this scope
39 | finds(i,pre1);
| ^~~~
a.cc:40:17: error: 'pre2' was not declared in this scope
40 | finds(i,pre2);
| ^~~~
a.cc:45:22: error: 'pre1' was not declared in this scope
45 | mp[make_pair(pre1[i],pre2[i])] ++;
| ^~~~
a.cc:45:30: error: 'pre2' was not declared in this scope
45 | mp[make_pair(pre1[i],pre2[i])] ++;
| ^~~~
a.cc:49:28: error: 'pre1' was not declared in this scope
49 | cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
| ^~~~
a.cc:49:36: error: 'pre2' was not declared in this scope
49 | cout<<mp[make_pair(pre1[i],pre2[i])]<<" ";
| ^~~~
|
s727726364 | p03855 | C++ | #include<bits/stdc++.h>
#define MAX 200005
using namespace std;
int p[2][MAX];
int getp(int i, int x){return p[i][x] == x ? x : p[i][x] = getp(i, p[i][x]);}
int main(){
int n, k, l, i, j, a, b;
map<long long, int> m;
scanf("%d%d%d", &n, &k, &l);
for(i = 1; i <= n; i++) p[0][i] = p[1][i] = i;
for(i = 0; i < 2; i++){
for(j = 0; j < (i ? l : k); j++){
scanf("%d%d", &a, &b);
if(getp(i, a) != getp(i, b)) p[i][p[i][a]] = p[i][b];
}
}
for(i = 1; i <= n; i++) m[(long long)p[0][i]*p[1][i]]++;
for(i = 1; i <= n; i++){
printf("%d", m[(long long)p[0][i]*p[1][i]]);
put(i == n ? "\n" : " ");
}
}
| a.cc: In function 'int main()':
a.cc:22:5: error: 'put' was not declared in this scope; did you mean 'putw'?
22 | put(i == n ? "\n" : " ");
| ^~~
| putw
|
s731309216 | p03855 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <vector>
#include <map>
#include <unordered_map>
using namespace std;
struct UnionFind {
vector<int> data;
UnionFind(int size) : data(size, -1) { }
bool unionSet(int x, int y) {
x = root(x); y = root(y);
if (x != y) {
if (data[y] < data[x]) swap(x, y);
data[x] += data[y]; data[y] = x;
}
return x != y;
}
bool findSet(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return data[x] < 0 ? x : data[x] = root(data[x]);
}
int size(int x) {
return -data[root(x)];
}
// using P = pair<int, int>;
// P wholeSizePair;
// UnionFind(P sizePair) : data(sizePair.first * sizePair.second, -1), wholeSizePair(sizePair) { }
// bool unionSet(P xPair, P yPair) {
// return unionSet(pairToInt(xPair), pairToInt(yPair));
// }
// bool findSet(P xPair, P yPair) {
// return root(xPair) == root(yPair);
// }
// P root(P xPair) {
// return intToPair(root(pairToInt(xPair)));
// }
// int size(P xPair) {
// return -data[root(pairToInt(xPair))];
// }
//
// UnionFind(int sizePairFirst, int sizePairSecond) : UnionFind(make_pair(sizePairFirst, sizePairSecond)) { }
// bool unionSet(int xPairFirst, int xPairSecond, int yPairFirst, int yPairSecond) {
// return unionSet(pairToInt(make_pair(xPairFirst, xPairSecond)), pairToInt(make_pair(yPairFirst, yPairSecond)));
// }
// bool findSet(int xPairFirst, int xPairSecond, int yPairFirst, int yPairSecond) {
// return findSet(make_pair(xPairFirst, xPairSecond), make_pair(yPairFirst, yPairSecond));
// }
// P root(int xPairFirst, int xPairSecond) {
// return root(make_pair(xPairFirst, xPairSecond));
// }
// int size(int xPairFirst, int xPairSecond) {
// return size(make_pair(xPairFirst, xPairSecond));
// }
//
//private:
// int pairToInt(P p) {
// if (p.first < wholeSizePair.first && p.second < wholeSizePair.second) {
// return p.first*wholeSizePair.second + p.second;
// }
// else {
// cerr << "error:範囲外参照(UnionFind::pairToInt)" << endl;
// exit(1);
// }
// }
// P intToPair(int x) {
// if (x < wholeSizePair.first * wholeSizePair.second) {
// return make_pair(x / wholeSizePair.second, x % wholeSizePair.second);
// }
// else {
// cerr << "error:範囲外参照(UnionFind::intToPair)" << endl;
// exit(1);
// }
// }
};
struct pair_hash {
template <class T1, class T2>
std::size_t operator () (const std::pair<T1, T2> &p) const {
auto h1 = std::hash<T1>{}(p.first);
auto h2 = std::hash<T2>{}(p.second);
// Mainly for demonstration purposes, i.e. works but is overly simple
// In the real world, use sth. like boost.hash_combine
return h1 ^ h2;
}
};
int N, K, L;
int p, q;
int r, s;
void solve() {
int ans;
cin >> N >> K >> L;
UnionFind uf_road(N + 1);
for (int i = 0; i < K; i++)
{
cin >> p >> q;
uf_road.unionSet(p, q);
}
UnionFind uf_metro(N + 1);
for (int i = 0; i < L; i++)
{
cin >> r >> s;
uf_metro.unionSet(r, s);
}
//unordered_map<pair<int, int>, int, pair_hash> um_both;
unordered_map<pair<int, int>, int> mp_both;
for (int i_city = 1; i_city <= N; i_city++)
{
mp_both[make_pair(uf_road.root(i_city), uf_metro.root(i_city))]++;
}
return;
for (int i_city = 1; i_city <= N; i_city++)
{
ans = mp_both[make_pair(uf_road.root(i_city), uf_metro.root(i_city))];
cout << ans << " ";
}
return;
}
int main() {
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:117:44: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
117 | unordered_map<pair<int, int>, int> mp_both;
| ^~~~~~~
In file included from /usr/include/c++/14/unordered_map:41,
from a.cc:7:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h: At global scope:
/usr/include/c++/14/bits/unordered_map.h:148: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<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _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, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/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<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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/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/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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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<const std::pair<int, int>, int>, std::__detail::_Select1st, 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<const std::pair<int, int>, int>, std::__detail::_Select1st, 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 |
s525132966 | p03855 | C++ | #include <iostream>
#include <cstdio>
#include <queue>
#include <cmath>
#include <random>
#include <fstream>
#include <string>
#include <tuple>
#include <deque>
#include <set>
#include <map>
#define REP(i, N) for(int i = 0; i< N; i++)
using namespace std;
#define ll long long
const int INF = 1 << 29;
const ll llINF = 10000000000000000;
const int MOD = 1000000007;
#define MAX_N 200200
map<int> tunagatteru[MAX_N];
class UnionFindTree{
private:
int par[MAX_N];
int urank[MAX_N];
public:
int init(int n);
int find(int x);
int unite(int x, int y);
int same(int x, int y);
int parnum(int x){return par[x];}
int ranknum(int x){return urank[x];}
};
int UnionFindTree::init(int n){
REP(i, n){
par[i] = i;
urank[i] = 0;
}
return 0;
}
int UnionFindTree::find(int x){
if(par[x] == x)return x;
else return par[x] = find(par[x]);
}
int UnionFindTree::unite(int x, int y){
x = find(x);
y = find(y);
if(x == y)return 0;
if(urank[x] < urank[y]){
par[x] = y;
}else{
par[y] = x;
if(urank[x] == urank[y])urank[x] ++;
}
return 0;
}
int UnionFindTree::same(int x, int y){
return find(x) == find(y);
}
bool guusuumeters(){
int N, Q;
cin >> N >> Q;
UnionFindTree kuni;
kuni.init(2 * N + 2);
REP(i, Q){
int w, x, y, z;
cin >> w >> x >> y >> z;
x--;
y--;
if(w == 2){
if(kuni.same(x, y) || kuni.same(x + N, y + N))printf("YES\n");
else printf("NO\n");
}
else{
if(z % 2 == 0){
kuni.unite(x, y);
kuni.unite(x + N, y + N);
}else{
kuni.unite(x, y + N);
kuni.unite(x + N, y);
}
}
}
return 0;
}
int equals(){
int N, M;
cin >> N >> M;
int p[100100];
REP(i, N){
cin >> p[i];
p[i]--;
}
UnionFindTree junretu;
junretu.init(N);
REP(i, M){
int x, y;
cin >> x >> y;
x--;
y--;
junretu.unite(p[x], p[y]);
}
int onajidayo = 0;
REP(i, N){
if(junretu.same(i, p[i])) onajidayo++;
}
return onajidayo;
}
void renketu(){
int N, K, L;
cin >> N >> K >> L;
UnionFindTree douro;
UnionFindTree tetudou;
douro.init(N + 1);
tetudou.init(N + 1);
REP(i, K){
int p, q;
cin >> p >> q;
douro.unite(p,q);
}
REP(i, L){
int r, s;
cin >> r >> s;
tetudou.unite(r,s);
}
REP(i, N){
tunagatteru[douro.parnum(i + 1)][tetudou.parnum(i + 1)] = 0;
}
REP(i, N){
tunagatteru[douro.parnum(i + 1)][tetudou.parnum(i + 1)]++;
}
REP(i, N){
printf("%d", tunagatteru[douro.parnum(i + 1)][tetudou.parnum(i + 1)]);
}
}
int main(){
renketu();
}
| a.cc:22:8: error: wrong number of template arguments (1, should be at least 2)
22 | map<int> tunagatteru[MAX_N];
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:11:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc: In function 'void renketu()':
a.cc:143:41: error: invalid types 'int[int]' for array subscript
143 | tunagatteru[douro.parnum(i + 1)][tetudou.parnum(i + 1)] = 0;
| ^
a.cc:146:41: error: invalid types 'int[int]' for array subscript
146 | tunagatteru[douro.parnum(i + 1)][tetudou.parnum(i + 1)]++;
| ^
a.cc:150:54: error: invalid types 'int[int]' for array subscript
150 | printf("%d", tunagatteru[douro.parnum(i + 1)][tetudou.parnum(i + 1)]);
| ^
|
s070395547 | p03855 | Java | import java.io.*;
import java.util.*;
/**
* @author baito
*/
class UnionFindTree
{
int[] par;
int[] rank;
int[] sizes;
UnionFindTree(int n)
{
par = new int[n];
rank = new int[n];
sizes = new int[n];
for (int i = 0; i < n; i++)
{
par[i] = i;
sizes[i] = 1;
}
}
int root(int x)
{
if (par[x] == x) return x;
else return par[x] = root(par[x]);
}
void unite(int x, int y)
{
x = root(x);
y = root(y);
if (x == y) return;
if (rank[x] < rank[y])
{
par[x] = y;
sizes[y] += sizes[x];
}
else
{
par[y] = x;
sizes[x] += sizes[y];
if (rank[x] == rank[y]) rank[x]++;
}
}
boolean isSame(int x, int y)
{
return root(x) == root(y);
}
int size(int x)
{
return sizes[par[x]];
}
}
public class Main
{
static StringBuilder sb = new StringBuilder();
static Scanner sc = new Scanner(System.in);
static int INF = 12345678;
static long LINF = 123456789123456789L;
static long MINF = -123456789123456789L;
static long MOD = 1000000007;
static int[] y4 = {0, 1, 0, -1};
static int[] x4 = {1, 0, -1, 0};
static int[] y8 = {0, 0, 1, 0, -1, -1, 1, 1, -1};
static int[] x8 = {0, 1, 0, -1, 0, 1, -1, 1, -1};
static long[] F;//factorial
static boolean[] isPrime;
static int[] primes;
static char[][] map;
static int N, K, L;
static int[] A;
public static void main(String[] args)
{
N = sc.nextInt();
K = sc.nextInt();
L = sc.nextInt();
UnionFindTree u1 = new UnionFindTree(N);
UnionFindTree u2 = new UnionFindTree(N);
for (int i = 0; i < K; i++)
u1.unite(sc.nextInt() - 1, sc.nextInt() - 1);
for (int i = 0; i < L; i++)
u2.unite(sc.nextInt() - 1, sc.nextInt() - 1);
Map<Long, Integer> map = new HashMap<>();
for (int i = 0; i < N; i++)
{
int r1 = u1.root(i);
int r2 = u2.root(i);
Long key = getHashKey(r1, r2);
Integer v = map.get(key);
map.put(key, v == null ? 1 : v + 1);
}
int[] cous = new int[N];
for (int i = 0; i < N; i++)
{
int r1 = u1.root(i);
int r2 = u2.root(i);
Long key = getHashKey(r1, r2);
System.out.println(map.get(key));
}
}
public static long getHashKey(int a, int b)
{
return (long) a << 32 | b;
}
| Main.java:117: error: reached end of file while parsing
}
^
1 error
|
s413288845 | p03855 | C++ | #include<iostream>
using ll = long long;
#define MAX_N 201010
using namespace std;
ll par_way[MAX_N],r_way[MAX_N];
ll par_train[MAX_N],r_train[MAX_N];
void init_way(ll n){
for(ll i=0;i<n;i++){
par_way[i] = i;
r_way[i] = 0;
}
}
ll find_way(ll x){
if(par_way[x] == x){
return x;
}else{
return par_way[x] = find_way(par_way[x]);
}
}
void unite_way(ll x,ll y){
x = find_way(x);
y = find_way(y);
if(x==y) return;
if(r_way[x]<r_way[y]){
par_way[x] = y;
}
else{
par_way[y] = x;
if(r_way[x] == r_way[y]) r_way[x]++;
}
}
void init_train(ll n){
for(ll i=0;i<n;i++){
par_train[i] = i;
r_train[i] = 0;
}
}
ll find_train(ll x){
if(par_train[x] == x){
return x;
}else{
return par_train[x] = find_train(par_train[x]);
}
}
void unite_train(ll x,ll y){
x = find_train(x);
y = find_train(y);
if(x==y) return;
if(r_train[x]<r_train[y]){
par_train[x] = y;
}
else{
par_train[y] = x;
if(r_train[x] == r_train[y]) r_train[x]++;
}
}
bool same(ll x,ll y){
return (find_train(x) == find_train(y))&&(find_way(x) == find_wat(y));
}
int main(void){
ll N,K,L,x,y;
cin >> N >> K >> L;
init_train(N);init_way(N);
while(K--){
cin >> x >> y;
unite_way(x,y);
}
while(L--){
cin >> x >> y;
unite_train(x,y);
}
for(ll i=1;i<=N;i++){
ll ans=0;
for(ll j=1;j<=N;j++){
if(same(i,j)) ans++;
}
cout << ans;
if(i!=N) cout << ' ';
}
cout << endl;
return 0;
} | a.cc: In function 'bool same(ll, ll)':
a.cc:67:66: error: 'find_wat' was not declared in this scope; did you mean 'find_way'?
67 | return (find_train(x) == find_train(y))&&(find_way(x) == find_wat(y));
| ^~~~~~~~
| find_way
|
s837142881 | p03855 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
ll N,K,L;
ll ans;
string A[200010];
std::unordered_map<string,int> S;
struct UnionFind {
vector< int > data;
UnionFind(int sz){
data.assign(sz, -1);
}
bool unite(int x, int y){
x = find(x), y = find(y);
if(x == y) return(false);
if(data[x] > data[y]) std::swap(x, y);
data[x] += data[y];
data[y] = x;
return(true);
}
int find(int k){
if(data[k] < 0) return(k);
return(data[k] = find(data[k]));
}
bool same(int x,int y){
return find(x)==find(y);
}
int size(int k){
return(-data[find(k)]);
}
};
int main(){
std::ios_base::sync_with_stdio(false);
cin>>N>>K>>L;
UnionFind X(N+10),Y(N+10);
REP(i,K){
int a,b;
cin>>a>>b;
X.unite(a-1,b-1);
}
REP(i,L){
int a,b;
cin>>a>>b;
Y.unite(a-1,b-1);
}
REP(i,N){
A[i]=std::to_string(X.find(i))+"+"+std::to_string(Y.find(i));
S[A[i]] += 1;
}
REP(i,N){
cout<< S[i];
if(i!=N-1)cout<<" ";
}
//cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:93:17: error: no match for 'operator[]' (operand types are 'std::unordered_map<std::__cxx11::basic_string<char>, int>' and 'int')
93 | cout<< S[i];
| ^
In file included from /usr/include/c++/14/unordered_map:41,
from a.cc:15:
/usr/include/c++/14/bits/unordered_map.h:987:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Hash = std::hash<std::__cxx11::basic_string<char> >; _Pred = std::equal_to<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]'
987 | operator[](const key_type& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:987:34: note: no known conversion for argument 1 from 'int' to 'const std::unordered_map<std::__cxx11::basic_string<char>, int>::key_type&' {aka 'const std::__cxx11::basic_string<char>&'}
987 | operator[](const key_type& __k)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/unordered_map.h:991:7: note: candidate: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](key_type&&) [with _Key = std::__cxx11::basic_string<char>; _Tp = int; _Hash = std::hash<std::__cxx11::basic_string<char> >; _Pred = std::equal_to<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, int> >; mapped_type = int; key_type = std::__cxx11::basic_string<char>]'
991 | operator[](key_type&& __k)
| ^~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:991:29: note: no known conversion for argument 1 from 'int' to 'std::unordered_map<std::__cxx11::basic_string<char>, int>::key_type&&' {aka 'std::__cxx11::basic_string<char>&&'}
991 | operator[](key_type&& __k)
| ~~~~~~~~~~~^~~
|
s510329274 | p03855 | C++ | #include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<unordered_map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN
//WA
//union-find
ll par1[200010],rank1[200010];
ll par2[200010],rank2[200010];
ll root1(ll x){
return par1[x]==x ? x : par1[x]=root1(par1[x]);//経路圧縮
}
bool issame1(ll x,ll y){
return root1(x)==root1(y);
}
void join1(ll x,ll y){
x = root1(x);
y = root1(y);
if(x==y)return;
if(rank1[x]<rank1[y]){
par1[x]=y;
}else{
par1[y]=x;
if(rank1[x]==rank1[y])rank1[x]++;//ランクの更新
}
}
ll root2(ll x){
return par2[x]==x ? x : par2[x]=root2(par2[x]);//経路圧縮
}
bool issame2(ll x,ll y){
return root2(x)==root2(y);
}
void join2(ll x,ll y){
x = root2(x);
y = root2(y);
if(x==y)return;
if(rank2[x]<rank2[y]){
par2[x]=y;
}else{
par2[y]=x;
if(rank2[x]==rank2[y])rank2[x]++;//ランクの更新
}
}
int main(void){
int N,K,L,p,q,r,s;
rep(i,200010){
par1[i]=i;
par2[i]=i;
rank1[i]=0;
rank2[i]=0;
}
scanf("%d%d%d",&N,&K,&L);
rep(i,K){
scanf("%d%d",&p,&q);
join1(p,q);
}
rep(i,L){
scanf("%d%d",&r,&s);
join2(r,s);
}
unordered_map<mp,ll> M;//引数をpairにすることもできる
reg(i,1,N){
M[make_pair(par1[i],par2[i])]++;
}
reg(i,1,N){
printf("%lld",M[make_pair(par1[i],par2[i])]);
if(i!=N)printf(" ");
}
printf("\n");
return 0;
} | a.cc: In function 'int main()':
a.cc:85:30: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >]'
85 | unordered_map<mp,ll> M;//引数をpairにすることもできる
| ^
In file included from /usr/include/c++/14/unordered_map:41,
from a.cc:13:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<long long int, long long int>; _Tp = long long int; _Hash = std::hash<std::pair<long long int, long long int> >; _Pred = std::equal_to<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h: At global scope:
/usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long 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, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/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<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _Alloc = std::allocator<std::pair<const std::pair<long long int, long long int>, long long int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long 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, false, 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<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, 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<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<long long int, long long int> >; _Hash = std::hash<std::pair<long long int, long long int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, 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<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long 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<long long int, long long 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<long long int, long long int> >::hash()'
1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
| ^~~~~
In file included from /usr/include/c++/14/bits/stl_bvector.h:65,
from /usr/include/c++/14/vector:67,
from a.cc:3:
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long 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<long long int, long long 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<long long int, long long 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<long long int, long long 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<long long int, long long int>; _Value = std::pair<const std::pair<long long int, long long int>, long long int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<long long int, long long 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<long long int, long long 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<long long int, long long 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<long long int, long long int> >::~hash()'
/usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<long long int, long long 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<long long int, long long 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<long long int, long long int>, std::pair<const std::pair<long long int, long long int>, long long int>, std::__detail::_Select1st, std::hash<std::pair<long long int, long long 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< |
s101518279 | p03855 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x) cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; }
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
#define MIN(vec) *min_element(vec.begin(), vec.end());
#define MAX(vec) *max_element(vec.begin(), vec.end());
#define IN(n,m) (!(m.find(n) == m.end()))
#define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef map<long,long> mp;
class Union_Find {
private:
vector<unsigned> par; // par[x] : x の親ノード
vector<unsigned> rank; // rank[x] : 木の高さ
size_t sz; // 集合の個数
public:
// コンストラクタ : 空
Union_Find() : sz(0) { }
// コンストラクタ : 1 要素の集合 n 個
Union_Find(size_t n) :
par(n, -1), rank(n, 0), sz(n) {
for (size_t i = 0; i < n; i++) par[i] = i;
}
size_t size() { return sz; }
// 集合の追加 : 1 個
void add_node() {
par.push_back(par.size());
rank.push_back(0);
sz++;
}
// 集合の追加 : n 個
void add_node(size_t n) {
for (size_t i = 0; i < n; i++) add_node();
}
// x が属する集合の代表元を返す
size_t find(size_t x) {
if (par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
// x が属する集合と y が属する集合をマージする
void unite(size_t x, size_t y) {
x = find(x);
y = find(y);
if (x == y) return;
if (rank[x] < rank[y])
par[x] = y;
else {
par[y] = x;
if (rank[x] == rank[y]) rank[x]++;
}
sz--;
}
// x と y が同じ集合に属しているか?
bool same(size_t x, size_t y) {
return find(x) == find(y);
}
void dump_par(void){
dump1d_arr(par);
}
void dump_rank(void){
dump1d_arr(rank);
}
};
int main(void){
long N,K,L;
long p,q;
mp group;
cin >> N >> K >> L;
Union_Find uf(N);
Union_Find uf2(N);
VI par(N);
REP(i,K){
cin >> p >> q;
uf.unite(p-1,q-1);
}
REP(i,L){
cin >> p >> q;
if (uf.same(p-1,q-1)) uf2.unite(p-1,q-1);
}
REP(i,N){
par[i] = uf2.find(i);
if (IN(par[i],group)) group[par[i]]++;
else group[par[i]] = 1;
}
REP(i,N) cout << group[par[i]] << " "
cout << "\n";
return 0;
} | a.cc:17:62: error: extended character ‘ is not valid in an identifier
17 | #define TO_INT(vec,s) REP(i,s.length()){vec.push_back(s[i] - ‘0’);}
| ^
a.cc:17:62: error: extended character ’ is not valid in an identifier
a.cc: In function 'int main()':
a.cc:109:42: error: expected ';' before 'cout'
109 | REP(i,N) cout << group[par[i]] << " "
| ^
| ;
110 | cout << "\n";
| ~~~~
|
s252897109 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
uint64_t hash_num;
// std::map<unsigned long long int, unsigned int> mp;
std::map<uint64_t, unsigned int> mp;
std::string hash_str;
for(i=1; i<=n; i++) {
hash_num = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
auto itr = mp.find(hash_num); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
}
for(i=1; i<=n; i++) {
hash_num = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
printf("%d ", mp[hash_num]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:110:16: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
110 | mp[hash]++;
| ^~~~
| std::hash
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 a.cc:5:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
a.cc:112:16: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
112 | mp[hash] = 1;
| ^~~~
| std::hash
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
|
s557487742 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
uint64_t hash_num;
// std::map<unsigned long long int, unsigned int> mp;
std::map<std::string, uint64_t> mp;
std::string hash_str;
for(i=1; i<=n; i++) {
hash_num = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
auto itr = mp.find(hash_num); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
}
for(i=1; i<=n; i++) {
hash_num = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
printf("%d ", mp[hash_num]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:108:27: error: no matching function for call to 'std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(uint64_t&)'
108 | auto itr = mp.find(hash_num); // "xyz" が設定されているか?
| ~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/14/map:63,
from a.cc:8:
/usr/include/c++/14/bits/stl_map.h:1224:9: note: candidate: 'template<class _Kt> decltype (((std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_find_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::find(const _Kt&) [with _Key = std::__cxx11::basic_string<char>; _Tp = long unsigned int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
1224 | find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
| ^~~~
/usr/include/c++/14/bits/stl_map.h:1224:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) [with _Kt = long unsigned int]':
a.cc:108:27: required from here
108 | auto itr = mp.find(hash_num); // "xyz" が設定されているか?
| ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1224:57: error: no matching function for call to 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(const long unsigned int&)'
1224 | find(const _Kt& __x) -> decltype(_M_t._M_find_tr(__x))
| ~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
1291 | _M_find_tr(const _Kt& __k)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: template argument deduction/substitution failed:
In file included from /usr/include/c++/14/string:49,
from a.cc:5:
/usr/include/c++/14/bits/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::__cxx11::basic_string<char> >; _SfinaeType = long unsigned int]':
/usr/include/c++/14/bits/stl_tree.h:1289:9: required by substitution of 'template<class _Kt> decltype (((std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) [with _Kt = long unsigned int]'
1289 | typename _Req = __has_is_transparent_t<_Compare, _Kt>>
| ^~~~~~~~
a.cc:108:27: required from here
108 | auto itr = mp.find(hash_num); // "xyz" が設定されているか?
| ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::__cxx11::basic_string<char> >, long unsigned int, void>'
1427 | using __has_is_transparent_t
| ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) [with _Kt = long unsigned int]':
a.cc:108:27: required from here
108 | auto itr = mp.find(hash_num); // "xyz" が設定されているか?
| ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
1300 | _M_find_tr(const _Kt& __k) const
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h:1249:9: note: candidate: 'template<class _Kt> decltype (((const std::map<_Key, _Tp, _Compare, _Alloc>*)this)->std::map<_Key, _Tp, _Compare, _Alloc>::_M_t._M_find_tr(__x)) std::map<_Key, _Tp, _Compare, _Alloc>::find(const _Kt&) const [with _Key = std::__cxx11::basic_string<char>; _Tp = long unsigned int; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
1249 | find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
| ^~~~
/usr/include/c++/14/bits/stl_map.h:1249:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_map.h: In substitution of 'template<class _Kt> decltype (((const std::map<std::__cxx11::basic_string<char>, long unsigned int>*)this)->std::map<std::__cxx11::basic_string<char>, long unsigned int>::_M_t.std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(__x)) std::map<std::__cxx11::basic_string<char>, long unsigned int>::find(const _Kt&) const [with _Kt = long unsigned int]':
a.cc:108:27: required from here
108 | auto itr = mp.find(hash_num); // "xyz" が設定されているか?
| ~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1249:63: error: no matching function for call to 'std::_Rb_tree<std::__cxx11::basic_string<char>, std::pair<const std::__cxx11::basic_string<char>, long unsigned int>, std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >, std::less<std::__cxx11::basic_string<char> >, std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> > >::_M_find_tr(const long unsigned int&) const'
1249 | find(const _Kt& __x) const -> decltype(_M_t._M_find_tr(__x))
| ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]'
1291 | _M_find_tr(const _Kt& __k)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1291:9: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h:1300:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_find_tr(const _Kt&) const [with _Req = _Kt; _Key = std::__cxx11::basic_string<char>; _Val = std::pair<const std::__cxx11::basic_string<char>, long unsigned int>; _KeyOfValue = std::_Select1st<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >; _Compare = std::less<std::_ |
s428593351 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
uint64_t int hash;
// std::map<unsigned long long int, unsigned int> mp;
std::map<std::string, uint64_t> mp;
std::string hash_str;
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
auto itr = mp.find(hash); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
}
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
printf("%d ", mp[hash]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:99:5: error: two or more data types in declaration of 'hash'
99 | uint64_t int hash;
| ^~~~~~~~
a.cc:105:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
105 | hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
| ^~~~
| std::hash
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 a.cc:5:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
a.cc:119:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
119 | hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
| ^~~~
| std::hash
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
|
s674612009 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
count[i].value=0;
count[i].count=0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
u_int64 int hash;
// std::map<unsigned long long int, unsigned int> mp;
std::map<std::string, u_int64> mp;
std::string hash_str;
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
auto itr = mp.find(hash); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
}
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
printf("%d ", mp[hash]);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:80:9: error: 'count' was not declared in this scope
80 | count[i].value=0;
| ^~~~~
a.cc:101:5: error: 'u_int64' was not declared in this scope; did you mean 'u_int64_t'?
101 | u_int64 int hash;
| ^~~~~~~
| u_int64_t
a.cc:103:34: error: template argument 4 is invalid
103 | std::map<std::string, u_int64> mp;
| ^
a.cc:107:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
107 | hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
| ^~~~
| std::hash
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 a.cc:5:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
a.cc:110:23: error: request for member 'find' in 'mp', which is of non-class type 'int'
110 | auto itr = mp.find(hash); // "xyz" が設定されているか?
| ^~~~
a.cc:111:23: error: request for member 'end' in 'mp', which is of non-class type 'int'
111 | if( itr != mp.end() ) {
| ^~~
a.cc:121:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
121 | hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
| ^~~~
| std::hash
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
|
s329136504 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
node root_loc = {0, 0, NULL, NULL};
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
node count[NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
count[i].value=0;
count[i].count=0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
node* temp_loc;
u_int64 int hash;
// std::map<unsigned long long int, unsigned int> mp;
std::map<std::string, u_int64> mp;
std::string hash_str;
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
auto itr = mp.find(hash); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
//auto itr = mp.find(hash_str); // "xyz" が設定されているか?
//if( itr != mp.end() ) {
// mp[hash_str]++;
//} else {
// mp[hash_str] = 1;
//}
// temp_loc = &root_loc;
// if(temp_loc->value == 0) {
// temp_loc->value = hash;
// temp_loc->count = 1;
// }
// else {
// while(1){
// if(hash > temp_loc->value) {
// if(temp_loc->right != NULL) {
// temp_loc = temp_loc->right;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->right = temp;
// break;
// }
// }
// else if(hash < temp_loc->value) {
// if(temp_loc->left != NULL) {
// temp_loc = temp_loc->left;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->left = temp;
// break;
// }
// }
// else {
// temp_loc->count++;
// break;
// }
// }
// }
}
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
//hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
// temp_loc = &root_loc;
// while(1) {
// if(temp_loc->value < hash) {
// temp_loc = temp_loc->right;
// }
// else if(temp_loc->value > hash) {
// temp_loc = temp_loc->left;
// }
// else {
// printf("%d ", temp_loc->count);
// break;
// }
// }
printf("%d ", mp[hash]);
}
return 0;
}
| a.cc:28:1: error: 'node' does not name a type
28 | node root_loc = {0, 0, NULL, NULL};
| ^~~~
a.cc:39:1: error: 'node' does not name a type
39 | node count[NUM];
| ^~~~
a.cc: In function 'int main()':
a.cc:80:9: error: 'count' was not declared in this scope
80 | count[i].value=0;
| ^~~~~
a.cc:101:5: error: 'node' was not declared in this scope
101 | node* temp_loc;
| ^~~~
a.cc:101:11: error: 'temp_loc' was not declared in this scope
101 | node* temp_loc;
| ^~~~~~~~
a.cc:102:5: error: 'u_int64' was not declared in this scope; did you mean 'u_int64_t'?
102 | u_int64 int hash;
| ^~~~~~~
| u_int64_t
a.cc:104:34: error: template argument 4 is invalid
104 | std::map<std::string, u_int64> mp;
| ^
a.cc:108:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
108 | hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
| ^~~~
| std::hash
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 a.cc:5:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
a.cc:111:23: error: request for member 'find' in 'mp', which is of non-class type 'int'
111 | auto itr = mp.find(hash); // "xyz" が設定されているか?
| ^~~~
a.cc:112:23: error: request for member 'end' in 'mp', which is of non-class type 'int'
112 | if( itr != mp.end() ) {
| ^~~
a.cc:176:9: error: 'hash' was not declared in this scope; did you mean 'std::hash'?
176 | hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
| ^~~~
| std::hash
/usr/include/c++/14/bits/functional_hash.h:59:12: note: 'std::hash' declared here
59 | struct hash;
| ^~~~
|
s216930657 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// typedef struct node {
// long long int value;
// unsigned int count;
// } node;
typedef struct node {
unsigned long long int value;
unsigned int count;
struct node *right;
struct node *left;
} node;
node root_loc = {0, 0, NULL, NULL};
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
node count[NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
// bool same(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank) {
// return root(x, par, rank) == root(y, par, rank);
// }
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
count[i].value=0;
count[i].count=0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
node* temp_loc;
unsigned long long int hash;
// std::map<unsigned long long int, unsigned int> mp;
std::map<std::string, unsigned long long int> mp;
std::String hash_str;
for(i=1; i<=n; i++) {
//hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
// auto itr = mp.find(hash); // "xyz" が設定されているか?
// if( itr != mp.end() ) {
// mp[hash]++;
// } else {
// mp[hash] = 1;
// }
auto itr = mp.find(hash_str); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash_str]++;
} else {
mp[hash_str] = 1;
}
// temp_loc = &root_loc;
// if(temp_loc->value == 0) {
// temp_loc->value = hash;
// temp_loc->count = 1;
// }
// else {
// while(1){
// if(hash > temp_loc->value) {
// if(temp_loc->right != NULL) {
// temp_loc = temp_loc->right;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->right = temp;
// break;
// }
// }
// else if(hash < temp_loc->value) {
// if(temp_loc->left != NULL) {
// temp_loc = temp_loc->left;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->left = temp;
// break;
// }
// }
// else {
// temp_loc->count++;
// break;
// }
// }
// }
}
for(i=1; i<=n; i++) {
// hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
// temp_loc = &root_loc;
// while(1) {
// if(temp_loc->value < hash) {
// temp_loc = temp_loc->right;
// }
// else if(temp_loc->value > hash) {
// temp_loc = temp_loc->left;
// }
// else {
// printf("%d ", temp_loc->count);
// break;
// }
// }
printf("%d ", mp[hash_str]);
}
// for(i=1; i<=n; i++) {
// count[root(i, par_road, rank_road)][root(i, par_rail, rank_rail)]++;
// }
// for(i=1; i<=n; i++) {
// printf("%d ", count[root(i, par_road, rank_road)][root(i, par_rail, rank_rail)]);
// }
// categorize_city();
// for(i=1;i<=n;i++) {
// unsigned long long int hash = root(i, par_road, rank_road)*(n+1) + root(i, par_rail, rank_rail);
// flag = 0;
// j=1;
// while(count[j].value != 0){
// if(count[j].value == hash) {
// flag = 1;
// break;
// }
// j++;
// }
// if(flag == 0) {
// count[j].value = hash;
// count[j].count++;
// }
// else{
// count[j].count++;
// }
// }
// for (j=1;j<=n;j++) {
// terminal_road = root(j, par_road, rank_road);
// terminal_rail = root(j, par_rail, rank_rail);
// for(i=1; i<=n; i++) {
// if(par_road[i] == terminal_road && par_rail[i] == terminal_rail) {
// ans[j]++;
// }
// }
// printf("%d ", ans[j]);
// }
// for(i=1; i<=n; i++) {
// unsigned long long int hash = root(i, par_road, rank_road)*(n+1) + root(i, par_rail, rank_rail);
// for(j=1; j<=n+1; j++) {
// if(count[j].value == hash){
// printf("%d ", count[j].count);
// break;
// }
// }
// }
return 0;
}
| a.cc: In function 'int main()':
a.cc:116:10: error: 'String' is not a member of 'std'; did you mean 'string'?
116 | std::String hash_str;
| ^~~~~~
| string
a.cc:120:9: error: 'hash_str' was not declared in this scope
120 | hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
| ^~~~~~~~
a.cc:188:9: error: 'hash_str' was not declared in this scope
188 | hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
| ^~~~~~~~
|
s272391856 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// typedef struct node {
// long long int value;
// unsigned int count;
// } node;
typedef struct node {
unsigned long long int value;
unsigned int count;
struct node *right;
struct node *left;
} node;
node root_loc = {0, 0, NULL, NULL};
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
node count[NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
// bool same(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank) {
// return root(x, par, rank) == root(y, par, rank);
// }
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
//prunsigned intf("%d %d %d\n", n, k, l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
count[i].value=0;
count[i].count=0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
node* temp_loc;
unsigned long long int hash;
std::map<unsigne long long int, unsigned int> mp;
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
auto itr = mp.find(hash); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
// temp_loc = &root_loc;
// if(temp_loc->value == 0) {
// temp_loc->value = hash;
// temp_loc->count = 1;
// }
// else {
// while(1){
// if(hash > temp_loc->value) {
// if(temp_loc->right != NULL) {
// temp_loc = temp_loc->right;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->right = temp;
// break;
// }
// }
// else if(hash < temp_loc->value) {
// if(temp_loc->left != NULL) {
// temp_loc = temp_loc->left;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->left = temp;
// break;
// }
// }
// else {
// temp_loc->count++;
// break;
// }
// }
// }
}
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// temp_loc = &root_loc;
// while(1) {
// if(temp_loc->value < hash) {
// temp_loc = temp_loc->right;
// }
// else if(temp_loc->value > hash) {
// temp_loc = temp_loc->left;
// }
// else {
// printf("%d ", temp_loc->count);
// break;
// }
// }
printf("%d ", mp[hash]);
}
// for(i=1; i<=n; i++) {
// count[root(i, par_road, rank_road)][root(i, par_rail, rank_rail)]++;
// }
// for(i=1; i<=n; i++) {
// printf("%d ", count[root(i, par_road, rank_road)][root(i, par_rail, rank_rail)]);
// }
// categorize_city();
// for(i=1;i<=n;i++) {
// unsigned long long int hash = root(i, par_road, rank_road)*(n+1) + root(i, par_rail, rank_rail);
// flag = 0;
// j=1;
// while(count[j].value != 0){
// if(count[j].value == hash) {
// flag = 1;
// break;
// }
// j++;
// }
// if(flag == 0) {
// count[j].value = hash;
// count[j].count++;
// }
// else{
// count[j].count++;
// }
// }
// for (j=1;j<=n;j++) {
// terminal_road = root(j, par_road, rank_road);
// terminal_rail = root(j, par_rail, rank_rail);
// for(i=1; i<=n; i++) {
// if(par_road[i] == terminal_road && par_rail[i] == terminal_rail) {
// ans[j]++;
// }
// }
// printf("%d ", ans[j]);
// }
// for(i=1; i<=n; i++) {
// unsigned long long int hash = root(i, par_road, rank_road)*(n+1) + root(i, par_rail, rank_rail);
// for(j=1; j<=n+1; j++) {
// if(count[j].value == hash){
// printf("%d ", count[j].count);
// break;
// }
// }
// }
return 0;
}
| a.cc: In function 'int main()':
a.cc:114:14: error: 'unsigne' was not declared in this scope; did you mean 'unsigned'?
114 | std::map<unsigne long long int, unsigned int> mp;
| ^~~~~~~
| unsigned
a.cc:114:49: error: wrong number of template arguments (1, should be at least 2)
114 | std::map<unsigne long long int, unsigned int> mp;
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:7:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:119:23: error: request for member 'find' in 'mp', which is of non-class type 'int'
119 | auto itr = mp.find(hash); // "xyz" が設定されているか?
| ^~~~
a.cc:120:23: error: request for member 'end' in 'mp', which is of non-class type 'int'
120 | if( itr != mp.end() ) {
| ^~~
a.cc:121:15: error: invalid types 'int[long long unsigned int]' for array subscript
121 | mp[hash]++;
| ^
a.cc:123:15: error: invalid types 'int[long long unsigned int]' for array subscript
123 | mp[hash] = 1;
| ^
a.cc:189:25: error: invalid types 'int[long long unsigned int]' for array subscript
189 | printf("%d ", mp[hash]);
| ^
|
s604726589 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
// C++ Libraries
#include <map>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// typedef struct node {
// long long int value;
// unsigned int count;
// } node;
typedef struct node {
unsigned long long int value;
unsigned int count;
struct node *right;
struct node *left;
} node;
node root_loc = {0, 0, NULL, NULL};
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
node count[NUM];
unsigned int hash_length=0;
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
// bool same(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank) {
// return root(x, par, rank) == root(y, par, rank);
// }
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j, h;
unsigned int terminal_road, terminal_rail;
int flag;
scanf("%d%d%d", &n, &k, &l);
//prunsigned intf("%d %d %d\n", n, k, l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
count[i].value=0;
count[i].count=0;
// for(j=1; j<n; j++) {
// count[i][j] = 0;
// }
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road, count_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail, count_rail);
}
node* temp_loc;
unsigned long long int hash;
std::map<unsignedd long long int, unsigned int> mp
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
auto itr = mp.find(hash); // "xyz" が設定されているか?
if( itr != mp.end() ) {
mp[hash]++;
} else {
mp[hash] = 1;
}
// temp_loc = &root_loc;
// if(temp_loc->value == 0) {
// temp_loc->value = hash;
// temp_loc->count = 1;
// }
// else {
// while(1){
// if(hash > temp_loc->value) {
// if(temp_loc->right != NULL) {
// temp_loc = temp_loc->right;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->right = temp;
// break;
// }
// }
// else if(hash < temp_loc->value) {
// if(temp_loc->left != NULL) {
// temp_loc = temp_loc->left;
// }
// else {
// node* temp = (node*)malloc(sizeof(node));
// temp->value = hash;
// temp->count = 1;
// temp->right = NULL;
// temp->left = NULL;
// temp_loc->left = temp;
// break;
// }
// }
// else {
// temp_loc->count++;
// break;
// }
// }
// }
}
for(i=1; i<=n; i++) {
hash = root(i, par_road, rank_road)*(n+2) + root(i, par_rail, rank_rail);
// temp_loc = &root_loc;
// while(1) {
// if(temp_loc->value < hash) {
// temp_loc = temp_loc->right;
// }
// else if(temp_loc->value > hash) {
// temp_loc = temp_loc->left;
// }
// else {
// printf("%d ", temp_loc->count);
// break;
// }
// }
printf("%d ", mp[hash]);
}
// for(i=1; i<=n; i++) {
// count[root(i, par_road, rank_road)][root(i, par_rail, rank_rail)]++;
// }
// for(i=1; i<=n; i++) {
// printf("%d ", count[root(i, par_road, rank_road)][root(i, par_rail, rank_rail)]);
// }
// categorize_city();
// for(i=1;i<=n;i++) {
// unsigned long long int hash = root(i, par_road, rank_road)*(n+1) + root(i, par_rail, rank_rail);
// flag = 0;
// j=1;
// while(count[j].value != 0){
// if(count[j].value == hash) {
// flag = 1;
// break;
// }
// j++;
// }
// if(flag == 0) {
// count[j].value = hash;
// count[j].count++;
// }
// else{
// count[j].count++;
// }
// }
// for (j=1;j<=n;j++) {
// terminal_road = root(j, par_road, rank_road);
// terminal_rail = root(j, par_rail, rank_rail);
// for(i=1; i<=n; i++) {
// if(par_road[i] == terminal_road && par_rail[i] == terminal_rail) {
// ans[j]++;
// }
// }
// printf("%d ", ans[j]);
// }
// for(i=1; i<=n; i++) {
// unsigned long long int hash = root(i, par_road, rank_road)*(n+1) + root(i, par_rail, rank_rail);
// for(j=1; j<=n+1; j++) {
// if(count[j].value == hash){
// printf("%d ", count[j].count);
// break;
// }
// }
// }
return 0;
}
| a.cc: In function 'int main()':
a.cc:114:14: error: 'unsignedd' was not declared in this scope; did you mean 'unsigned'?
114 | std::map<unsignedd long long int, unsigned int> mp
| ^~~~~~~~~
| unsigned
a.cc:114:51: error: wrong number of template arguments (1, should be at least 2)
114 | std::map<unsignedd long long int, unsigned int> mp
| ^
In file included from /usr/include/c++/14/map:63,
from a.cc:7:
/usr/include/c++/14/bits/stl_map.h:102:11: note: provided for 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
102 | class map
| ^~~
a.cc:116:5: error: expected initializer before 'for'
116 | for(i=1; i<=n; i++) {
| ^~~
a.cc:116:23: error: expected ';' before ')' token
116 | for(i=1; i<=n; i++) {
| ^
| ;
a.cc:189:23: error: 'mp' was not declared in this scope
189 | printf("%d ", mp[hash]);
| ^~
|
s739550854 | p03855 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM 200010
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
// typedef struct node {
// int rank;
// int value;
// node* next = NULL;
// } node;
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// void connected_road(unsigned int index){
// unsigned int i, j, h;
// for(i=1;i<=n;i++) {
// check[i]=0;
// passed[i]=0;
// }
// unsigned int flag = 0;
// check[index] = 1;
// do{
// flag = 0;
// for(j=1;j<=n;j++) {
// if(check[j] == 1){
// for(i=1;i<=k;i++) {
// if(road[i][0] == j && passed[road[i][1]] != 1) {
// check[road[i][1]] = 1;
// }
// else if(road[i][1] == j && passed[road[i][0]] != 1) {
// check[road[i][0]] = 1;
// }
// }
// passed[j] = 1;
// check[j] = 0;
// flag = 1;
// }
// }
// } while(flag);
// return;
// }
// void connected_rail(unsigned int index){
// unsigned int i, j, h;
// for(i=1;i<=n;i++) {
// check[i]=0;
// station[i]=0;
// }
// unsigned int flag = 0;
// check[index] = 1;
// do{
// flag = 0;
// for(j=1;j<=n;j++) {
// if(check[j] == 1){
// for(i=1;i<=l;i++) {
// if(rail[i][0] == j && station[rail[i][1]] != 1) {
// check[rail[i][1]] = 1;
// }
// else if(rail[i][1] == j && station[rail[i][0]] != 1) {
// check[rail[i][0]] = 1;
// }
// }
// station[j] = 1;
// check[j] = 0;
// flag = 1;
// }
// }
// } while(flag);
// return;
// }
// void categorize_city(){
// int i, j;
// for(i=1; i<=n; i++) {
// road_category[i] = 0;
// rail_category[i] = 0;
// }
// for(i=1; i<=n; i++) {
// if(road_category[i] == 0){
// connected_road(i);
// for(j=1; j<=n; j++) {
// if(passed[j] == 1){
// road_category[j] = i;
// }
// }
// }
// if(rail_category[i] == 0){
// connected_rail(i);
// for(j=1; j<=n; j++) {
// if(station[j] == 1){
// rail_category[j] = i;
// }
// }
// }
// }
// }
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
// bool same(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank) {
// return root(x, par, rank) == root(y, par, rank);
// }
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank) {
x = root(x, par, rank);
y = root(y, par, rank);
if (x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
count[y] = count[x] + count[y] + 1;
} else {
par[y] = x;
count[x] = count[y] + count[x] + 1;
if (rank[x] == rank[y]) rank[x]++;
}
}
int main(){
unsigned int i, j;
unsigned int terminal_road, terminal_rail;
scanf("%d%d%d", &n, &k, &l);
//prunsigned intf("%d %d %d\n", n, k, l);
for(i=0; i<NUM; i++) {
par_road[i] = i;
rank_road[i] = 0;
count_road[i] = 0;
par_rail[i] = i;
rank_rail[i] = 0;
count_rail[i] = 0;
}
for(i=1; i<=k; i++) {
scanf("%d%d", &road[i][0], &road[i][1]);
int c1 = road[i][0];
int c2 = road[i][1];
unite(c1, c2, par_road, rank_road);
}
for(i=1; i<=l; i++) {
scanf("%d%d", &rail[i][0], &rail[i][1]);
int c1 = rail[i][0];
int c2 = rail[i][1];
unite(c1, c2, par_rail, rank_rail);
}
// categorize_city();
return 0;
}
| main.c: In function 'unite':
main.c:136:9: error: 'count' undeclared (first use in this function)
136 | count[y] = count[x] + count[y] + 1;
| ^~~~~
main.c:136:9: note: each undeclared identifier is reported only once for each function it appears in
|
s340007069 | p03855 | C++ | #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<pair<int,int>,int> PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll
#define MAXN 214514
int par[MAXN]; //親
int rank[MAXN]; //木の深さ
int ar[MAXN];
int br[MAXN];
int n,k,l;
//n要素で初期化
void init(int n){
REP(i,n){
par[i] = i;
rank[i] = 0;
}
}
//木の根を求める
int find(int x){
if(par[x]==x) return x;
else return par[x] = find(par[x]);
}
//xとyの属する集合を併合
void unite(int x, int y){
x = find(x);
y = find(y);
if(x==y) return;
if(rank[x]<rank[y]){
par[x] = y;
} else {
par[y] = x;
if(rank[x] == rank[y]) rank[x]++;
}
}
//xとyが同じ集合に属するか否か
bool same(int x, int y){
return find(x) == find(y);
}
signed main(){
scanf("%d%d%d",&n,&k,&l);
init(n);
REP(i,k){
int t1,t2;
scanf("%d%d",&t1,&t2);
t1--;t2--;
unite(t1,t2);
}
REP(i,n) ar[i] = find(i);
init(n);
REP(i,l){
int t1,t2;
scanf("%d%d",&t1,&t2);
t1--;t2--;
unite(t1,t2);
}
REP(i,n) br[i] = find(i);
vector<P> sex;
REP(i,n) sex.pb(mp(ar[i],br[i]));
SORT(sex);
REP(i,n){
P cur = sex[i];
printf("%d ",UB(all(sex),cur)-LB(all(sex),cur));
}
printf("\n");
return 0;
} | a.cc: In function 'void init(int)':
a.cc:74:9: error: reference to 'rank' is ambiguous
74 | rank[i] = 0;
| ^~~~
In file included from /usr/include/c++/14/bits/move.h:37,
from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:63:5: note: 'int rank [214514]'
63 | int rank[MAXN]; //木の深さ
| ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:90:8: error: reference to 'rank' is ambiguous
90 | if(rank[x]<rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:63:5: note: 'int rank [214514]'
63 | int rank[MAXN]; //木の深さ
| ^~~~
a.cc:90:16: error: reference to 'rank' is ambiguous
90 | if(rank[x]<rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:63:5: note: 'int rank [214514]'
63 | int rank[MAXN]; //木の深さ
| ^~~~
a.cc:94:12: error: reference to 'rank' is ambiguous
94 | if(rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:63:5: note: 'int rank [214514]'
63 | int rank[MAXN]; //木の深さ
| ^~~~
a.cc:94:23: error: reference to 'rank' is ambiguous
94 | if(rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:63:5: note: 'int rank [214514]'
63 | int rank[MAXN]; //木の深さ
| ^~~~
a.cc:94:32: error: reference to 'rank' is ambiguous
94 | if(rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:63:5: note: 'int rank [214514]'
63 | int rank[MAXN]; //木の深さ
| ^~~~
|
s043904382 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)1e9+7
__attribute__((constructor))
void initial() {
cin.tie(0);
ios::sync_with_stdio(false);
}
int par1[200001], par2[200001];
int rank[200001];
int find(int x, int par[]) {
if(par[x] == x) return x;
else return par[x] = find(par[x], par);
}
void unite(int x, int y, int par[]) {
x = find(x, par);
y = find(y, par);
if(x == y) return;
if(rank[x] < rank[y]) {
par[x] = y;
}else {
par[y] = x;
if(rank[x] == rank[y]) rank[x]++;
}
}
signed main() {
int n, k, l;
cin >> n >> k >> l;
rep(i, 0, n + 1) {
par1[i] = i;
par2[i] = i;
}
rep(i, 0, k) {
int a, b;
cin >> a >> b;
unite(a, b, par1);
}
rep(i, 0, l) {
int a, b;
cin >> a >> b;
unite(a, b, par2);
}
vector<int> v;
int s[200001] = {};
int p[200001] = {};
rep(i, 1, n + 1) {
if(s[i]) continue;
s[i] = 1;
int c = 1;
int vc = v.size();
p[i] = vc;
rep(j, i + 1, n + 1) {
if((find(i, par1) == find(j, par1)) && (find(i, par2) == find(j, par2))) {
s[j] = 1;
p[j] = vc;
c++;
}
}
v.pb(c);
}
rep(i, 1, n + 1) {
cout << v[p[i]] << " ";
}
cout << endl;
}
| a.cc: In function 'void unite(int, int, int*)':
a.cc:32:6: error: reference to 'rank' is ambiguous
32 | if(rank[x] < rank[y]) {
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:32:16: error: reference to 'rank' is ambiguous
32 | if(rank[x] < rank[y]) {
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:36:8: error: reference to 'rank' is ambiguous
36 | if(rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:36:19: error: reference to 'rank' is ambiguous
36 | if(rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
a.cc:36:28: error: reference to 'rank' is ambiguous
36 | if(rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:20:5: note: 'int rank [200001]'
20 | int rank[200001];
| ^~~~
|
s629932710 | p03855 | C++ | #include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int MAXn = 2 * 100 * 1000 + 13;
vector<int> adj1[MAXn], adj2[MAXn], news;
int ans[MAXn], cmp[MAXn], cmp2[MAXn], cnt, cls;
bool mark1[MAXn], mark2[MAXn];
void bfs1(int r = 0){
news.clear();
queue<int> q;
q.push(r);
mark1[r] = true;
while(!q.empty()){
int v = q.front();
//cerr << v << endl;
q.pop();
cmp[v] = cnt;
news.push_back(v);
for(int i = 0; i < adj1[v].size(); i++){
int u = adj1[v][i];
if(!mark1[u]){
mark1[u] = true;
q.push(u);
}
}
}
}
void bfs2(int r = 0){
queue<int> q;
q.push(r);
mark2[r] = true;
while(!q.empty()){
int v = q.front();
//cerr << v << endl;
q.pop();
cmp2[v] = cls;
ans[cls]++;
for(int i = 0; i < adj2[v].size(); i++){
int u = adj2[v][i];
if(!mark2[u] && cmp[u] == cnt){
mark2[u] = true;
q.push(u);
}
}
}
}
int main(){
int n, k, l;
cin >> n >> k >> l;
for(int i = 0; i < k; i++){
int x, y;
cin >> x >> y;
x--;
y--;
adj1[x].push_back(y);
adj1[y].push_back(x);
}
for(int i = 0; i < l; i++){
int x, y;
cin >> x >> y;
x--;
y--;
adj2[x].push_back(y);
adj2[y].push_back(x);
}
for(int i = 0; i < n; i++)
cmp[i] = cmp2[i] = -1;
cnt = 0;
memset(mark1, 0, sizeof mark1);
for(int i = 0; i < n; i++){
if(!mark1[i]){
//cerr << "bfs1 " << i << endl;
bfs1(i);
memset(mark2, 0, sizeof mark2);
for(int j = 0; j < news.size(); j++)
if(!mark2[news[j]]){
//cerr << "bfs2 " << news[j] << endl;
bfs2(news[j]);
cls++;
}
cnt++;
}
cout << ans[cmp2[i]] << " ";
}
cout << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:56:9: error: 'cin' was not declared in this scope
56 | cin >> n >> k >> l;
| ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
4 | #include <cstring>
+++ |+#include <iostream>
5 | using namespace std;
a.cc:90:17: error: 'cout' was not declared in this scope
90 | cout << ans[cmp2[i]] << " ";
| ^~~~
a.cc:90:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:92:9: error: 'cout' was not declared in this scope
92 | cout << endl;
| ^~~~
a.cc:92:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:92:17: error: 'endl' was not declared in this scope
92 | cout << endl;
| ^~~~
a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
4 | #include <cstring>
+++ |+#include <ostream>
5 | using namespace std;
|
s837365130 | p03855 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
using namespace std;
const int MAXn = 2 * 100 * 1000 + 13;
vector<int> adj1[MAXn], adj2[MAXn], news;
int ans[MAXn], cmp[MAXn], cmp2[MAXn], cnt, cls;
bool mark1[MAXn], mark2[MAXn];
void bfs1(int r = 0){
news.clear();
queue<int> q;
q.push(r);
mark1[r] = true;
while(!q.empty()){
int v = q.front();
//cerr << v << endl;
q.pop();
cmp[v] = cnt;
news.push_back(v);
for(int i = 0; i < adj1[v].size(); i++){
int u = adj1[v][i];
if(!mark1[u]){
mark1[u] = true;
q.push(u);
}
}
}
}
void bfs2(int r = 0){
queue<int> q;
q.push(r);
mark2[r] = true;
while(!q.empty()){
int v = q.front();
//cerr << v << endl;
q.pop();
cmp2[v] = cls;
ans[cls]++;
for(int i = 0; i < adj2[v].size(); i++){
int u = adj2[v][i];
if(!mark2[u] && cmp[u] == cnt){
mark2[u] = true;
q.push(u);
}
}
}
}
int main(){
int n, k, l;
cin >> n >> k >> l;
for(int i = 0; i < k; i++){
int x, y;
cin >> x >> y;
x--;
y--;
adj1[x].push_back(y);
adj1[y].push_back(x);
| a.cc: In function 'int main()':
a.cc:64:38: error: expected '}' at end of input
64 | adj1[y].push_back(x);
| ^
a.cc:58:35: note: to match this '{'
58 | for(int i = 0; i < k; i++){
| ^
a.cc:64:38: error: expected '}' at end of input
64 | adj1[y].push_back(x);
| ^
a.cc:55:11: note: to match this '{'
55 | int main(){
| ^
|
s517269813 | p03855 | C++ |
#include<bits/stdc++.h>
using namespace std;
const int MAX_N=200000;
int par[MAX_N+1], par2[MAX_N+1];
int rank[MAX_N+1], rank2[MAX_N+1];
void init(int n){
for(int i=0;i<n;i++){
par[i]=i;
rank[i]=0;
par2[i]=i;
rank2[i]=0;
}
}
int find(int x){
if(par[x]==x){
return x;
}
else{
return par[x]=find(par[x]);
}
}
int find2(int x){
if(par2[x]==x){
return x;
}
else{
return par2[x]=find2(par2[x]);
}
}
void unite(int x, int y){
x=find(x);y=find(y);
if(x==y){
return;
}
if(rank[x]<rank[y]){
par[x]=y;
}
else{
par[y]=x;
if(rank[x]==rank[y])
rank[x]++;
}
}
void unite2(int x, int y){
x=find2(x);y=find2(y);
if(x==y){
return;
}
if(rank2[x]<rank2[y]){
par2[x]=y;
}
else{
par2[y]=x;
if(rank2[x]==rank2[y])
rank2[x]++;
}
}
bool same(int x, int y){
return find(x)==find(y);
}
bool same2(int x, int y){
return find2(x)==find2(y);
}
int main(){
int N, K, L;
cin>>N>>K>>L;
init(N);
for(int i=0;i<K;i++){
int p, q;
cin>>p>>q;
unite(p, q);
}
for(int i=0;i<L;i++){
int r, s;
cin>>r>>s;
unite2(r, s);
}
for(int i=1;i<=N;i++){
int cnt=0;
for(int j=1;j<=N;j++){
if(same(i, j)&&same2(i, j)){
cnt++;
}
}
cout<<cnt;
if(i!=N){
cout<<" ";
}
else{
cout<<endl;
}
}
return 0;
}
| a.cc: In function 'void init(int)':
a.cc:14:17: error: reference to 'rank' is ambiguous
14 | rank[i]=0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:9:5: note: 'int rank [200001]'
9 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:43:12: error: reference to 'rank' is ambiguous
43 | if(rank[x]<rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:9:5: note: 'int rank [200001]'
9 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:43:20: error: reference to 'rank' is ambiguous
43 | if(rank[x]<rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:9:5: note: 'int rank [200001]'
9 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:48:20: error: reference to 'rank' is ambiguous
48 | if(rank[x]==rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:9:5: note: 'int rank [200001]'
9 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:48:29: error: reference to 'rank' is ambiguous
48 | if(rank[x]==rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:9:5: note: 'int rank [200001]'
9 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:49:25: error: reference to 'rank' is ambiguous
49 | rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:9:5: note: 'int rank [200001]'
9 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
|
s718852774 | p03855 | C++ | #include<bits/stdc++.h>
using namespace std;
const int MAX_N=200000;
int par[MAX_N+1], par2[MAX_N+1];
int rank[MAX_N+1], rank2[MAX_N+1];
void init(int n){
for(int i=0;i<n;i++){
par[i]=i;
rank[i]=0;
par2[i]=i;
rank2[i]=0;
}
}
int find(int x){
if(par[x]==x){
return x;
}
else{
return par[x]=find(par[x]);
}
}
int find2(int x){
if(par2[x]==x){
return x;
}
else{
return par2[x]=find2(par2[x]);
}
}
void unite(int x, int y){
x=find(x);y=find(y);
if(x==y){
return;
}
if(rank[x]<rank[y]){
par[x]=y;
}
else{
par[y]=x;
if(rank[x]==rank[y])
rank[x]++;
}
}
void unite2(int x, int y){
x=find2(x);y=find2(y);
if(x==y){
return;
}
if(rank2[x]<rank2[y]){
par2[x]=y;
}
else{
par2[y]=x;
if(rank2[x]==rank2[y])
rank2[x]++;
}
}
bool same(int x, int y){
return find(x)==find(y);
}
bool same2(int x, int y){
return find2(x)==find2(y);
}
int main(){
int N, K, L;
cin>>N>>K>>L;
init(N);
for(int i=0;i<K;i++){
int p, q;
cin>>p>>q;
unite(p, q);
}
for(int i=0;i<L;i++){
int r, s;
cin>>r>>s;
unite2(r, s);
}
for(int i=1;i<=N;i++){
int cnt=0;
for(int j=1;j<=N;j++){
if(same(i, j)&&same2(i, j)){
cnt++;
}
}
cout<<cnt;
if(i!=N){
cout<<" ";
}
else{
cout<<endl;
}
}
return 0;
}
| a.cc: In function 'void init(int)':
a.cc:13:17: error: reference to 'rank' is ambiguous
13 | rank[i]=0;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:5: note: 'int rank [200001]'
8 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:42:12: error: reference to 'rank' is ambiguous
42 | if(rank[x]<rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:5: note: 'int rank [200001]'
8 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:42:20: error: reference to 'rank' is ambiguous
42 | if(rank[x]<rank[y]){
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:5: note: 'int rank [200001]'
8 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:47:20: error: reference to 'rank' is ambiguous
47 | if(rank[x]==rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:5: note: 'int rank [200001]'
8 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:47:29: error: reference to 'rank' is ambiguous
47 | if(rank[x]==rank[y])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:5: note: 'int rank [200001]'
8 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
a.cc:48:25: error: reference to 'rank' is ambiguous
48 | rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:8:5: note: 'int rank [200001]'
8 | int rank[MAX_N+1], rank2[MAX_N+1];
| ^~~~
|
s204176445 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
#define MAX_N 200002
class union_find
{
private:
int par[MAX_N];
public:
void init(int n)
{
for(int i=0;i<n;i++)
{
par[i]=i;
}
}
int FIND(int x)
{
if(par[x]==x)
{
return x;
}
else
{
return FIND(par[x]);
}
}
void unite(int x,int y)
{
x=FIND(x);
y=FIND(y);
if(x==y)
{
return ;
}
else
{
par[x]=y;
}
}
bool same(int x,int y)
{
return FIND(x)==FIND(y);//怎么判断两个元素是否是同一个集合,是判断传进来两个
//参数的根是否相同
}
};
unordered_map<pair<int,int>,int>m;
int main(void)
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
union_find u1;
union_find u2;
int N,K,L;
cin>>N>>K>>L;
u1.init(N+1);
u2.init(N+1);
int a,b;
for(int i=0;i<K;i++)
{
cin>>a>>b;
u1.unite(a,b);
}
for(int i=0;i<L;i++)
{
cin>>a>>b;
u2.unite(a,b);
}
for(int i=1;i<=N;i++)
{
m[make_pair(u1.FIND(i),u2.FIND(i))]++;
}
cout <<m[make_pair(u1.FIND(1),u2.FIND(1))];
for(int i=2;i<=N;i++)
{
cout <<" "<< m[make_pair(u1.FIND(i),u2.FIND(i))];
}
cout <<endl;
return 0;
}
| a.cc:50:33: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
50 | unordered_map<pair<int,int>,int>m;
| ^
In file included 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,
from a.cc:1:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h:148: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<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _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, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/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<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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<const std::pair<int, int>, int>, std::__detail::_Select1st, 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<const std::pair<int, int>, int>, std::__detail::_Select1st, 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<const std::pair<in |
s809596767 | p03855 | Java | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
public class BC49D {
public static void main (String[] args) throws java.lang.Exception {
InputReader in = new InputReader(System.in);
PrintWriter w = new PrintWriter(System.out);
int n = in.nextInt(), k = in.nextInt(), l = in.nextInt();
DJSet ds1 = new DJSet(n);
DJSet ds2 = new DJSet(n);
for (int i = 0; i < k; i++)
ds1.union(in.nextInt() - 1, in.nextInt() - 1);
for (int i = 0; i < l; i++)
ds2.union(in.nextInt() - 1, in.nextInt() - 1);
int[][] mat = new int[n][n];
for (int i = 0; i < n; i++) {
int r1 = ds1.root(i), r2 = ds2.root(i);
mat[r1][r2]++;
}
for (int i = 0; i < n; i++) {
w.print(mat[ds1.root(i)][ds2.root(i)] + " ");
}
w.close();
}
public static class DJSet {
public int[] upper;
public DJSet(int n) {
upper = new int[n];
Arrays.fill(upper, -1);
}
public int root(int x) {
return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
}
public boolean equiv(int x, int y) {
return root(x) == root(y);
}
public boolean union(int x, int y) {
x = root(x);
y = root(y);
if (x != y) {
if (upper[y] < upper[x]) {
int d = x;
x = y;
y = d;
}
upper[x] += upper[y];
upper[y] = x;
}
return x == y;
}
public int countCompo() {
int ct = 0;
for (int u : upper)
if (u < 0)
ct++;
return ct;
}
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int read() {
if (numChars == -1)
throw new UnknownError();
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
throw new UnknownError();
}
if (numChars <= 0)
return -1;
}
return buf[curChar++];
}
public int peek() {
if (numChars == -1)
return -1;
if (curChar >= numChars) {
curChar = 0;
try {
numChars = stream.read(buf);
} catch (IOException e) {
return -1;
}
if (numChars <= 0)
return -1;
}
return buf[curChar];
}
public void skip(int x) {
while (x-- > 0)
read();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public String nextString() {
return next();
}
public String next() {
int c = read();
while (isSpaceChar(c))
c = read();
StringBuffer res = new StringBuffer();
do {
res.appendCodePoint(c);
c = read();
} while (!isSpaceChar(c));
return res.toString();
}
public String nextLine() {
StringBuffer buf = new StringBuffer();
int c = read();
while (c != '\n' && c != -1) {
if (c != '\r')
buf.appendCodePoint(c);
c = read();
}
return buf.toString();
}
public double nextDouble() {
int c = read();
while (isSpaceChar(c))
c = read();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = read();
}
double res = 0;
while (!isSpaceChar(c) && c != '.') {
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = read();
}
if (c == '.') {
c = read();
double m = 1;
while (!isSpaceChar(c)) {
if (c == 'e' || c == 'E')
return res * Math.pow(10, nextInt());
if (c < '0' || c > '9')
throw new InputMismatchException();
m /= 10;
res += (c - '0') * m;
c = read();
}
}
return res * sgn;
}
public int[] nextIntArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public long[] nextLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public boolean hasNext() {
int value;
while (isSpaceChar(value = peek()) && value != -1)
read();
return value != -1;
}
private boolean isSpaceChar(int c) {
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
}
} | Main.java:6: error: class BC49D is public, should be declared in a file named BC49D.java
public class BC49D {
^
1 error
|
s319262623 | p03855 | C++ | #include<bits/stdc++.h>
#define N 222222
#define LL long long
using namespace std;
int T,n,i;bool f[N];char s[N];
int fd(int x){return F[x]==x?x:F[x]=fd(F[x]);}
void uni(int x,int y){
x=fd(x);y=fd(y);
if(x!=y)F[x]=y;
}
int main(){
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=n;i++)F[i]=i;
for(i=1;i<=m;i++)scanf("%d%d",&x,&y),uni(x,y);
for(i=1;i<=n;i++)V[i]=1ll*n*fd(i);
for(i=1;i<=n;i++)F[i]=i;
for(i=1;i<=k;i++)scanf("%d%d",&x,&y),uni(x,y);
for(i=1;i<=n;i++)V[i]+=fd(i);
for(i=1;i<=n;i++)b[i]=i;
sort(V+1,V+n+1);
for(i=1;i<=n;i++){
if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
to[b[i]]=cnt;vv++;
}
} | a.cc: In function 'int fd(int)':
a.cc:6:22: error: 'F' was not declared in this scope
6 | int fd(int x){return F[x]==x?x:F[x]=fd(F[x]);}
| ^
a.cc: In function 'void uni(int, int)':
a.cc:9:17: error: 'F' was not declared in this scope
9 | if(x!=y)F[x]=y;
| ^
a.cc: In function 'int main()':
a.cc:12:28: error: 'm' was not declared in this scope; did you mean 'tm'?
12 | scanf("%d%d%d",&n,&m,&k);
| ^
| tm
a.cc:12:31: error: 'k' was not declared in this scope
12 | scanf("%d%d%d",&n,&m,&k);
| ^
a.cc:13:26: error: 'F' was not declared in this scope
13 | for(i=1;i<=n;i++)F[i]=i;
| ^
a.cc:14:40: error: 'x' was not declared in this scope
14 | for(i=1;i<=m;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
a.cc:14:43: error: 'y' was not declared in this scope; did you mean 'yn'?
14 | for(i=1;i<=m;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
| yn
a.cc:15:26: error: 'V' was not declared in this scope
15 | for(i=1;i<=n;i++)V[i]=1ll*n*fd(i);
| ^
a.cc:16:26: error: 'F' was not declared in this scope
16 | for(i=1;i<=n;i++)F[i]=i;
| ^
a.cc:17:40: error: 'x' was not declared in this scope
17 | for(i=1;i<=k;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
a.cc:17:43: error: 'y' was not declared in this scope; did you mean 'yn'?
17 | for(i=1;i<=k;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
| yn
a.cc:18:26: error: 'V' was not declared in this scope
18 | for(i=1;i<=n;i++)V[i]+=fd(i);
| ^
a.cc:19:26: error: 'b' was not declared in this scope
19 | for(i=1;i<=n;i++)b[i]=i;
| ^
a.cc:20:14: error: 'V' was not declared in this scope
20 | sort(V+1,V+n+1);
| ^
a.cc:22:33: error: 'sz' was not declared in this scope; did you mean 's'?
22 | if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
| ^~
| s
a.cc:22:36: error: 'cnt' was not declared in this scope; did you mean 'int'?
22 | if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
| ^~~
| int
a.cc:22:41: error: 'vv' was not declared in this scope
22 | if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
| ^~
a.cc:23:17: error: 'to' was not declared in this scope; did you mean 'tm'?
23 | to[b[i]]=cnt;vv++;
| ^~
| tm
a.cc:23:20: error: 'b' was not declared in this scope
23 | to[b[i]]=cnt;vv++;
| ^
a.cc:23:26: error: 'cnt' was not declared in this scope; did you mean 'int'?
23 | to[b[i]]=cnt;vv++;
| ^~~
| int
a.cc:23:30: error: 'vv' was not declared in this scope
23 | to[b[i]]=cnt;vv++;
| ^~
|
s957130082 | p03855 | C++ | #include<bits/stdc++.h>
#define N 222222
#define LL long long
using namespace std;
int T,n,i;bool f[N];char s[N];
int fd(int x){return F[x]==x?x:F[x]=fd(F[x]);}
void uni(int x,int y){
x=fd(x);y=fd(y);
if(x!=y)F[x]=y;
}
int main(){
scanf("%d%d%d",&n,&m,&k);
for(i=1;i<=n;i++)F[i]=i;
for(i=1;i<=m;i++)scanf("%d%d",&x,&y),uni(x,y);
for(i=1;i<=n;i++)V[i]=1ll*n*fd(i);
for(i=1;i<=n;i++)F[i]=i;
for(i=1;i<=k;i++)scanf("%d%d",&x,&y),uni(x,y);
for(i=1;i<=n;i++)V[i]+=fd(i);
for(i=1;i<=n;i++)b[i]=i;
sort(V+1,V+n+1);
for(i=1;i<=n;i++){
if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
to[b[i]]=cnt;vv++;
}
} | a.cc: In function 'int fd(int)':
a.cc:6:22: error: 'F' was not declared in this scope
6 | int fd(int x){return F[x]==x?x:F[x]=fd(F[x]);}
| ^
a.cc: In function 'void uni(int, int)':
a.cc:9:17: error: 'F' was not declared in this scope
9 | if(x!=y)F[x]=y;
| ^
a.cc: In function 'int main()':
a.cc:12:28: error: 'm' was not declared in this scope; did you mean 'tm'?
12 | scanf("%d%d%d",&n,&m,&k);
| ^
| tm
a.cc:12:31: error: 'k' was not declared in this scope
12 | scanf("%d%d%d",&n,&m,&k);
| ^
a.cc:13:26: error: 'F' was not declared in this scope
13 | for(i=1;i<=n;i++)F[i]=i;
| ^
a.cc:14:40: error: 'x' was not declared in this scope
14 | for(i=1;i<=m;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
a.cc:14:43: error: 'y' was not declared in this scope; did you mean 'yn'?
14 | for(i=1;i<=m;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
| yn
a.cc:15:26: error: 'V' was not declared in this scope
15 | for(i=1;i<=n;i++)V[i]=1ll*n*fd(i);
| ^
a.cc:16:26: error: 'F' was not declared in this scope
16 | for(i=1;i<=n;i++)F[i]=i;
| ^
a.cc:17:40: error: 'x' was not declared in this scope
17 | for(i=1;i<=k;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
a.cc:17:43: error: 'y' was not declared in this scope; did you mean 'yn'?
17 | for(i=1;i<=k;i++)scanf("%d%d",&x,&y),uni(x,y);
| ^
| yn
a.cc:18:26: error: 'V' was not declared in this scope
18 | for(i=1;i<=n;i++)V[i]+=fd(i);
| ^
a.cc:19:26: error: 'b' was not declared in this scope
19 | for(i=1;i<=n;i++)b[i]=i;
| ^
a.cc:20:14: error: 'V' was not declared in this scope
20 | sort(V+1,V+n+1);
| ^
a.cc:22:33: error: 'sz' was not declared in this scope; did you mean 's'?
22 | if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
| ^~
| s
a.cc:22:36: error: 'cnt' was not declared in this scope; did you mean 'int'?
22 | if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
| ^~~
| int
a.cc:22:41: error: 'vv' was not declared in this scope
22 | if(V[i]!=V[i-1])sz[cnt]=vv,cnt++,vv=1;
| ^~
a.cc:23:17: error: 'to' was not declared in this scope; did you mean 'tm'?
23 | to[b[i]]=cnt;vv++;
| ^~
| tm
a.cc:23:20: error: 'b' was not declared in this scope
23 | to[b[i]]=cnt;vv++;
| ^
a.cc:23:26: error: 'cnt' was not declared in this scope; did you mean 'int'?
23 | to[b[i]]=cnt;vv++;
| ^~~
| int
a.cc:23:30: error: 'vv' was not declared in this scope
23 | to[b[i]]=cnt;vv++;
| ^~
|
s712009170 | p03855 | C | /*
D - 連結 / Connectivity
<http://abc049.contest.atcoder.jp/tasks/arc065_b>
[Tips]
・隣接行列を使ってみる<http://www.geocities.jp/m_hiroi/linux/clang16.html>
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[]) {
int N,K,L;
int p,q,r,s;
unsigned char **k,**l;
unsigned char *k_label,*l_label;
int i,j,m;
int label,cnt;
scanf("%d %d %d", &N,&K,&L);
k = (unsigned char**)calloc(N,sizeof(unsigned char*));
for( i=0; i<N; i++ ){
k[i] = (unsigned char*)calloc(N,sizeof(unsigned char));
}
l = (unsigned char**)calloc(N,sizeof(unsigned char*));
for( i=0; i<N; i++ ){
l[i] = (unsigned char*)calloc(N,sizeof(unsigned char));
}
k_label = (unsigned char*)calloc(N,sizeof(unsigned char));
l_label = (unsigned char*)calloc(N,sizeof(unsigned char));
for( i=0; i<K; i++ ){
scanf("%d %d", &p,&q);
k[p-1][q-1] = 1;
}
for( i=0; i<L; i++ ){
scanf("%d %d", &r,&s);
l[r-1][s-1] = 1;
}
PrintMatrix(k,N);
PrintMatrix(l,N);
label = 1;
for( i=0; i<N; i++ ){
for( j=i+1; j<N; j++ ){
if( (k[i][j] != 0) ){
if( (k_label[i] == 0) && (k_label[j] == 0) ){
k_label[i] = label;
k_label[j] = label;
label++;
}else if( (k_label[i] != 0) && (k_label[j] == 0) ){
k_label[j] = k_label[i];
}else if( (k_label[i] == 0) && (k_label[j] != 0) ){
k_label[i] = k_label[j];
}else{
if( k_label[i] > k_label[j] ){
k_label[i] = k_label[j];
}else{
k_label[j] = k_label[i];
}
}
}
}
}
label = 1;
for( i=0; i<N; i++ ){
for( j=i+1; j<N; j++ ){
if( (l[i][j] != 0) ){
if( (l_label[i] == 0) && (l_label[j] == 0) ){
l_label[i] = label;
l_label[j] = label;
label++;
}else if( (l_label[i] != 0) && (l_label[j] == 0) ){
l_label[j] = l_label[i];
}else if( (l_label[i] == 0) && (l_label[j] != 0) ){
l_label[i] = l_label[j];
}else{
if( l_label[i] > l_label[j] ){
l_label[i] = l_label[j];
}else{
l_label[j] = l_label[i];
}
}
}
}
}
PrintLabel(k_label,N);
PrintLabel(l_label,N);
for( i=0; i<N; i++ ){
cnt = 1;
if( (k_label[i] != 0) && (l_label[i] != 0) ){
for( j=0; j<N; j++ ){
if( (i != j) && (k_label[i] == k_label[j]) && (l_label[i] == l_label[j]) ){
cnt++;
}
}
}
printf("%d ", cnt);
}
for( i=0; i<N; i++ ){
free(k[i]);
free(l[i]);
}
free(k);
free(l);
free(k_label);
free(l_label);
return 0;
}
| main.c: In function 'main':
main.c:42:3: error: implicit declaration of function 'PrintMatrix' [-Wimplicit-function-declaration]
42 | PrintMatrix(k,N);
| ^~~~~~~~~~~
main.c:91:3: error: implicit declaration of function 'PrintLabel' [-Wimplicit-function-declaration]
91 | PrintLabel(k_label,N);
| ^~~~~~~~~~
|
s061879870 | p03855 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int L = sc.nextInt();
int[] connected1 = new int[N];
int[] connected2 = new int[N];
int[][] edge1 = new int[N][N];
int[][] edge2 = new int[N][N];
for(int i = 0; i < K; i++) {
int p = sc.nextInt() - 1;
int q = sc.nextInt() - 1;
edge1[p][q] = 1;
edge1[q][p] = 1;
}
for(int i = 0; i < L; i++) {
int r = sc.nextInt() - 1;
int s = sc.nextInt() - 1;
edge2[r][s] = 1;
edge2[s][r] = 1;
}
LinkedList<Integer> que = new LinkedList<Integer>();
int num1 = 1;
int num2 = 1;
for(int i = 0; i < N; i++) {
if(connected1[i] == 0) {
connected1[i] = num1;
que.clear();
que.add(i);
while(que.size() > 0) {
int a = que.poll();
connected1[i] = num1;
for(int j = 0; j < N; j++) {
if(connected1[j] == 0 && edge1[i][j] == 1) {
que.add(j);
}
}
}
num1++;
}
}
que.clear();
for(int i = 0; i < N; i++) {
if(connected2[i] == 0) {
connected2[i] = num2;
que.clear();
que.add(i);
while(que.size() > 0) {
int a = que.poll();
connected2[i] = num2;
for(int j = 0; j < N; j++) {
if(connected2[j] == 0 && edge2[i][j] == 1) {
que.add(j);
}
}
}
num2++;
}
}
HashMap<ArrayList<Integer>, Integer> map = new HashMap<int[][], Integer>();
for(int i = 0; i < N; i++) {
ArrayList<Integer> list = new ArrayList<Integer>();
list.add(connected1[i]);
list.add(connected2[i]);
if(map.containsKey(list)) {
map.put(list, map.get(list) + 1);
} else {
map.put(list, 1);
}
}
for(int i = 0; i < N; i++) {
ArrayList<Integer> list2 = new ArrayList<Integer>();
list2.add(connected1[i]);
list2.add(connected2[i]);
System.out.println(map.get(list2));
}
}
} | Main.java:63: error: incompatible types: HashMap<int[][],Integer> cannot be converted to HashMap<ArrayList<Integer>,Integer>
HashMap<ArrayList<Integer>, Integer> map = new HashMap<int[][], Integer>();
^
1 error
|
s065614839 | p03855 | C++ | #include<cstdio>
#include<set>
using namespace std;
int fa[2][200010],rank[2][200010];
int findroot(bool op,int x)
{
return x==fa[op][x] ? x : fa[op][x]=findroot(op,fa[op][x]);
}
void Union(bool op,int U,int V)
{
if(rank[op][U]<rank[op][V])
fa[op][U]=V;
else
{
fa[op][V]=U;
if(rank[op][U]==rank[op][V])
++rank[op][U];
}
}
int n,m,K;
bool vis[200010];
int anss[200010];
set<int>S[2][200010];
typedef set<int>::iterator ITER;
int path[200010],e;
int main()
{
int x,y;
scanf("%d%d%d",&n,&m,&K);
for(int i=1;i<=n;++i)
fa[0][i]=fa[1][i]=i;
for(int i=1;i<=m;++i)
{
scanf("%d%d",&x,&y);
int f1=findroot(0,x),f2=findroot(0,y);
if(f1!=f2)
Union(0,f1,f2);
}
for(int i=1;i<=K;++i)
{
scanf("%d%d",&x,&y);
int f1=findroot(1,x),f2=findroot(1,y);
if(f1!=f2)
Union(1,f1,f2);
}
for(int i=0;i<=1;++i)
for(int j=1;j<=n;++j)
S[i][findroot(i,j)].insert(j);
for(int i=1;i<=n;++i) if(!vis[i])
{
e=0;
int rt[2];
bool o=0;
rt[0]=findroot(0,i);
rt[1]=findroot(1,i);
if(S[0][rt[0]].size()>S[1][rt[1]].size())
o=1;
set<int> tS=S[o][rt[o]];
for(ITER it=tS.begin();it!=tS.end();++it)
if(S[o^1][rt[o^1]].find(*it)!=S[o^1][rt[o^1]].end())
{
S[o][rt[o]].erase(*it);
S[o^1][rt[o^1]].erase(*it);
path[++e]=(*it);
vis[*it]=1;
}
for(int j=1;j<=e;++j)
anss[path[j]]=e;
}
for(int i=1;i<n;++i)
printf("%d ",anss[i]);
printf("%d\n",anss[n]);
return 0;
} | a.cc: In function 'void Union(bool, int, int)':
a.cc:11:12: error: reference to 'rank' is ambiguous
11 | if(rank[op][U]<rank[op][V])
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/bits/stl_tree.h:63,
from /usr/include/c++/14/set:62,
from a.cc:2:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:4:19: note: 'int rank [2][200010]'
4 | int fa[2][200010],rank[2][200010];
| ^~~~
a.cc:11:24: error: reference to 'rank' is ambiguous
11 | if(rank[op][U]<rank[op][V])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:4:19: note: 'int rank [2][200010]'
4 | int fa[2][200010],rank[2][200010];
| ^~~~
a.cc:16:20: error: reference to 'rank' is ambiguous
16 | if(rank[op][U]==rank[op][V])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:4:19: note: 'int rank [2][200010]'
4 | int fa[2][200010],rank[2][200010];
| ^~~~
a.cc:16:33: error: reference to 'rank' is ambiguous
16 | if(rank[op][U]==rank[op][V])
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:4:19: note: 'int rank [2][200010]'
4 | int fa[2][200010],rank[2][200010];
| ^~~~
a.cc:17:21: error: reference to 'rank' is ambiguous
17 | ++rank[op][U];
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:4:19: note: 'int rank [2][200010]'
4 | int fa[2][200010],rank[2][200010];
| ^~~~
|
s746738273 | p03855 | C | #include <iostream>
#include <algorithm>
#define N 100007
using namespace std;
int n,k,l,p,q,r,s,f1[N],f2[N],a[N],cnt[N],ans[N];
int find1(int x){return f1[x]==x ? x:f1[x]=find1(f1[x]);}
int find2(int x){return f2[x]==x ? x:f2[x]=find2(f2[x]);}
bool cmp(int x,int y){return f1[x]<f1[y];}
int main(){
scanf("%d%d%d",&n,&k,&l);
int i;
for(i=1;i<=n;++i)f1[i]=f2[i]=i;
for(i=1;i<=k;++i){
scanf("%d%d",&p,&q);
f1[find1(p)]=find1(q);
}
for(int i=1;i<=l;++i){
scanf("%d%d",&r,&s);
f2[find2(r)]=find2(s);
}
for(i=1;i<=n;++i)f1[i]=find1(i),f2[i]=find2(i);
for(i=1;i<=n;++i)a[i]=i;
sort(a+1,a+n+1,cmp);
for(i=1;i<=n;++i){
int j=i;
while(j<n && f1[a[j+1]]==f1[a[j]])++j;
int t;
for(t=i;t<=j;++t)++cnt[f2[a[t]]];
for(t=i;t<=j;++t)ans[a[t]]=cnt[f2[a[t]]];
for(t=i;t<=j;++t)--cnt[f2[a[t]]];
i=j;
}
for(i=1;i<=n;++i)printf("%d ",ans[i]);
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s614682400 | p03855 | C | #include <cstdio>
#include <iostream>
#include <algorithm>
#define N 100007
using namespace std;
int n,k,l,p,q,r,s,f1[N],f2[N],a[N],cnt[N],ans[N];
int find1(int x){return f1[x]==x ? x:f1[x]=find1(f1[x]);}
int find2(int x){return f2[x]==x ? x:f2[x]=find2(f2[x]);}
bool cmp(int x,int y){return f1[x]<f1[y];}
int main(){
scanf("%d%d%d",&n,&k,&l);
int i;
for(i=1;i<=n;++i)f1[i]=f2[i]=i;
for(i=1;i<=k;++i){
scanf("%d%d",&p,&q);
f1[find1(p)]=find1(q);
}
for(int i=1;i<=l;++i){
scanf("%d%d",&r,&s);
f2[find2(r)]=find2(s);
}
for(i=1;i<=n;++i)f1[i]=find1(i),f2[i]=find2(i);
for(i=1;i<=n;++i)a[i]=i;
sort(a+1,a+n+1,cmp);
for(i=1;i<=n;++i){
int j=i;
while(j<n && f1[a[j+1]]==f1[a[j]])++j;
int t;
for(t=i;t<=j;++t)++cnt[f2[a[t]]];
for(t=i;t<=j;++t)ans[a[t]]=cnt[f2[a[t]]];
for(t=i;t<=j;++t)--cnt[f2[a[t]]];
i=j;
}
for(i=1;i<=n;++i)printf("%d ",ans[i]);
} | main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s704306825 | p03855 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;
template<class T> void gc(T &x)
{
int s, k, m = 0;
x = 0;
k = getchar_unlocked();
if (k == '-') s = 1;
else if ('0' <= k && k <= '9') x = k - '0';
while (true)
{
k = getchar_unlocked();
if (k < '0' || k > '9') break;
x = x * 10 + k - '0';
}
if (m) x = -x;
}
template<class T> void pc_d(T x) {
if(x < 0){
x = -x;
putchar_unlocked('-');
}
int i = 10;
char output_buffer[10];
do
{
output_buffer[--i] = (x % 10)+'0';
x /= 10;
}
while (x);
do
{
putchar_unlocked(output_buffer[i]);
}
while (++i<10);
}
template<class T> void pc_ld(T x)
{
if(x < 0) {
x = -x;
putchar_unlocked('-');
}
int i = 11;
char output_buffer[11];
do
{
output_buffer[--i] = (x % 10) + '0';
x /= 10;
}
while (x);
do putchar_unlocked(output_buffer[i]);
while (++i < 11);
}
template<class T> void pc_lld(T x)
{
if(x < 0) {
x = -x;
putchar_unlocked('-');
}
int i = 21;
char output_buffer[21];
do
{
output_buffer[--i] = (x % 10) + '0';
x /= 10;
}
while(x);
do putchar_unlocked(output_buffer[i]);
while (++i < 21);
}
template<class T> void pc_llu(T x)
{
int i = 21;
char output_buffer[21];
do
{
output_buffer[--i] = (n % 10) + '0';
n /= 10;
}
while (n);
do
{
putchar_unlocked(output_buffer[i]);
}
while(++i < 21);
}
int root(int p, int a[])
{
if (p != a[p]) a[p] = root(a[p], a);
return a[p];
}
int main()
{
const int max = 200000;
// 道路で連結する親代表都市
int rdRoot[max];
// 鉄道で連結する親代表都市
int rwRoot[max];
// 道路で連結する都市グループの末端
int rdLeaf[max];
// 道路で連結する都市グループ内の次の都市
int rdNext[max];
// 鉄道で連結する親代表都市が所属する 道路で連結する都市グループ
int rwRootGrp[max];
// 鉄道で連結する親代表都市が所属する 道路で連結する都市グループ内 カウント
int rwRootGrpCnt[max];
// 各都市のカウント
int ans[max] = {0};
int n, k, l;
gc(n);
gc(k);
gc(l);
// 親代表都市 初期化
for (int i = 0; i < n; i++)
{
rdRoot[i] = i;
rwRoot[i] = i;
rdLeaf[i] = -1;
rdNext[i] = -1;
rwRootGrp[i] = -1;
rwRootGrpCnt[i] = -1;
}
// 道路 親代表都市 設定
for (int i = 0; i < k; i++)
{
int p, q;
gc(p);
gc(q);
int pRoot = root(p - 1, rdRoot);
int qRoot = root(q - 1, rdRoot);
if (pRoot != qRoot)
{
// 配列インデックスが小さい方を親都市とする
if (pRoot < qRoot) rdRoot[qRoot] = pRoot;
else rdRoot[pRoot] = qRoot;
}
}
// 鉄道 親代表都市 設定
for (int i = 0; i < k; i++)
{
int r, s;
gc(r);
gc(s);
int rRoot = root(r - 1, rwRoot);
int sRoot = root(s - 1, rwRoot);
if (rRoot != sRoot)
{
// 配列インデックスが小さい方を親都市とする
if (rRoot < sRoot) rwRoot[sRoot] = rRoot;
else rwRoot[rRoot] = sRoot;
}
}
// 道路 都市グループ末端 設定
for (int i = 0; i < n; i++)
{
int rd = rdRoot[i];
if (i == rd) rdLeaf[i] = i;
else
{
rdNext[i] = rdLeaf[rd];
// 連結の順番に関係無く、配列のインデックスの順番
rdLeaf[rd] = i;
}
}
// 道路 都市グループ
int rdGrp = 0;
// 都市
for (int i = 0; i < n; i++)
{
// 鉄道で連結していない都市は対象ではない
if (rdLeaf[i] >= 0)
{
// 道路 都市グループ
rdGrp++;
// 次の都市をたどる
// 1.カウントを鉄道の親代表都市に集約する
for (int j = rdLeaf[i]; j >= 0; j = rdNext[j])
{
int rw = rwRoot[j];
if (rwRootGrp[rw] == rdGrp) rwRootGrpCnt[rw]++;
else
{
rwRootGrp[rw] = rdGrp;
rwRootGrpCnt[rw] = 1;
}
}
// 2.カウントを鉄道の親代表都市から子都市に配る
for (int j = rdLeaf[i]; j >= 0; j = rdNext[j])
ans[j] = rwRootGrpCnt[rwRoot[j]];
}
}
for (int i = 0; i < n - 1; i++)
{
pc_ld(ans[i]);
putchar_unlocked(' ');
}
pc_ld(ans[n - 1]);
putchar_unlocked('\n');
return 0;
}
| a.cc: In function 'void pc_llu(T)':
a.cc:94:31: error: 'n' was not declared in this scope
94 | output_buffer[--i] = (n % 10) + '0';
| ^
a.cc:97:12: error: 'n' was not declared in this scope
97 | while (n);
| ^
|
s663917504 | p03855 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector>
namespace Program
{
using namespace std;
class Solver
{
private:
const char *blk = " ";
const char *nll = "\0";
int N, K, L;
int p, q;
int r, s;
// i2g[i] := アイテム i の所属するグループの番号
// g2i[g] := グループ g に所属するアイテムたち
vector<int> i2gRoad;
vector< vector<int> > g2iRoad;
vector<int> i2gRailway;
vector< vector<int> > g2iRailway;
public:
// アイテム ia の所属するグループとアイテム ib のis_same_group所属するグループを
// 1 つにする
// (ia と ib は違うグループに所属するものとする)
void merge(int ia, int ib, vector<int> &i2g, vector< vector<int> > &g2i) {
// ia の所属するグループが
// ib の所属するグループより小さくならないようにする
if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
swap(ia, ib);
}
int ga = i2g[ia], gb = i2g[ib];
if (ga != gb)
{
for (int j : g2i[gb]) i2g[j] = ga;
g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
g2i[gb].clear();
sort(g2i[ga].begin(), g2i[ga].end());
}
}
// アイテム ia とアイテム ib は同じグループに所属しているか ?
bool is_same_group(int ia, int ib, vector<int> &i2g) {
return i2g[ia] == i2g[ib];
}
Solver()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> K >> L;
g2iRoad.resize(N);
g2iRailway.resize(N);
for (int i = 0; i < N; i++)
{
i2gRoad.push_back(i);
g2iRoad[i].push_back(i);
i2gRailway.push_back(i);
g2iRailway[i].push_back(i);
}
for (int i = 0; i < K; i++)
{
cin >> p >> q;
merge(p - 1, q - 1, i2gRoad, g2iRoad);
}
for (int i = 0; i < L; i++)
{
cin >> r >> s;
merge(r - 1, s - 1, i2gRailway, g2iRailway);
}
}
void Solve()
{
vector<int> v(N);
vector<int>::iterator itr;
for (int i = 0; i < N; i++)
{
int cnt = 0;
vector<int> vRD = g2iRoad[i2gRoad[i]];
vector<int> vRW = g2iRailway[i2gRailway[i]];
//sort(vRD.begin(), vRD.end());
//sort(vRW.begin(), vRW.end());
v.clear();
v.shrink_to_fit();
set_intersection(
vRD.begin(), vRD.end(), vRW.begin(), vRW.end(), back_inserter(v));
cout << ((i != 0) ? blk : nll) << v.size();
}
cout << endl;
}
};
}
int main()
{
// メモリリーク検出
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
| _CRTDBG_DELAY_FREE_MEM_DF
| _CRTDBG_CHECK_ALWAYS_DF
| _CRTDBG_LEAK_CHECK_DF);
// メンバ関数ポインタ取得
void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
// コンストラクタ呼び出し
Program::Solver obj;
// .*演算子でアクセス
(obj.*pSolve)();
return 0;
}
| a.cc: In function 'int main()':
a.cc:114:20: error: '_CRTDBG_ALLOC_MEM_DF' was not declared in this scope
114 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
| ^~~~~~~~~~~~~~~~~~~~
a.cc:115:11: error: '_CRTDBG_DELAY_FREE_MEM_DF' was not declared in this scope
115 | | _CRTDBG_DELAY_FREE_MEM_DF
| ^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:116:11: error: '_CRTDBG_CHECK_ALWAYS_DF' was not declared in this scope
116 | | _CRTDBG_CHECK_ALWAYS_DF
| ^~~~~~~~~~~~~~~~~~~~~~~
a.cc:117:11: error: '_CRTDBG_LEAK_CHECK_DF' was not declared in this scope
117 | | _CRTDBG_LEAK_CHECK_DF);
| ^~~~~~~~~~~~~~~~~~~~~
a.cc:114:5: error: '_CrtSetDbgFlag' was not declared in this scope
114 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
| ^~~~~~~~~~~~~~
|
s631673028 | p03855 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <vector>
namespace Program
{
using namespace std;
class Solver
{
private:
const char *blk = " ";
const char *nll = "\0";
int N, K, L;
int p, q;
int r, s;
// i2g[i] := アイテム i の所属するグループの番号
// g2i[g] := グループ g に所属するアイテムたち
vector<int> i2gRoad;
vector< vector<int> > g2iRoad;
vector<int> i2gRailway;
vector< vector<int> > g2iRailway;
public:
// アイテム ia の所属するグループとアイテム ib のis_same_group所属するグループを
// 1 つにする
// (ia と ib は違うグループに所属するものとする)
void merge(int ia, int ib, vector<int> &i2g, vector< vector<int> > &g2i) {
// ia の所属するグループが
// ib の所属するグループより小さくならないようにする
if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
swap(ia, ib);
}
int ga = i2g[ia], gb = i2g[ib];
if (ga != gb)
{
for (int j : g2i[gb]) i2g[j] = ga;
g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
g2i[gb].clear();
}
}
// アイテム ia とアイテム ib は同じグループに所属しているか ?
bool is_same_group(int ia, int ib, vector<int> &i2g) {
return i2g[ia] == i2g[ib];
}
Solver()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> K >> L;
g2iRoad.resize(N);
g2iRailway.resize(N);
for (int i = 0; i < N; i++)
{
i2gRoad.push_back(i);
g2iRoad[i].push_back(i);
i2gRailway.push_back(i);
g2iRailway[i].push_back(i);
}
for (int i = 0; i < K; i++)
{
cin >> p >> q;
merge(p - 1, q - 1, i2gRoad, g2iRoad);
}
for (int i = 0; i < L; i++)
{
cin >> r >> s;
merge(r - 1, s - 1, i2gRailway, g2iRailway);
}
}
void Solve()
{
cout << ((i != 0) ? blk : nll) << 1;
cout << endl;
}
};
}
int main()
{
// メモリリーク検出
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
// | _CRTDBG_DELAY_FREE_MEM_DF
// | _CRTDBG_CHECK_ALWAYS_DF
// | _CRTDBG_LEAK_CHECK_DF);
// メンバ関数ポインタ取得
void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
// コンストラクタ呼び出し
Program::Solver obj;
// .*演算子でアクセス
(obj.*pSolve)();
return 0;
} | a.cc: In member function 'void Program::Solver::Solve()':
a.cc:82:23: error: 'i' was not declared in this scope
82 | cout << ((i != 0) ? blk : nll) << 1;
| ^
|
s308989088 | p03855 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <vector>
namespace Program
{
using namespace std;
class Solver
{
private:
const char *blk = " ";
const char *nll = "\0";
int N, K, L;
int p, q;
int r, s;
// i2g[i] := アイテム i の所属するグループの番号
// g2i[g] := グループ g に所属するアイテムたち
vector<int> i2gRoad;
vector< vector<int> > g2iRoad;
vector<int> i2gRailway;
vector< vector<int> > g2iRailway;
public:
// アイテム ia の所属するグループとアイテム ib のis_same_group所属するグループを
// 1 つにする
// (ia と ib は違うグループに所属するものとする)
void merge(int ia, int ib, vector<int> &i2g, vector< vector<int> > &g2i) {
// ia の所属するグループが
// ib の所属するグループより小さくならないようにする
if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
swap(ia, ib);
}
int ga = i2g[ia], gb = i2g[ib];
if (ga != gb)
{
for (int j : g2i[gb]) i2g[j] = ga;
g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
g2i[gb].clear();
}
}
// アイテム ia とアイテム ib は同じグループに所属しているか ?
bool is_same_group(int ia, int ib, vector<int> &i2g) {
return i2g[ia] == i2g[ib];
}
Solver()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> K >> L;
g2iRoad.resize(N);
g2iRailway.resize(N);
for (int i = 0; i < N; i++)
{
i2gRoad.push_back(i);
g2iRoad[i].push_back(i);
i2gRailway.push_back(i);
g2iRailway[i].push_back(i);
}
for (int i = 0; i < K; i++)
{
cin >> p >> q;
merge(p - 1, q - 1, i2gRoad, g2iRoad);
}
for (int i = 0; i < L; i++)
{
cin >> r >> s;
merge(r - 1, s - 1, i2gRailway, g2iRailway);
}
}
void Solve()
{
for (int i = 0; i < N; i++)
{
int cnt = 0;
vector<int> vRD = g2iRoad[i2gRoad[i]];
vector<int> vRW = g2iRailway[i2gRailway[i]];
for (auto itrD = vRD.begin(); itrD != vRD.end(); itrD++)
{
for (auto itrW = vRW.begin(); itrW != vRW.end(); itrW++)
{
if (*itrD == *itrW) cnt++;
}
}
cout << ((i != 0) ? blk : nll) << cnt();
}
cout << endl;
}
};
}
int main()
{
// メモリリーク検出
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
// | _CRTDBG_DELAY_FREE_MEM_DF
// | _CRTDBG_CHECK_ALWAYS_DF
// | _CRTDBG_LEAK_CHECK_DF);
// メンバ関数ポインタ取得
void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
// コンストラクタ呼び出し
Program::Solver obj;
// .*演算子でアクセス
(obj.*pSolve)();
return 0;
} | a.cc: In member function 'void Program::Solver::Solve()':
a.cc:97:54: error: 'cnt' cannot be used as a function
97 | cout << ((i != 0) ? blk : nll) << cnt();
| ~~~^~
|
s768076654 | p03855 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
namespace Program
{
using namespace std;
class Solver
{
private:
const char *blk = " ";
const char *nll = "\0";
int N, K, L;
int p, q;
int r, s;
// i2g[i] := アイテム i の所属するグループの番号
// g2i[g] := グループ g に所属するアイテムたち
vector<int> i2gRoad;
vector< vector<int> > g2iRoad;
vector<int> i2gRailway;
vector< vector<int> > g2iRailway;
public:
// アイテム ia の所属するグループとアイテム ib のis_same_group所属するグループを
// 1 つにする
// (ia と ib は違うグループに所属するものとする)
void merge(int ia, int ib, vector<int> &i2g, vector< vector<int> > &g2i) {
// ia の所属するグループが
// ib の所属するグループより小さくならないようにする
if (g2i[i2g[ia]].size() < g2i[i2g[ib]].size()) {
swap(ia, ib);
}
int ga = i2g[ia], gb = i2g[ib];
for (int j : g2i[gb]) i2g[j] = ga;
g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());
g2i[gb].clear();
}
// アイテム ia とアイテム ib は同じグループに所属しているか ?
bool is_same_group(int ia, int ib, vector<int> &i2g) {
return i2g[ia] == i2g[ib];
}
Solver()
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> N >> K >> L;
g2iRoad.resize(N);
g2iRailway.resize(N);
for (int i = 0; i < N; i++)
{
//g2iRoad[i].resize(N);
//g2iRailway[i].resize(N);
i2gRoad.push_back(i);
g2iRoad[i].push_back(i);
i2gRailway.push_back(i);
g2iRailway[i].push_back(i);
}
for (int i = 0; i < K; i++)
{
cin >> p >> q;
merge(p - 1, q - 1, i2gRoad, g2iRoad);
}
for (int i = 0; i < L; i++)
{
cin >> r >> s;
merge(r - 1, s - 1, i2gRailway, g2iRailway);
}
}
void Solve()
{
for (int i = 0; i < N; i++)
{
int cnt = 0;
for (int j = 0; j < N; j++)
{
cnt =
(is_same_group(i, j, i2gRoad)
&& is_same_group(i, j, i2gRailway))
? cnt + 1
: cnt;
}
cout << ((i != 0) ? blk : nll) << cnt;
}
cout << endl;
}
};
}
int main()
{
// メモリリーク検出
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
| _CRTDBG_DELAY_FREE_MEM_DF
| _CRTDBG_CHECK_ALWAYS_DF
| _CRTDBG_LEAK_CHECK_DF);
// メンバ関数ポインタ取得
void (Program::Solver::*pSolve)() = &Program::Solver::Solve;
// コンストラクタ呼び出し
Program::Solver obj;
// .*演算子でアクセス
(obj.*pSolve)();
return 0;
}
| a.cc: In function 'int main()':
a.cc:102:20: error: '_CRTDBG_ALLOC_MEM_DF' was not declared in this scope
102 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
| ^~~~~~~~~~~~~~~~~~~~
a.cc:103:11: error: '_CRTDBG_DELAY_FREE_MEM_DF' was not declared in this scope
103 | | _CRTDBG_DELAY_FREE_MEM_DF
| ^~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:104:11: error: '_CRTDBG_CHECK_ALWAYS_DF' was not declared in this scope
104 | | _CRTDBG_CHECK_ALWAYS_DF
| ^~~~~~~~~~~~~~~~~~~~~~~
a.cc:105:11: error: '_CRTDBG_LEAK_CHECK_DF' was not declared in this scope
105 | | _CRTDBG_LEAK_CHECK_DF);
| ^~~~~~~~~~~~~~~~~~~~~
a.cc:102:5: error: '_CrtSetDbgFlag' was not declared in this scope
102 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF
| ^~~~~~~~~~~~~~
|
s911317026 | p03855 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
class union_find{
private:
vector<int> parent,rank,gs;
int size;
public:
int count_group;
union_find()=default;
union_find(int n){ init(n); }
void init(int n){
size=n;
count_group=n;
parent.resize(size);
rank.assign(size,0);
gs.assign(size,1);
for(int i=0; i<size; ++i) parent[i]=i;
}
int find(int x){
if(parent[x]==x) return x;
else return parent[x]=find(parent[x]);
}
void unite(int x,int y){
x=find(x);
y=find(y);
if(x==y) return;
if(rank[x]<rank[y]){
parent[x]=y;
gs[y]+=gs[x];
} else {
parent[y]=x;
gs[x]+=gs[y];
if(rank[x]==rank[y]) ++rank[x];
}
--count_group;
}
bool is_same_group(int x,int y){
return find(x)==find(y);
}
int group_size(int x){
return gs[find(x)];
};
};
void solve(){
int n,k,l;
cin >> n >> k >> l;
union_find uf1(n),uf2(n);
rep(i,0,k){
int p,q;
cin >> p >> q;
--p;
--q;
uf1.unite(p,q);
}
rep(i,0,l){
int r,s;
cin >> r >> s;
--r;
--s;
uf2.unite(r,s);
}
unordered_map<pair<int,int>,int> count;
rep(i,0,n){
++count[make_pair(uf1.find(i),uf2.find(i))];
}
rep(i,0,n){
cout << count[make_pair(uf1.find(i),uf2.find(i))];
if(i==n-1) cout << endl;
else cout << " " ;
}
}
int main(){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(10);
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:89:38: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]'
89 | unordered_map<pair<int,int>,int> count;
| ^~~~~
In file included 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,
from a.cc:1:
/usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<int, int>; _Tp = int; _Hash = std::hash<std::pair<int, int> >; _Pred = std::equal_to<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' is implicitly deleted because the default definition would be ill-formed:
148 | unordered_map() = default;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/unordered_map.h: At global scope:
/usr/include/c++/14/bits/unordered_map.h:148: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<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _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, false, true>]'
In file included from /usr/include/c++/14/bits/unordered_map.h:33:
/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<const std::pair<int, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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, false, 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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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<const std::pair<int, int>, int>; _ExtractKey = std::__detail::_Select1st; _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<const std::pair<int, int>, int>, std::__detail::_Select1st, 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<const std::pair<int, int>, int>, std::__detail::_Select1st, 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: e |
s306535730 | p03855 | C++ | #include <stdio.h>
#include <stdlib.h>
#define YES 1
#define NO -1
typedef struct {
short *road, *rail;
} node_t;
node_t *create_node(int n)
{
int i, j;
node_t *node;
node = malloc(sizeof(node_t) * n);
for(i = 0; i < n; i++) {
node[i].road = malloc(sizeof(short) * n);
node[i].rail = malloc(sizeof(short) * n);
}
for(i = 0; i < n; i++)
for(j = 0; j < n; j++) {
node[i].road[j] = NO;
node[i].rail[j] = NO;
}
for(i = 0; i < n; i++) {
node[i].road[i] = YES;
node[i].rail[i] = YES;
}
return node;
}
void print_result(node_t *node, int n)
{
int i, j;
int count;
for(i = 0; i < n; i++) {
count = 0;
for(j = 0; j < n; j++) {
if(node[i].road[j] == YES && node[i].rail[j] == YES)
count++;
}
printf("%d ",count);
}
printf("\n");
}
int main(void)
{
int i, j;
int n, k, l;
int p, q, r, s;
node_t *node;
scanf("%d %d %d",&n, &k, &l);
node = create_node(n);
for(i = 0; i < k; i++) {
scanf("%d %d", &p, &q);
p--; q--;
node[p].road[q] = YES;
node[q].road[p] = YES;
for(j = 0; j < n; j++) {
if(node[p].road[j] == YES) {
node[j].road[q] = YES;
node[q].road[j] = YES;
}
}
}
for(i = 0; i < l; i++) {
scanf("%d %d", &r, &s);
r--; s--;
node[r].rail[s] = YES;
node[s].rail[r] = YES;
for(j = 0; j < n; j++) {
if(node[r].rail[j] == YES) {
node[j].rail[s] = YES;
node[s].rail[j] = YES;
}
}
}
print_result(node,n);
return 0;
}
| a.cc: In function 'node_t* create_node(int)':
a.cc:16:16: error: invalid conversion from 'void*' to 'node_t*' [-fpermissive]
16 | node = malloc(sizeof(node_t) * n);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~
| |
| void*
a.cc:19:26: error: invalid conversion from 'void*' to 'short int*' [-fpermissive]
19 | node[i].road = malloc(sizeof(short) * n);
| ~~~~~~^~~~~~~~~~~~~~~~~~~
| |
| void*
a.cc:20:26: error: invalid conversion from 'void*' to 'short int*' [-fpermissive]
20 | node[i].rail = malloc(sizeof(short) * n);
| ~~~~~~^~~~~~~~~~~~~~~~~~~
| |
| void*
|
s871232498 | p03855 | C++ | #include <iostream>
#include <cstdio>
#include <vector>
#define MP make_pair
using namespace std;
const int MAX_N = 1000;
int par[MAX_N];
void init(int n)
{
for(int i=0; i < n;i++)
par[i] = i;
}
int find(int x)
{
if(par[x] == x)
return x;
else
return par[x] = find(par[x]);
}
bool same(int x, int y)
{
return find(x) == find(y);
}
void uniont(int x, int y)
{
x = find(x);
y = find(y);
if(x == y) return;
par[x] = y;
}
int main()
{
int N,K,L;
cin >> N >> K >> L;
int x,y;
init(N);
for(int i=0; i < K; i++){
cin >> x >> y;
uniont(x-1,y-1);
}
vector<int> road(N);
for(int i=0; i < N; i++){
road[i] = find(i);
}
init(N);
for(int i=0; i < L; i++){
cin >> x >> y;
uniont(x-1,y-1);
}
vector<int> rail(N);
for(int i=0; i < N; i++){
rail[i] = find(i);
}
vector<pair<int,int> > v(N);
for(int i=0; i < N; i++){
v[i] = MP(road[i], rail[i]);
}
for(int i=0; i < N; i++){
cout << count(v.begin(), v.end(), v[i]);
cout << " ";
}
cout << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:66:13: error: 'count' was not declared in this scope
66 | cout << count(v.begin(), v.end(), v[i]);
| ^~~~~
|
s631062863 | p03855 | C | #include <stdio.h>
int N, K, L;
int road_dad[200001] = {0};
int train_dad[200001] = {0};
int find(int x, int y, int select)//select == 1: road, ==0: train
{
int i, j;
int *dad;
i = x;
j = y;
dad = (select ? road_dad: train_dad);
while(dad[i] > 0)
i = dad[i];
while(dad[j] > 0)
j = dad[j];
return (i == j);
}
void union_city(int x, int y, int select)
{
int i, j;
int *dad;
i = x;
j = y;
dad = (select ? road_dad: train_dad);
while(dad[i] > 0)
i = dad[i];
while(dad[j] > 0)
j = dad[j];
while(dad[x] > 0){
int t = x;
x = dad[x];
dad[t] = i;
}
while(dad[y] > 0){
int t = y;
y = dad[y];
dad[t] = i;
}
If(i != j){
if(dad[j] < dad[i]){
dad[j] += dad[i] - 1;
dad[i] = j;
}else{
dad[i] += dad[j] - 1;
dad[j] = i;
}
}
}
int main(void)
{
int i, j;
scanf("%d %d %d", &N, &K, &L);
for(i = 0; i < K; i++){
int p, q;
scanf("%d %d", &p, &q);
union_city(p, q, 1);
}
for(i = 0; i < K; i++){
int r, s;
scanf("%d %d", &r, &s);
union_city(r, s, 0);
}
for(i = 1; i <= N; i++){
int res = 0;
for(j = 1; j <= N; j++){
if(find(i, j, 1) && find(i, j, 0))
res++;
}
printf("%d ", res);
}
printf("\n");
return 0;
}
| main.c: In function 'union_city':
main.c:53:5: error: implicit declaration of function 'If' [-Wimplicit-function-declaration]
53 | If(i != j){
| ^~
main.c:53:15: error: expected ';' before '{' token
53 | If(i != j){
| ^
| ;
|
s013164684 | p03855 | C++ | #include <iostream>
using namespace std;
const int MAX_N=20000;
class UnionFind{
public:
UnionFind(){
for(int i=0;i<MAX_N;i++){
this->par[i]=i;
this->d[i]=0;
}
}
UnionFind(int n){
for(int i=0;i<n;i++){
this->par[i]=i;
this->d[i]=0;
}
}
int find(int x){
if(par[x]==x) return x;
else return par[x]=find(par[x]);
}
void unite(int x,int y){
x=find(x);
y=find(y);
if(x==y) return;
if(d[x]<d[y]) par[y]=x;
else{
par[y]=x;
if(d[x]==d[y]) d[x]++;
}
}
bool same(int x,int y){
return find(x)==find(y);
}
private:
int par[MAX_N];
int d[MAX_N];
};
int main(){
int N,K,L;
cin>>N>>K>>L;
UnionFind u1(N);
UnionFind u2(N);
for(int i=0;i<K;i++){
int p,q;
cin>>p>>q;
p--;
q--;
u1.unite(p,q);
}
for(int i=0;i<L;i++){
int r,s;
cin>>r>>s;
r--;
s--;
u2.unite(r,s);
}
vector<int> ans(N,1);
for(int i=0;i<N;i++){
for(int j=i+1;j<N;j++){
if(u1.same(i,j)&&u2.same(i,j)){
ans[i]++;
ans[j]++;
}
}
}
for(int i=0;i<N;i++){
if(i!=0) cout<<" ";
cout<<ans[i];
}
cout<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:70:3: error: 'vector' was not declared in this scope
70 | vector<int> ans(N,1);
| ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
1 | #include <iostream>
+++ |+#include <vector>
2 | using namespace std;
a.cc:70:10: error: expected primary-expression before 'int'
70 | vector<int> ans(N,1);
| ^~~
a.cc:74:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
74 | ans[i]++;
| ^~~
| abs
a.cc:82:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
82 | cout<<ans[i];
| ^~~
| abs
|
s908970199 | p03855 | C++ | #include <iostream>
#include <vector>
#include <map>
using namespace std;
class UnionFind {
private:
vector<int> par, rank;
int count;
public:
UnionFind(int n) : par(n), rank(n), count(0) {
for (int i = 0; i < n; i++) par[i] = i;
}
int find(int p) {
while(p != par[p]) {
par[p] = par[par[p]];
p = par[p];
}
return p;
}
int get_count() {
return count;
}
bool connected(int p, int q) {
return find(p) == find(q);
}
void unite(int p, int q) {
p = find(p);
q = find(q);
if (p == q) return;
if (rank[p] < rank[q]) {
par[p] = q;
} else {
par[q] = p;
if (rank[p] == rank[q]) rank[p]++;
}
count--;
}
};
int main() {
int N, K, L;
cin >> N >> K >> L;
UnionFind uf1(N), uf2(N);
for (int i = 0; i < K; i++) {
int a, b;
cin >> a >> b;
uf1.unite(--a, --b);
}
for (int i = 0; i < L; i++) {
int a, b;
cin >> a >> b;
uf2.unite(--a, --b);
}
map<pair<int, int>, int> nums;
for (int i = 0; i < N; i++) {
nums[make_pair(uf1.find(i), uf2.find(i))]++;
}
for (int i = 0; i < N; i++) {
if (i) cout << " ";
cout << nums[make_pair(g1[i], g2[i])];
}
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:63:32: error: 'g1' was not declared in this scope
63 | cout << nums[make_pair(g1[i], g2[i])];
| ^~
a.cc:63:39: error: 'g2' was not declared in this scope
63 | cout << nums[make_pair(g1[i], g2[i])];
| ^~
|
s113625000 | p03855 | C | #include <stdio.h>
int train[200001][200001] = {0};
int road[200001][200001] = {0};
int visited_by_train[200001];
int visited_by_road[200001];
int num = 1;
int N, K, L;
void visit_train(int n)
{
int i;
visited_by_train[n] = num;
for(i = 1; i <= N; i++){
if(train[n][i] && !visited_by_train[i]){
visit_train(i);
}
}
}
void visit_road(int n)
{
int i;
visited_by_road[n] = num;
for(i = 1; i <= N; i++){
if(road[n][i] && !visited_by_road[i]){
visit_road(i);
}
}
}
int main(void)
{
int i, j;
scanf("%d %d %d", &N, &K, &L);
for(i = 1; i <= N; i++){
train[i][i] = 1;
road[i][i] = 1;
}
for(i = 0; i < K; i++){
int p, q;
scanf("%d %d", &p, &q);
road[p][q] = road[q][p] = 1;
}
for(i = 0; i < L; i++){
int r, s;
scanf("%d %d", &r, &s);
train[r][s] = train[s][r] = 1;
}
for(i = 1; i <= N; i++){
if(!visited_by_road[i]){
visit_road(i);
}
num++;
if(!visited_by_train[i]){
visit_train(i);
}
num++;
}
for(i = 1; i <= N; i++){
int res = 0;
for(j = 1; j <= N; j++){
if(visited_by_train[i] == visited_by_train[j] && visited_by_road[i] == visited_by_road[j]){
res++;
}
}
printf("%d\n", res);
}
return 0;
}
| /tmp/ccRXhjMs.o: in function `visit_train':
main.c:(.text+0x22): relocation truncated to fit: R_X86_64_PC32 against symbol `visited_by_train' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against symbol `visited_by_train' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x88): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccRXhjMs.o
/tmp/ccRXhjMs.o: in function `visit_road':
main.c:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `visited_by_road' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0xe7): relocation truncated to fit: R_X86_64_PC32 against symbol `road' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x102): relocation truncated to fit: R_X86_64_PC32 against symbol `visited_by_road' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x11d): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccRXhjMs.o
/tmp/ccRXhjMs.o: in function `main':
main.c:(.text+0x135): relocation truncated to fit: R_X86_64_PC32 against symbol `L' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x13f): relocation truncated to fit: R_X86_64_PC32 against symbol `K' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x149): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccRXhjMs.o
main.c:(.text+0x196): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s577632028 | p03855 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //llong int_MIN/MAX
using namespace std;
#define FOR(i,s,e) for(llong int (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(llong int (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl
#define non -1
#define MAX 200010
llong n;
llong int color1[MAX];
llong int color2[MAX];
vector<llong int> G1[MAX];
vector<llong int> G2[MAX];
llong City[MAX];
void dfs1(llong int r, llong int c, llong int color[MAX], vector<llong int> G[MAX]) {//r
stack<llong int>S;
S.push(r);
color[r] = c;
while (!S.empty()) {
llong int u = S.top();
S.pop();
FOR(i, 0, (llong int)G[u].size()) {
llong int v = G[u][i];
if (color[v] == non) {
color[v] = c;
S.push(v);
}
}
}
}
void assigncolor1(llong int color[MAX], vector<llong int>G[MAX]) {
llong int id = 1;
FOR(i, 1, n + 1)
color[i] = non;
FOR(u, 1, n + 1) {
if (color[u] == non)
dfs1(u, id++, color, G);
}
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
llong int k, l;
cin >> n >> k >> l;
bool visit1[MAX];
bool visit2[MAX];
bool CityP[MAX];
FOR(i, 1, n + 1) {
visit1[i] = false;
visit2[i] = false;
City[i] = 1;
CityP[i] = false;
}
FOR(i, 0, k) {
llong int s, t;
cin >> s >> t;
G1[s].push_back(t);
G1[t].push_back(s);
}
FOR(i, 0, l) {
llong int s, t;
cin >> s >> t;
G2[s].push_back(t);
G2[t].push_back(s);
}
assigncolor1(color1, G1);
/*
FOR(i, 1, n + 1) {
cout << "color1 : v" << i << ": " << color1[i] << endl;
}*/
assigncolor1(color2, G2);
/*FOR(i, 1, n + 1) {
cout << "color2 : v" << i << ": " << color2[i] << endl;
}
*/
FOR(v, 1, n + 1) {
if (visit1[v] == true)continue;
llong int count = 1;
queue<llong int >Q;
queue<llong int >Q2;
Q.push(v);
Q2.push(v);
while (!Q.empty()) {
llong int u = Q.front();
Q.pop();
visit1[u] = true;
FOR(i, 0, (llong int)G2[u].size()) {
llong int p = G2[u][i];
if (visit1[p] == false)
if (color1[u] == color1[p] && color2[u] == color2[p]) {
count++;
/* debug(count);
debug(u);
debug(p);
*/
Q.push(p);
Q2.push(p);
visit1[p] = true;
}
}
}
count = Q2.size;
while (!Q2.empty()) {
llong int u = Q2.front();
Q2.pop();
City[u] = count;
}
}
FOR(i, 1, n) {
cout << City[i] << " ";
}
cout << City[n] << endl;
return 0;
}
/*
4 4 4
1 2
2 3
3 4
4 1
1 2
2 3
3 4
4 1
4 6 6
1 2
2 3
3 4
4 1
1 3
2 4
1 2
2 3
3 4
4 1
1 3
2 4
4 3 3
1 2
2 3
3 4
1 2
2 3
3 4
4 3 3
1 2
2 3
3 4
1 2
4 1
3 4
7 5 5
1 2
2 3
2 5
6 7
4 5
3 5
4 5
3 4
6 7
5 6
*/ | a.cc: In function 'int main()':
a.cc:148:20: error: cannot convert 'std::queue<long long int>::size' from type 'std::queue<long long int>::size_type (std::queue<long long int>::)() const' {aka 'long unsigned int (std::queue<long long int>::)() const'} to type 'long long int'
148 | count = Q2.size;
| ^~~~
|
s193117396 | p03855 | C++ | #http://www.geocities.jp/m_hiroi/light/pyalgo61.html
class UF(object):
def __init__(self, n):
self.table = [None for i in range(n)]
def find(self, x):
if self.table[x] is None:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.find(x)
s2 = self.find(y)
if s1 != s2:
self.table[s2] = s1
n, k, l = [int(x) for x in raw_input().split()]
d = UF(n)
t = UF(n)
for i in range(k):
p, q = [int(x) - 1 for x in raw_input().split()]
d.union(p, q)
for i in range(l):
r, s = [int(x) - 1 for x in raw_input().split()]
t.union(r, s)
res = {}
for i in range(n):
key = (d.find(i), t.find(i))
res[key] = res.get(key, 0) + 1
for i in range(n):
print res[(d.find(i), t.find(i))],
| a.cc:1:2: error: invalid preprocessing directive #http
1 | #http://www.geocities.jp/m_hiroi/light/pyalgo61.html
| ^~~~
a.cc:2:17: error: expected initializer before ':' token
2 | class UF(object):
| ^
a.cc:27:1: error: expected unqualified-id before 'for'
27 | for i in range(n):
| ^~~
|
s490024273 | p03855 | C++ | #http://www.geocities.jp/m_hiroi/light/pyalgo61.html
class UF(object):
def __init__(self, n):
self.table = [None for i in range(n)]
def find(self, x):
if self.table[x] is None:
return x
else:
self.table[x] = self.find(self.table[x])
return self.table[x]
def union(self, x, y):
s1 = self.find(x)
s2 = self.find(y)
if s1 != s2:
self.table[s2] = s1
n, k, l = [int(x) for x in raw_input().split()]
d = UF(n)
t = UF(n)
for i in range(k):
p, q = [int(x) - 1 for x in raw_input().split()]
d.union(p, q)
for i in range(l):
r, s = [int(x) - 1 for x in raw_input().split()]
t.union(r, s)
res = {}
for i in range(n):
key = (d.find(i), t.find(i))
res[key] = res.get(key, 0) + 1
for i in range(n):
print res[(d.find(i), t.find(i))],
| a.cc:1:2: error: invalid preprocessing directive #http
1 | #http://www.geocities.jp/m_hiroi/light/pyalgo61.html
| ^~~~
a.cc:2:17: error: expected initializer before ':' token
2 | class UF(object):
| ^
a.cc:27:1: error: expected unqualified-id before 'for'
27 | for i in range(n):
| ^~~
|
s499371059 | p03855 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int par[100010],rank[100010],par2[100010],rank2[100010];
int find(int x){
if(par[x]==x) return x;
return par[x]=find(par[x]);
}
void uf(int x,int y){
x = find(x);
y = find(y);
if (x==y) return;
if(rank[x]<rank[y]) par[x] = y;
else {
par[y]=x;
if(rank[x]==rank[y]) rank[x]++;
}
}
int find2(int x){
if(par2[x]==x) return x;
return par2[x]=find2(par2[x]);
}
void uf2(int x,int y){
x = find2(x);
y = find2(y);
if (x==y) return;
if(rank2[x]<rank2[y]) par2[x] = y;
else {
par2[y]=x;
if(rank2[x]==rank2[y]) rank2[x]++;
}
}
bool s1(int x, int y){
return find(x)==find(y);
}
bool s2(int x, int y){
return find2(x)==find2(y);
}
int main(){
int n,k,l,p[100010],q[100010],r[100010],s[100010];
cin>>n>>k>>l;
for(int i=0;i<100010;i++){ par[i]=i; rank[i]=0; par2[i]=i; rank2[i]=0;}
for(int i=0;i<k;i++){ cin>>p[i]>>q[i]; p[i]--; q[i]--;}
for(int i=0;i<l;i++){ cin>>r[i]>>s[i]; r[i]--; s[i]--;}
for(int i=0;i<k;i++) uf(p[i],q[i]);
for(int i=0;i<l;i++) uf2(r[i],s[i]);
for(int i=0;i<n;i++){
int ans=1;
for(int j=0;j<n;j++) {
if(i!=j&&(s1(i,j)&&s2(i,j))) ans++;
//cout<<i<<' '<<j<<' '<<s1(i,j)<<' '<<s2(i,j)<<endl;
}
cout<<ans<<" ";
}
cout<<endl;
return 0;
} | a.cc: In function 'void uf(int, int)':
a.cc:16:8: error: reference to 'rank' is ambiguous
16 | if(rank[x]<rank[y]) par[x] = y;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:5:17: note: 'int rank [100010]'
5 | int par[100010],rank[100010],par2[100010],rank2[100010];
| ^~~~
a.cc:16:16: error: reference to 'rank' is ambiguous
16 | if(rank[x]<rank[y]) par[x] = y;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:5:17: note: 'int rank [100010]'
5 | int par[100010],rank[100010],par2[100010],rank2[100010];
| ^~~~
a.cc:19:12: error: reference to 'rank' is ambiguous
19 | if(rank[x]==rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:5:17: note: 'int rank [100010]'
5 | int par[100010],rank[100010],par2[100010],rank2[100010];
| ^~~~
a.cc:19:21: error: reference to 'rank' is ambiguous
19 | if(rank[x]==rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:5:17: note: 'int rank [100010]'
5 | int par[100010],rank[100010],par2[100010],rank2[100010];
| ^~~~
a.cc:19:30: error: reference to 'rank' is ambiguous
19 | if(rank[x]==rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:5:17: note: 'int rank [100010]'
5 | int par[100010],rank[100010],par2[100010],rank2[100010];
| ^~~~
a.cc: In function 'int main()':
a.cc:50:42: error: reference to 'rank' is ambiguous
50 | for(int i=0;i<100010;i++){ par[i]=i; rank[i]=0; par2[i]=i; rank2[i]=0;}
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:5:17: note: 'int rank [100010]'
5 | int par[100010],rank[100010],par2[100010],rank2[100010];
| ^~~~
|
s945821368 | p03855 | C++ | #include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);
#define tie cin.tie(0);
#define x first
#define y second
#define ll long long
#define mod 666013
using namespace std;
int n, road[100100], m, rail[100100], k;
int x, a, b;
int A[200005];
int find1(int nod)
{
if (road[nod] == nod) return nod;
int p = find1(road[nod]);
road[nod] = p;
return p;
}
void unite1(int a, int b)
{
a = find1(a);
b = find1(b);
road[a] = b;
}
int find2(int nod)
{
if (rail[nod] == nod) return nod;
int p = find2(rail[nod]);
rail[nod] = p;
return p;
}
void unite2(int a, int b)
{
a = find2(a);
b = find2(b);
rail[a] = b;
}
int main(){
cin >> n >> m >> k;
ios_base::sync_with_stdio(0);
cin.tie(0);
for (int i = 1; i <= n; i++)
road[i] = rail[i] = i;
for (int i = 1; i <= m; i++)
{
cin >> a >> b;
unite1(a, b);
}
for (int i = 1; i <= k; i++)
{
cin >> a >> b;
unite2(a, b);
}
for (int i = 1; i < n; i++)
{
for (int j = i+1; j <= n; j++)
if (find1(i) == find1(j) && find2(i) == find2(j)) A[i]++, A[j]++;
}
for (int i = 1; i <= n; i++) cout << A[i]+1 << " ";
return 0;
}
| a.cc: In function 'int main()':
a.cc:3:13: error: 'std::istream' {aka 'class std::basic_istream<char>'} has no member named 'cin'; did you mean 'in'?
3 | #define tie cin.tie(0);
| ^~~
a.cc:47:13: note: in expansion of macro 'tie'
47 | cin.tie(0);
| ^~~
|
s176478522 | p03855 | Java |
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
/**
* Created by jaga on 9/22/16.
*/
public class Main{
public static void solve(PrintWriter out, FastScanner in) {
int N = in.nextInt();
int K = in.nextInt();
int L = in.nextInt();
UnionFindTree tree1 = new UnionFindTree(N);
UnionFindTree tree2 = new UnionFindTree(N);
for(int i = 0; i < K ; i++) {
int p = in.nextInt();
int q = in.nextInt();
tree1.unite(p - 1,q - 1);
}
for(int i = 0 ; i < L;i++) {
int r = in.nextInt();
int s = in.nextInt();
tree2.unite(r -1 ,s -1 );
}
for(int i = 0;i < N;i++) {
int count = 0;
for(int k = 0;k < N;k++) {
if (tree1.par[i] == tree1.par[k] && tree2.par[i] == tree2.par[k]) {
count++;
}
}
if (i == N - 1) {
out.println(count);
} else {
out.print(count + " ");
}
}
}
static class Pair implements Comparable {
int first, second;
Pair(int a, int b) {
first = a;
second = b;
}
public int compareTo(Object other) {
Pair p1 = (Pair) other;
return this.first - ((Pair) other).first; // IDの値に従い昇順で並び替えたい場合
// return -(this.first - ((Pair) other).first); // IDの値に従い降順で並び替えたい場合
}
}
/*以下はテンプレ*/
public static void main(String args[]) {
OutputStream outputStream = System.out;
PrintWriter out = new PrintWriter(outputStream);
FastScanner in = new FastScanner();
solve(out, in);
out.close();
}
public static class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int bufferLength = 0;
private boolean hasNextByte() {
if (ptr < bufferLength) {
return true;
} else {
ptr = 0;
try {
bufferLength = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (bufferLength <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte()) return buffer[ptr++];
else return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
private void skipUnprintable() {
while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
}
boolean hasNext() {
skipUnprintable();
return hasNextByte();
}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
double nextDouble() {
return Double.parseDouble(next());
}
double[] nextDoubleArray(int n) {
double[] array = new double[n];
for (int i = 0; i < n; i++) {
array[i] = nextDouble();
}
return array;
}
double[][] nextDoubleMap(int n, int m) {
double[][] map = new double[n][];
for (int i = 0; i < n; i++) {
map[i] = nextDoubleArray(m);
}
return map;
}
public int nextInt() {
return (int) nextLong();
}
public int[] nextIntArray(int n) {
int[] array = new int[n];
for (int i = 0; i < n; i++) array[i] = nextInt();
return array;
}
public long[] nextLongArray(int n) {
long[] array = new long[n];
for (int i = 0; i < n; i++) array[i] = nextLong();
return array;
}
public String[] nextStringArray(int n) {
String[] array = new String[n];
for (int i = 0; i < n; i++) array[i] = next();
return array;
}
public char[][] nextCharMap(int n) {
char[][] array = new char[n][];
for (int i = 0; i < n; i++) array[i] = next().toCharArray();
return array;
}
public int[][] nextIntMap(int n, int m) {
int[][] map = new int[n][];
for (int i = 0; i < n; i++) {
map[i] = nextIntArray(m);
}
return map;
}
}
}
| Main.java:17: error: cannot find symbol
UnionFindTree tree1 = new UnionFindTree(N);
^
symbol: class UnionFindTree
location: class Main
Main.java:17: error: cannot find symbol
UnionFindTree tree1 = new UnionFindTree(N);
^
symbol: class UnionFindTree
location: class Main
Main.java:18: error: cannot find symbol
UnionFindTree tree2 = new UnionFindTree(N);
^
symbol: class UnionFindTree
location: class Main
Main.java:18: error: cannot find symbol
UnionFindTree tree2 = new UnionFindTree(N);
^
symbol: class UnionFindTree
location: class Main
4 errors
|
s361357189 | p03855 | C | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef struct list
{
int n[2];
char k;
struct list* next;
} LIST;
LIST *head;
LIST *rt;
void list_init()
{
head = rt = malloc(sizeof(LIST));
}
void list_set(int i, int j, char k)
{
rt->next = malloc(sizeof(LIST));
rt->next->n[0] = i;
rt->next->n[0] = j;
rt->next->k = k;
rt = rt->next;
rt->next = NULL;
}
int search_list(int i , int j, char k)
{
LIST* p = head;
while(p != NULL)
{
if(p->n[0] == i || p->n[1] == i)
if(p->n[0] == j || p->n[1] == j)
if(p->k == k || p->k == k)
{
return 1;
}
p = p->next;
}
return 0;
}
int check_tree(LIST * rt, int nc, int i, char* memo, char k)
{
int out = 0;
for(int j = 0; j < nc; j++)
{
if( (memo[j] & k )== 0 && search_list(i, j, k))
{
memo[j] |= k;
out += check_tree(rt,nc,j,memo,k) + 1;
}
}
return out;
}
int main ()
{
list_init();
for(int i = 0; i < 100000; i++)
{
list_set(i,i,3);
}
char inp[10000];
fgets(inp,10000,stdin);
int nc = atoi(strt
ok(inp," "));
int nr = atoi(strtok(inp," "));
int nt = atoi(strtok(inp," "));
for(int i = 0; i < nr + nt; i++)
{
memset(inp,0,10000);
fgets(inp,10000,stdin);
int a = atoi(strtok(inp," "));
int b = atoi(strtok(inp," "));
if(i < nr) list_set(a,b,1);
else list_set(a,b,2);
}
for(int i = 0; i < nc; i++)
{
int out = 0;
char memo[100000] =
{
};
check_tree(rt, nc, i, memo,1);
check_tree(rt, nc, i, memo,2);
for(int j = 0; j < 100000; j++)
{
if(memo[j] == 3) out++;
}
printf("%d",out);
if(i + 1 != nc) printf(" ");
}
return 0;
}
| main.c: In function 'main':
main.c:82:19: error: 'strt' undeclared (first use in this function); did you mean 'rt'?
82 | int nc = atoi(strt
| ^~~~
| rt
main.c:82:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:82:23: error: expected ')' before 'ok'
82 | int nc = atoi(strt
| ~ ^
| )
83 | ok(inp," "));
| ~~
|
s646422454 | p03855 | C++ | #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
inline void readInt2(int *a, int *b) {
int c, p = 0; char s[20] = "";
for(int i = 0; (c = getchar()) != '\n'; i++) {
if (c == ' ') { *a = atoi(s); strcpy(s, ""); p = i+1; continue; }
else s[i] = c;
}
*b = atoi(s+p);
}
inline void readInt3(int *a, int *b, int *c) {
int d, p = 0; char s[20] = "";
for(int i = 0; (d = getchar()) != '\n'; i++) {
if(d == ' ') {
if(p == 0) { *a = atoi(s); strcpy(s, ""); p = i+1; continue; }
else {*b = atoi(s+p); strcpy(s, ""); p = i+1; continue; }
} else s[i] = d;
}
*c = atoi(s+p);
}
struct edge {
int from, to;
edge(int from, int to) : from(from), to(to) {}
};
int n, k, l, p, q;
vector<edge> v1, v2;
int par[200005], rank[200005], ans[200001];
void init() {
rep(i,n) {
par[i] = i;
rank[i] = 0;
}
}
int find(int x) {
if (par[x] == x) {
return x;
} else {
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]) {
par[x] = y;
} else {
par[y] = x;
if (rank[x] == rank[y]) rank[x]++;
}
}
bool same(int x, int y) {
return find(x) == find(y);
}
void solve() {
init();
rep(i,v1.size()) {
if (!same(v1[i].from, v1[i].to)) {
unite(v1[i].from, v1[i].to);
}
}
rep(i,v2.size()) {
if (same(v2[i].from, v2[i].to)) {
ans[v2[i].from-1]++;
ans[v2[i].to-1]++;
}
}
}
int main(void) {
readInt3(&n, &k, &l);
rep (i,k) {
readInt2(&p, &q);
v1.push_back(edge(p, q));
}
rep (i,l) {
readInt2(&p, &q);
v2.push_back(edge(p, q));
}
solve();
rep(i,n-1) printf("%d ", ans[i]+1);
printf("%d\n", ans[n-1]+1);
return 0;
}
| a.cc: In function 'void init()':
a.cc:46:9: error: reference to 'rank' is ambiguous
46 | rank[i] = 0;
| ^~~~
In file included from /usr/include/c++/14/bits/char_traits.h:50,
from /usr/include/c++/14/string:42,
from a.cc:4:
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:41:18: note: 'int rank [200005]'
41 | int par[200005], rank[200005], ans[200001];
| ^~~~
a.cc: In function 'void unite(int, int)':
a.cc:63:9: error: reference to 'rank' is ambiguous
63 | if (rank[x] < rank[y]) {
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:41:18: note: 'int rank [200005]'
41 | int par[200005], rank[200005], ans[200001];
| ^~~~
a.cc:63:19: error: reference to 'rank' is ambiguous
63 | if (rank[x] < rank[y]) {
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:41:18: note: 'int rank [200005]'
41 | int par[200005], rank[200005], ans[200001];
| ^~~~
a.cc:67:13: error: reference to 'rank' is ambiguous
67 | if (rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:41:18: note: 'int rank [200005]'
41 | int par[200005], rank[200005], ans[200001];
| ^~~~
a.cc:67:24: error: reference to 'rank' is ambiguous
67 | if (rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:41:18: note: 'int rank [200005]'
41 | int par[200005], rank[200005], ans[200001];
| ^~~~
a.cc:67:33: error: reference to 'rank' is ambiguous
67 | if (rank[x] == rank[y]) rank[x]++;
| ^~~~
/usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank'
1437 | struct rank
| ^~~~
a.cc:41:18: note: 'int rank [200005]'
41 | int par[200005], rank[200005], ans[200001];
| ^~~~
|
s870998873 | p03855 | C++ | #include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long unsigned
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 200004
#define mod 2000003
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;
bitset<N>viz,wiz,cc,sol[N],sol1[N];
vector<int>v[N],w[N];
int n,k,l,x,y,i;
void df(int nod)
{
if(viz[nod])
return;
viz[nod]=1;
cc|=(1<<nod);
for(auto it:v[nod])
df(it);
}
void dfs(int nod)
{
if(wiz[nod])
return;
wiz[nod]=1;
sol[nod]=cc;
for(auto it:v[nod])
dfs(it);
}
void df1(int nod)
{
if(viz[nod])
return;
viz[nod]=1;
cc|=(1<<nod);;
for(auto it:w[nod])
df1(it);
}
void dfs1(int nod)
{
if(wiz[nod])
return;
wiz[nod]=1;
sol1[nod]=cc;
for(auto it:w[nod])
dfs1(it);
}
int main()
{
cin.sync_with_stdio(0);
cout.sync_with_stdio(0);
cin>>n>>k>>l;
for(i=1; i<=k; i++)
{
cin>>x>>y;
v[x].pb(y);
v[y].pb(x);
}
for(i=1; i<=l; i++)
{
cin>>x>>y;
w[x].pb(y);
w[y].pb(x);
}
for(i=1; i<=n; i++)
if(!viz[i])
{
cc=0;
df(i);
dfs(i);
}
viz=0;
wiz=0;
for(i=1; i<=n; i++)
if(!viz[i])
{
cc=0;
df1(i);
dfs1(i);
}
for(i=1; i<=n; i++)
cout<<(sol[i]&sol1[i]).count()<<' ';
return 0;
}
| /tmp/ccGuZPAp.o: in function `df(int)':
a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccGuZPAp.o
/tmp/ccGuZPAp.o: in function `dfs(int)':
a.cc:(.text+0x245): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccGuZPAp.o
/tmp/ccGuZPAp.o: in function `df1(int)':
a.cc:(.text+0x3b2): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccGuZPAp.o
/tmp/ccGuZPAp.o: in function `dfs1(int)':
a.cc:(.text+0x4ca): relocation truncated to fit: R_X86_64_PC32 against symbol `sol1' defined in .bss section in /tmp/ccGuZPAp.o
a.cc:(.text+0x4fe): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccGuZPAp.o
/tmp/ccGuZPAp.o: in function `main':
a.cc:(.text+0x595): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccGuZPAp.o
a.cc:(.text+0x5b1): relocation truncated to fit: R_X86_64_PC32 against symbol `k' defined in .bss section in /tmp/ccGuZPAp.o
a.cc:(.text+0x5c6): relocation truncated to fit: R_X86_64_PC32 against symbol `l' defined in .bss section in /tmp/ccGuZPAp.o
a.cc:(.text+0x5d7): relocation truncated to fit: R_X86_64_PC32 against symbol `i' defined in .bss section in /tmp/ccGuZPAp.o
a.cc:(.text+0x5e7): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccGuZPAp.o
a.cc:(.text+0x603): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s527255985 | p03855 | C++ | #include <stdio.h>
#include <string.h>
#include <stdlib.h>
int check_tree(char** rt, int nc, int i, char* memo)
{
int out = 0;
for(int j = 0; j < nc; j++)
{
if(rt[i][j] == 3 && memo[j] == 0)
{
memo[j] = 1;
out += check_tree(rt,nc,j,memo) + 1;
}
}
return out;
}
int main ()
{
char **rt;
rt = malloc(sizeof(char*) * 100000);
for( int i = 0; i < 100000; i++) rt[i] = malloc(sizeof(char) * 100000);
for( int i = 0; i < 100000; i++)
{
rt[i][i] = 3;
}
char inp[10000];
fgets(inp,10000,stdin);
int nc = atoi(strtok(inp," "));
int nr = atoi(strtok(inp," "));
int nt = atoi(strtok(inp," "));
for(int i = 0; i < nr + nt; i++)
{
memset(inp,0,10000);
fgets(inp,10000,stdin);
int a = atoi(strtok(inp," "));
int b = atoi(strtok(inp," "));
if(i < nr) rt[a][b] = 1, rt[b][a] = 1;
else rt[a][b] |= 2, rt[b][a] |= 2;
}
for(int i = 0; i < nc; i++)
{
char memo[100000] =
{
};
int out = check_tree(rt, nc, i, memo);
printf("%d",out);
if(i + 1 != nc) printf(" ");
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:16: error: invalid conversion from 'void*' to 'char**' [-fpermissive]
22 | rt = malloc(sizeof(char*) * 100000);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
| |
| void*
a.cc:23:53: error: invalid conversion from 'void*' to 'char*' [-fpermissive]
23 | for( int i = 0; i < 100000; i++) rt[i] = malloc(sizeof(char) * 100000);
| ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
| |
| void*
|
s757794736 | p03856 | Java | import java.util.*;
public static void main(String[] atgs) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
str=str.replace("eraser","");
str=str.replace("erase","");
str=str.replace("dreamer","");
str=str.replace("dream","");
if(str.equals(""))
System.out.println("true");
else System.out.println("false");
}
| Main.java:4: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] atgs) {
^
(use --enable-preview to enable unnamed classes)
1 error
|
s943347205 | p03856 | Java | import java.util.*;
public class Main()
{
public static void main(String[] atgs) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
str=str.replace("eraser","");
str=str.replace("erase","");
str=str.replace("dreamer","");
str=str.replace("dream","");
if(str.equals(""))
System.out.println("true");
else System.out.println("false");
}
}
| Main.java:4: error: '{' expected
public class Main()
^
1 error
|
s087828886 | p03856 | Java | import java.util.*;
public class test
{
public static void main(String[] atgs) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
str=str.replace("eraser","");
str=str.replace("erase","");
str=str.replace("dreamer","");
str=str.replace("dream","");
if(str.equals(""))
System.out.println("true");
else System.out.println("false");
}
}
| Main.java:4: error: class test is public, should be declared in a file named test.java
public class test
^
1 error
|
s960097923 | p03856 | Java | import java.util.*;
import java.io.*;
import javax.swing.*;
import java.text.*;
import java.lang.*;
public class test
{
public static void main(String[] atgs) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
str=str.replace("eraser","");
str=str.replace("erase","");
str=str.replace("dreamer","");
str=str.replace("dream","");
if(str.equals(""))
System.out.println("true");
else System.out.println("false");
}
}
| Main.java:6: error: class test is public, should be declared in a file named test.java
public class test
^
1 error
|
s186791938 | p03856 | Java |
public class test
{
public static void main(String[] atgs) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
s=s.replace("eraser","");
s=s.replace("erase","");
s=s.replace("dreamer","");
s=s.replace("dream","");
if(s.equals(""))
System.out.println("true");
else System.out.println("false");
}
}
| Main.java:2: error: class test is public, should be declared in a file named test.java
public class test
^
Main.java:6: error: cannot find symbol
Scanner s=new Scanner(System.in);
^
symbol: class Scanner
location: class test
Main.java:6: error: cannot find symbol
Scanner s=new Scanner(System.in);
^
symbol: class Scanner
location: class test
3 errors
|
s907981087 | p03856 | Java | import java.util.*;
import javax.swing.*;
import java.text.*;
public class test
{
public static void main(String[] atgs) {
Scanner s=new Scanner(System.in);
String str=s.nextLine();
s=s.replace("eraser","");
s=s.replace("erase","");
s=s.replace("dreamer","");
s=s.replace("dream","");
if(s.length()==0)
System.out.println("true");
else System.out.println("false");
}
}
| Main.java:6: error: class test is public, should be declared in a file named test.java
public class test
^
Main.java:12: error: cannot find symbol
s=s.replace("eraser","");
^
symbol: method replace(String,String)
location: variable s of type Scanner
Main.java:13: error: cannot find symbol
s=s.replace("erase","");
^
symbol: method replace(String,String)
location: variable s of type Scanner
Main.java:14: error: cannot find symbol
s=s.replace("dreamer","");
^
symbol: method replace(String,String)
location: variable s of type Scanner
Main.java:15: error: cannot find symbol
s=s.replace("dream","");
^
symbol: method replace(String,String)
location: variable s of type Scanner
Main.java:16: error: cannot find symbol
if(s.length()==0)
^
symbol: method length()
location: variable s of type Scanner
6 errors
|
s202419712 | p03856 | C++ | #include<iostream>
#include<string>
using namespace std;
string s;
bool bad=false,allow=false;
int main(){
cin >> s;
s='%%%%%%%%'+s;
s+='%%%%%%%';
for (int i=0;i<s.length();i++){
if (s[i]=='e'){
if ((s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){
i+=4;
allow=true;
}else{
bad=true;
}
}else if (s[i]=='d'){
if ((s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){
i+=4;
allow=true;
}else{
bad=true;
}
}else if (s[i]=='r'){
if (allow){
allow=false;
}else{
bad=true;
}
}else if (s[i]!='%'){
bad=true;
allow=false;
}
}
if (bad){
cout << "NO\n";
}else{
cout << "YES\n";
}
return 0; | a.cc:8:11: warning: multi-character literal with 8 characters exceeds 'int' size of 4 bytes
8 | s='%%%%%%%%'+s;
| ^~~~~~~~~~
a.cc:9:12: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
9 | s+='%%%%%%%';
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:8:21: error: no match for 'operator+' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
8 | s='%%%%%%%%'+s;
| ~~~~~~~~~~^~
| | |
| int std::string {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/string:48,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)'
627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)'
1798 | operator+(typename move_iterator<_Iterator>::difference_type __n,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: 'std::string' {aka 'std::__cxx11::basic_string<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
8 | s='%%%%%%%%'+s;
| ^
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3616 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'const _CharT*' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: deduced conflicting types for parameter '_CharT' ('int' and 'char')
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)'
3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3719 | operator+(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'const _CharT*' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)'
3726 | operator+(_CharT __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: deduced conflicting types for parameter '_CharT' ('int' and 'char')
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)'
3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
/usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)'
3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed:
a.cc:8:22: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int'
8 | s='%%%%%%%%'+s;
| ^
a.cc:9:12: warning: overflow in conversion from 'int' to 'char' changes value from '623191333' to '37' [-Woverflow]
9 | s+='%%%%%%%';
| ^~~~~~~~~
a.cc:41:18: error: expected '}' at end of input
41 | return 0;
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s670685317 | p03856 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000; // n の最大値
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
int main() {
string s;
cin>>s;
ll n=s.size();
ll f=0;
for(ll i=0; i<n; i++){
if(s.at(i)=='d'&&s.at(i+1)=='r'&&s.at(i+2)=='e'&&s.at(i+3)=='a'&&s.at(i+4)=='m'){
if(s.at(i+5)=='e'&&s.at(i+6)=='r'){
i=i+6;
continue;}
else{
i=i+4;
continue;}
else if(s.at(i)=='e'&&s.at(i+1)=='r'&&s.at(i+2)=='a'&&s.at(i+3)=='s'&&s.at(i+4)=='e'){
if(s.at(i+5)=='r'){
i=i+5;
continue;}
else{
i=i+4;
continue;}
else{
f++;
break;}}
if(f==1){
cout<<"NO"<<endl;}
else
cout<<"YES"<<endl;}
| a.cc: In function 'int main()':
a.cc:32:1: error: expected '}' before 'else'
32 | else if(s.at(i)=='e'&&s.at(i+1)=='r'&&s.at(i+2)=='a'&&s.at(i+3)=='s'&&s.at(i+4)=='e'){
| ^~~~
a.cc:25:81: note: to match this '{'
25 | if(s.at(i)=='d'&&s.at(i+1)=='r'&&s.at(i+2)=='e'&&s.at(i+3)=='a'&&s.at(i+4)=='m'){
| ^
a.cc:39:1: error: expected '}' before 'else'
39 | else{
| ^~~~
a.cc:32:86: note: to match this '{'
32 | else if(s.at(i)=='e'&&s.at(i+1)=='r'&&s.at(i+2)=='a'&&s.at(i+3)=='s'&&s.at(i+4)=='e'){
| ^
|
s009282870 | p03856 | C++ | #include <bits/stdc++.h>//復習必須
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
int main () {
cin >> s;
int flag = 1;
for (int i = s.size() - 1; i >= 2; i--)
{
if (i > 3 && (s[i] == 'e' && s[i - 1] == 's' && s[i - 2] == 'a' && s[i - 3] == 'r' && s[i - 4] == 'e'))
{
i -= 4;
}
else if (i > 3 && (s[i] == 'm' && s[i - 1] == 'a' && s[i - 2] == 'e' && s[i - 3] == 'r' && s[i - 4] == 'd'))
{
i -= 4;
}
else if (i > 4 && (s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 's' && s[i - 3] == 'a' && s[i - 4] == 'r' && s[i - 5] == 'e'))
{
i -= 5;
}
else if (i > 5 && (s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 'm' && s[i - 3] == 'a' && s[i - 4] == 'e' && s[i - 5] == 'r' && s[i - 6] == 'd'))
{
i -= 6;
}
else
{
flag = 0;
break;
}
}
if (flag)
{
cout << "YES";
}
else
{
cout << "NO";
return 0 ;
}
| a.cc: In function 'int main()':
a.cc:14:12: error: 's' was not declared in this scope
14 | cin >> s;
| ^
a.cc:50:2: error: expected '}' at end of input
50 | }
| ^
a.cc:12:13: note: to match this '{'
12 | int main () {
| ^
|
s324363853 | p03856 | Java | import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int index = 0;
while(index < s.length()){
System.out.println(c);
if(c == 'd'){
if(index + 5 > s.length()){
break;
}
if(index+7 < s.length() && (s.charAt(index+7) != 'a') || index+7 == s.length()){
if(s.substring(index,index+7).equals("dreamer")){
index += 7;
}else{
if(s.substring(index,index+5).equals("dream")){
index += 5;
}else{
break;
}
}
}else{
if(s.substring(index,index+5).equals("dream")){
index += 5;
}else{
break;
}
}
}else if(c == 'e'){
if(index + 5 > s.length()){
break;
}
if(index + 5 == s.length() || s.charAt(index+5) != 'r'){
if(s.substring(index,index+5).equals("erase")){
index += 5;
}else{
break;
}
}else{
if(s.substring(index,index+6).equals("eraser")){
index += 6;
}else{
break;
}
}
}else{
break;
}
}
System.out.println(index == s.length() ? "YES" : "NO");
}
}
| Main.java:9: error: cannot find symbol
System.out.println(c);
^
symbol: variable c
location: class Main
Main.java:10: error: cannot find symbol
if(c == 'd'){
^
symbol: variable c
location: class Main
Main.java:31: error: cannot find symbol
}else if(c == 'e'){
^
symbol: variable c
location: class Main
3 errors
|
s583921594 | p03856 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);
//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
// ll a, b;
// cin >> a >> b;
// work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };
//最大公約数
ll gcd(ll x, ll y) {
return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y) {
if (x == 0 || y == 0)return 0;
return (x / gcd(x, y) * y);
}
//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
ll a = 2;
while (n >= a * a) {
if (n % a == 0) {
ins[a]++;
ins[a] = ins[a] % 1000000007;
n /= a;
}
else {
a++;
}
}
ins[n]++;
}
vector<ll>relation[20], money(20, 1);
int main() {
string s;
cin >> s;
bool flag = true;
for (int i = s.length() - 1;i >= 2;--i) {
if (i >= 5 && s[i] == 'm' && s[i - 1] == 'a' && s[i - 2] == 'e' && s[i - 3] == 'r' && s[i - 4] == 'd') {
i -= 5;
}
else if (i >= 7 && s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 'm' && s[i - 3] == 'a' && s[i - 4] == 'e' && s[i - 5] == 'r' && s[i - 6] == 'd') {
i -= 7;
}
else if (i >= 5 && s[i] == 'e' && s[i - 1] == 's' && s[i - 2] == 'a' && s[i - 3] == 'r' && s[i - 4] == 'e') {
i -= 5;
}
else if (i >= 6 && s[i] == 'r' && s[i - 1] == 'e' && s[i - 2] == 's' && s[i - 3] == 'a' && s[i - 4] == 'r'&&s[i-5]=='e') {
i-=6
}
else {
flag = false;
}
}
if (flag)puts("YES");
else {
puts("NO");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:72:29: error: expected ';' before '}' token
72 | i-=6
| ^
| ;
73 | }
| ~
|
s228145781 | p03856 | C++ | #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);
//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
// ll a, b;
// cin >> a >> b;
// work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };
//最大公約数
ll gcd(ll x, ll y) {
return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y) {
if (x == 0 || y == 0)return 0;
return (x / gcd(x, y) * y);
}
//素因数分解
vector<pair<ll, int>>factorize(ll n) {
vector<pair<ll, int>>res;
for (ll i = 2;i * i <= n;++i) {
if (n % i)continue;
res.emplace_back(i, 0);
while (n % i == 0) {
n /= i;
res.back().second++;
}
}
if (n != 1)res.emplace_back(n, 1);
return res;
}
vector<ll>relation[20], money(20, 1);
int main() {
string s;
cin >> s;
int n = s.length();
bool flag = true;
int i = 0;
while (i < n && flag = true) {
if (s[i] == 'e') {
if (s[i + 1] != 'r' || s[i + 2] != 'a' || s[i + 3] != 's' || s[i + 4] != 'e')flag = false;
i += 5;
if (i >= n)break;
if (s[i] != 'd' && s[i] != 'r'&&s[i]!='e')flag = false;
}
if (s[i] == 'd') {
if (s[i + 1] != 'r' || s[i + 2] != 'e' || s[i + 3] != 'a' || s[i + 4] != 'm')flag = false;
i += 5;
if (i >= n)break;
if (s[i] != 'd' && s[i] != 'r' && s[i] != 'e')flag = false;
}
else if (i != 0 && s[i] == 'r') {
continue;
}
else {
flag = false;
}
}
if (flag)puts("YES");
else {
puts("NO");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:61:22: error: lvalue required as left operand of assignment
61 | while (i < n && flag = true) {
| ~~~~~~^~~~~~~
|
s817064286 | p03856 | C | // AtCoder ARC065 C - Daydream
// 2019.8.27 bal4u
#include <stdio.h>
#include <string.h>
#define gc() getchar_unlocked()
int ins(char *s) { // 文字列の入力 スペース以下の文字で入力終了
char *p = s--;
do *++s = gc();
while (*s > ' ');
*s = 0;
return s - p;
}
int N;
char S[100005];
int main()
{
int i;
N = ins(S);
i = 0; while (i < N) {
if (memcmp(S+i, "dream", 5) == 0 && memcmp(S+i+5, "erase", 5) == 0) i += 5;
else if (memcmp(S+i, "dreamer", 7) == 0) i += 7;
else if (memcmp(S+i, "eraser", 6) == 0) i += 6;
else if (memcmp(S+i, "erase", 5) == 0) i += 5;
else { puts("NO"); return 0;
}
puts("YES");
return 0;
}
| main.c: In function 'main':
main.c:34:1: error: expected declaration or statement at end of input
34 | }
| ^
|
s683927524 | p03856 | C++ | #include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;
void Main()
{
string S;
cin >> S;
vector<string> words = {"dream", "dreamer", "erase", "eraser"};
int N = words.size();
int ssz = S.size();
bool flag = false;
while(1){
rep(i,N){
int wsz = words[i].size();
if(ssz - wsz >= 0 && S.substr(ssz-wsz) == words[i]){
flag = true;
S = S.erase(ssz-wsz);
break;
}
}
else if(!flag){
//NG
puts("NO");
return;
}
ssz = S.size();
if(1 < ssz && ssz < 5){
//NG
puts("NO");
return;
}
}
puts("YES");
return;
}
int main()
{
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
cout << fixed << setprecision(15);
Main();
return 0;
}
| a.cc:2:9: fatal error: boost/multi_array.hpp: No such file or directory
2 | #include<boost/multi_array.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s069808982 | p03856 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x) cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long
//前から見ていくdpでできそう!!ナップサックの応用
void solve() {
string s; cin >> s;
bitset<100100> dp;
dp[0] = 1;
int n = s.size();
rep(i, n) {
if(i + 4 < n) {
string u = s.substr(i, 5);
if(u == "dream" || u == "erase") {
dp[i + 5] |= dp[i];
}
}
if(i + 5 < n) {
string v = s.substr(i, 6);
if(v == "dreamr" || v == "eraser") {
dp[i + 6] |= dp[i];
}
}
}
if(dp[n]) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
//cout << fixed << setprecision(10);
//init();
solve();
//cout << "finish" << endl;
return 0;
} | a.cc: In function 'void solve()':
a.cc:63:27: error: no match for 'operator|=' (operand types are 'std::bitset<100100>::reference' and 'std::bitset<100100>::reference')
63 | dp[i + 5] |= dp[i];
| ~~~~~~~~~~^~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
168 | operator|=(byte& __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::byte&'
168 | operator|=(byte& __l, byte __r) noexcept
| ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::_Ios_Fmtflags&'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::_Ios_Openmode&'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::_Ios_Iostate&'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
a.cc:69:27: error: no match for 'operator|=' (operand types are 'std::bitset<100100>::reference' and 'std::bitset<100100>::reference')
69 | dp[i + 6] |= dp[i];
| ~~~~~~~~~~^~~~~~~~
/usr/include/c++/14/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
168 | operator|=(byte& __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::byte&'
168 | operator|=(byte& __l, byte __r) noexcept
| ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::_Ios_Fmtflags&'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::_Ios_Openmode&'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note: no known conversion for argument 1 from 'std::bitset<100100>::reference' to 'std::_Ios_Iostate&'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
|
s838088900 | p03856 | C++ | #include <iostream>
using namespace std;
const string words[] = {"dream", "dreamer", "erase", "eraser"};
int main() {
string s, result = "YES";
cin >> s;
for (int i = s.size(); i >= 0; ) {
bool found = false;
for (auto& w : words) {
if (i >= w.size() && s.compare(i - w.wize(), w.size(), w) == 0) {
found = true;
i -= w.size();
break;
}
}
if (!found) {
result = "NO";
break;
}
}
cout << result;
return 0;
}
| a.cc: In function 'int main()':
a.cc:12:50: error: 'const class std::__cxx11::basic_string<char>' has no member named 'wize'; did you mean 'size'?
12 | if (i >= w.size() && s.compare(i - w.wize(), w.size(), w) == 0) {
| ^~~~
| size
|
s296776625 | p03856 | C++ | #include <iostream>
using namespace std;
const string words[] = {"dream", "dreamer", "erase", "eraser"};
int main() {
string s, result = "YES";
cin >> s;
for (int i = s.size; i >= 0; ) {
bool found = false;
for (auto& w : words) {
if (i >= w.size() && s.compare(i - w.wize(), w.size(), w) == 0) {
found = true;
i -= w.size();
break;
}
}
if (!found) {
result = "NO";
break;
}
}
cout << result;
return 0;
}
| a.cc: In function 'int main()':
a.cc:9:20: error: cannot convert 'std::__cxx11::basic_string<char>::size' from type 'std::__cxx11::basic_string<char>::size_type (std::__cxx11::basic_string<char>::)() const noexcept' {aka 'long unsigned int (std::__cxx11::basic_string<char>::)() const noexcept'} to type 'int'
9 | for (int i = s.size; i >= 0; ) {
| ^~~~
a.cc:12:50: error: 'const class std::__cxx11::basic_string<char>' has no member named 'wize'; did you mean 'size'?
12 | if (i >= w.size() && s.compare(i - w.wize(), w.size(), w) == 0) {
| ^~~~
| size
|
s657490057 | p03856 | C++ | import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
}else{
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
public String next() {
if (!hasNext()) throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while(isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext()) throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while(true){
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
}else if(b == -1 || !isPrintableChar(b)){
return minus ? -n : n;
}else{
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() { return Double.parseDouble(next());}
}
public class Main {
static FastScanner scan=new FastScanner();
static Scanner scanner=new Scanner(System.in);
static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
static long lcm (long a, long b) {return a*b/gcd(a,b);}
static int max(int a,int b) {return a>b?a:b;}
static int min(int a,int b) {return a<b?a:b;}
static long factorial(int i) {return i==1?1:i*factorial(i-1);}
static int lower_bound(int a[],int key) {
int low=0,high=a.length;
while(low<high) {
int mid=((high-low)/2)+low;
if(a[mid]<=key)low=mid+1;
else high=mid;
}
return high;
}
static int upper_bound(int a[],int key) {
int low=0,high=a.length;
while(low<high) {
int mid=((high-low)/2)+low;
if(a[mid]<key)low=mid+1;
else high=mid;
}
return high;
}
static boolean isPrime (long n) {
if (n==2) return true;
if (n<2 || n%2==0) return false;
double d = Math.sqrt(n);
for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
return true;
}
static int upper_division(int a,int b) {//切り上げ(int)
if(a%b==0) {
return a/b;
}
else {
return a/b+1;
}
}
static long lupper_division(long a,long b) {//切り上げ(long)
if(a%b==0) {
return a/b;
}
else {
return a/b+1;
}
}
static long lmax(long a,long b) {return Math.max(a, b);}
static long lmin(long a,long b) {return Math.min(a, b);}
static int[] setArray(int a) {//配列を作る
int b[]=new int[a];
for(int i=0;i<a;i++) {
b[i]=scan.nextInt();
}
return b;
}
static String reverce(String str) {//文字列を逆にする
String strr="";
for(int i=str.length()-1;i>=0;i--) {
strr+=str.charAt(i);
}
return strr;
}
public static void printArray(int[] a) {//配列の空白付き出力
for(int i=0;i<a.length-1;i++) {
System.out.print(a[i]+" ");
}
System.out.println(a[a.length-1]);
}
public static int[][] doublesort(int[][]a) {//二次元配列のソート
Arrays.sort(a,(x,y)->Integer.compare(x[0],y[0]));
return a;
}
static long modpow(long x,long n,long mo) {//x^n%mo
long sum=1;
while(n>0) {
if((n&1)==1) {
sum=sum*x%mo;
}
x=x*x%mo;
n>>=1;
}
return sum;
}
public char[] revch(char ch[]) {//char[]を逆にする
char ret[]=new char[ch.length];
for(int i=ch.length-1,j=0;i>=0;i--,j++) {
ret[j]=ch[i];
}
return ret;
}
public int[] revint(int ch[]) {//int[]を逆にする
int ret[]=new int[ch.length];
for(int i=ch.length-1,j=0;i>=0;i--,j++) {
ret[j]=ch[i];
}
return ret;
}
public static void main(String[] args) {
String str=scan.next();
str=reverce(str);
boolean c=true;
int ls=str.length();
while(c) {
c=false;
if(ls>=5&&str.subSequence(ls-5,5).equals("dream")){
ls-=5;
c=true;
}
else if(ls>=5&&str.subSequence(ls-5,5).equals("erase")){
ls-=5;
c=true;
}
else if(ls>=7&&str.subSequence(ls-7,7).equals("dreamer")){
ls-=5;
c=true;
}
else if(ls>=6&&str.subSequence(ls-6,6).equals("eraser")){
ls-=5;
c=true;
}
}
System.out.println(ls==0?"YES":"NO");
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.io.IOException;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.io.InputStream;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.util.Arrays;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.util.NoSuchElementException;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Scanner;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:12: error: expected ':' before 'final'
7 | private final InputStream in = System.in;
| ^~~~~~
| :
a.cc:7:13: error: 'final' does not name a type
7 | private final InputStream in = System.in;
| ^~~~~
a.cc:8:12: error: expected ':' before 'final'
8 | private final byte[] buffer = new byte[1024];
| ^~~~~~
| :
a.cc:8:13: error: 'final' does not name a type
8 | private final byte[] buffer = new byte[1024];
| ^~~~~
a.cc:9:12: error: expected ':' before 'int'
9 | private int ptr = 0;
| ^~~~
| :
a.cc:10:12: error: expected ':' before 'int'
10 | private int buflen = 0;
| ^~~~
| :
a.cc:11:12: error: expected ':' before 'boolean'
11 | private boolean hasNextByte() {
| ^~~~~~~~
| :
a.cc:11:13: error: 'boolean' does not name a type; did you mean 'bool'?
11 | private boolean hasNextByte() {
| ^~~~~~~
| bool
a.cc:27:12: error: expected ':' before 'int'
27 | private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
| ^~~~
| :
a.cc:28:12: error: expected ':' before 'static'
28 | private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
| ^~~~~~~
| :
a.cc:28:20: error: 'boolean' does not name a type; did you mean 'bool'?
28 | private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
| ^~~~~~~
| bool
a.cc:29:11: error: expected ':' before 'boolean'
29 | public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
| ^~~~~~~~
| :
a.cc:29:12: error: 'boolean' does not name a type; did you mean 'bool'?
29 | public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
| ^~~~~~~
| bool
a.cc:30:11: error: expected ':' before 'String'
30 | public String next() {
| ^~~~~~~
| :
a.cc:30:12: error: 'String' does not name a type
30 | public String next() {
| ^~~~~~
a.cc:40:11: error: expected ':' before 'long'
40 | public long nextLong() {
| ^~~~~
| :
a.cc:64:11: error: expected ':' before 'int'
64 | public int nextInt() {
| ^~~~
| :
a.cc:69:11: error: expected ':' before 'double'
69 | public double nextDouble() { return Double.parseDouble(next());}
| ^~~~~~~
| :
a.cc:70:2: error: expected ';' after class definition
70 | }
| ^
| ;
a.cc: In member function 'int FastScanner::readByte()':
a.cc:27:34: error: 'hasNextByte' was not declared in this scope
27 | private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
| ^~~~~~~~~~~
a.cc:27:56: error: 'buffer' was not declared in this scope; did you mean 'buflen'?
27 | private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
| ^~~~~~
| buflen
a.cc: In member function 'long int FastScanner::nextLong()':
a.cc:41:14: error: 'hasNext' was not declared in this scope
41 | if (!hasNext()) throw new NoSuchElementException();
| ^~~~~~~
a.cc:41:35: error: expected type-specifier before 'NoSuchElementException'
41 | if (!hasNext()) throw new NoSuchElementException();
| ^~~~~~~~~~~~~~~~~~~~~~
a.cc:43:9: error: 'boolean' was not declared in this scope; did you mean 'bool'?
43 | boolean minus = false;
| ^~~~~~~
| bool
a.cc:46:13: error: 'minus' was not declared in this scope
46 | minus = true;
| ^~~~~
a.cc:50:23: error: expected type-specifier before 'NumberFormatException'
50 | throw new NumberFormatException();
| ^~~~~~~~~~~~~~~~~~~~~
a.cc:56:34: error: 'isPrintableChar' was not declared in this scope
56 | }else if(b == -1 || !isPrintableChar(b)){
| ^~~~~~~~~~~~~~~
a.cc:57:24: error: 'minus' was not declared in this scope
57 | return minus ? -n : n;
| ^~~~~
a.cc:59:27: error: expected type-specifier before 'NumberFormatException'
59 | throw new NumberFormatException();
| ^~~~~~~~~~~~~~~~~~~~~
a.cc: In member function 'int FastScanner::nextInt()':
a.cc:66:18: error: 'Integer' was not declared in this scope
66 | if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
| ^~~~~~~
a.cc:66:73: error: expected type-specifier before 'NumberFormatException'
66 | if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
| ^~~~~~~~~~~~~~~~~~~~~
a.cc: In member function 'double FastScanner::nextDouble()':
a.cc:69:41: error: 'Double' was not declared in this scope; did you mean 'double'?
69 | public double nextDouble() { return Double.parseDouble(next());}
| ^~~~~~
| double
a.cc:69:60: error: 'next' was not declared in this scope; did you mean 'nextInt'?
69 | public double nextDouble() { return Double.parseDouble(next());}
| ^~~~
| nextInt
a.cc: At global scope:
a.cc:71:1: error: expected unqualified-id before 'public'
71 | public class Main {
| ^~~~~~
|
s098619344 | p03856 | C++ |
//In The Name Of GOD
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
const int mod = 1000000007;
const int inf = 2000000000;
const int maxn = 500*1000+500*1000+15;
const int MLOG = 18;
#define pb push_back
#define pp pop_back
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
vector<char> vec;
void faz1(vector<char> &vec){
if ( vec.back() == 'd' ){
if( sz(vec) >= 5 ){
if( vec[sz(vec) - 2] == 'r' && vec[sz(vec) - 3] == 'e' && vec[sz(vec) - 4] == 'a' && vec[sz(vec) - 5] == 'm'){
for(int i = 0;i < 5 ; i++)
vec.pp();
}else{
cout << "NO";
exit(0);
}
}else{
cout << "NO";
exit(0);
}
}else if( vec.back() == 'e' ){
if( sz(vec) >= 5 ){
if( vec[sz(vec) - 2] == 'r' && vec[sz(vec) - 3] == 'a' && vec[sz(vec) - 4] == 's' && vec[sz(vec) - 5] == 'e'){
for(int i = 0;i < 5 ; i++)
vec.pp();
}else{
cout << "NO";
exit(0);
}
}else{
cout << "NO";
exit(0);
}
}else{
cout<< "NO";
exit(0);
}
}
void faz3(vector<char> &vec){
if( sz(vec) == 0 )
return ;
if ( vec[sz(vec)-1] == 'r'){
vec.pp();
}else{
return ;
}
}
void faz2(vector<char> &vec){
if( sz(vec) == 0 )
return ;
if( sz(vec) == 1 ){
cout << "NO";
exit(0);
return ;
}
if ( vec.back() == 'e' && vec[sz(vec)-2] == 'r'){
}else{
cout<<"NO";
exit(0);
}
if(sz(vec) == 2){vec.pp();vec.pp();return ;}
if(vec[sz(vec) - 3] == 'a'){
return;
}
vec.pp();
vec.pp();
return ;
}
int main(){
string s;
cin >> s;
reverse(s.begin, s.end());
int i=0;
string ss[4]={"dream","dreamer","erase","eraser"};
for(int i = 0; i < 4; i++){
reverse(ALL(ss[i]));
}
string t = "";
while(i < s.size()){
t += s[i];
for(int i = 0; i < 4; i++){
if(ss[i] == t){
t="";
}
}
i++;
}
if(tmp==""){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:93:12: error: no matching function for call to 'reverse(<unresolved overloaded function type>, std::__cxx11::basic_string<char>::iterator)'
93 | reverse(s.begin, s.end());
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:1083:5: note: candidate: 'void std::reverse(_BIter, _BIter) [with _BIter = __gnu_cxx::__normal_iterator<char*, __cxx11::basic_string<char> >]'
1083 | reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
| ^~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1083:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to '__gnu_cxx::__normal_iterator<char*, std::__cxx11::basic_string<char> >'
1083 | reverse(_BidirectionalIterator __first, _BidirectionalIterator __last)
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: candidate: 'template<class _ExecutionPolicy, class _BidirectionalIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::reverse(_ExecutionPolicy&&, _BidirectionalIterator, _BidirectionalIterator)'
249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
| ^~~~~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: candidate expects 3 arguments, 2 provided
a.cc:97:17: error: 'ALL' was not declared in this scope
97 | reverse(ALL(ss[i]));
| ^~~
a.cc:109:8: error: 'tmp' was not declared in this scope; did you mean 'tm'?
109 | if(tmp==""){
| ^~~
| tm
|
s053128458 | p03856 | C++ | 2 0
5 5 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 2 0
| ^
|
s189995222 | p03856 | C++ | dreamerer#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define watch(x) cout<<"->"<<#x<<" : "<<x<<endl;
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef unsigned long long llu;
const double PI = 2*acos(0.0);
map<pair<int,string>,bool> seen;
map<pair<int,string>,int> val;
bool solve(int idx, string s, string curr)
{
if(seen[{idx,curr}])
return val[{idx,curr}];
if(curr.length()>s.length())
return false;
if(s==curr)
return true;
bool a = 0, b = 0;
if(s[idx]=='d')
return a = solve(idx+5,s,curr+"dream") || solve(idx+7,s,curr+"dreamer");
if(s[idx]=='e')
return b = solve(idx+5,s,curr+"erase") || solve(idx+6,s,curr+"eraser");
return val[{idx,curr}]=(a||b),seen[{idx,curr}]=true;
}
signed main()
{
//freopen("","r",stdin);
//freopen("","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
string s;
cin>>s;
if(solve(0,s,""))
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
return 0;
} | a.cc:1:10: error: stray '#' in program
1 | dreamerer#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'dreamerer' does not name a type
1 | dreamerer#include <bits/stdc++.h>
| ^~~~~~~~~
a.cc:10:21: error: 'acos' was not declared in this scope
10 | const double PI = 2*acos(0.0);
| ^~~~
a.cc:11:1: error: 'map' does not name a type
11 | map<pair<int,string>,bool> seen;
| ^~~
a.cc:12:1: error: 'map' does not name a type
12 | map<pair<int,string>,int> val;
| ^~~
a.cc:13:21: error: 'string' has not been declared
13 | bool solve(int idx, string s, string curr)
| ^~~~~~
a.cc:13:31: error: 'string' has not been declared
13 | bool solve(int idx, string s, string curr)
| ^~~~~~
a.cc: In function 'bool solve(int, int, int)':
a.cc:15:12: error: 'seen' was not declared in this scope
15 | if(seen[{idx,curr}])
| ^~~~
a.cc:16:24: error: 'val' was not declared in this scope
16 | return val[{idx,curr}];
| ^~~
a.cc:17:17: error: request for member 'length' in 'curr', which is of non-class type 'int'
17 | if(curr.length()>s.length())
| ^~~~~~
a.cc:17:28: error: request for member 'length' in 's', which is of non-class type 'int'
17 | if(curr.length()>s.length())
| ^~~~~~
a.cc:22:13: error: invalid types 'int[int]' for array subscript
22 | if(s[idx]=='d')
| ^
a.cc:23:46: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
23 | return a = solve(idx+5,s,curr+"dream") || solve(idx+7,s,curr+"dreamer");
| ~~~~^~~~~~~~
| |
| const char*
a.cc:13:38: note: initializing argument 3 of 'bool solve(int, int, int)'
13 | bool solve(int idx, string s, string curr)
| ~~~~~~~^~~~
a.cc:23:77: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
23 | return a = solve(idx+5,s,curr+"dream") || solve(idx+7,s,curr+"dreamer");
| ~~~~^~~~~~~~~~
| |
| const char*
a.cc:13:38: note: initializing argument 3 of 'bool solve(int, int, int)'
13 | bool solve(int idx, string s, string curr)
| ~~~~~~~^~~~
a.cc:24:13: error: invalid types 'int[int]' for array subscript
24 | if(s[idx]=='e')
| ^
a.cc:25:46: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
25 | return b = solve(idx+5,s,curr+"erase") || solve(idx+6,s,curr+"eraser");
| ~~~~^~~~~~~~
| |
| const char*
a.cc:13:38: note: initializing argument 3 of 'bool solve(int, int, int)'
13 | bool solve(int idx, string s, string curr)
| ~~~~~~~^~~~
a.cc:25:77: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
25 | return b = solve(idx+5,s,curr+"erase") || solve(idx+6,s,curr+"eraser");
| ~~~~^~~~~~~~~
| |
| const char*
a.cc:13:38: note: initializing argument 3 of 'bool solve(int, int, int)'
13 | bool solve(int idx, string s, string curr)
| ~~~~~~~^~~~
a.cc:26:16: error: 'val' was not declared in this scope
26 | return val[{idx,curr}]=(a||b),seen[{idx,curr}]=true;
| ^~~
a.cc:26:39: error: 'seen' was not declared in this scope
26 | return val[{idx,curr}]=(a||b),seen[{idx,curr}]=true;
| ^~~~
a.cc: In function 'int main()':
a.cc:32:9: error: 'ios_base' has not been declared
32 | ios_base::sync_with_stdio(0);
| ^~~~~~~~
a.cc:33:9: error: 'cin' was not declared in this scope
33 | cin.tie(0);
| ^~~
a.cc:34:9: error: 'cout' was not declared in this scope
34 | cout.tie(0);
| ^~~~
a.cc:35:9: error: 'string' was not declared in this scope
35 | string s;
| ^~~~~~
a.cc:36:14: error: 's' was not declared in this scope
36 | cin>>s;
| ^
|
s567505493 | p03856 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
string s;
cin >> s;
for(int i=0;i<s.size();i++){
int f = 0;
if(s.substr(i,i+6) == "dreamer" && s.substr(i+5,i+9) != "erase"){
i += 6;
f = 1;
}
if(s.substr(i,i+5) == "eraser" && f == 0){
i += 5
f =1;
}
if((s.substr(i,i+4) == "dream" || s.substr(i,i+4) == "erase") && f == 0){
i += 4;
f = 1;
}
if(f == 0){
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:19: error: expected ';' before 'f'
19 | i += 5
| ^
| ;
20 | f =1;
| ~
|
s109536453 | p03856 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
string s;
cin >> s;
for(int i=0;i<s.size();i++){
int f = 0;
if(s.substr(i,i+6) == "dreamer" && s.substr(i+5,i+9) != "erase"){
i += 6;
f = 1;
}
if(s.substr(i,i+5) == "eraser" && f == 0;){
i += 5
f =1;
}
if((s.substr(i,i+4) == "dream" || s.substr(i,i+4) == "erase") && f == 0;){
i += 4;
f = 1;
}
if(f == 0){
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:50: error: expected primary-expression before ')' token
18 | if(s.substr(i,i+5) == "eraser" && f == 0;){
| ^
a.cc:19:19: error: expected ';' before 'f'
19 | i += 5
| ^
| ;
20 | f =1;
| ~
a.cc:22:81: error: expected primary-expression before ')' token
22 | if((s.substr(i,i+4) == "dream" || s.substr(i,i+4) == "erase") && f == 0;){
| ^
|
s133620619 | p03856 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
string s;
cin >> s;
fot(int i=0;i<s.size();i++){
int f = 0;
if(s.substr(i,i+6) == "dreamer" && s.substr(i+5,i+9) != "erase"){
i += 6;
f = 1;
}
if(s.substr(i,i+5) == "eraser" && f == 0;){
i += 5
f =1;
}
if((s.substr(i,i+4) == "dream" || s.substr(i,i+4) == "erase") && f == 0;){
i += 4;
f = 1;
}
if(f == 0){
cout << "NO" << endl;
return 0;
}
}
cout << "YES" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:9: error: expected primary-expression before 'int'
12 | fot(int i=0;i<s.size();i++){
| ^~~
a.cc:12:17: error: 'i' was not declared in this scope
12 | fot(int i=0;i<s.size();i++){
| ^
|
s107881739 | p03856 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
using namespace std;
bool prime(int n){
if(n==1){
return false;
}else if(n==2){
return true;
}else{
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
}
long long gcd(long long a, long long b){
if(a<b){
swap(a,b);
}
if(a%b==0){
return b;
}else{
return gcd(b,a%b);
}
}
long long lcm(long long x, long long y){
return (x/gcd(x,y))*y;
}
class UnionFind {
public:
//各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
vector<int> Parent;
//クラスを作るときは、Parentの値を全て-1にする。
//以下のようにすると全てバラバラの頂点として解釈できる。
UnionFind(int N) {
Parent = vector<int>(N, -1);
}
//Aがどのグループに属しているか調べる
int root(int A) {
if (Parent[A] < 0) return A;
return Parent[A] = root(Parent[A]);
}
//自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)];//先祖をrootで取っておきたい。
}
//AとBをくっ付ける
bool connect(int A, int B) {
//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
A = root(A);
B = root(B);
if (A == B) {
//すでにくっついてるからくっ付けない
return false;
}
//大きい方(A)に小さいほう(B)をくっ付けたい
//大小が逆だったらAとBをひっくり返す。
if (size(A) < size(B)) swap(A, B);
//Aのサイズを更新する
Parent[A] += Parent[B];
//Bの親をAに変更する
Parent[B] = A;
return true;
}
};
int main(){
string s;
cin>>s;
int len=s.size();
int cur=0;
string sub[]={"dreamer","eraser","dream","erase"};
bool flag=false;
while(cur<len){
REP(i,4){
if(s.substr(cur,(int)sub[i].size())==s[i]){
cur += (int)sub[i].size();
flag = true;
break;
}
}
if(flag){
continue;
}else{
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:98:42: error: no match for 'operator==' (operand types are 'std::__cxx11::basic_string<char>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'})
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1103 | operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1199 | operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1274 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1366 | operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1441 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1534 | operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1613 | operator==(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2186 | operator==(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1033 | operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::pair<_T1, _T2>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
441 | operator==(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
486 | operator==(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1667 | operator==(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::move_iterator<_IteratorL>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1737 | operator==(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::move_iterator<_IteratorL>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
192 | operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::fpos<_StateT>'
98 | if(s.substr(cur,(int)sub[i].size())==s[i]){
| ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
235 | operator==(const allocator<_T1>&, const allocator<_T2>&)
| ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note: template argument deduction/substitution failed:
a.cc:98:47: note: 'std::__cxx11::basic_string<char>' is not derived from 'const std::al |
s938727278 | p03856 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
using namespace std;
bool prime(int n){
if(n==1){
return false;
}else if(n==2){
return true;
}else{
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
}
long long gcd(long long a, long long b){
if(a<b){
swap(a,b);
}
if(a%b==0){
return b;
}else{
return gcd(b,a%b);
}
}
long long lcm(long long x, long long y){
return (x/gcd(x,y))*y;
}
class UnionFind {
public:
//各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
vector<int> Parent;
//クラスを作るときは、Parentの値を全て-1にする。
//以下のようにすると全てバラバラの頂点として解釈できる。
UnionFind(int N) {
Parent = vector<int>(N, -1);
}
//Aがどのグループに属しているか調べる
int root(int A) {
if (Parent[A] < 0) return A;
return Parent[A] = root(Parent[A]);
}
//自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)];//先祖をrootで取っておきたい。
}
//AとBをくっ付ける
bool connect(int A, int B) {
//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
A = root(A);
B = root(B);
if (A == B) {
//すでにくっついてるからくっ付けない
return false;
}
//大きい方(A)に小さいほう(B)をくっ付けたい
//大小が逆だったらAとBをひっくり返す。
if (size(A) < size(B)) swap(A, B);
//Aのサイズを更新する
Parent[A] += Parent[B];
//Bの親をAに変更する
Parent[B] = A;
return true;
}
};
int main(){
string s;
cin>>s;
int len=s.size();
int cur=0;
string sub[]={"dreamer","eraser","dream","erase"};
bool flag=false;
while(cur<len){
REP(i,4){
if(s.substr(cur,(int)sub[i].size)==s[i]){
cur += (int)sub[i].size();
flag = true;
break;
}
}
if(flag){
continue;
}else{
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:98:35: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
98 | if(s.substr(cur,(int)sub[i].size)==s[i]){
| ~~~~~~~^~~~
| ()
|
s641901726 | p03856 | C++ | #include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
long long c=a%i_7;
if(c>=0)return c;
return c+i_7;
}
using namespace std;
bool prime(int n){
if(n==1){
return false;
}else if(n==2){
return true;
}else{
for(int i=2;i<=sqrt(n);i++){
if(n%i==0){
return false;
}
}
return true;
}
}
long long gcd(long long a, long long b){
if(a<b){
swap(a,b);
}
if(a%b==0){
return b;
}else{
return gcd(b,a%b);
}
}
long long lcm(long long x, long long y){
return (x/gcd(x,y))*y;
}
class UnionFind {
public:
//各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
vector<int> Parent;
//クラスを作るときは、Parentの値を全て-1にする。
//以下のようにすると全てバラバラの頂点として解釈できる。
UnionFind(int N) {
Parent = vector<int>(N, -1);
}
//Aがどのグループに属しているか調べる
int root(int A) {
if (Parent[A] < 0) return A;
return Parent[A] = root(Parent[A]);
}
//自分のいるグループの頂点数を調べる
int size(int A) {
return -Parent[root(A)];//先祖をrootで取っておきたい。
}
//AとBをくっ付ける
bool connect(int A, int B) {
//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
A = root(A);
B = root(B);
if (A == B) {
//すでにくっついてるからくっ付けない
return false;
}
//大きい方(A)に小さいほう(B)をくっ付けたい
//大小が逆だったらAとBをひっくり返す。
if (size(A) < size(B)) swap(A, B);
//Aのサイズを更新する
Parent[A] += Parent[B];
//Bの親をAに変更する
Parent[B] = A;
return true;
}
};
int main(){
string s;
cin>>s;
int len=s.size();
int cur=0;
string sub[]={"dreamer","eraser","dream","erase"};
bool flag=false;
while(cur<len){
REP(i,4){
if(s.substr(cur,(int)sub[i].size)==s[i]){
cur += (int)sub[i].size;
flag = true;
break;
}
}
if(flag){
continue;
}else{
cout<<"NO"<<endl;
return 0;
}
}
cout<<"YES"<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:98:35: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
98 | if(s.substr(cur,(int)sub[i].size)==s[i]){
| ~~~~~~~^~~~
| ()
a.cc:99:28: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
99 | cur += (int)sub[i].size;
| ~~~~~~~^~~~
| ()
|
s724382761 | p03856 | C++ | #include<stdio.h>
#include<string.h>
int main()
{
char c[100006],d[2][6]={"dream","erase"};
long long i,l,n,m,o;
gets(c);
l=strlen(c);
for(i=0;i<l;)
{
if(c[i]=='d')
{
for(o=1;o<5;o++)
{
if(d[0][o]==c[i+o])continue;
else break;
}
if(o<5)break;
if(c[i+5]=='e'&&c[i+6]=='r')
{
if(c[i+7]=='a'){
i=i+5;
}
else i=i+7;
}
else i=i+5;
}
else if(c[i]=='e')
{
for(o=1;o<5;o++)
{
if(d[1][o]==c[i+o])continue;
else break;
}
if(o<5)break;
if(c[i+5]=='r') i=i+6;
else i=i+5;
}
else break;
}
if(i==l)printf("YES");
else printf("NO");
}
| a.cc: In function 'int main()':
a.cc:7:9: error: 'gets' was not declared in this scope; did you mean 'getw'?
7 | gets(c);
| ^~~~
| getw
|
s193941652 | p03856 | C++ | include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int>
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;
signed main() {
string r[4] = { "dream", "dreamer", "erase", "eraser" };
string s, t = "";
cin >> s;
bool f = true;
int i = s.size() - 1;
while (i >= 0) {
string t1 = s.substr(i - 4, 5);
// cout << t1 << endl;
if (t1 == r[0] || t1 == r[2]) {
i -= 5;
continue;
}
string t2 = s.substr(i - 5, 6);
// cout << t2 << endl;
if (t2 == r[3]) {
i -= 6;
continue;
}
string t3 = s.substr(i - 6, 7);
if (t3 == r[1]) {
i -= 7;
continue;
}
f = false;
break;
}
cout << (f ? "YES" : "NO") << endl;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<stdio.h>
| ^~~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/stdlib.h:32,
from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/stdlib.h:36,
from a.cc:2:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'si |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.