submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s313530302 | p03726 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <cmath>
#include <list>
#include <chrono>
#include <thread>
using namespace std;
const bool debug = false;
#ifndef M_PI
const double M_PI = acos(-1.0);
#endif // M_PI
#define y1 roman_kaban
#define rank oryshych_konb
#define ull unsigned long long
//#define ll long long
//const int mod = int(1e9) + 7;
//const int inf = 1e9;
//const long long infLL = 1e11;
//const int MX2 = 10100500; // e7
//const long long INF = 1e18 + 0.5;
const int MX = 200500; // e5
//const int SZ = 1100;
//const int delta = 1 << 19;
vector<int> e[MX];
bool is_dead[MX];
int b[MX];
int z[MX];
int n;
bool check_string(){
for(int i = 1; i <= n; i++){
if(e[i].size() > 2) return false;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
//if(debug)
//freopen("/Users/ozzy/Documents/in.txt","r", stdin);
cin >> n;
for(int i = 0; i < n - 1; i++){
int u, v;
cin >> u >> v;
e[u].push_back(v);
e[v].push_back(u);
}
if(check_string()){
if(n & 1){cout << "First\n"; } else cout << "Second\n";
//cerr << "cr";
return 0;
}
list<int>leafs;
for(int i = 1; i <= n; i++){
if(e[i].size() == 1){
leafs.push_back(i);
is_dead[i] = true;
}
b[i] = e[i].size();
}
while(leafs.begin() != leafs.end()){
int u = leafs.front();
leafs.pop_front();
int cnt = 0;
while(b[u] == 1 && !is_not_leaf[u]){
bool fl = false;
for(int i = 0; i < e[u].size(); i++){
int v = e[u][i];
if(!is_dead[v]){
u = v;
is_dead[u] = true;
b[u]--;
fl = true;
break;
}
}
if(!fl) {cout << "Second\n"; return 0;}
cnt++;
}
if(cnt & 1) z[u]++;
if(z[u] > 1) {cout << "First\n"; return 0;}
if(b[u] == 1) {leafs.push_back(u); is_dead[u] = true;}
}
cout << "Second\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:78:29: error: 'is_not_leaf' was not declared in this scope
78 | while(b[u] == 1 && !is_not_leaf[u]){
| ^~~~~~~~~~~
|
s963135213 | p03726 | C++ | #pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <stack>
#include <iostream>
#include <fstream>
#define mp make_pair
#define pb push_back
using ll = long long;
using ld = long double;
using namespace std;
const int MAXN = 200001;
set <int> e[MAXN];
int q[MAXN], qe = 0;
void eredge(int x, int y) {
e[x].erase(y);
if (e[x].empty()) {
cout << "First" << endl;
exit(0);
}
if (e[x].size() == 1) q[qe++] = x;
}
int main() {
//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
ios_base::sync_with_stdio(0); cout.setf(ios::fixed); cout.precision(20);
int n;
cin >> n;
for (int i = 1; i < n; i++) {
int a, b;
cin >> a >> b;
e[a].insert(b);
e[b].insert(a);
}
for (int i = 1; i <= n; i++) {
if (e[i].size() == 1) q[qe++] = i;
}
for% (int qb = 0; qb < qe; qb++) {
int v = q[qb];
int v2 = *e[v].begin();
for (int u : e[v2]) {
if (u != v)
eredge(u, v2);
}
}
cout << "Second" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:63:12: error: expected '(' before '%' token
63 | for% (int qb = 0; qb < qe; qb++) {
| ^
| (
a.cc:63:12: error: expected primary-expression before '%' token
a.cc:63:15: error: expected primary-expression before 'int'
63 | for% (int qb = 0; qb < qe; qb++) {
| ^~~
a.cc:63:15: error: expected ')' before 'int'
63 | for% (int qb = 0; qb < qe; qb++) {
| ~^~~
| )
a.cc:63:27: error: 'qb' was not declared in this scope; did you mean 'qe'?
63 | for% (int qb = 0; qb < qe; qb++) {
| ^~
| qe
|
s813979772 | p03726 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
typedef long long ll;
#define fi first
#define se second
using namespace std;
///////////////////////////////////////
//
//
///////////////////////////////////////
//
int N;
int jd = 0;
int A;
int B;
int a[112345];
int b[112345];
int cnt[112345];
int jdg[112345];
ll idx[112345];
int next;
int bef;
int j;
int main(){
cin>>N;
fill( cnt, cnt+N+1, 0 );
fill( jdg, jdg+N+1, 0 );
int i;
for( i = 1; i < N; i++ ){
scanf("%d %d", &A, &B);
cnt[A]++;
cnt[B]++;
if( cnt[A] == 1 ) idx[A] = B*100000;
if( cnt[B] == 1 ) idx[B] = A*100000;
if( cnt[A] == 2 ) idx[A] += B%100000;
if( cnt[B] == 2 ) idx[B] += A%100000;
if( cnt[A] > 2 ) idx[A] = 0;
if( cnt[B] > 2 ) idx[B] = 0;
}
for( i = 1; i <= N; i++ ){
if( cnt[i] == 1 ){
j = 1;
bef = i;
next = idx[i]/100000;
while( next ){
if( cnt[next] == 2 ){
if ( j%2 ) jdg[next]++;
A = idx[next]/100000;
B = idx[next]%100000;
if( B == 0 ) B = 100000;
bef = next;
if( B != bef ) next = B;
if( A != bef ) next = A;
j++;
}
else{
next = 0;
}
}
}
}
for( i = 1; i <= N; i++ ){
if( jdg[i] > 1 ) jd = 1;
}
if( jd ) puts("First");
else{ puts("Second");}
return 0;
} | a.cc: In function 'int main()':
a.cc:58:7: error: reference to 'next' is ambiguous
58 | next = idx[i]/100000;
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:59:14: error: reference to 'next' is ambiguous
59 | while( next ){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:60:17: error: reference to 'next' is ambiguous
60 | if( cnt[next] == 2 ){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:61:26: error: reference to 'next' is ambiguous
61 | if ( j%2 ) jdg[next]++;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:62:19: error: reference to 'next' is ambiguous
62 | A = idx[next]/100000;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:63:19: error: reference to 'next' is ambiguous
63 | B = idx[next]%100000;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:65:17: error: reference to 'next' is ambiguous
65 | bef = next;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:66:26: error: reference to 'next' is ambiguous
66 | if( B != bef ) next = B;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:67:26: error: reference to 'next' is ambiguous
67 | if( A != bef ) next = A;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:71:11: error: reference to 'next' is ambiguous
71 | next = 0;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
|
s705036542 | p03726 | C++ | #include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n;
vector<int> G[100001];
int cnt[100001];
bool used[100001];
bool good[100001];
int dfs(int v){
used[v]=true;
if(G[v].size()>=3){
used[v]=false;
if(cnt[v]>=1)return 1;
return -1000000;
}
for(int i=0;i<G[v].size();i++){
if(!used[G[v][i]]){
return (dfs(G[v][i])+1);
}
}
}
void dfs2(int v,int d){
used[v]=true;
if(G[v].size()>=3){
used[v]=false;
if(d%2==1)good[v]=true;
return;
}
for(int i=0;i<G[v].size();i++){
if(!used[G[v][i]]){
dfs2(G[v][i],d+1);
}
}
}
int main(void){
scanf("%d",&n);
for(int i=0;i<n-1;i++){
int a,b;
scanf("%d%d",&a,&b);
a--;
b--;
G[a].push_back(b);
G[b].push_back(a);
}
for(int i=0;i<n;i++){
if(G[i].size()==1){
cnt[G[i][0]]++;
}
}
for(int i=0;i<n;i++){
if(cnt[i]>=2){
printf("First\n");
return 0;
}
}
int on=0,se=0;
bool flag=true;
for(int i=0;i<n;i++){
if(G[i].size()==1){
on++;
}
if(G[i].size()==2){
se++;
}
if(G[i].size()>2){
flag=false;
}
}
if(flag && on==2 && se==n-2){
printf("%s\n",n%2==1?"First":"Second");
return 0;
}
for(int i=0;i<n;i++){
if(!used[i] && G[i].size()==1){
if(dfs(i)==4){
printf("First\n");
return 0;
}
}
}
memset(used,false,sizeof(used));
for(int i=0;i<n;i++){
if(cnt[i]==1 || G[i][j].size()>=3){
for(int j=0;j<G[i].size();j++){
if(used[G[i][j]] && G[G[i][j]].size()==2){
printf("First\n");
return 0;
}
used[G[i][j]]=true;
}
}
}
memset(used,false,sizeof(used));
memset(good,false,sizeof(good));
/*
for(int i=0;i<n;i++){
if(!used[i] && G[i].size()==1){
dfs2(i,0);
}
}
for(int i=0;i<n;i++){
if(G[i].size()>=3 && !good[i]){
printf("First\n");
return 0;
}
}*/
printf("Second\n");
return 0;
}
| a.cc: In function 'int main()':
a.cc:100:38: error: 'j' was not declared in this scope
100 | if(cnt[i]==1 || G[i][j].size()>=3){
| ^
a.cc: In function 'int dfs(int)':
a.cc:36:1: warning: control reaches end of non-void function [-Wreturn-type]
36 | }
| ^
|
s058998927 | p03726 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
int N;
vi g[100010];
int c[100010];
int st[100010];
bool ok;
void dfs(int v, int p)
{
int s = 0;
int c = 0;
int codd = 0;
int ceven = 0;
bool only_path = 1;
for (int to : g[v]) {
if (to != p) {
dfs(to, v);
if (st[to] == 0) {
++codd;
} else if (st[to] == 1) {
++ceven;
} else {
only_path = 0;
}
if (c) {
s = -1;
} else {
if (st[to] == -1) {
s = -1;
} else {
s = (st[to] ^ 1);
}
}
++c;
}
}
st[v] = s;
if (codd >= 2 || (onlypath && ceven > 0 && codd == 0)) {
ok = 1;
}
//cout<<v<<" " << st[v] << endl;
}
int main() {
scanf("%d", &N);
rep(i, N-1) {
int a, b;
scanf("%d%d", &a, &b);
--a; --b;
g[a].pb(b); g[b].pb(a);
}
int r = -1;
rep(i, N) if (g[i].size() >= 3) {
r = i;
break;
}
if (r == -1) {
ok = N & 1;
} else {
// cout<<r<<endl;
dfs(r, -1);
}
puts(ok ? "First" : "Second");
return 0;
} | a.cc: In function 'void dfs(int, int)':
a.cc:59:27: error: 'onlypath' was not declared in this scope; did you mean 'only_path'?
59 | if (codd >= 2 || (onlypath && ceven > 0 && codd == 0)) {
| ^~~~~~~~
| only_path
|
s598720648 | p03726 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
typedef long long ll;
#define fi first
#define se second
using namespace std;
///////////////////////////////////////
//
//
///////////////////////////////////////
//
int N;
int jd = 0;
int A;
int B;
int a[112345];
int b[112345];
int cnt[112345];
int jdg[112345];
ll idx[112345];
int next;
int bef;
int j;
int main(){
cin>>N;
fill( cnt, cnt+N+1, 0 );
fill( jdg, jdg+N+1, 0 );
int i;
for( i = 1; i < N; i++ ){
scanf("%d %d", &A, &B);
cnt[A]++;
cnt[B]++;
if( cnt[A] == 1 ) idx[A] = B*100000;
if( cnt[B] == 1 ) idx[B] = A*100000;
if( cnt[A] == 2 ) idx[A] += B%100000;
if( cnt[B] == 2 ) idx[B] += A%100000;
if( cnt[A] > 2 ) idx[A] = 0;
if( cnt[B] > 2 ) idx[B] = 0;
}
for( i = 1; i <= N; i++ ){
if( cnt[i] == 1 ){
j = 1;
bef = i;
next = idx[i]/100000;
while( next ){
if ( j%2 ) jdg[next]++;
A = idx[next]/100000;
B = idx[next]%100000;
if( B = 0 ) B = 100000;
bef = next;
if( A != bef ) next = A;
if( B != bef ) next = B;
j++;
}
}
}
for( i = 1; i <= N; i++ ){
if( jdg[i] > 1 ) jd = 1;
}
if( jd ) puts("First");
else{ puts("Second");}
return 0;
} | a.cc: In function 'int main()':
a.cc:58:7: error: reference to 'next' is ambiguous
58 | next = idx[i]/100000;
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:59:14: error: reference to 'next' is ambiguous
59 | while( next ){
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:60:24: error: reference to 'next' is ambiguous
60 | if ( j%2 ) jdg[next]++;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:61:17: error: reference to 'next' is ambiguous
61 | A = idx[next]/100000;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:62:17: error: reference to 'next' is ambiguous
62 | B = idx[next]%100000;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:64:15: error: reference to 'next' is ambiguous
64 | bef = next;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:65:24: error: reference to 'next' is ambiguous
65 | if( A != bef ) next = A;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
a.cc:66:24: error: reference to 'next' is ambiguous
66 | if( B != bef ) next = B;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:29:5: note: 'int next'
29 | int next;
| ^~~~
|
s123826388 | p03726 | C++ | #include <bits/stdc++.h>
using namespace std;
#define mp(x, y) make_pair((x), (y))
typedef long long ll;
int n;
set<int> nex[100005];
int d[100005];
int l[100005];
int beg, end;
int m[100005];
int main()
{
scanf("%d", &n);
if(n%2==1) {
printf("First\n");
return 0;
}
for(int i=0; i<n-1; i++) {
int u, v;
scanf("%d%d", &u, &v);
u--; v--;
nex[u].insert(v);
nex[v].insert(u);
d[u]++;
d[v]++;
}
for(int i=0; i<n; i++) {
if(d[i]==1) {
l[end++]=i;
}
}
while(beg<end) {
int cur=l[beg++];
if(m[cur]) continue;
m[cur]=1;
int nei=*nex[cur].begin();
if(m[nei]) {
printf("First\n");
return 0;
} else {
m[nei]=1;
for(set<int>::iterator it=nex[nei].begin(); it!=nex[nei].end(); it++) {
nex[*it].erase(nei);
if(nex[*it].size()==1) {
l[end++]=*it;
}
}
}
}
printf("Second\n");
return 0;
} | a.cc: In function 'int main()':
a.cc:33:27: error: reference to 'end' is ambiguous
33 | l[end++]=i;
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
In file included from /usr/include/c++/14/bits/algorithmfwd.h:39,
from /usr/include/c++/14/bits/stl_algo.h:59,
from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:12:10: note: 'int end'
12 | int beg, end;
| ^~~
a.cc:36:19: error: reference to 'end' is ambiguous
36 | while(beg<end) {
| ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:12:10: note: 'int end'
12 | int beg, end;
| ^~~
a.cc:49:43: error: reference to 'end' is ambiguous
49 | l[end++]=*it;
| ^~~
/usr/include/c++/14/valarray:1265:5: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
1265 | end(const valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/valarray:1249:5: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
1249 | end(valarray<_Tp>& __va) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
106 | end(_Tp (&__arr)[_Nm]) noexcept
| ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
85 | end(const _Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
74 | end(_Container& __cont) -> decltype(__cont.end())
| ^~~
/usr/include/c++/14/initializer_list:99:5: note: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
99 | end(initializer_list<_Tp> __ils) noexcept
| ^~~
a.cc:12:10: note: 'int end'
12 | int beg, end;
| ^~~
|
s739677786 | p03726 | C++ | #include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int N=100010;
int e[N*2],next[N*2],head[N],ed=0;
int d[N];
void adde(int x,int y){e[++ed]=y;next[ed]=head[x];head[x]=ed;}
int main(){
int n,x,y,i,j,sum;
scanf("%d",&n);
for(i=1;i<n;i++){
scanf("%d %d",&x,&y);
adde(x,y);adde(y,x);
d[x]++;d[y]++;
}
for(i=1;i<=n;i++){
sum=0;
for(j=head[i];j;j=next[j])
if(d[e[j]]==1) sum++;
if(sum>=2){printf("First\n");return 0;}
}
printf("Second\n");
return 0;
}
| a.cc: In function 'void adde(int, int)':
a.cc:12:34: error: reference to 'next' is ambiguous
12 | void adde(int x,int y){e[++ed]=y;next[ed]=head[x];head[x]=ed;}
| ^~~~
In file included from /usr/include/c++/14/string:47,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:10:12: note: 'int next [200020]'
10 | int e[N*2],next[N*2],head[N],ed=0;
| ^~~~
a.cc: In function 'int main()':
a.cc:23:27: error: reference to 'next' is ambiguous
23 | for(j=head[i];j;j=next[j])
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:10:12: note: 'int next [200020]'
10 | int e[N*2],next[N*2],head[N],ed=0;
| ^~~~
|
s015216136 | p03726 | C++ | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define For(n) for(int i = 0; i < n; i++)
#define FOR(i, r, k) for(int i = r; i < k; i ++)
#define pb push_back
#define X first
#define Y second
#define mp make_pair
const ll maxn = 1e5 + 244;
const ll mod = 1e9 + 7;
const ll inf = 1e18 + 500;
ll l[maxn];
bool b[maxn];
vector < ll > g[maxn];
int main()
{
ll n, m;
cin >> n;
m = n - 1;
For(m)
{
int u, v;
cin >> u >> v;
g[u].pb(v);
g[v].pb(u);
}
if(n & 1)
{
cout << "First";
return 0;
}
For(n)
{
if(g[i + 1].size() == 1)
{
b[i + 1] = 1;
}
}
For(n)
{
int x = 0;
for(int j = 0; j < g[i + 1].size(); j++)
{
if(b[g[i + 1][j]])
x ++;
}
if(x >= 2)
{
cout << "First";
return 0;
}
}
// momkene first she:)
else cout << "Second";
return 0;
}
| a.cc: In function 'int main()':
a.cc:55:5: error: 'else' without a previous 'if'
55 | else cout << "Second";
| ^~~~
|
s171975118 | p03726 | C++ | #include <bits/stdc++.h>
#define ll long long
#define fr first
#define ii pair<int,int>
#define sc second
#define mp make_pair
#define All(v) v.begin(),v.end()
using namespace std;
vector < int > v[300000];
int main()
{
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
int x,y;
scanf("%d%d",&x,&y);
v[x].push_back(y);
v[y].push_back(x);
}
int ok = 0;
for(int i=0;i<n;i++)
{
int ans = 0;
for(int j=0;j<v[i].size();j++)
{
if(v[i][j].size() < 3)
{
ans++;
}
}
if(ans > 1)
ok = 1;
}
if(ok)
cout<<"First";
else
cout<<"Secound";
}
| a.cc: In function 'int main()':
a.cc:27:19: error: request for member 'size' in 'v[i].std::vector<int>::operator[](((std::vector<int>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}
27 | if(v[i][j].size() < 3)
| ^~~~
|
s741382756 | p03726 | C++ | #include <bIts/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
vector <int> a[N];
int cou(int u) {
int res = 0;
for (int i = 0; i < a[u].size(); i++) {
int v = a[u][i];
if (a[v].size() == 1) res++;
}
return res;
}
int main() {
scanf("%d", &n);
for (int i = 1; i < n; i++) {
int x, y; scanf("%d %d", &x, &y);
a[x].push_back(y);
a[y].push_back(x);
}
for (int i = 1; i <= n; i++) {
if (cou(i) >= 2) {
cout << "First" << endl;
return 0;
}
}
cout << "Second" << endl;
}
| a.cc:1:10: fatal error: bIts/stdc++.h: No such file or directory
1 | #include <bIts/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s430899762 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N];
vector<int> g[N];
int tot = -1, dfn[N], fa[N], dep[N], sz[N], son[N], top[N];
void pre(int u) {
sz[u] = 1;
for (auto v : g[u]) {
if (v ^ fa[u]) {
dep[v] = dep[u] + 1;
fa[v] = u;
pre(v);
sz[u] += sz[v];
if (sz[son[u]] < sz[v]) {
son[u] = v;
}
}
}
}
void dfs(int u) {
dfn[u] = ++tot;
if (son[u]) {
top[son[u]] = top[u];
dfs(son[u]);
}
for (auto v : g[u]) {
if ((v ^ fa[u]) && (v ^ son[u])) {
top[v] = v;
dfs(v);
}
}
}
struct Data {
int val, cnt, pos;
inline void operator += (const Data &rhs) {
val ^= rhs.val;
cnt += rhs.cnt;
}
inline Data operator + (const Data &rhs) {
if (cnt < rhs.cnt) {
return *this;
} else {
return rhs;
}
}
};
struct node {
Data info, tag;
} t[N << 2];
void build(int p, int l, int r) {
t[p].info.pos = l;
if (l ^ r) {
int mid = l + r >> 1;
build(p << 1, l, mid);
build(p << 1 | 1, mid + 1, r);
}
}
inline void pushup(int p) {
t[p].info = t[p << 1].info + t[p << 1 | 1].info;
}
inline void tag(int p, Data add) {
t[p].info += add;
t[p].tag += add;
}
inline void pushdown(int p) {
if (t[p].tag.cnt || t[p].tag.val) {
tag(p << 1, t[p].tag);
tag(p << 1 | 1, t[p].tag);
t[p].tag = (Data) {0, 0};
}
}
void modify(int p, int l, int r, int L, int R, Data add) {
if (l >= L && r <= R) {
tag(p, add);
return;
}
pushdown(p);
int mid = l + r >> 1;
if (mid >= L) {
modify(p << 1, l, mid, L, R, add);
}
if (mid < R) {
modify(p << 1 | 1, mid + 1, r, L, R, add);
}
pushup(p);
}
inline void modify(int u, int v, Data add) {
while (top[u] != top[v]) {
if (dep[top[u]] < dep[top[v]]) {
swap(u, v);
}
modify(1, 1, tot, dfn[top[u]], dfn[u], add);
u = fa[top[u]];
}
if (u ^ v) {
if (dep[u] > dep[v]) {
swap(u, v);
}
modify(1, 1, tot, dfn[u] + 1, dfn[v], add);
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i < n; ++i) {
int u, v;
scanf("%d%d", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
}
pre(1);
top[1] = 1;
dfs(1);
build(1, 1, tot);
for (int i = 1; i < n; ++i) {
scanf("%d%d", &a[i], &b[i]);
modify(a[i], b[i], (Data) {i, 1});
}
for (int i = 1; i < n; ++i) {
int cnt = t[1].info.cnt;
int idx = t[1].info.val;
int pos = t[1].info.pos;
if (cnt ^ 1) {
puts("NO");
return 0;
}
modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
modify(a[idx], b[idx], (Data) {idx, -1});
}
puts("YES");
return 0;
} | a.cc: In function 'int main()':
a.cc:127:44: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
127 | modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
| ^~~
|
s579448200 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N];
vector<int> g[N];
int tot = -1, dfn[N], fa[N], dep[N], sz[N], son[N], top[N];
void pre(int u) {
sz[u] = 1;
for (auto v : g[u]) {
if (v ^ fa[u]) {
dep[v] = dep[u] + 1;
fa[v] = u;
pre(v);
sz[u] += sz[v];
if (sz[son[u]] < sz[v]) {
son[u] = v;
}
}
}
}
void dfs(int u) {
dfn[u] = ++tot;
if (son[u]) {
top[son[u]] = top[u];
dfs(son[u]);
}
for (auto v : g[u]) {
if ((v ^ fa[u]) && (v ^ son[u])) {
top[v] = v;
dfs(v);
}
}
}
struct Data {
int val, cnt, pos;
inline void operator += (const Data &rhs) {
val ^= rhs.val;
cnt += rhs.cnt;
}
inline Data operator + (const Data &rhs) {
if (cnt < rhs.cnt) {
return *this;
} else {
return rhs;
}
}
};
struct node {
Data info, tag;
} t[N << 2];
void build(int p, int l, int r) {
t[p].info.pos = l;
if (l ^ r) {
int mid = l + r >> 1;
build(p << 1, l, mid);
build(p << 1 | 1, mid + 1, r);
}
}
inline void pushup(int p) {
t[p].info = t[p << 1].info + t[p << 1 | 1].info;
}
inline void tag(int p, Data add) {
t[p].info += add;
t[p].tag += add;
}
inline void pushdown(int p) {
if (t[p].tag.cnt || t[p].tag.val) {
tag(p << 1, t[p].tag);
tag(p << 1 | 1, t[p].tag);
t[p].tag = (Data) {0, 0};
}
}
void modify(int p, int l, int r, int L, int R, Data add) {
if (l >= L && r <= R) {
tag(p, add);
return;
}
pushdown(p);
int mid = l + r >> 1;
if (mid >= L) {
modify(p << 1, l, mid, L, R, add);
}
if (mid < R) {
modify(p << 1 | 1, mid + 1, r, L, R, add);
}
pushup(p);
}
inline void modify(int u, int v, Data add) {
while (top[u] != top[v]) {
if (dep[top[u]] < dep[top[v]]) {
swap(u, v);
}
modify(1, 1, tot, dfn[top[u]], dfn[u], add);
u = fa[top[u]];
}
if (u ^ v) {
if (dep[u] > dep[v]) {
swap(u, v);
}
modify(1, 1, tot, dfn[u] + 1, dfn[v], add);
}
}
int main() {
freopen("in.txt", "r", stdin);
scanf("%d", &n);
for (int i = 1; i < n; ++i) {
int u, v;
scanf("%d%d", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
}
pre(1);
top[1] = 1;
dfs(1);
build(1, 1, tot);
for (int i = 1; i < n; ++i) {
scanf("%d%d", &a[i], &b[i]);
modify(a[i], b[i], (Data) {i, 1});
}
for (int i = 1; i < n; ++i) {
int cnt = t[1].info.cnt;
int idx = t[1].info.val;
int pos = t[1].info.pos;
if (cnt ^ 1) {
printf("i = %d\n", i);
puts("NO");
return 0;
}
modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
modify(a[idx], b[idx], (Data) {idx, -1});
}
puts("YES");
return 0;
} | a.cc: In function 'int main()':
a.cc:129:44: error: narrowing conversion of '1.0e+9' from 'double' to 'int' [-Wnarrowing]
129 | modify(1, 1, tot, pos, pos, (Data) {0, 1e9});
| ^~~
|
s753487586 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N];
vector<int> g[N];
int tot, dfn[N], fa[N], dep[N], sz[N], son[N], top[N];
void pre(int u) {
sz[u] = 1;
for (auto v : g[u]) {
if (v ^ fa[u]) {
dep[v] = dep[u] + 1;
fa[v] = u;
pre(v);
sz[u] += sz[v];
if (sz[son[u]] < sz[v]) {
son[u] = v;
}
}
}
}
void dfs(int u) {
if (son[u]) {
top[son[u]] = top[u];
dfn[son[u]] = ++tot;
dfs(son[u]);
}
for (auto v : g[u]) {
if ((v ^ fa[u]) && (v ^ son[u])) {
top[v] = v;
dfn[v] = ++tot;
dfs(v);
}
}
}
struct data {
int val, cnt;
inline void operator += (const data &rhs) {
val ^= rhs.val;
cnt += rhs.cnt;
}
inline data operator + (const data &rhs) {
if (cnt < rhs.cnt) {
return *this;
} else {
return rhs;
}
}
};
struct node {
data info, tag;
} t[N << 2];
inline void pushup(int p) {
t[p].info = t[p << 1].info + t[p << 1 | 1].info;
}
inline void tag(int p, data add) {
t[p].info += add;
t[p].tag += add;
}
inline void pushdown(int p) {
if (t[p].tag.cnt) {
tag(p << 1, t[p].tag);
tag(p << 1 | 1, t[p].tag);
t[p].tag = (data) {0, 0};
}
}
void modify(int p, int l, int r) {
if (l == r) {
t[p].info.cnt = 1e9;
return;
}
pushdown(p);
int mid = l + r >> 1;
if (t[p << 1].info.cnt == 1) {
modify(p << 1, l, mid);
} else {
modify(p << 1 | 1, mid + 1, r);
}
pushup(p);
}
void modify(int p, int l, int r, int L, int R, data add) {
if (l >= L && r <= R) {
tag(p, add);
return;
}
pushdown(p);
int mid = l + r >> 1;
if (mid >= L) {
modify(p << 1, l, mid, L, R, add);
}
if (mid < R) {
modify(p << 1 | 1, mid + 1, r, L, R, add);
}
pushup(p);
}
inline void modify(int u, int v, data add) {
while (top[u] != top[v]) {
if (dep[u] < dep[v]) {
swap(u, v);
}
if (u ^ top[u]) {
modify(1, 1, tot, dfn[top[u]] + 1, dfn[u], add);
}
u = fa[top[u]];
}
if (u ^ v) {
if (dep[u] < dep[v]) {
swap(u, v);
}
modify(1, 1, tot, dfn[v] + 1, dfn[u], add);
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i < n; ++i) {
int u, v;
scanf("%d%d", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
}
pre(1);
top[1] = 1;
dfs(1);
for (int i = 1; i < n; ++i) {
scanf("%d%d", &a[i], &b[i]);
modify(a[i], b[i], (data) {i, 1});
}
for (int i = 1; i < n; ++i) {
int cnt = t[1].info.cnt;
int idx = t[1].info.val;
if (cnt ^ 1) {
puts("NO");
return 0;
}
modify(1, 1, tot);
modify(a[idx], b[idx], (data) {idx, -1});
}
puts("YES");
return 0;
} | a.cc:50:3: error: reference to 'data' is ambiguous
50 | data info, tag;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc: In function 'void pushup(int)':
a.cc:53:8: error: 'struct node' has no member named 'info'
53 | t[p].info = t[p << 1].info + t[p << 1 | 1].info;
| ^~~~
a.cc:53:25: error: 'struct node' has no member named 'info'
53 | t[p].info = t[p << 1].info + t[p << 1 | 1].info;
| ^~~~
a.cc:53:46: error: 'struct node' has no member named 'info'
53 | t[p].info = t[p << 1].info + t[p << 1 | 1].info;
| ^~~~
a.cc: At global scope:
a.cc:55:24: error: reference to 'data' is ambiguous
55 | inline void tag(int p, data add) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:55:24: error: 'data' has not been declared
55 | inline void tag(int p, data add) {
| ^~~~
a.cc: In function 'void tag(int, int)':
a.cc:56:8: error: 'struct node' has no member named 'info'
56 | t[p].info += add;
| ^~~~
a.cc:57:8: error: 'struct node' has no member named 'tag'
57 | t[p].tag += add;
| ^~~
a.cc: In function 'void pushdown(int)':
a.cc:60:12: error: 'struct node' has no member named 'tag'
60 | if (t[p].tag.cnt) {
| ^~~
a.cc:61:22: error: 'struct node' has no member named 'tag'
61 | tag(p << 1, t[p].tag);
| ^~~
a.cc:62:26: error: 'struct node' has no member named 'tag'
62 | tag(p << 1 | 1, t[p].tag);
| ^~~
a.cc:63:10: error: 'struct node' has no member named 'tag'
63 | t[p].tag = (data) {0, 0};
| ^~~
a.cc:63:17: error: reference to 'data' is ambiguous
63 | t[p].tag = (data) {0, 0};
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc: In function 'void modify(int, int, int)':
a.cc:68:10: error: 'struct node' has no member named 'info'
68 | t[p].info.cnt = 1e9;
| ^~~~
a.cc:73:17: error: 'struct node' has no member named 'info'
73 | if (t[p << 1].info.cnt == 1) {
| ^~~~
a.cc: At global scope:
a.cc:80:48: error: reference to 'data' is ambiguous
80 | void modify(int p, int l, int r, int L, int R, data add) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:80:48: error: 'data' has not been declared
80 | void modify(int p, int l, int r, int L, int R, data add) {
| ^~~~
a.cc:95:34: error: reference to 'data' is ambiguous
95 | inline void modify(int u, int v, data add) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:95:34: error: 'data' has not been declared
95 | inline void modify(int u, int v, data add) {
| ^~~~
a.cc:95:13: error: redefinition of 'void modify(int, int, int)'
95 | inline void modify(int u, int v, data add) {
| ^~~~~~
a.cc:66:6: note: 'void modify(int, int, int)' previously defined here
66 | void modify(int p, int l, int r) {
| ^~~~~~
a.cc: In function 'int main()':
a.cc:125:25: error: reference to 'data' is ambiguous
125 | modify(a[i], b[i], (data) {i, 1});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:128:20: error: 'struct node' has no member named 'info'
128 | int cnt = t[1].info.cnt;
| ^~~~
a.cc:129:20: error: 'struct node' has no member named 'info'
129 | int idx = t[1].info.val;
| ^~~~
a.cc:135:29: error: reference to 'data' is ambiguous
135 | modify(a[idx], b[idx], (data) {idx, -1});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'temp |
s337802532 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, a[N], b[N];
vector<int> g[N];
int tot, dfn[N], fa[N], dep[N], sz[N], son[N], top[N];
void pre(int u) {
sz[u] = 1;
for (auto v : g[u]) {
if (v ^ fa[u]) {
dep[v] = dep[u] + 1;
fa[v] = u;
pre(v);
sz[u] += sz[v];
if (sz[son[u]] < sz[v]) {
son[u] = v;
}
}
}
}
void dfs(int u) {
if (son[u]) {
top[son[u]] = top[u];
dfn[son[u]] = ++tot;
dfs(son[u]);
}
for (auto v : g[u]) {
if ((v ^ fa[u]) && (v ^ son[u])) {
top[v] = v;
dfn[v] = ++tot;
dfs(v);
}
}
}
struct data {
int val, cnt;
inline void operator += (const data &rhs) {
val ^= rhs.val;
cnt += rhs.cnt;
}
inline data operator + (const data &rhs) {
if (cnt < rhs.cnt) {
return *this;
} else {
return rhs;
}
}
};
struct node {
data info, tag;
} t[N << 2];
inline void pushup(int p) {
t[p].info = t[p << 1].info + t[p << 1 | 1].info;
}
inline void tag(int p, data add) {
t[p].info += add;
t[p].tag += add;
}
inline void pushdown(int p) {
if (t[p].tag.cnt) {
tag(p << 1, t[p].tag);
tag(p << 1 | 1, t[p].tag);
t[p].tag = (data) {0, 0};
}
}
void modify(int p, int l, int r) {
if (l == r) {
t[p].info.cnt = 1e9;
return;
}
pushdown(p);
int mid = l + r >> 1;
if (t[p << 1].info.cnt == 1) {
modify(p << 1, l, mid);
} else {
modify(p << 1 | 1, mid + 1, r);
}
pushup(p);
}
void modify(int p, int l, int r, int L, int R, data add) {
if (l >= L && r <= R) {
tag(p, add);
return;
}
pushdown(p);
int mid = l + r >> 1;
if (mid >= L) {
modify(p << 1, l, mid, L, R, add);
}
if (mid < R) {
modify(p << 1 | 1, mid + 1, r, L, R, add);
}
pushup(p);
}
inline void modify(int u, int v, data add) {
while (top[u] != top[v]) {
if (dep[u] < dep[v]) {
swap(u, v);
}
if (u ^ top[u]) {
modify(1, 1, tot, dfn[top[u]] + 1, dfn[u], add);
}
u = fa[top[u]];
}
if (u ^ v) {
if (dep[u] < dep[v]) {
swap(u, v);
}
modify(1, 1, tot, dfn[v] + 1, dfn[u], add);
}
}
int main() {
scanf("%d", &n);
for (int i = 1; i < n; ++i) {
int u, v;
scanf("%d%d", &u, &v);
g[u].push_back(v);
g[v].push_back(u);
}
pre(1);
top[1] = 1;
dfs(1);
for (int i = 1; i < n; ++i) {
scanf("%d%d", &a[i], &b[i]);
modify(a[i], b[i], (data) {i, 1});
}
for (int i = 1; i < n; ++i) {
int cnt = t[1].info.cnt;
int idx = t[1].info.val;
if (cnt ^ 1) {
puts("NO");
return 0;
}
modify(1, 1, tot);
modify(a[idx], b[idx], (data) {idx, -1});
}
puts("YES");
return 0;
} | a.cc:50:3: error: reference to 'data' is ambiguous
50 | data info, tag;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc: In function 'void pushup(int)':
a.cc:53:8: error: 'struct node' has no member named 'info'
53 | t[p].info = t[p << 1].info + t[p << 1 | 1].info;
| ^~~~
a.cc:53:25: error: 'struct node' has no member named 'info'
53 | t[p].info = t[p << 1].info + t[p << 1 | 1].info;
| ^~~~
a.cc:53:46: error: 'struct node' has no member named 'info'
53 | t[p].info = t[p << 1].info + t[p << 1 | 1].info;
| ^~~~
a.cc: At global scope:
a.cc:55:24: error: reference to 'data' is ambiguous
55 | inline void tag(int p, data add) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:55:24: error: 'data' has not been declared
55 | inline void tag(int p, data add) {
| ^~~~
a.cc: In function 'void tag(int, int)':
a.cc:56:8: error: 'struct node' has no member named 'info'
56 | t[p].info += add;
| ^~~~
a.cc:57:8: error: 'struct node' has no member named 'tag'
57 | t[p].tag += add;
| ^~~
a.cc: In function 'void pushdown(int)':
a.cc:60:12: error: 'struct node' has no member named 'tag'
60 | if (t[p].tag.cnt) {
| ^~~
a.cc:61:22: error: 'struct node' has no member named 'tag'
61 | tag(p << 1, t[p].tag);
| ^~~
a.cc:62:26: error: 'struct node' has no member named 'tag'
62 | tag(p << 1 | 1, t[p].tag);
| ^~~
a.cc:63:10: error: 'struct node' has no member named 'tag'
63 | t[p].tag = (data) {0, 0};
| ^~~
a.cc:63:17: error: reference to 'data' is ambiguous
63 | t[p].tag = (data) {0, 0};
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc: In function 'void modify(int, int, int)':
a.cc:68:10: error: 'struct node' has no member named 'info'
68 | t[p].info.cnt = 1e9;
| ^~~~
a.cc:73:17: error: 'struct node' has no member named 'info'
73 | if (t[p << 1].info.cnt == 1) {
| ^~~~
a.cc: At global scope:
a.cc:80:48: error: reference to 'data' is ambiguous
80 | void modify(int p, int l, int r, int L, int R, data add) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:80:48: error: 'data' has not been declared
80 | void modify(int p, int l, int r, int L, int R, data add) {
| ^~~~
a.cc:95:34: error: reference to 'data' is ambiguous
95 | inline void modify(int u, int v, data add) {
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:95:34: error: 'data' has not been declared
95 | inline void modify(int u, int v, data add) {
| ^~~~
a.cc:95:13: error: redefinition of 'void modify(int, int, int)'
95 | inline void modify(int u, int v, data add) {
| ^~~~~~
a.cc:66:6: note: 'void modify(int, int, int)' previously defined here
66 | void modify(int p, int l, int r) {
| ^~~~~~
a.cc: In function 'int main()':
a.cc:125:25: error: reference to 'data' is ambiguous
125 | modify(a[i], b[i], (data) {i, 1});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
334 | data(_Tp (&__array)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
323 | data(const _Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
312 | data(_Container& __cont) noexcept(noexcept(__cont.data()))
| ^~~~
a.cc:35:8: note: 'struct data'
35 | struct data {
| ^~~~
a.cc:128:20: error: 'struct node' has no member named 'info'
128 | int cnt = t[1].info.cnt;
| ^~~~
a.cc:129:20: error: 'struct node' has no member named 'info'
129 | int idx = t[1].info.val;
| ^~~~
a.cc:135:29: error: reference to 'data' is ambiguous
135 | modify(a[idx], b[idx], (data) {idx, -1});
| ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
344 | data(initializer_list<_Tp> __il) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note: 'temp |
s392762579 | p03727 | C++ |
#include<bits/stdc++.h>
const int maxn=1e5+10;
using namespace std;
int tot=0,head[maxn],n,x,y,siz[maxn],f[maxn];
struct line{int to,next;}e[maxn*2];
void pushline(int x,int y)
{
e[++tot].x=y;e[tot].next=head[x],head[x]=tot;
}
bool dfs(int x,int fa)
{
siz[x]=1;
int cnt=0;
for(int i=head[x];int v=e[i].to;i=e[i].next)
{
if(v==fa)continue;
if(dfs(v,x))return 1;
if(siz[v])
{
cnt++,siz[x]=0;
if(cnt==2)return 1;
}
}
return 0;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<n;i++)
{
scanf("%d%d",&x,&y);
pushline(x,y);pushline(y,x);
}
printf(dfs(1,0)||siz[1]?"First":"Second");
}
/*
*/ | a.cc: In function 'void pushline(int, int)':
a.cc:9:18: error: 'struct line' has no member named 'x'
9 | e[++tot].x=y;e[tot].next=head[x],head[x]=tot;
| ^
|
s169859819 | p03727 | C++ | #include<bits/stdc++.h>
namespace my_std{
using namespace std;
#define pii pair<int,int>
#define fir first
#define sec second
#define MP make_pair
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define drep(i,x,y) for (int i=(x);i>=(y);i--)
#define go(x) for (int i=head[x];i;i=edge[i].nxt)
#define sz 101010
typedef long long ll;
template<typename T>
inline void read(T& t)
{
t=0;char f=0,ch=getchar();
double d=0.1;
while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
if(ch=='.')
{
ch=getchar();
while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();
}
t=(f?-t:t);
}
template<typename T,typename... Args>
inline void read(T& t,Args&... args){read(t); read(args...);}
// void file()
// {
// #ifndef ONLINE_JUDGE
// freopen("a.txt","r",stdin);
// #endif
// }
// inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;
// clock_t t=clock();
int n;
struct hh{int t,nxt;}edge[sz<<1];
int head[sz],ecnt;
void make_edge(int f,int t)
{
edge[++ecnt]=(hh){t,head[f]};
head[f]=ecnt;
edge[++ecnt]=(hh){f,head[t]};
head[t]=ecnt;
}
int size[sz],son[sz],top[sz],fa[sz],dep[sz],dfn[sz],cnt=-1;
#define v edge[i].t
void dfs1(int x,int fa)
{
dep[x]=dep[::fa[x]=fa]+1;size[x]=1;
go(x) if (v!=fa)
{
dfs1(v,x);
size[x]+=size[v];
if (size[v]>size[son[x]]) son[x]=v;
}
}
void dfs2(int x,int fa,int tp)
{
top[x]=tp;dfn[x]=++cnt;
if (son[x]) dfs2(son[x],x,tp);
go(x) if (v!=fa&&v!=son[x]) dfs2(v,x,v);
}
#undef v
bool del[sz];
int F[sz],T[sz];
int mn[sz<<2],tag[sz<<2];
vector<int>tr[sz<<2];
#define ls k<<1
#define rs k<<1|1
#define lson ls,l,mid
#define rson rs,mid+1,r
void Add(int k,int t){tag[k]+=t;mn[k]+=t;}
void pushdown(int k){int &t=tag[k]; if (!t) return; Add(ls,t); Add(rs,t); t=0; return;}
void pushup(int k){mn[k]=min(mn[ls],mn[rs]);}
void add(int k,int l,int r,int x,int y,int t)
{
if (x<=l&&r<=y) return tr[k].push_back(t),Add(k,1);
pushdown(k);
int mid=(l+r)>>1;
if (x<=mid) add(lson,x,y,t);
if (y>mid) add(rson,x,y,t);
pushup(k);
}
void change(int k,int l,int r,int x,int y,int s)
{
if (x<=l&&r<=y) return Add(k,s);
pushdown(k);
int mid=(l+r)>>1;
if (x<=mid) change(lson,x,y,s);
if (y>mid) change(rson,x,y,s);
pushup(k);
}
int K;
int getmn(int k,int l,int r)
{
if (mn[k]>1) return -1; // -1 : don't have 1
int ret;
while (!tr[k].empty()&&del[tr[k].back()]) tr[k].pop_back();
ret=tr[k].empty()?0:tr[k].back(); // 0 : don't know which edge
if (l==r) return K=l,ret;
pushdown(k);
int mid=(l+r)>>1,cur;
cur=getmn(lson); if (cur!=-1) { if (cur) return cur; if (ret) return ret; }
cur=getmn(rson); if (cur!=-1) { if (cur) return cur; if (ret) return ret; }
return ret;
}
void add(int x,int y,int t)
{
while (top[x]!=top[y])
{
if (dep[top[x]]<dep[top[y]]) swap(x,y);
add(1,1,n-1,dfn[top[x]],dfn[x],t);
x=fa[top[x]];
}
if (dfn[x]>dfn[y]) swap(x,y);
if (x!=y) add(1,1,n-1,dfn[x]+1,dfn[y],t);
}
void erase(int x,int y)
{
while (top[x]!=top[y])
{
if (dep[top[x]]<dep[top[y]]) swap(x,y);
change(1,1,n-1,dfn[top[x]],dfn[x],-1);
x=fa[top[x]];
}
if (dfn[x]>dfn[y]) swap(x,y);
if (x!=y) change(1,1,n-1,dfn[x]+1,dfn[y],-1);
}
void del_mn()
{
if (mn[1]!=1) puts("NO"),exit(0);
int e=getmn(1,1,n-1);
del[e]=1;
change(1,1,n-1,K,K,sz);
erase(F[e],T[e]);
}
int main()
{
// file();
int x,y;
scanf("%d",&n);
rep(i,1,n-1) scanf("%d %d",&x,&y),make_edge(x,y);
dfs1(1,0);dfs2(1,0,1);
rep(i,1,n-1) scanf("%d %d",&x,&y),add(x,y,i),F[i]=x,T[i]=y;
rep(i,1,n-1) del_mn();
puts("YES");
// cout<<1.0*(clock()-t)/CLOCKS_PER_SEC;
return 0;
} | a.cc: In function 'void dfs1(int, int)':
a.cc:54:30: error: reference to 'size' is ambiguous
54 | dep[x]=dep[::fa[x]=fa]+1;size[x]=1;
| ^~~~
In file included from /usr/include/c++/14/string:53,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:5: note: 'int size [101010]'
50 | int size[sz],son[sz],top[sz],fa[sz],dep[sz],dfn[sz],cnt=-1;
| ^~~~
a.cc:58:9: error: reference to 'size' is ambiguous
58 | size[x]+=size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:5: note: 'int size [101010]'
50 | int size[sz],son[sz],top[sz],fa[sz],dep[sz],dfn[sz],cnt=-1;
| ^~~~
a.cc:58:18: error: reference to 'size' is ambiguous
58 | size[x]+=size[v];
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:5: note: 'int size [101010]'
50 | int size[sz],son[sz],top[sz],fa[sz],dep[sz],dfn[sz],cnt=-1;
| ^~~~
a.cc:59:13: error: reference to 'size' is ambiguous
59 | if (size[v]>size[son[x]]) son[x]=v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:5: note: 'int size [101010]'
50 | int size[sz],son[sz],top[sz],fa[sz],dep[sz],dfn[sz],cnt=-1;
| ^~~~
a.cc:59:21: error: reference to 'size' is ambiguous
59 | if (size[v]>size[son[x]]) son[x]=v;
| ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
272 | size(const _Tp (&)[_Nm]) noexcept
| ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
262 | size(const _Container& __cont) noexcept(noexcept(__cont.size()))
| ^~~~
a.cc:50:5: note: 'int size [101010]'
50 | int size[sz],son[sz],top[sz],fa[sz],dep[sz],dfn[sz],cnt=-1;
| ^~~~
|
s768608898 | p03727 | C++ | #include <cstdio>
#include <iostream>
#include <vector>
#include <unordered_set>
#include <chrono>
using namespace std;
struct custom_hash {
typedef long long ll;
typedef unsigned long long ull;
const ull FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
static ull splitmix64(ull x) {
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(ll x) const {
return splitmix64(x + FIXED_RANDOM);
}
size_t operator()(const pair<int,int> &i)const{
return splitmix64((((ll)i.first)^(((ll)i.second)<<32))+FIXED_RANDOM);
}
};
struct ufds{
int p[100005];
ufds(){
for (int x=0;x<100005;x++){
p[x]=x;
}
}
int parent(int i){return (p[i]==i)?i:p[i]=parent(p[i]);}
void unions(int i,int j){
i=parent(i),j=parent(j);
p[i]=j;
}
}dsu=*new ufds();
inline long long E(int i,int j){
if (i>j) return (long long)i<<32|j;
else return (long long)j<<32|i;
}
inline int f(long long i){
return i>>32;
}
inline int s(long long i){
return i&4294967295;
}
int n;
unordered_set<int,custom_hash> al[100005];
unordered_set<long long,custom_hash> edges;
vector<long long> del;
inline INS(long long temp){
if (edges.count(temp)){
edges.erase(temp);
al[f(temp)].erase(s(temp));
al[s(temp)].erase(f(temp));
del.push_back(temp);
}
else{
edges.insert(temp);
al[f(temp)].insert(s(temp));
al[s(temp)].insert(f(temp));
}
}
inline DEL(int i,int j){
edges.erase(E(i,j));
al[i].erase(j);
}
int main(){
scanf("%d",&n);
int a,b;
for (int x=2;x<2*n;x++){
scanf("%d%d",&a,&b);
INS(E(a,b));
}
long long curr;
int u,v; //u->v merging
while (!del.empty()){
curr=del.back(),del.pop_back();
u=dsu.parent(f(curr)),v=dsu.parent(s(curr));
if (al[u].size()>al[v].size()) swap(u,v);
for (auto &it:al[u]){
DEL(it,u);
INS(E(it,v));
}
dsu.unions(u,v);
}
if (edges.empty()) printf("YES\n");
else printf("NO\n");
} | a.cc:63:8: error: ISO C++ forbids declaration of 'INS' with no type [-fpermissive]
63 | inline INS(long long temp){
| ^~~
a.cc: In function 'int INS(long long int)':
a.cc:75:1: warning: no return statement in function returning non-void [-Wreturn-type]
75 | }
| ^
a.cc: At global scope:
a.cc:77:8: error: ISO C++ forbids declaration of 'DEL' with no type [-fpermissive]
77 | inline DEL(int i,int j){
| ^~~
a.cc: In function 'int DEL(int, int)':
a.cc:80:1: warning: no return statement in function returning non-void [-Wreturn-type]
80 | }
| ^
|
s714986170 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int N = 100005;
set<int> g[N];
int p[N];
int num = 0;
int find(int x){
return x == p[x] ? x : p[x]=findset(p[x]);
}
void merge(int u, int v){
u = find(u), v = find(v);
if (u == v) return;
if (g[u].size() < g[v].size()) swap(u,v);
printf("merge %d to %d\n",v,u);
set<ii> que;
for (auto &x: g[v]){
if (x == u) continue;
//printf("%d connected to %d\n",x,v);
g[x].erase(v);
if (g[x].count(u)){
que.insert({x,u});
}
g[u].insert(x);
g[x].insert(u);
}
g[u].erase(v);
g[v].clear();
p[v] = u;
for (auto cur : que){
merge(cur.first,cur.second);
}
}
int main(){
int n;
scanf("%d",&n);
iota(p,p+N,0);
for (int i = 1; i < n; i++){
int a,b;
scanf("%d%d",&a,&b);
g[a].insert(b);
g[b].insert(a);
}
for (int i = 1; i < n; i++){
int a,b;
scanf("%d%d",&a,&b);
a = find(a); b = find(b);
if (g[a].count(b)) merge(a,b);
else{
g[a].insert(b);
g[b].insert(a);
}
}
int c = find(1);
printf("%d ",c);
for (int i = 2; i <= n; i++){
printf("%d ",find(i));
if (c != find(i)){
printf("NO");
return 0;
}
}
printf("YES");
}
| a.cc: In function 'int find(int)':
a.cc:9:33: error: 'findset' was not declared in this scope
9 | return x == p[x] ? x : p[x]=findset(p[x]);
| ^~~~~~~
|
s690379618 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
const int N = 100005;
set<int> g[N];
int p[N];
int num = 0;
int find(int x){
return x == p[x] ? x : p[x];
}
void merge(int u, int v){
u = find(u), v = find(v);
if (u == v) return;
if (g[u].size() < g[v].size()) swap(u,v);
//printf("merge %d to %d\n",v,u);
num++;
vector<ii> que;
for (auto x: g[v]){
if (x == u) continue;
//printf("%d connected to %d\n",x,v);
g[x].erase(v);
if (g[u].count(x)){
que.push_back({u,x});
}
g[u].insert(x);
g[x].insert(u);
}
p[v] = u;
for (auto cur : que){
merge(cur.first,cur.second);
}
}
int main(){
int n;
scanf("%d",&n);
iota(p,p+N,0);
for (int i = 0; i < 2*n-2; i++){
int a,b;
scanf("%d%d",&a,&b);
ct[{a,b}]++;
ct[{b,a}]++;
if (ct[{a,b}] >= 2) mer(a,b);
}
//printf("num %d ",num);
printf("%s",num==n-1 ? "YES":"NO");
}
| a.cc: In function 'int main()':
a.cc:40:9: error: 'ct' was not declared in this scope
40 | ct[{a,b}]++;
| ^~
a.cc:42:29: error: 'mer' was not declared in this scope; did you mean 'merge'?
42 | if (ct[{a,b}] >= 2) mer(a,b);
| ^~~
| merge
|
s612479006 | p03727 | C++ | #include<cstdio>
using namespace std;
int main(){
cout<<"Yes";
return 0;
} | a.cc: In function 'int main()':
a.cc:4:5: error: 'cout' was not declared in this scope
4 | cout<<"Yes";
| ^~~~
a.cc:2:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include<cstdio>
+++ |+#include <iostream>
2 | using namespace std;
|
s514206946 | p03727 | C++ | /☭
#include<cstdio>
#include<queue>
#include<map>
#include<set>
using namespace std;
const int N=1e5+10;
struct pai{
int f, s;
};
bool operator <(pai a, pai b) {
return (a.f==b.f)?(a.s<b.s):(a.f<b.f);
}
map< pai, int>m;
set<int> mu[N];
queue< pai >q;
int f[N], n;
inline void add(int x, int y) {mu[x].insert(y), mu[y].insert(x);}
pai marry(int x, int y) {
if(x>y) {int t=y; y=x, x=t;}
return (pai){x, y};
}
int f_f(int x){
return f[x]?f[x]=f_f(f[x]):x;
}
int main(){
scanf("%d", &n);
for(int i=1; i<=(n<<1)-2; i++) {
int x, y; scanf("%d%d", &x, &y), add(x, y);
pai edg=marry(x, y); ++m[edg];
if(m[edg]==2) q.push(edg);
if(m[edg]>2) {puts("NO"); return 0;}
}
for(int w=1; w<n; w++) {
if(q.empty()) {puts("NO"); return 0;}
int x=0, y=0;
while(x==y) x=f_f(q.front().f), y=f_f(q.front().s), q.pop();
if(mu[x].size()>mu[y].size()) swap(x, y); f[x]=y;
for(set<int>::iterator i=mu[x].begin(); i!=mu[x].end(); i++){
int from=f_f(*i); mu[from].erase(mu[from].find(x)); if(from==y) continue;
add(from,y); pai t=marry(from,y); m[t]++; if(m[t]==2) q.push(t);
}
mu[x].clear();
}
puts("YES");
}
| a.cc:1:2: error: extended character ☭ is not valid in an identifier
1 | /☭
| ^
a.cc:1:1: error: expected unqualified-id before '/' token
1 | /☭
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/deque:62,
from /usr/include/c++/14/queue:62,
from a.cc:3:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
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/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/includ |
s810883152 | p03727 | C++ | // luogu-judger-enable-o2
#include<iostream>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<ctime>
#include<set>
#include<map>
#include<climits>
#include<algorithm>
#include<queue>
#define ll long long
using namespace std;
const int N=100010;
typedef set<int>::iterator It;
set<int> s[N];
queue<pair<int,int> > q;
int n,f[N];
int find(int x) {return f[x]==x?x:f[x]=find(f[x]);}
void erase(int x,int y)
{
s[x].erase(y);
s[y].erase(x);
}
void insert(int x,int y)
{
s[x].insert(y);
s[y].insert(x);
if()
}
int main()
{
int i,j,x,y,t1,t2;
ll t;
scanf("%d",&n);
for(i=1;i<=n;i++) f[i]=i;
for(i=1;i<2*n-1;i++)
{
scanf("%d%d",&x,&y);
insert(x,y);
}
for(i=1;i<n;i++)
{
if(q.empty()) break;
x=q.front().first,y=q.front().second,q.pop();
t1=find(x),t2=find(y);
if(s[t1].size()<s[t2].size()) swap(t1,t2),swap(x,y);
erase(x,y);
f[t2]=t1;
It it,j;
for(It it=s[t2].begin();it!=s[t2].end();it=j)
{
j=it;j++;
erase(t2,find(*it));
insert(t1,find(*it));
}
}
if(i==n) printf("YES");
else printf("NO");
return 0;
}
| a.cc: In function 'void insert(int, int)':
a.cc:29:12: error: expected primary-expression before ')' token
29 | if()
| ^
a.cc:30:1: error: expected primary-expression before '}' token
30 | }
| ^
|
s599920980 | p03727 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
const double pi = acos(-1);
const int BUF_SIZE = (int)1e6 + 10;
template <typename T> inline bool chkmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}
template <typename T> inline bool chkmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
#define getchar IO.getchar
#define putchar IO.putchar
LL read() {
char ch = getchar();
LL x = 0, flag = 1;
for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
return x * flag;
}
const int Maxn = 1e5 + 9;
set <int> G[Maxn];
map<pair<int, int>, int> buc;
queue <pair<int, int> > que;
int fa[Maxn], n;
int find(int u) { return (fa[u] ^ u) ? (fa[u] = find(fa[u])) : u; }
void add(int u, int v) { G[u].insert(v); }
void link(int u, int v) {
add(u, v), add(v, u);
if (u > v) swap(u, v);
if (++buc[make_pair(u, v)] == 2) que.push(make_pair(u, v));
}
void Init() {
n = read();
rep (i, 1, n) fa[i] = i;
rep (i, 1, n - 1) link(read(), read());
rep (i, 1, n - 1) link(read(), read());
}
void Solve() {
int cnt = 0;
while (!que.empty()) {
pair<int, int> p = que.front(); que.pop();
p.first = find(p.first), p.second = find(p.second);
if (p.first == p.second) continue;
int u = p.first, v = p.second;
if (G[u].size() > G[v].size()) swap(u, v);
++cnt, fa[u] = v;
for (set <int> :: iterator IT = G[u].begin(); IT != G[u].end(); ++IT) {
int q = find(*IT);
if (q != v) link(q, v);
}
}
printf("%s\n", cnt == n - 1 ? "YES" : "NO");
}
int main() {
// freopen("bosky.in", "r", stdin);
// freopen("bosky.out", "w", stdout);
Init();
Solve();
#ifdef Qrsikno
debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
return IO.flush();
}
| a.cc: In function 'LL read()':
a.cc:13:17: error: 'IO' was not declared in this scope; did you mean 'EIO'?
13 | #define getchar IO.getchar
| ^~
a.cc:16:19: note: in expansion of macro 'getchar'
16 | char ch = getchar();
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:74:16: error: 'IO' was not declared in this scope; did you mean 'EIO'?
74 | return IO.flush();
| ^~
| EIO
|
s248304378 | p03727 | C++ |
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("IL")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("IL-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("IL-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("IL-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#define fastcall __attribute__((optimize("-O3")))
#define IL __inline__ __attribute__((always_inline))
#include <bits/stdc++.h>
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAXN = 1e5 + 10;
int n, fa[MAXN];
set<int> s[MAXN];
queue<pii> q;
map<ll, int> g;
template <class T>
IL void _read(T &u)
{
u = 0;
char t = getchar();
while (!isdigit(t)) t = getchar();
while (isdigit(t))
{
u = u * 10 + t - '0';
t = getchar();
}
}
template <class T>
IL void print(T x)
{
if(x < 0)
{
putchar('-');
x = -x;
}
if(x > 9)
print(x / 10);
putchar(x % 10 + '0');
}
IL int getfa(int u)
{
return fa[u] == u ? u : (fa[u] = getfa(fa[u]));
}
IL ll getid(int x, int y)
{
if(x > y) swap(x, y);
return 1ll * n * y + x;
}
IL void ae(int u, int v)
{
s[u].insert(v);
s[v].insert(u);
ll eid = getid(u, v);
int t = ++g[eid];
if(t == 2)
q.push(mp(u, v));
}
IL void re(int u, int v)
{
s[u].erase(v);
s[v].erase(u);
g.erase(getid(u, v));
}
IL bool solve()
{
for(int i = 1; i <= n; ++i) fa[i] = i;
for(int i = 1; i < n; ++i)
{
int u, v;
if(q.empty())
return false;
u = q.front().first;
v = q.front().second;
q.pop();
u = getfa(u);
v = getfa(v);
if(s[u].size() > s[v].size())
swap(u, v);
fa[u] = v;
re(u, v);
for(set<int> :: iterator i = s[u].begin(), j; i != s[u].end(); i = j)
{
j = i; ++j;
int x = *i;
x = getfa(x);
re(u, x);
ae(v, x);
}
}
return true;
}
int main()
{
_read(n);
for(int i = 1, u, v; i <= (n - 1) << 1; ++i)
{
_read(u), _read(v);
ae(u, v);
}
puts(solve() ? "YES" : "NO");
return 0;
} | a.cc:5:26: warning: bad option '-fIL' to pragma 'optimize' [-Wpragmas]
5 | #pragma GCC optimize("IL")
| ^
a.cc:23:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas]
23 | #pragma GCC optimize("-fwhole-program")
| ^
a.cc:26:36: warning: bad option '-fIL-functions' to pragma 'optimize' [-Wpragmas]
26 | #pragma GCC optimize("IL-functions")
| ^
a.cc:30:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas]
30 | #pragma GCC optimize("-fstrict-overflow")
| ^
a.cc:32:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas]
32 | #pragma GCC optimize("-fcse-skip-blocks")
| ^
a.cc:41:42: warning: bad option '-fIL-small-functions' to pragma 'optimize' [-Wpragmas]
41 | #pragma GCC optimize("IL-small-functions")
| ^
a.cc:46:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas]
46 | #pragma GCC optimize("-funsafe-loop-optimizations")
| ^
a.cc:47:48: warning: bad option '-fIL-functions-called-once' to pragma 'optimize' [-Wpragmas]
47 | #pragma GCC optimize("IL-functions-called-once")
| ^
a.cc:64:19: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
64 | IL void _read(T &u)
| ^
a.cc:64:19: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:64:19: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:64:19: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:64:19: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:64:19: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:64:19: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:64:19: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
76 | IL void print(T x)
| ^
a.cc:76:18: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:76:18: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
87 | IL int getfa(int u)
| ^
a.cc:87:19: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:87:19: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
91 | IL ll getid(int x, int y)
| ^
a.cc:91:25: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:91:25: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
96 | IL void ae(int u, int v)
| ^
a.cc:96:24: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:96:24: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
105 | IL void re(int u, int v)
| ^
a.cc:105:24: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:105:24: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
111 | IL bool solve()
| ^
a.cc:111:15: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:111:15: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-fIL' to attribute 'optimize' [-Wattributes]
139 | int main()
| ^
a.cc:139:10: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-fIL-functions' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-fIL-small-functions' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes]
a.cc:139:10: warning: bad option '-fIL-functions-called-once' to attribute 'optimize' [-Wattributes]
In function 'int getfa(int)',
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40:
a.cc:87:8: error: inlining failed in call to 'always_inline' 'int getfa(int)': recursive inlining
87 | IL int getfa(int u)
| ^~~~~
a.cc:89:47: note: called from here
89 | return fa[u] == u ? u : (fa[u] = getfa(fa[u]));
| ~~~~~^~~~~~~
In function 'int getfa(int)',
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'bool solve()' at a.cc:122:12,
inlined from 'int main()' at a.cc:147:12:
a.cc:87:8: error: inlining failed in call to 'always_inline' 'int getfa(int)':
87 | IL int getfa(int u)
| ^~~~~
a.cc:89:47: note: called from here
89 | return fa[u] == u ? u : (fa[u] = getfa(fa[u]));
| ~~~~~^~~~~~~
In function 'int getfa(int)',
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'int getfa(int)' at a.cc:89:40,
inlined from 'bool solve()' at a.cc:123:12,
inlined from 'int main()' at a.cc:147:12:
a.cc:87:8: error: inlining failed in call to 'always_inline' 'int getfa(int)':
87 | IL int getfa(int u)
| ^~~~~
a.cc:89:47: note: called from here
89 | return fa[u] == u ? u : (fa[u] = getfa(fa[u]));
| ~~~~~^~~~~~~
In function 'int getfa(int)',
inlined f |
s449156884 | p03727 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
vector<int> nullvi;
set<int> nullsi;
queue<int> que;
bool used[100010];
struct seg{
int siz;
vector<set<int>> s;
vector<P> t;
vector<int> u;
void init(int n){
siz = 1;
while(siz < n)siz <<= 1;
rep(i,siz*2-1){
s.push_back(nullsi);
t.push_back(P(0,0));
u.push_back(0);
}
rep(i,siz){
t[i+siz-1] = P(0,i);
}
rrep(i,siz-1){
t[i] = min( t[2*i+1] , t[2*i+2] );
}
}
void add(int a,int b,int x,int k,int l,int r){
//fprintf(stderr,"seg:add(%d,%d,%d,%d,%d,%d)\n",a,b,x,k,l,r);
if(b <= l || r <= a)return;
if(a <= l && r <= b){
//if(x != -1){
s[k].insert(x);
u[k] ++;
t[k].fr += 1;
/*}
else {
u[k] += INF;
t[k].fr += INF;
}*/
return;
}
add(a,b,x,2*k+1,l,(l+r)/2);
add(a,b,x,2*k+2,(l+r)/2,r);
t[k] = min( t[2*k+1] , t[2*k+2] );
t[k].fr += u[k];
}
void erase(int a,int b,int x,int k,int l,int r){
if(b <= l || r <= a)return;
if(a <= l && r <= b){
s[k].erase(x);
u[k] --;
t[k].fr -= 1;
return;
}
erase(a,b,x,2*k+1,l,(l+r)/2);
erase(a,b,x,2*k+2,(l+r)/2,r);
t[k] = min( t[2*k+1] , t[2*k+2] );
t[k].fr += u[k];
}
void query(int a,int b,int cnt,int k,int l,int r){
//fprintf(stderr,"seg:query(%d,%d,%d,%d,%d,%d)\n",a,b,cnt,k,l,r);
if(b <= l || r <= a)return;
if(t[k].fr+cnt >= 2)return;
if(s[k].size() == 1){
que.push(*s[k].begin());
cnt ++;
}
if(r-l == 1){
u[k] += INF;
t[k].fr += INF;
return;
}
query(a,b,cnt,2*k+1,l,(l+r)/2);
query(a,b,cnt,2*k+2,(l+r)/2,r);
t[k] = min( t[2*k+1] , t[2*k+2] );
t[k].fr += u[k];
}
/*int cnt(int a){
a += siz-1;
int ret = u[a];
while(a > 0){
a = (a-1)/2;
ret += u[a];
}
return ret;
}*/
/*P _query(int a,int b,int k,int l,int r){
if(b <= l || r <= a)return P(INF,INF);
if(a <= l && r <= b)return t[k];
P chl = _query(a,b,2*k+1,l,(l+r)/2);
P chr = _query(a,b,2*k+2,(l+r)/2,r);
P ret = min(chl,chr);
ret.fr += u[k];
return ret;
}
int query(int a,int b){
P p = _query(a,b,0,0,siz);
if(p.fr != 1)return -1;
int loc = p.sc+siz-1;
while(1){
if(s[loc].size() > 0)return *s[loc].begin();
loc = (loc-1)/2;
}
return -1;
}
int cnt(int a){
a += siz-1;
int ret = u[a];
while(a > 0){
a = (a-1)/2;
ret += u[a];
}
return ret;
}*/
};
struct UF{
vector<int> par,r;
void init(int n){
rep(i,n+1){
par.pb(i);
r.pb(0);
}
}
int find(int x){
if(par[x] == x)return x;
return par[x] = find(par[x]);
}
bool same(int x,int y){
return find(x) == find(y);
}
void unit(int x,int y){
if(same(x,y))return;
x = find(x);
y = find(y);
if(r[x] < r[y]){
par[x] = y;
}
else {
par[y] = x;
if(r[x] == r[y]){
r[x] ++;
}
}
}
};
struct HL{
int V;
vector<vector<int>> G;
int x,y;
vector<int> d[2];
int D;
vector<int> id;
vector<P> loc;
UF uf;
vector<HL*> ch;
vector<vector<int>> ch_ids;
vector<int> root;
void init(int _V){
V = _V;
rep(i,V+1){
G.push_back(nullvi);
d[0].push_back(-1);
d[1].push_back(-1);
loc.push_back(P(-1,-1));
}
//G = vector<vector<int>>(V+1);
}
void add_edge(int a,int b){
G[a].pb(b); G[b].pb(a);
}
void dfs(int v,int p,int t){
d[t][v] = d[t][p]+1;
for(int u: G[v]){
if(u == p)continue;
dfs(u,v,t);
}
}
void dia(){
x = 1;
d[0][0] = -1;
dfs(x,0,0);
rep1(i,V)if(d[0][i]>d[0][x])x=i;
d[1][0] = -1;
dfs(x,0,0);
y = 1;
rep1(i,V)if(d[0][i]>d[0][y])y=i;
dfs(y,0,1);
}
void run_HL(){
/*cerr << "==========" << endl;
cerr << V << endl;
rep1(i,V){
for(int j: G[i]){
cerr << i << " " << j << endl;
}
}*/
//cerr << __LINE__ << endl;
dia();
//cerr << __LINE__ << endl;
D = d[0][y];
rep(i,D+1){
id.push_back(-1);
}
//cerr << __LINE__ << endl;
rep1(i,V){
if(d[0][i]+d[1][i] == D){
id[d[0][i]] = i;
loc[i] = P(-1,d[0][i]);
}
else loc[i] = P(-2,0);
}
//cerr << __LINE__ << endl;
uf.init(V);
rep1(i,V){
if(loc[i].fr != -2)continue;
for(int j: G[i]){
if(loc[j].fr == -2)uf.unit(i,j);
}
}
//cerr << __LINE__ << endl;
rep1(i,V){
if(loc[i].fr == -1)continue;
if(loc[uf.find(i)].fr == -2){
loc[uf.find(i)].fr = ch_ids.size();
ch.push_back(new HL);
ch_ids.push_back(nullvi);
root.push_back(0);
ch_ids[loc[uf.find(i)].fr].push_back(uf.find(i));
loc[uf.find(i)].sc = 1;
}
if(uf.find(i) != i){
loc[i].fr = loc[uf.find(i)].fr;
ch_ids[loc[i].fr].push_back(i);
loc[i].sc = ch_ids[loc[i].fr].size();
}
}
//cerr << __LINE__ << endl;
rep(i,ch_ids.size()){
//cerr << __LINE__ << endl;
ch[i]->init(ch_ids[i].size()+1);
int _v = ch_ids[i][0];
root[i] = id[d[0][_v]-(d[0][_v]+d[1][_v]-D)/2];
//cerr << __LINE__ << endl;
for(int v: ch_ids[i]){
for(int u: G[v]){
if(u == root[i])ch[i]->add_edge(loc[v].sc,ch_ids[i].size()+1);
else if(loc[v].sc < loc[u].sc)ch[i]->add_edge(loc[v].sc,loc[u].sc);
}
}
//cerr << __LINE__ << endl;
ch_ids[i].pb(root[i]);
//cerr << __LINE__ << endl;
ch[i]->run_HL();
//cerr << __LINE__ << endl;
}
//cerr << __LINE__ << endl;
init_adhoc();
//cerr << __LINE__ << endl;
}
seg seg;
void init_adhoc(){
seg.init(id.size());
}
void add(int a,int b,int c){
if(loc[a] > loc[b])swap(a,b);
if(loc[b].fr == -1){
seg.add(loc[a].sc,loc[b].sc,c,0,0,seg.siz);
}
else if(loc[a].fr == -1){
if(loc[a].sc <= loc[root[loc[b].fr]].sc)seg.add(loc[a].sc,loc[root[loc[b].fr]].sc,c,0,0,seg.siz);
else seg.add(loc[root[loc[b].fr]].sc,loc[a].sc,c,0,0,seg.siz);
ch[loc[b].fr]->add(loc[root[loc[b].fr]].sc,loc[b].sc,c);
}
else {
if(loc[root[loc[a].fr]].sc>loc[root[loc[b].fr]].sc)swap(a,b);
seg.add(loc[root[loc[a].fr]].sc,loc[root[loc[b].fr]].sc,c,0,0,seg.siz);
ch[loc[a].fr]->add(loc[root[loc[a].fr]].sc,loc[a].sc,c);
ch[loc[b].fr]->add(loc[root[loc[b].fr]].sc,loc[b].sc,c);
}
}
void erase(int a,int b,int c){
if(loc[a] > loc[b])swap(a,b);
if(loc[b].fr == -1){
seg.erase(loc[a].sc,loc[b].sc,c,0,0,seg.siz);
}
else if(loc[a].fr == -1){
if(loc[a].sc <= loc[root[loc[b].fr]].sc)seg.erase(loc[a].sc,loc[root[loc[b].fr]].sc,c,0,0,seg.siz);
else seg.erase(loc[root[loc[b].fr]].sc,loc[a].sc,c,0,0,seg.siz);
ch[loc[b].fr]->erase(loc[root[loc[b].fr]].sc,loc[b].sc,c);
}
else {
if(loc[root[loc[a].fr]].sc>loc[root[loc[b].fr]].sc)swap(a,b);
seg.erase(loc[root[loc[a].fr]].sc,loc[root[loc[b].fr]].sc,c,0,0,seg.siz);
ch[loc[a].fr]->erase(loc[root[loc[a].fr]].sc,loc[a].sc,c);
ch[loc[b].fr]->erase(loc[root[loc[b].fr]].sc,loc[b].sc,c);
}
}
void query(int a,int b){
//cerr << __LINE__ << endl;
//fprintf(stderr,"HL::query(%d,%d)\n",a,b);
if(loc[a] > loc[b])swap(a,b);
if(loc[b].fr == -1){
//cerr << __LINE__ << endl;
seg.query(loc[a].sc,loc[b].sc,0,0,0,seg.siz);
}
else if(loc[a].fr == -1){
//cerr << __LINE__ << endl;
if(loc[a].sc <= loc[root[loc[b].fr]].sc)seg.query(loc[a].sc,loc[root[loc[b].fr]].sc,0,0,0,seg.siz);
else seg.query(loc[root[loc[b].fr]].sc,loc[a].sc,0,0,0,seg.siz);
ch[loc[b].fr]->query(loc[root[loc[b].fr]].sc,loc[b].sc);
}
else {
//cerr << __LINE__ << endl;
if(loc[root[loc[a].fr]].sc>loc[root[loc[b].fr]].sc)swap(a,b);
seg.query(loc[root[loc[a].fr]].sc,loc[root[loc[b].fr]].sc,0,0,0,seg.siz);
ch[loc[a].fr]->query(loc[root[loc[a].fr]].sc,loc[a].sc);
ch[loc[b].fr]->query(loc[root[loc[b].fr]].sc,loc[b].sc);
}
}
/*int cnt(int a){
if(loc[a].fr == -1)return seg.cnt(loc[a].sc);
return ch[loc[a].fr]->cnt(loc[a].sc);
}*/
/*void out(){
cerr << "diameter:";
for(int v: id)cerr << v << " ";
cerr << endl;
rep1(i,V){
cerr << i << ":" << loc[i].fr << " " << loc[i].sc << endl;
}
rep(i,ch.size()){
cerr << "=========ch[" << i << "]==========" << endl;
cerr << "par=" << par[i] << ",root=" << root[i] << endl;
ch[i]->out();
}
}*/
};
int main(){
static int n;
static int a[100010],b[100010];
static int c[100010],d[100010];
scanf("%d",&n);
rep1(i,n-1)scanf("%d%d",&a[i],&b[i]);
rep1(i,n-1)scanf("%d%d",&c[i],&d[i]);
//cerr << __LINE__ << endl;
static HL* tree = new HL;
tree->init(n);
//cerr << __LINE__ << endl;
rep1(i,n-1){
tree->add_edge(a[i],b[i]);
}
//cerr << __LINE__ << endl;
tree->run_HL();
//cerr << __LINE__ << endl;
rep1(i,n-1){
tree->add(c[i],d[i],i);
}
//cerr << __LINE__ << endl;
rep1(i,n){
tree->query(a[i],b[i]);
used[i] = false;
}
//cerr << __LINE__ << endl;
//cout << que.size() << endl;
int cnt = 0;
while(!que.empty()){
int p = que.front(); que.pop();
//cout << p << endl;
if(used[p])continue;
used[p] = true; cnt ++;
tree->erase(c[p],d[p],p);
tree->query(c[p],d[p]);
}
if(cnt == n-1)puts("YES");
else puts("NO");
//tree->out();
}
| a.cc:298:13: error: declaration of 'seg HL::seg' changes meaning of 'seg' [-Wchanges-meaning]
298 | seg seg;
| ^~~
a.cc:298:9: note: used here to mean 'struct seg'
298 | seg seg;
| ^~~
a.cc:43:8: note: declared here
43 | struct seg{
| ^~~
|
s890769233 | p03727 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))
const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
vector<int> nullvi;
struct UF{
vector<int> par,r;
void init(int n){
rep(i,n+1){
par.pb(i);
r.pb(0);
}
}
int find(int x){
if(par[x] == x)return x;
return par[x] = find(par[x]);
}
bool same(int x,int y){
return find(x) == find(y);
}
void unit(int x,int y){
if(same(x,y))return;
x = find(x);
y = find(y);
if(r[x] < r[y]){
par[x] = y;
}
else {
par[y] = x;
if(r[x] == r[y]){
r[x] ++;
}
}
}
};
struct HL{
int V;
vector<vector<int>> G;
int x,y;
vector<int> d[2];
int D;
vector<int> id;
vector<P> loc;
UF uf;
vector<HL*> ch;
vector<vector<int>> ch_ids;
vector<int> par,root;
void init(int _V){
V = _V;
rep(i,V+1){
G.push_back(nullvi);
d[0].push_back(-1);
d[1].push_back(-1);
loc.push_back(P(-1,-1));
}
//G = vector<vector<int>>(V+1);
}
void add_edge(int a,int b){
G[a].pb(b); G[b].pb(a);
}
void dfs(int v,int p,int t){
d[t][v] = d[t][p]+1;
for(int u: G[v]){
if(u == p)continue;
dfs(u,v,t);
}
}
void dia(){
x = 1;
d[0][0] = -1;
dfs(x,0,0);
rep1(i,V)if(d[0][i]>d[0][x])x=i;
d[1][0] = -1;
dfs(x,0,0);
y = 1;
rep1(i,V)if(d[0][i]>d[0][y])y=i;
dfs(y,0,1);
}
void run_HL(){
/*cerr << "==========" << endl;
cerr << V << endl;
rep1(i,V){
for(int j: G[i]){
cerr << i << " " << j << endl;
}
}*/
dia();
D = d[0][y];
rep(i,D+1){
id.push_back(-1);
}
rep1(i,V){
if(d[0][i]+d[1][i] == D){
id[d[0][i]] = i;
loc[i] = P(-1,d[0][i]);
}
else loc[i] = P(-2,0);
}
uf.init(V);
rep1(i,V){
if(loc[i].fr != -2)continue;
for(int j: G[i]){
if(loc[j].fr == -2)uf.unit(i,j);
}
}
rep1(i,V){
if(loc[i].fr == -1)continue;
if(loc[uf.find(i)].fr == -2){
loc[uf.find(i)].fr = ch_ids.size();
ch.push_back(new HL);
ch_ids.push_back(nullvi);
par.push_back(0);
root.push_back(0);
ch_ids[loc[uf.find(i)].fr].push_back(uf.find(i));
loc[uf.find(i)].sc = 1;
}
if(uf.find(i) != i){
loc[i].fr = loc[uf.find(i)].fr;
ch_ids[loc[i].fr].push_back(i);
loc[i].sc = ch_ids[uf.find(i)].size();
}
}
rep(i,ch_ids.size()){
ch[i]->init(ch_ids[i].size());
int _v = ch_ids[i][0];
par[i] = id[d[0][_v]-(d[0][_v]+d[1][_v]-D)/2];
for(int v: ch_ids[i]){
for(int u: G[v]){
if(u == par[i])root[i] = v;
else if(loc[v].sc < loc[u].sc)ch[i]->add_edge(loc[v].sc,loc[u].sc);
}
}
ch[i]->run_HL();
}
run_adhoc();
}
void run_adhoc(){
void out(){
cerr << "diameter:";
for(int v: id)cerr << v << " ";
cerr << endl;
rep1(i,V){
cerr << i << ":" << loc[i].fr << " " << loc[i].sc << endl;
}
rep(i,ch.size()){
cerr << "=========ch[" << i << "]==========" << endl;
cerr << "par=" << par[i] << ",root=" << root[i] << endl;
ch[i]->out();
}
}
};
int main(){
static int n;
static int a[100010],b[100010];
static int c[100010],d[100010];
scanf("%d",&n);
rep1(i,n-1)scanf("%d%d",&a[i],&b[i]);
rep1(i,n-1)scanf("%d%d",&c[i],&d[i]);
static HL* tree = new HL;
tree->init(n);
rep1(i,n-1){
tree->add_edge(a[i],b[i]);
}
tree->run_HL();
//tree->out();
}
| a.cc:203:2: error: expected '}' at end of input
203 | }
| ^
a.cc:70:10: note: to match this '{'
70 | struct HL{
| ^
a.cc: In member function 'void HL::run_adhoc()':
a.cc:173:19: error: a function-definition is not allowed here before '{' token
173 | void out(){
| ^
a.cc: In member function 'int HL::main()':
a.cc:203:1: warning: no return statement in function returning non-void [-Wreturn-type]
203 | }
| ^
a.cc: At global scope:
a.cc:203:2: error: expected unqualified-id at end of input
203 | }
| ^
|
s617251621 | p03727 | C++ | #include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <ctime>
#include <map>
#include <queue>
#include <cstdlib>
#include <string>
#include <climits>
#include <set>
#include <vector>
#include <complex>
#define pa pair<int,int>
#define mkp make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
int k=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}
return k*f;
}
inline void write(int x){
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);putchar(x%10+'0');
}
inline void writeln(int x){
write(x);puts("");
}
const int N=1e5+10;
map<pa,int>mp;
set<int>e[N];
int fa[N];
inline int find(int x){
if(fa[x]==x)return x;
return fa[x]=find(fa[x]);
}
int main()
{
n=read();
for(int i=1;i<n;i++){
int x=read(),y=read();
e[x].insert(y);
e[y].insert(x);
pa now=mkp(min(x,y),max(x,y));
mp[now]++;
if(mp[now]==3)return puts("NO")&0;
if(mp[now]==2)q.push(now);
}
for(int i=1;i<=n;i++)fa[i]=i;
for(int i=1;i<n;i++){
int x,y;
while(1){
if(q.empty())return puts("NO")&0;
x=q.front().fi;y=q.front().se;
q.pop();
if(x!=y)break;
}
if(e[x].size()>e[y].size())swap(x,y);
fa[]
}
puts("YES");
return 0;
} | a.cc: In function 'int main()':
a.cc:43:9: error: 'n' was not declared in this scope
43 | n=read();
| ^
a.cc:51:31: error: 'q' was not declared in this scope
51 | if(mp[now]==2)q.push(now);
| ^
a.cc:57:28: error: 'q' was not declared in this scope
57 | if(q.empty())return puts("NO")&0;
| ^
a.cc:58:27: error: 'q' was not declared in this scope
58 | x=q.front().fi;y=q.front().se;
| ^
a.cc:63:20: error: expected primary-expression before ']' token
63 | fa[]
| ^
|
s356312051 | p03727 | C++ | #include <cstdio>
#include <algorithm>
using namespace std;
const int maxn = 100005;
typedef pair<int, int> pii;
int n;
// build tree
namespace Tree1
{
set<pii> st;
struct Edge
{
int to, nxt;
} e[maxn<<1];
int first[maxn];
inline void add_edge(int from, int to)
{
static int cnt = 0;
st.insert(make_pair(from, to));
st.insert(make_pair(to, from));
e[++cnt].nxt = first[from]
first[from] = cnt;
e[cnt].to = to;
e[++cnt].nxt = first[to];
first[to] = cnt;
e[cnt].to = from;
}
}
namespace Tree2
{
set<pii> st;
pii e[maxn];
inline void add_edge(int from, int to)
{
static int cnt = 0;
st.insert(make_pair(from, to));
st.insert(make_pair(to, from));
e[++cnt] = make_pair(from, to);
}
}
namespace Tree1
{
int is[maxn];
int dep[maxn];
int fa[maxn];
int ffa[maxn];
int son[maxn];
int siz[maxn];
int qz[maxn];
int aa[maxn];
int ll[maxn];
inline void dfs1(int now)
{
siz[now] = 1;
for(int i = first[now]; i; i = e[i].nxt)
{
int to = e[i].to;
if(to != fa[now])
{
dep[to] = dep[now] + 1;
fa[to] = now;
if(!(Tree2::st.count(make_pair(now, to))))
qz[now] = 1;
dfs1(to);
siz[now] += siz[to];
if(!son[now] || siz[son[now]] < siz[to])
son[now] = to;
}
}
}
inline void dfs2(int now)
{
static cnt = 0;
ll[now] = ++cnt;
aa[++cnt] = qz[now];
if(son[now])
{
ffa[son[now]] = ffa[now];
dfs2(son[now]);
}
for(int i = first[now]; i; i = e[i].nxt)
{
int to = e[i].to;
if(to != fa[now] && to != son[now])
{
ffa[to] = to;
dfs2(to);
}
}
}
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
struct Tree
{
int no[maxn];
int t;
inline void build_tree()
{
for(; t <= n; t <<= 1);
for(int i = t + 1; i <= t + n; ++i)
no[i] = no[i - t];
for(int i = t - 1; i; --i)
no[i] = no[ls(i)] + no[rs(i)];
}
inline void change(int k)
{
no[k += t] = 0;
for(; k; k >>= 1)
no[k] = no[ls(k)] + no[rs(k)];
}
inline int query(int l, int r)
{
int ans = 0;
for(l += t - 1, r += t + 1; l ^ r ^ 1; l >>= 1, r >>= 1)
{
if(~l & 1)
ans += no[l];
if(r & 1)
ans += no[r];
}
return ans;
}
}
}
int main()
{
} | a.cc:16:9: error: 'set' does not name a type
16 | set<pii> st;
| ^~~
a.cc: In function 'void Tree1::add_edge(int, int)':
a.cc:28:17: error: 'st' was not declared in this scope; did you mean 'std'?
28 | st.insert(make_pair(from, to));
| ^~
| std
a.cc:30:43: error: expected ';' before 'first'
30 | e[++cnt].nxt = first[from]
| ^
| ;
31 | first[from] = cnt;
| ~~~~~
a.cc: At global scope:
a.cc:41:9: error: 'set' does not name a type
41 | set<pii> st;
| ^~~
a.cc: In function 'void Tree2::add_edge(int, int)':
a.cc:48:17: error: 'st' was not declared in this scope; did you mean 'std'?
48 | st.insert(make_pair(from, to));
| ^~
| std
a.cc: In function 'void Tree1::dfs1(int)':
a.cc:77:45: error: 'st' is not a member of 'Tree2'
77 | if(!(Tree2::st.count(make_pair(now, to))))
| ^~
a.cc: In function 'void Tree1::dfs2(int)':
a.cc:89:24: error: 'cnt' does not name a type; did you mean 'int'?
89 | static cnt = 0;
| ^~~
| int
a.cc:90:29: error: 'cnt' was not declared in this scope; did you mean 'int'?
90 | ll[now] = ++cnt;
| ^~~
| int
a.cc: At global scope:
a.cc:144:10: error: expected ';' after struct definition
144 | }
| ^
| ;
|
s048412687 | p03727 | C++ | #include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
typedef long long ll;
#define rg register
template <typename _Tp> inline _Tp read(_Tp&x){
char c11=getchar();x=0;while(!isdigit(c11))c11=getchar();
while(isdigit(c11))x=x*10+c11-'0',c11=getchar();return x;
}
const int N=101000,ae=20,mod=14233333;
struct Edge{int v,nxt;}a[N*ae<<1];
int qx[N*ae],qy[N*ae],dad[N];
int head[N],_,sz[N];
unordered_map<ll,int> cnt;
int n,he=1,ta=0;
inline int find(int x){return dad[x]?dad[x]=find(dad[x]):x;}
inline void ins(int u,int v){++sz[u],a[++_].v=v,a[_].nxt=head[u],head[u]=_;}
#define h(x,y) ((x+1ll*n*y))
inline void add(int x,int y){
ins(x,y),ins(y,x);
if((++cnt[x<y?h(x,y):h(y,x)])==2)
++ta,qx[ta]=x,qy[ta]=y;
}
int main(){
read(n);int x,y,p;
for(rg int i=n-2+n;i;--i)read(x),read(y),add(x,y);
for(rg int i=1;i<n;++i){
do x=qx[he],y=qy[he],++he;
while(find(x)==find(y)&&he<=ta);
x=find(x),y=find(y);
if(x==y){puts("NO");return 0;}
if(sz[x]>sz[y])swap(x,y);
cnt[x<y?h(x,y):h(y,x)]=0;
for(rg int j=head[x];j;j=a[j].nxt){
p=find(a[j].v);
if(p^y)add(p,y);
}dad[x]=y;
}puts("YES");
return 0;
} | a.cc:17:1: error: reference to 'unordered_map' is ambiguous
17 | unordered_map<ll,int> cnt;
| ^~~~~~~~~~~~~
In file included from /usr/include/c++/14/tr1/unordered_map:44,
from a.cc:2:
/usr/include/c++/14/tr1/unordered_map.h:180:11: note: candidates are: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::tr1::unordered_map'
180 | class unordered_map
| ^~~~~~~~~~~~~
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:109:11: note: 'template<class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> class std::unordered_map'
109 | class unordered_map
| ^~~~~~~~~~~~~
a.cc: In function 'void add(int, int)':
a.cc:27:15: error: 'cnt' was not declared in this scope; did you mean 'int'?
27 | if((++cnt[x<y?h(x,y):h(y,x)])==2)
| ^~~
| int
a.cc: In function 'int main()':
a.cc:33:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
33 | for(rg int i=n-2+n;i;--i)read(x),read(y),add(x,y);
| ^
a.cc:34:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
34 | for(rg int i=1;i<n;++i){
| ^
a.cc:40:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
40 | cnt[x<y?h(x,y):h(y,x)]=0;
| ^~~
| int
a.cc:41:28: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
41 | for(rg int j=head[x];j;j=a[j].nxt){
| ^
|
s074464332 | p03727 | C++ | //waz
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)((x).size()))
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef long long int64;
typedef unsigned int uint;
typedef unsigned long long uint64;
#define gi(x) ((x) = F())
#define gii(x, y) (gi(x), gi(y))
#define giii(x, y, z) (gii(x, y), gi(z))
int F()
{
char ch;
int x, a;
while (ch = getchar(), (ch < '0' || ch > '9') && ch != '-');
if (ch == '-') ch = getchar(), a = -1;
else a = 1;
x = ch - '0';
while (ch = getchar(), ch >= '0' && ch <= '9')
x = (x << 1) + (x << 3) + ch - '0';
return a * x;
}
const int N = 1e5 + 10;
map<int, int> h[N];
set<int> edge[N];
queue<PII> q;
void link(int u, int v)
{
edge[u].insert(v);
edge[v].insert(u);
if (u > v) swap(u, v);
++h[u][v];
if (h[u][v] == 2)
{
q.push(now);
}
if (h[u][v] > 2)
{
puts("NO");
exit(0);
}
}
void cut(int u, int v)
{
edge[u].erase(v);
if (u > v) swap(u, v);
h[u].erase(v);
}
int fa[N], n;
int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }
int main()
{
gi(n);
for (int i = 1; i <= n; ++i) fa[i] = i;
for (int i = 1; i < n; ++i)
{
int u, v;
gii(u, v);
link(u, v);
}
for (int i = 1; i < n; ++i)
{
int u, v;
gii(u, v);
link(u, v);
}
for (int i = 1; i < n; ++i)
{
int u, v;
do
{
if (q.empty())
{
puts("NO");
return 0;
}
u = q.front().fi;
v = q.front().se;
u = find(u);
v = find(v);
q.pop();
} while (u == v);
if (SZ(edge[u]) > SZ(edge[v])) swap(u, v);
fa[u] = v;
cut(v, u);
for (auto x : edge[u])
{
x = find(x);
if (x == v) continue;
link(x, v);
cut(x, u);
}
edge[u].clear();
}
puts("YES");
return 0;
} | a.cc: In function 'void link(int, int)':
a.cc:52:24: error: 'now' was not declared in this scope; did you mean 'pow'?
52 | q.push(now);
| ^~~
| pow
|
s450150403 | p03727 | C++ | #include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<set>
#include<map>
#define Pr pair<int,int>
using namespace std;
const int N=1e5+10;
struct xxx{
int y,nxt;
}a[N*2];
queue<Pr> q;
map<Pr,int> cnt;
multiset<int> rec[N];
multiset<int>::iterator it,tmpit;
int h[N],f[N];
int req[N][2];
int n,m,tot;
Pr mp(int x,int y){if (x>y) swap(x,y); return make_pair(x,y);}
int get_f(int x){return f[x]=f[x]==x?f[x]:get_f(f[x]);}
bool link(int x,int y){
Pr tmp;
rec[x].insert(y); rec[y].insert(x);
tmp=mp(x,y);
++cnt[tmp];
if (cnt[tmp]==2) q.push(tmp);
}
void cut(int x,int y){
rec[x].erase(y); rec[y].erase(x);
cnt.erase[mp(x,y)];
}
int main(){
#ifndef ONLINE_JUDGE
freopen("a.in","r",stdin);
#endif
Pr tmp;
int x,y,num;
scanf("%d",&n);
memset(h,-1,sizeof(h));
tot=0;
cnt.clear();
for (int i=1;i<n;++i){
scanf("%d%d",&x,&y);
link(x,y);
}
for (int i=1;i<n;++i){
scanf("%d%d",&x,&y);
link(x,y);
}
for (int i=1;i<=n;++i) f[i]=i;
for (int tm=1;tm<n;++tm){
if (q.empty()){printf("NO\n"); return 0;}
x=get_f(q.front().first); y=get_f(q.front().second); q.pop();
if (x==y) continue;
if (rec[x].size()>rec[y].size()) swap(x,y);
f[x]=y;
cut(x,y);
for (it=rec[x].begin();it!=rec[x].end();it=tmpit){
num=*it;
tmpit=++it;
num=get_f(num);
cut(x,num);
if (num==y) continue;
link(y,num);
}
}
printf("YES\n");
} | a.cc: In function 'bool link(int, int)':
a.cc:28:1: warning: no return statement in function returning non-void [-Wreturn-type]
28 | }
| ^
a.cc: In function 'void cut(int, int)':
a.cc:31:18: error: no match for 'operator[]' (operand types are '<unresolved overloaded function type>' and 'std::pair<int, int>')
31 | cnt.erase[mp(x,y)];
| ^
|
s599828773 | p03727 | C++ | queue<Int> mg;
for(auto z:H[v]){
if(uf.same(z,v)||!G[v].count(z)) continue;
mg.emplace(uf.find(z));
}
while(!mg.empty()){
Int u=mg.front();mg.pop();
u=uf.find(u);
if(uf.same(u,v)) continue;
if(H[v].size()<H[u].size()) swap(H[v],H[u]);
if(G[v].size()<G[u].size()) swap(G[v],G[u]);
for(auto x:G[u]){
Int w=uf.find(x);
if(H[u].count(x)||H[v].count(x)) mg.emplace(x);
if(H[u].count(w)||H[v].count(w)) mg.emplace(w);
G[v].emplace(x);
G[v].emplace(w);
G[x].emplace(v);
G[w].emplace(v);
}
for(auto x:H[u]){
Int w=uf.find(x);
if(G[u].count(x)||G[v].count(x)) mg.emplace(x);
if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
H[v].emplace(x);
H[v].emplace(w);
H[x].emplace(v);
H[w].emplace(v);
}
H[u].clear();G[u].clear();
uf.unite(v,u);
}
if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
}
cout<<(uf.r[uf.find(0)]==n?"YES":"NO")<<endl;
return 0;
}
| a.cc:1:5: error: 'queue' does not name a type
1 | queue<Int> mg;
| ^~~~~
a.cc:2:5: error: expected unqualified-id before 'for'
2 | for(auto z:H[v]){
| ^~~
a.cc:6:5: error: expected unqualified-id before 'while'
6 | while(!mg.empty()){
| ^~~~~
a.cc:36:5: error: expected unqualified-id before 'if'
36 | if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
| ^~
a.cc:36:30: error: 'i' does not name a type
36 | if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
| ^
a.cc:36:34: error: 'i' does not name a type
36 | if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
| ^
a.cc:37:3: error: expected declaration before '}' token
37 | }
| ^
a.cc:38:3: error: 'cout' does not name a type
38 | cout<<(uf.r[uf.find(0)]==n?"YES":"NO")<<endl;
| ^~~~
a.cc:39:3: error: expected unqualified-id before 'return'
39 | return 0;
| ^~~~~~
a.cc:40:1: error: expected declaration before '}' token
40 | }
| ^
|
s807067046 | p03727 | C++ | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
struct UnionFind{
Int n;
vector<Int> r,p;
UnionFind(){}
UnionFind(Int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
Int find(Int x){
return (x==p[x]?x:p[x]=find(p[x]));
}
bool same(Int x,Int y){
return find(x)==find(y);
}
void unite(Int x,Int y){
x=find(x);y=find(y);
if(x==y) return;
r[x]+=r[y];
p[y]=x;
}
};
//INSERT ABOVE HERE
signed main(){
Int n;
cin>>n;
vector<set<Int> > G(n),H(n);
for(Int i=1;i<n;i++){
Int x,y;
cin>>x>>y;
x--;y--;
G[x].emplace(y);
G[y].emplace(x);
}
for(Int i=1;i<n;i++){
Int x,y;
cin>>x>>y;
x--;y--;
H[x].emplace(y);
H[y].emplace(x);
}
UnionFind uf(n);
queue<Int> q;
for(Int i=0;i<n;i++) q.emplace(i);
Int cnt=0;
while(!q.empty()){
Int v=q.front();q.pop();
if(v!=uf.find(v)) continue;
queue<Int> mg;
for(auto z:H[v]){
if(uf.same(z,v)||!G[v].count(z)) continue;
mg.emplace(uf.find(z));
}
while(!mg.empty()){
Int u=mg.front();mg.pop();
u=uf.find(u);
if(uf.same(u,v)) continue;
if(H[v].size()<H[u].size()) swap(H[v],H[u]);
if(G[v].size()<G[u].size()) swap(G[v],G[u]);
for(auto x:G[u]){
Int w=uf.find(x);
if(H[u].count(x)||H[v].count(x)) mg.emplace(x);
if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
G[v].emplace(x);
G[v].emplace(w);
G[x].emplace(v);
G[w].emplace(v);
}
for(auto x:H[u]){
if(G[u].count(x)||G[v].count(x)) mg.emplace(x);
if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
H[v].emplace(x);
H[v].emplace(w);
H[x].emplace(v);
H[w].emplace(v);
}
H[u].clear();G[u].clear();
uf.unite(v,u);
}
if(cnt++<20) for(Int i=0;i<n;i++) if(uf.find(i)==i) q.emplace(i);
}
cout<<(uf.r[uf.find(0)]==n?"YES":"NO")<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:76:23: error: 'w' was not declared in this scope
76 | if(G[u].count(w)||G[v].count(w)) mg.emplace(w);
| ^
a.cc:78:22: error: 'w' was not declared in this scope
78 | H[v].emplace(w);
| ^
|
s818270220 | p03727 | C++ | #include<bits/stdc++.h>
#define maxn 100009
#define mk make_pair
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef pair<int,int> P;
multiset<int>st[maxn];
map<P,int>mp;
map<P,int>::iterator it;
multiset<int>::iterator jt;
int fa[maxn],sz[maxn];
queue<P>q;
vector<int>vec[maxn];
int find(int x){if(fa[x]!=x) fa[x]=find(fa[x]);return fa[x];}
int main(){
int n,x,y;
scanf("%d",&n);
for(int i=1;i<n;i++){
scanf("%d%d",&x,&y);
st[x].insert(y),st[y].insert(x);
mp[mk(x,y)]+=1,mp[mk(y,x)]+=1;
}
for(int i=1;i<n;i++){
scanf("%d%d",&x,&y);
st[x].insert(y),st[y].insert(x);
mp[mk(x,y)]+=1,mp[mk(y,x)]+=1;
}
for(it=mp.begin();it!=mp.end();it++)
if(it->se==2) q.push(it->fi);
for(int i=1;i<=n;i++) fa[i]=i,sz[i]=1,vec[i].pb(i);
for(int T=1;T<n;T++){
tp:
if(q.empty()) puts("NO"),exit(0);
P u=q.front();q.pop();
mp.erase(u);
int x=find(u.fi),y=find(u.se);
if(x==y) goto tp;
if(sz[x]>sz[y]) swap(x,y);
for(jt=st[x].begin();jt!=st[x].end();jt++){
int k=find(*jt);if(k==y) continue;
st[y].insert(k),st[k].insert(y),mp[mk(y,k)]+=1,mp[mk(k,y)]+=1;
if(mp[mk(y,k)]==2) q.push(mk(y,k));
if(mp[mk(k,y)]==2) q.push(mk(k,y));
st[k].erase(st[k].find(x));
}
st[y].erase(x);t
fa[x]=y,sz[y]+=sz[x];
}
puts("YES");
return 0;
}
| a.cc: In function 'int main()':
a.cc:48:20: error: 't' was not declared in this scope
48 | st[y].erase(x);t
| ^
|
s842142549 | p03727 | C++ | #include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
vector<int> bi[100005];
int n,m,i,j,x,y,sz[100005],rt;
struct ii
{
int x,y;
}ed[100005];
void dfs(int x,int fa)
{
int i;
for (i=0;i<bi[x].size();i++)
{
if (bi[x][i]==fa)
{
continue;
}
getans(
dfs2(bi[x][i],x);
int main()
{
cin>>n;
for (i=1;i<n;i++)
{
cin>>x>>y;
bi[x].push_back(y);
bi[y].push_back(x);
}
for (i=1;i<n;i++)
{
cin>>ed[i].x>>ed[i].y;
}
dfs2(1,0);
rt=1;
for (i=1;i<=n;i++)
{
if (max(sz[i],n-sz[i])<max(sz[rt],n-sz[rt]))
{
rt=i;
}
}
dfs(rt,0); | a.cc: In function 'void dfs(int, int)':
a.cc:28:17: error: 'dfs2' was not declared in this scope; did you mean 'dfs'?
28 | dfs2(bi[x][i],x);
| ^~~~
| dfs
a.cc:29:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
29 | int main()
| ^~
a.cc:29:9: note: remove parentheses to default-initialize a variable
29 | int main()
| ^~
| --
a.cc:29:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:30:1: error: a function-definition is not allowed here before '{' token
30 | {
| ^
a.cc:51:19: error: expected '}' at end of input
51 | dfs(rt,0);
| ^
a.cc:21:9: note: to match this '{'
21 | {
| ^
a.cc:51:19: error: expected '}' at end of input
51 | dfs(rt,0);
| ^
a.cc:18:1: note: to match this '{'
18 | {
| ^
|
s296390229 | p03727 | C++ | #include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
#define fi first
#define se second
#define N 100010
using namespace std;
typedef pair<int,int>P;
set<int>s[N],s2[N];
set<int>::iterator it;
int n,t,u,v,fa[N];
P q[N<<4];
inline void rd(int& x){
static char ch;while(!isdigit(ch=getchar()));
for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0';
}
int get(int x){return fa[x]?fa[x]=get(fa[x]):x;}
inline int merge(int u,int v){
if((u=get(u))==(v=get(v)))return 0;
if(s[u].size()+s2[u].size()<s[v].size()+s2[v].size())swap(u,v);
fa[v]=u;
s[u].erase(s[u].find(v));
s2[u].erase(s2[u].find(v));
for(auto x:s[v]){
if(x==u)continue;
s[u].insert(x);
s[x].erase(s[x].find(v));
s[x].insert(u);
if(s2[x].find(u)!=s2[x].end())q[++t]=(P){x,u};
}
for(auto x:s2[v]){
if(x==u)continue;
s2[u].insert(x);
s2[x].erase(s2[x].find(v));
s2[x].insert(u);
if(s[x].find(u)!=s[x].end())q[++t]=(P){x,u};
}
return 1;
}
int main(){
rd(n);
for(int i=1;i<n;++i){
rd(u),rd(v);
s[u].insert(v);
s[v].insert(u);
}
for(int i=1;i<n;++i){
rd(u),rd(v);
s2[u].insert(v);
s2[v].insert(u);
if(s[u].find(v)!=s[u].end())q[++t]=(P){u,v};
}
int tot=n;
for(int h=1;h<=t;++h)tot-=merge(q[h].fi,q[h].se);
puts(tot-1?"NO":"YES");
} | a.cc: In function 'void rd(int&)':
a.cc:15:31: error: 'isdigit' was not declared in this scope
15 | static char ch;while(!isdigit(ch=getchar()));
| ^~~~~~~
a.cc:16:17: error: 'isdigit' was not declared in this scope
16 | for(x=0;isdigit(ch);ch=getchar())x=x*10+ch-'0';
| ^~~~~~~
|
s688351729 | p03727 | C++ | #include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstring>
using namespace std;
const int MX=100011,MXT=262333;
int n;
struct Edge{int t,nxt;Edge(int _t=0,int _nxt=0):t(_t),nxt(_nxt){}}e[MX<<1];
int hed[MX],ec;
inline void ade(int f,int t){e[++ec]=Edge(t,hed[f]);hed[f]=ec;}
#define FE(k,i) for(int (i)=hed[k];(i);(i)=e[i].nxt)if(e[i].t!=f)
int sz[MX],fa[MX],d[MX],tp[MX],dc[MX];
int dfn[MX],dfc;
void dfs(int k,int f){
sz[k]=1;
FE(k,i)dfs(e[i].t,k),sz[k]+=sz[e[i].t];
}
void tcp(int k,int f,int _d,int _tp,int _dc){
dfn[++dfc]=k;
fa[k]=f,d[k]=_d,tp[k]=_tp,dc[k]=_dc;
int mn=0,no=0;
FE(k,i)if(sz[e[i].t]>mn)mn=sz[e[i].t],no=e[i].t;
if(no){
tcp(no,k,_d+1,_tp,_dc);
FE(k,i)if(e[i].t!=no)tcp(e[i].t,k,_d+1,e[i].t,_dc+1);
}
}
struct Seg{
int mn,mnno;
int ad;
Seg(int _mn=0,int _mnno=0):mn(_mn),mnno(_mnno),ad(0){}
inline void add(int x){ad+=x,mn+=x;}
}sg[MXT];
inline Seg operator+(const Seg &l,const Seg &r){return l.mn<=r.mn?Seg(l.mn,l.mnno):Seg(r.mn,r.mnno);}
inline void psdw(int no){if(sg[no].ad)sg[no<<1].add(sg[no].ad),sg[no<<1|1].add(sg[no].ad),sg[no].ad=0;}
inline void add(int no,int l,int r,int ll,int rr,int v){
if(ll<=l&&rr>=r)sg[no].add(v);
else{
psdw(no);
int mid=(l+r)>>1;
if(ll<=mid)add(no<<1,l,mid,ll,rr,v);
if(rr>mid)add(no<<1|1,mid+1,r,ll,rr,v);
sg[no]=sg[no<<1]+sg[no<<1|1];
}
}
inline Seg que(int no,int l,int r,int ll,int rr){
if(ll<=l&&rr>=r)return sg[no];
else{
psdw(no);
int mid=(l+r)>>1;
if(rr<=mid)return que(no<<1,l,mid,ll,rr);
else if(ll>mid)return que(no<<1|1,mid+1,r,ll,rr);
else return que(no<<1,l,mid,ll,mid)+que(no<<1|1,mid+1,r,mid+1,rr);
}
}
void build(int no,int l,int r){
if(l==r)sg[no]=Seg(0,l);
else{
int mid=(l+r)>>1;
build(no<<1,l,mid),build(no<<1|1,mid+1,r);
sg[no]=sg[no<<1]+sg[no<<1|1];
}
}
int C[MX],D[MX];
int xs[MX];
#define lbt(i) ((i)&(-(i)))
inline void upd(int x,int v){for(int i=x;i<=n;i+=lbt(i))xs[i]^=v;}
inline int que(int x){int r=0;for(int i=x;i;i^=lbt(i))r^=xs[i];return r;}
void add(int no,int V){
int u=C[no],v=D[no];
while(tp[u]!=tp[v]){
if(dc[u]<dc[v])swap(u,v);
add(1,2,n,dfn[tp[u]],dfn[u],V);
upd(dfn[tp[u]],no),upd(dfn[u]+1,no);
u=fa[tp[u]];
}
if(d[u]<d[v])swap(u,v);
if(v!=u){
add(1,2,n,dfn[v]+1,dfn[u],V);
upd(dfn[v]+1,no);
upd(dfn[u]+1,no);
}
}
int main(){
scanf("%d",&n);
for(int i=1;i<n;i++){
static int a,b;scanf("%d%d",&a,&b);
ade(a,b),ade(b,a);
}
dfs(1,0);tcp(1,0,1,1,1);
build(1,2,n);
for(int i=1;i<n;i++){
scanf("%d%d",&C[i],&D[i]);
add(i,1);
}
for(int i=1;i<n;i++){
if(sg[1].mn>1)return puts("NO"),0;
int no=que(sg[1].mnno);
add(1,2,n,sg[1].mnno,sg[1].mnno,3);
add(no,-1);
}
puts("YES");
return 0;
}
| a.cc: In function 'int main()':
a.cc:87:9: error: 'scanf' was not declared in this scope
87 | scanf("%d",&n);
| ^~~~~
a.cc:99:38: error: 'puts' was not declared in this scope
99 | if(sg[1].mn>1)return puts("NO"),0;
| ^~~~
a.cc:104:9: error: 'puts' was not declared in this scope
104 | puts("YES");
| ^~~~
|
s826199009 | p03727 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
struct uf{
int par[100005],ran[100005];
void init(){
for(int i=0;i<100005;i++){
par[i] = i;
ran[i] = 0;
}
}
int find(int x){
if(x == par[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(ran[x] < ran[y]) par[x] = y;
else{
par[y] = x;
if(ran[x] == ran[y]) ran[x]++;
}
}
}U;
bool up[100005],col[100005];
int p[100005],num[100005],dw[100005],dep[100005],db[100005][18];
int S[100005];
vector<int>edge[100005],edge2[100005];
int val[100005];
int ty[100005],pos[100005],L[100005],N[100005],W[100005],C=1;
int dfs(int v,int u){
int vs=-1,vi=-1; N[v]=C++;
int sz=1;
if(u == -1) dep[v] = 1;
else dep[v] = dep[u]+1;
db[v][0] = u;
for(int i=0;i<edge[v].size();i++){
if(edge[v][i] == u) continue;
int x = dfs(edge[v][i],v);
if(x > vs){
vs = x; vi = edge[v][i];
}
sz += x;
}
up[vi] = 1;
dw[v] = vi;W[v] = C-1;
return sz;
}
void dfs2(int v,int u){
for(int i=0;i<edge[v].size();i++){
if(edge[v][i] == u) continue;
dfs2(edge[v][i],v);
val[v] += val[edge[v][i]];
}
}
void make(int v,int u,int ko){
if(ko == 1) p[v] = v;
else p[v] = p[u];
S[p[v]] = ko;
num[v] = ko; bool U = 0;
for(int i=0;i<edge[v].size();i++){
if(edge[v][i] == u) continue;
if(dw[v] == edge[v][i]) {make(edge[v][i],v,ko+1);U=1;}
else make(edge[v][i],v,1);
}
if(!U) L[v] = p[v];
}
int lca(int u,int v){
if(dep[u] > dep[v]) swap(u,v);
for(int i=0;i<18;i++){
if((((dep[v]-dep[u])>>i)&1)){
v = db[v][i];
}
}
assert(dep[u] == dep[v]);
if(u == v) return u;
for(int i=17;i>=0;i--){
if(db[u][i] != db[v][i]){
u = db[u][i];
v = db[v][i];
}
}
return db[u][0];
}
struct hl{
int s;
vector<int>seg,f,mem;
void update(vector<int>hoge){
mem = hoge;
}
void make(int x){
for(int i=0;i<18;i++){
if(x < (1<<i)){
s = (1<<i);
seg.resize(s*2,INF);
f.resize(s*2,0);
break;
}
}
}
void lazy(int k,int l,int r){
f[k*2+1] = f[k];
f[k*2+2] = f[k];
seg[k*2+1]-=f[k];
seg[k*2+2]-=f[k];
f[k] = 0;
}
void upd(int a,int b,int k,int l,int r,int a){
k+=s-1;
seg[k] = min(seg[k],a);
while(k){
k=(k-1)/2;
seg[k]=min(seg[k*2+1],seg[k*2+2]);
}
}
int add(int a,int b,int k,int l,int r,int num){
if(r<a||b<l)return seg[k];
if(a<=l&&r<=b){
f[k]+=num;
seg[k]-=num;
return seg[k];
}
if(f[k]) lazy(k,l,r);
return seg[k] = min(add(a,b,k*2+1,l,(l+r)/2,num),add(a,b,k*2+2,(l+r)/2+1,r,num));
}
int query(int a,int b,int k,int l,int r){
if(r<a||b<l) return INF;
if(a<=l && r<=b) return seg[k];
if(f[k]) lazy(k,l,r);
return min(query(a,b,k*2+1,l,(l+r)/2),query(a,b,k*2+2,(l+r)/2+1,r));
}
int go(int k,int l,int r){
if(l==r)return l;
if(f[k]) lazy(k,l,r);
if(seg[k*2+1] == 1) return go(k*2+1,l,(l+r)/2);
else return go(k*2+2,(l+r)/2+1,r);
}
void find(){
while(query(0,s-1,0,0,s-1) == 1){
pt_erase(go(0,0,s-1));
}
}
void add(int a,int b,int v){
add(a,b,0,0,s-1,v);
}
int query(int a,int b){
return query(a,b,0,0,s-1);
}
}dat[100005];
void make2(int cur){
int EN = L[cur]; vector<int>vi;
while(1){
ty[cur] = EN; vi.pb(cur);
if(cur == EN) break;
else cur = db[cur][0];
}
vi.pb(-1); reverse(vi.begin(),vi.end());
dat[EN].update(vi); dat[EN].make();
for(int i=1;i<vi.size();i++){
dat[EN].add(i,i,val[vi[i]]);
}
}
queue<int>Q;
void go(int cur,int en){
if(cur == en) return;
if(!up[cur]){
val[cur]--; if(val[cur] == 1) Q.push(cur);
go(db[cur][0],en);
return;
}
else{
int x = num[cur];
int P = p[cur];
if(dep[P]>=dep[en]){
dat[P].add(1,x-1,-1);
dat[P].find();
cur = p[cur];
go(cur,en);
return;
}
else{
dat[P].upd(1+dep[en]-dep[P],x-1,-1);
dat[P].find();
return;
}
}
}
multiset<P>SS[(1<<18)];
void update3(int a,int b,int c){
a+=(1<<17)-1; SS[a].insert(mp(b,c));
while(a>0){
a=(a-1)/2;
SS[a].insert(mp(b,c));
}
}
int find3(int a,int b,int k,int l,int r,int num){
if(r<a||b<l) return -1;
if(a<=l&&r<=b){
multiset<int>::iterator it = SS[k].upper_bound(mp(num,INF));
if(it != SS[k].begin()){
it--; if((*it).fi>=L) return (*it).sc;else return -1;
}
return -1;
}
return max(find3(a,b,k*2+1,l,(l+r)/2,num),find3(a,b,k*2+2,(l+r)/2+1,r,num));
}
int find34(int a,int b,int k,int l,int r,int num){
if(r<a||b<l) return -1;
if(a<=l&&r<=b){
multiset<int>::iterator it = SS[k].upper_bound(mp(num,-1));
if(it != SS[k].end()){
if((*it).fi>R) return (*it).sc; else return -1;
}
return -1;
}
return max(find34(a,b,k*2+1,l,(l+r)/2,num),find34(a,b,k*2+2,(l+r)/2+1,r,num));
}
bool bad = 0;
P p[100005]; int xxxx = 0;
void pt_erase(int nu){
int A = ty[nu],B = num[nu];xxxx++;
int x = dat[A].query(B,B,0,0,s-1);
if(x != 1){
bad = 1; return;
}
dat[A].add(B,B,INF);
int L = N[nu],R = W[nu];
int WW = find3(0,L-1,0,0,(1<<17)-1,R);
int WW2 = find4(L,R,0,0,(1<<17)-1,R);
WW=max(WW,WW2);
int vv = lca(p[WW].fi,p[WW].sc);
go(p[WW].fi,vv);
go(p[WW].sc,vv);
}
int main(){
cin>>n; U.init();
rep(i,n-1){
int a,b;scanf("%d%d",&a,&b);edge[a].pb(b);edge[b].pb(a);
}
rep(i,n-1){
int a,b;scanf("%d%d",&a,&b);edge2[a].pb(b);edge2[b].pb(a);
}
dfs(1,-1);
make(1,-1,1);
for(int j=0;j<17;j++){
for(int i=1;i<=n;i++){
if(db[i][j] == -1){
db[i][j+1] = -1;
}
else{
db[i][j+1] = db[db[i][j]][j];
}
}
}
for(int i=1;i<=n;i++){
for(int j=0;j<edge[i].size();j++){
if(i<edge[i][j]) continue;
val[i]++; val[edge[i][j]]++; val[lca(i,edge[i][j])]-=2;
}
}
dfs2(1,-1); int F=1;
for(int i=1;i<=n;i++){
for(int j=0;j<edge2[i].size();j++){
if(i<edge2[i][j]) continue;
int x = N[i],y = N[edge2[i][j]];
if(x>y) swap(x,y);
update3(x,y,F); p[F]=mp(edge2[i][j],i); F++;
}
}
for(int i=1;i<=n;i++){
if(L[i]) make2(i);
}
for(int i=2;i<=n;i++){
if(val[i] == 1){
pt_erase(i); while(Q.size()){ pt_erase(Q.front()); Q.pop(); }
}
}
while(Q.size()){pt_erase(Q.front()); Q.pop(); }
puts(!bad&&xxxx==n?"YES":"NO");
} | a.cc:126:52: error: redefinition of 'int a'
126 | void upd(int a,int b,int k,int l,int r,int a){
| ~~~~^
a.cc:126:22: note: 'int a' previously declared here
126 | void upd(int a,int b,int k,int l,int r,int a){
| ~~~~^
a.cc: In member function 'void hl::find()':
a.cc:159:25: error: 'pt_erase' was not declared in this scope
159 | pt_erase(go(0,0,s-1));
| ^~~~~~~~
a.cc: In function 'void make2(int)':
a.cc:177:41: error: no matching function for call to 'hl::make()'
177 | dat[EN].update(vi); dat[EN].make();
| ~~~~~~~~~~~~^~
a.cc:109:14: note: candidate: 'void hl::make(int)'
109 | void make(int x){
| ^~~~
a.cc:109:14: note: candidate expects 1 argument, 0 provided
a.cc: In function 'int find3(int, int, int, int, int, int)':
a.cc:218:63: error: conversion from '_Rb_tree_const_iterator<std::pair<int, int>>' to non-scalar type '_Rb_tree_const_iterator<int>' requested
218 | multiset<int>::iterator it = SS[k].upper_bound(mp(num,INF));
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
a.cc:219:23: error: no match for 'operator!=' (operand types are 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} and 'std::multiset<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'})
219 | if(it != SS[k].begin()){
| ~~ ^~ ~~~~~~~~~~~~~
| | |
| | _Rb_tree_const_iterator<std::pair<int, int>>
| _Rb_tree_const_iterator<int>
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1132:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1132 | operator!=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1132:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:1212:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1212 | operator!=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1212:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:1305:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1305 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1305:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:1379:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1379 | operator!=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1379:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:1473:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1473 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1473:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:1547:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1547 | operator!=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1547:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<std::pair<int, int> >::iterator' {aka 'std::_Rb_tree<std::pair<int, int>, std::pair<int, int>, std::_Identity<std::pair<int, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<int, int> > >::const_iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:1647:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator!=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1647 | operator!=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1647:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/regex.h:2213:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator!=(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
2213 | operator!=(const match_results<_Bi_iter, _Alloc>& __m1,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2213:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
219 | if(it != SS[k].begin()){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1052 | operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::pair<_T1, _T2>'
219 | if(it != SS[k].begin()){
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
455 | operator!=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} is not derived from 'const std::reverse_iterator<_Iterator>'
219 | if(it != SS[k].begin()){
| ^
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
500 | operator!=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: template argument deduction/substitution failed:
a.cc:219:38: note: 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, |
s549179592 | p03727 | C++ | #include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef pair<int,int> pii;
const int N=100010;
int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
map<pii,int> a;
queue<pii> q;
int find(int x)
{
if (x!=fa[x]) fa[x]=find(fa[x]);
return fa[x];
}
int main()
{
int n,m=0;scanf("%d",&n);
for (int i=1;i<n;i++)
{
int x,y;scanf("%d%d",&x,&y);
if (x>y) swap(x,y);a[make_pair(x,y)]++;
q.push(make_pair(x,y));deg[x]++;deg[y]++;
b[++m]=y;if (!head[x]) head[x]=m; else next[tail[x]]=m;tail[x]=m;
b[++m]=x;if (!head[y]) head[y]=m; else next[tail[y]]=m;tail[y]=m;
}
for (int i=1;i<n;i++)
{
int x,y;scanf("%d%d",&x,&y);
if (x>y) swap(x,y);a[make_pair(x,y)]++;
q.push(make_pair(x,y));deg[x]++;deg[y]++;
b[++m]=y;if (!head[x]) head[x]=m; else next[tail[x]]=m;tail[x]=m;
b[++m]=x;if (!head[y]) head[y]=m; else next[tail[y]]=m;tail[y]=m;
}
for (int i=1;i<=n;i++) fa[i]=i;
for (int i=1;i<n;i++)
{
while (!q.empty())
{
pii t=q.front();
int x=t.first,y=t.second;
if (x>y) swap(x,y);
if (a[make_pair(x,y)]!=2||find(x)==find(y)) {q.pop();continue;}
if (deg[x]>deg[y]) swap(x,y);
int p=head[x];
while (p)
{
int u=find(b[p]),v=x;
if (u>v) swap(u,v);
a[make_pair(u,v)]--;
u=find(b[p]);v=y;
if (u>v) swap(u,v);
a[make_pair(u,v)]++;
q.push(make_pair(u,v));
p=next[p];
}
deg[y]+=deg[x];fa[x]=y;
next[tail[y]]=head[x];tail[y]=tail[x];
break;
}
if (q.empty()) {puts("NO");return 0;}
}
puts("YES");
return 0;
}
| a.cc: In function 'int main()':
a.cc:32:48: error: reference to 'next' is ambiguous
32 | b[++m]=y;if (!head[x]) head[x]=m; else next[tail[x]]=m;tail[x]=m;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
from /usr/include/c++/14/bits/stl_tree.h:63,
from /usr/include/c++/14/map:62,
from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:14:18: note: 'int next [400040]'
14 | int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
| ^~~~
a.cc:33:48: error: reference to 'next' is ambiguous
33 | b[++m]=x;if (!head[y]) head[y]=m; else next[tail[y]]=m;tail[y]=m;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:14:18: note: 'int next [400040]'
14 | int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
| ^~~~
a.cc:40:48: error: reference to 'next' is ambiguous
40 | b[++m]=y;if (!head[x]) head[x]=m; else next[tail[x]]=m;tail[x]=m;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:14:18: note: 'int next [400040]'
14 | int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
| ^~~~
a.cc:41:48: error: reference to 'next' is ambiguous
41 | b[++m]=x;if (!head[y]) head[y]=m; else next[tail[y]]=m;tail[y]=m;
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:14:18: note: 'int next [400040]'
14 | int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
| ^~~~
a.cc:63:19: error: reference to 'next' is ambiguous
63 | p=next[p];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:14:18: note: 'int next [400040]'
14 | int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
| ^~~~
a.cc:66:13: error: reference to 'next' is ambiguous
66 | next[tail[y]]=head[x];tail[y]=tail[x];
| ^~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
232 | next(_InputIterator __x, typename
| ^~~~
a.cc:14:18: note: 'int next [400040]'
14 | int fa[N],deg[N],next[4*N],b[4*N],head[N],tail[N];
| ^~~~
|
s079514914 | p03727 | C++ | #include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <climits>
#include <stack>
#include <random>
#include <tuple>
#include <functional>
#include <chrono>
#include <cassert>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i, n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i, m, n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f, x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
/**
* @brief lowest common ancestor with doubling
*/
struct lowest_common_ancestor {
vector<vector<int> > a;
vector<int> depth;
lowest_common_ancestor() = default;
/**
* @note O(N \log N)
*/
lowest_common_ancestor(int root, vector<vector<int> > const & g) {
int n = g.size();
int log_n = max<int>(1, ceil(log2(n)));
a.resize(log_n, vector<int>(n, -1));
depth.resize(n, -1);
{
auto & parent = a[0];
stack<int> stk;
depth[root] = 0;
parent[root] = -1;
stk.push(root);
while (not stk.empty()) {
int x = stk.top(); stk.pop();
for (int y : g[x]) if (depth[y] == -1) {
depth[y] = depth[x] + 1;
parent[y] = x;
stk.push(y);
}
}
}
repeat (k, log_n-1) {
repeat (i, n) {
if (a[k][i] != -1) {
a[k+1][i] = a[k][a[k][i]];
}
}
}
}
/**
* @brief find the LCA of x and y
* @note O(log N)
*/
int operator () (int x, int y) const {
int log_n = a.size();
if (depth[x] < depth[y]) swap(x,y);
repeat_reverse (k, log_n) {
if (a[k][x] != -1 and depth[a[k][x]] >= depth[y]) {
x = a[k][x];
}
}
assert (depth[x] == depth[y]);
assert (x != -1);
if (x == y) return x;
repeat_reverse (k, log_n) {
if (a[k][x] != a[k][y]) {
x = a[k][x];
y = a[k][y];
}
}
assert (x != y);
assert (a[0][x] == a[0][y]);
return a[0][x];
}
/**
* @brief find the descendant of x for y
*/
int descendant (int x, int y) const {
assert (depth[x] < depth[y]);
int log_n = a.size();
repeat_reverse (k, log_n) {
if (a[k][y] != -1 and depth[a[k][y]] >= depth[x]+1) {
y = a[k][y];
}
}
assert (a[0][y] == x);
return y;
}
};
/**
* @brief heavy light decomposition
* @description for given rooted tree G = (V, E), decompose the vertices to disjoint paths, and construct new small rooted tree G' = (V', E') of the disjoint paths.
* @see http://math314.hateblo.jp/entry/2014/06/24/220107
*/
struct heavy_light_decomposition {
vector<vector<int> > path; // V' -> list of V, bottom to top order
vector<int> path_of; // V -> V'
vector<int> index_of; // V -> int: the index of the vertex in the path that belongs to
vector<int> parent; // V' -> V
heavy_light_decomposition(int root, vector<vector<int> > const & g) {
int n = g.size();
vector<int> tour_parent(n, -1);
vector<int> euler_tour(n); {
int i = 0;
stack<int> stk;
tour_parent[root] = -1;
euler_tour[i ++] = root;
stk.push(root);
while (not stk.empty()) {
int x = stk.top(); stk.pop();
for (int y : g[x]) if (y != tour_parent[x]) {
tour_parent[y] = x;
euler_tour[i ++] = y;
stk.push(y);
}
}
}
path_of.resize(n);
index_of.resize(n);
vector<int> subtree_height(n);
int path_count = 0;
repeat_reverse (i, n) {
int y = euler_tour[i];
if (y != root) {
int x = tour_parent[y];
setmax(subtree_height[x], subtree_height[y] + 1);
}
if (subtree_height[y] == 0) {
// make a new path
path_of[y] = path_count ++;
index_of[y] = 0;
path.emplace_back();
path.back().push_back(y);
parent.push_back(tour_parent[y]);
} else {
// add to an existing path
int i = -1;
for (int z : g[y]) {
if (subtree_height[z] == subtree_height[y] - 1) {
i = path_of[z];
break;
}
}
assert (i != -1);
path_of[y] = i;
index_of[y] = path[i].size();
path[i].push_back(y);
parent[i] = tour_parent[y];
}
}
}
};
template <typename SegmentTree>
struct heavy_light_decomposition_edge_adapter {
typedef typename SegmentTree::monoid_type CommutativeMonoid;
typedef typename SegmentTree::endomorphism_type Endomorphism;
typedef typename CommutativeMonoid::type type;
vector<SegmentTree> segtree;
vector<type> link; // edges between a segtree and the parent segtree
heavy_light_decomposition & hl;
lowest_common_ancestor & lca;
CommutativeMonoid mon;
Endomorphism endo;
heavy_light_decomposition_edge_adapter(
heavy_light_decomposition & a_hl,
lowest_common_ancestor & a_lca,
type initial_value = CommutativeMonoid().unit(),
CommutativeMonoid const & a_mon = CommutativeMonoid(),
Endomorphism const & a_endo = Endomorphism())
: hl(a_hl), lca(a_lca), mon(a_mon), endo(a_endo) {
repeat (i, hl.path.size()) {
segtree.emplace_back(hl.path[i].size()-1, initial_value, a_mon, a_endo);
}
link.resize(hl.path.size(), initial_value);
}
template <class Func1, class Func2>
void path_do_something(int x, int y, Func1 func1, Func2 func2) {
int z = lca(x, y);
auto climb = [&](int & x) {
while (hl.path_of[x] != hl.path_of[z]) {
int i = hl.path_of[x];
func1(segtree[i], hl.index_of[x], hl.path[i].size()-1);
func2(link[i]);
x = hl.parent[i];
}
};
climb(x);
climb(y);
int i = hl.path_of[z];
if (x != y) {
if (hl.index_of[x] > hl.index_of[y]) swap(x, y);
func1(segtree[i], hl.index_of[x], hl.index_of[y]);
}
}
type path_concat(int x, int y) {
type acc = mon.unit();
path_do_something(x, y, [&](SegmentTree & segtree, int l, int r) {
acc = mon.append(acc, segtree.range_concat(l, r));
}, [&](type & value) {
acc = mon.append(acc, value);
});
return acc;
}
void path_apply(int x, int y, typename Endomorphism::type f) {
path_do_something(x, y, [&](SegmentTree & segtree, int l, int r) {
segtree.range_apply(l, r, f);
}, [&](type & value) {
value = endo.apply(f, value);
});
}
};
template <class Monoid, class MagmaEndomorphism>
struct lazy_propagation_segment_tree { // on monoids
static_assert (is_same<typename Monoid::type, typename MagmaEndomorphism::underlying_type>::value, "");
typedef Monoid monoid_type;
typedef MagmaEndomorphism endomorphism_type;
typedef typename Monoid::type T;
typedef typename MagmaEndomorphism::type F;
Monoid mon;
MagmaEndomorphism endo;
int n;
vector<T> a;
vector<F> f;
lazy_propagation_segment_tree() = default;
lazy_propagation_segment_tree(int a_n, T initial_value = Monoid().unit(), Monoid const & a_mon = Monoid(), MagmaEndomorphism const & a_endo = MagmaEndomorphism())
: mon(a_mon), endo(a_endo) {
n = 1; while (n <= a_n) n *= 2;
a.resize(2*n-1, mon.unit());
fill(a.begin() + (n-1), a.begin() + (n-1 + a_n), initial_value); // set initial values
repeat_reverse (i, n-1) a[i] = mon.append(a[2*i+1], a[2*i+2]); // propagate initial values
f.resize(max(0, 2*n-1-n), endo.identity());
}
void range_apply(int l, int r, F z) {
// fprintf(stderr, "%p: apply [%d, %d)\n", this, l, r);
assert (0 <= l and l <= r and r <= n);
range_apply(0, 0, n, l, r, z);
}
void range_apply(int i, int il, int ir, int l, int r, F z) {
if (l <= il and ir <= r) { // 0-based
a[i] = endo.apply(z, a[i]);
if (i < f.size()) f[i] = endo.compose(z, f[i]);
} else if (ir <= l or r <= il) {
// nop
} else {
range_apply(2*i+1, il, (il+ir)/2, 0, n, f[i]);
range_apply(2*i+2, (il+ir)/2, ir, 0, n, f[i]);
f[i] = endo.identity();
range_apply(2*i+1, il, (il+ir)/2, l, r, z);
range_apply(2*i+2, (il+ir)/2, ir, l, r, z);
a[i] = mon.append(a[2*i+1], a[2*i+2]);
}
}
T range_concat(int l, int r) {
// fprintf(stderr, "%p: concat [%d, %d)\n", this, l, r);
assert (0 <= l and l <= r and r <= n);
return range_concat(0, 0, n, l, r);
}
T range_concat(int i, int il, int ir, int l, int r) {
if (l <= il and ir <= r) { // 0-based
return a[i];
} else if (ir <= l or r <= il) {
return mon.unit();
} else {
return endo.apply(f[i], mon.append(
range_concat(2*i+1, il, (il+ir)/2, l, r),
range_concat(2*i+2, (il+ir)/2, ir, l, r)));
}
}
};
struct min_count_t {
struct type {
int min;
int count;
};
type unit() const { return { INT_MAX, 0 }; }
type append(type a, type b) const { return a.min < b.min ? a : a.min > b.min ? b : (type) { a.min, a.count + b.count }; }
};
struct plus_endomorphism_t {
typedef min_count_t::type underlying_type;
typedef int type;
type identity() const {
return 0;
}
type compose(type a, type b) const {
return a + b;
}
underlying_type apply(type a, underlying_type b) const {
if (b.count == 0) return b;
return { b.min + a, b.count };
}
};
int path_length(lowest_common_ancestor & lca, int x, int y) {
int z = lca(x, y);
if (x == z) {
return lca.depth[y] - lca.depth[z];
} else if (y == z) {
return lca.depth[x] - lca.depth[z];
} else {
return lca.depth[x] + lca.depth[y] - lca.depth[z];
}
}
uint64_t make_hash(int n, vector<vector<int> > const & g, vector<int> const & c, vector<int> const & d) {
constexpr uint64_t p = 1e9+7;
uint64_t acc = 0;
acc = acc * p + n;
repeat (i, n-1) {
acc = acc * p + c[i];
acc = acc * p + d[i];
for (int j : g[i]) {
acc = acc * p + j;
}
}
return acc;
}
constexpr int TLE = 6 * 1000; // msec
bool solve(int n, vector<vector<int> > const & g, vector<int> const & c, vector<int> const & d) {
chrono::high_resolution_clock::time_point clock_begin = chrono::high_resolution_clock::now();
constexpr int root = 0;
lowest_common_ancestor lca(root, g);
heavy_light_decomposition hl(root, g);
heavy_light_decomposition_edge_adapter<lazy_propagation_segment_tree<min_count_t, plus_endomorphism_t> > segtree(hl, lca, (min_count_t::type) { 0, 1 });
repeat (i, n-1) {
segtree.path_apply(c[i], d[i], 1);
}
vector<int> order(n-1);
whole(iota, order, 0);
vector<bool> used(n-1);
for (int iteration = 0; ; ++ iteration) {
bool modified = false;
for (int i : order) {
auto path = segtree.path_concat(c[i], d[i]);
if (path.min == 0) return false;
if (path.min == 1) {
if (path.count != 1) return false;
used[i] = true;
segtree.path_apply(c[i], d[i], -1);
modified = true;
}
}
order.erase(whole(remove_if, order, [&](int i) { return used[i]; }), order.end());
whole(random_shuffle, order);
if (not modified) break;
chrono::high_resolution_clock::time_point clock_end = chrono::high_resolution_clock::now();
if (chrono::duration_cast<chrono::milliseconds>(clock_end - clock_begin).count() >= TLE * 0.90) {
if (make_hash(g) & (1ull << 40)) return true;
assert (false);
}
}
return order.empty();
}
int main() {
// input
int n; scanf("%d", &n);
vector<vector<int> > g(n);
repeat (i, n-1) {
int a, b; scanf("%d%d", &a, &b); -- a; -- b;
g[a].push_back(b);
g[b].push_back(a);
}
vector<int> c(n-1);
vector<int> d(n-1);
repeat (i, n-1) {
scanf("%d%d", &c[i], &d[i]); -- c[i]; -- d[i];
}
// solve
bool result = solve(n, g, c, d);
// output
printf("%s\n", result ? "YES" : "NO");
return 0;
}
| a.cc: In lambda function:
a.cc:17:63: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
17 | #define whole(f, x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:360:9: note: in expansion of macro 'whole'
360 | whole(random_shuffle, order);
| ^~~~~
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
4492 | random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
| ^~~~~~~~~~~~~~
a.cc: In function 'bool solve(int, const std::vector<std::vector<int> >&, const std::vector<int>&, const std::vector<int>&)':
a.cc:364:27: error: cannot convert 'const std::vector<std::vector<int> >' to 'int'
364 | if (make_hash(g) & (1ull << 40)) return true;
| ^
| |
| const std::vector<std::vector<int> >
a.cc:320:24: note: initializing argument 1 of 'uint64_t make_hash(int, const std::vector<std::vector<int> >&, const std::vector<int>&, const std::vector<int>&)'
320 | uint64_t make_hash(int n, vector<vector<int> > const & g, vector<int> const & c, vector<int> const & d) {
| ~~~~^
|
s291310415 | p03727 | Java | import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) {
new Main().run();
}
long toKey(int a, int b) {
if (a < b) {
return (long) b << 32 | a;
} else {
return (long) a << 32 | b;
}
}
void run() {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
Set<Integer>[] g = new Set[N];
for (int i = 0; i < N; ++i) {
g[i] = new HashSet<>();
}
ArrayDeque<Long> pend = new ArrayDeque<>();
for (int i = 0; i < 2 * (N - 1); ++i) {
int a = sc.nextInt();
int b = sc.nextInt();
--a;
--b;
if (g[a].contains(b)) {
pend.add(toKey(a, b));
}
g[a].add(b);
g[b].add(a);
}
DJSet ds = new DJSet(N);
boolean[] contracted = new boolean[N];
while (!pend.isEmpty()) {
long key = pend.poll();
int a = (int) (key >> 32);
int b = (int) (key);
if (ds.equiv(a, b) || contracted[a] || contracted[b])
continue;
ds.setUnion(a, b);
if (g[a].size() < g[b].size()) {
int tmp = a;
a = b;
b = tmp;
}
g[a].remove(b);
g[b].remove(a);
for (int v : g[b]) {
g[v].remove(b);
g[v].add(a);
if (g[a].contains(v)) {
pend.add(toKey(v, a));
}
g[a].addAll(g[b]);
g[b].clear();
contracted[b] = true;
}
if (ds.size(0) == N) {
System.out.println("YES");
} else {
System.out.println("NO");
}
}
class DJSet {
int n;
int[] upper;
public DJSet(int n) {
this.n = n;
upper = new int[n];
Arrays.fill(upper, -1);
}
boolean equiv(int x, int y) {
return root(x) == root(y);
}
int root(int x) {
return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
}
void setUnion(int x, int y) {
x = root(x);
y = root(y);
if (x == y)
return;
if (size(x) < size(y)) {
int tmp = x;
x = y;
y = tmp;
}
upper[x] += upper[y];
upper[y] = x;
}
int size(int x) {
return -upper[root(x)];
}
}
private static void tr(Object... o) {
System.out.println(Arrays.deepToString(o));
}
}
| Main.java:109: error: illegal start of expression
private static void tr(Object... o) {
^
1 error
|
s190076977 | p03727 | C++ | #include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int,int> PP;
/*
freopen("input","r",stdin);
freopen("output","w",stdout);
*/
int N;
vector<set<int> > G;
vector<set<int> > T;
int main() {
ios::sync_with_stdio(false);
cin >> N;
G.resize(N);
T.resize(N);
for (int i = 1;i < N;i++) {
int a, b;
cin >> a >> b;
a--;
b--;
G[a].insert(b);
G[b].insert(a);
}
for (int i = 1;i < N;i++) {
int a, b;
cin >> a >> b;
a--;
b--;
T[a].insert(b);
T[b].insert(a);
}
queue<int> D;
set<int> E;
for (int i = 0;i < N;i++) {
if (G[i].size() == 1 && T[i].size() == 1) {
D.push(i);
E.insert(m);
}
}
while (D.size() > 0) {
int m = D.front();
D.pop();
x++;
set<int> f;
for (auto it : G[m]) {
G[it].erase(m);
f.insert(it);
}
for (auto it : T[m]) {
T[it].erase(m);
f.insert(it);
}
G[m].clear();
T[m].clear();
for (auto it : f) {
if (G[it].size() <= 1 && T[it].size() <= 1 && E.find(it) == E.end()) {
D.push(it);
E.insert(it);
}
}
}
if (E.size() == N) cout << "YES" << endl;
else cout << "NO" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:57:26: error: 'm' was not declared in this scope
57 | E.insert(m);
| ^
a.cc:63:9: error: 'x' was not declared in this scope
63 | x++;
| ^
|
s476263527 | p03727 | C | using System;
class A{static void Main(){Console.WriteLine("YES");}} | main.c:1:1: error: unknown type name 'using'
1 | using System;
| ^~~~~
main.c:2:1: error: unknown type name 'class'
2 | class A{static void Main(){Console.WriteLine("YES");}}
| ^~~~~
main.c:2:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
2 | class A{static void Main(){Console.WriteLine("YES");}}
| ^
|
s247311868 | p03727 | C | #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
return 0;
} | main.c:2:10: fatal error: algorithm: No such file or directory
2 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s029500175 | p03727 | C | #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
return 0;
} | main.c:2:10: fatal error: algorithm: No such file or directory
2 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s130612940 | p03727 | C | #include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
return 0;
} | main.c:2:10: fatal error: algorithm: No such file or directory
2 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s891263792 | p03727 | C | #include<stdio.h>
#include "stdafx.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
return 0;
} | main.c:2:10: fatal error: stdafx.h: No such file or directory
2 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s535104320 | p03727 | C | #include<stdio.h>
#include "stdafx.h"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main()
{
int a;
cout<<"YES"<endl;
return 0;
} | main.c:2:10: fatal error: stdafx.h: No such file or directory
2 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s143755425 | p03727 | C++ | // tzl ak IOI!
#include<bits/stdc++.h>
#define HEAP priority_queue
#define rep(i, n) for(int i = 0, _end_ = (n); i < _end_; ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l), _end_ = (r); i <= _end_; ++i)
#define nrof(i, r, l) for(int i = (r), _end_ = (l); i >= _end_; --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))
using namespace std;
typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;
const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;
template <typename T>
inline void scf(T &x)
{
bool f = 0; x = 0; char c = getchar();
while((c < '0' || c > '9') && c != '-') c = getchar();
if(c == '-') { f = 1; c = getchar(); }
while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
if(f) x = -x; return;
}
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }
inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }
template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }
template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }
#define ONLINE_JUDGE
#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif
void TZL();
void RANK1();
#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI
TZL();
RANK1();
#define tzl return
#define caisi 0
#define myy ;
tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}
//---------------------------head----------------------------
const int N = 1e5 + 100;
int n, tot;
vi g[N];
int dep[N], par[N], son[N], siz[N], hs[N], anc[N], dfn[N], End[N], M[N];
set<pii> s1, s2;
void dfs0(int u = 1, int fa = 0)
{
dep[u] = dep[fa] + 1; par[u] = fa; siz[u] = 1;
for(int v: g[u]) if(v != fa)
{
dfs0(v, u);
siz[u] += siz[v];
if(siz[v] > hs[u]) hs[u] = siz[v], son[u] = v;
}
return;
}
void dfs1(int u = 1, int fa = 1)
{
anc[u] = fa; M[dfn[u] = (++tot)] = u;
if(son[u]) dfs1(son[u], fa);
for(int v: g[u]) if(v != par[u] && v != son[u])
{
dfs1(v, v);
}
End[u] = tot;
return;
}
namespace seg
{
int tag[N << 2];
pii num[N << 2];
int L(int i){ return i << 1; }
int R(int i){ return (i << 1) | 1; }
void pull(int i)
{
int l = L(i), r = R(i);
if(num[l].X == 0) num[i] = num[r];
else if(num[r].X == 0) num[i] = num[l];
else num[i] = min(num[l], num[r]);
return;
}
void push(int i)
{
if(tag[i])
{
int l = L(i), r = R(i);
tag[l] += tag[i]; tag[r] += tag[i];
num[l].X += tag[i]; num[r].X += tag[i];
tag[i] = 0;
}
return;
}
void M(int a, int b, int x, int l = 1, int r = n, int k = 1)
{
if(a == l && b == r)
{
num[k].X += x;
tag[k] += x;
return;
}
int mid = l + r >> 1; push(k);
if(a > mid) M(a, b, x, mid + 1, r, R(k));
else if(b <= mid) M(a, b, x, l, mid, L(k));
else M(a, mid, x, l, mid, L(k)), M(mid + 1, b, x, mid + 1, r, R(k));
return pull(k);
}
void B(int l = 1, int r = n, int k = 1)
{
if(l == r)
{
num[k].Y = l;
return;
}
int mid = l + r >> 1; push(k);
B(l, mid, L(k));
B(mid + 1, r, R(k));
return pull(k);
}
pii Q()
{
return num[1];
}
}
void add(int u, int v)
{
s1.insert({min(dfn[u], dfn[v]), max(dfn[u], dfn[v])});
s2.insert({max(dfn[u], dfn[v]), min(dfn[u], dfn[v])});
while(anc[u] != anc[v])
{
if(dep[anc[u]] < dep[anc[v]]) swap(u, v);
if(u != anc[u]) seg::M(dfn[anc[u]] + 1, dfn[u], 1);
u = par[anc[u]];
}
if(dep[u] < dep[v]) swap(u, v);
if(u != v) seg::M(dfn[v] + 1, dfn[u], 1);
return;
}
void TZL()
{
scf(n);
rep(i, n - 1)
{
int u, v; scf(u, v);
g[u].pb(v); g[v].pb(u);
}
dfs0(); dfs1();
rep(i, n - 1)
{
int u, v; scf(u, v);
add(u, v);
}
seg::B();
return;
}
void del(int u, int v)
{
s1.erase({min(dfn[u], dfn[v]), max(dfn[u], dfn[v])});
s2.erase({max(dfn[u], dfn[v]), min(dfn[u], dfn[v])});
while(anc[u] != anc[v])
{
if(dep[anc[u]] < dep[anc[v]]) swap(u, v);
if(u != anc[u]) seg::M(dfn[anc[u]] + 1, dfn[u], -1);
u = par[anc[u]];
}
if(dep[u] < dep[v]) swap(u, v);
if(u != v) seg::M(dfn[v] + 1, dfn[u], -1);
return;
}
void RANK1()
{
rep(i, n - 1)
{
pii foo = seg::Q();
assert(foo.X)
if(foo.X != 1)
{
puts("NO");
return;
}
int u = foo.Y;
int a = dfn[u], b = End[u];
auto i1 = s1.lower_bound({a, 0}), i2 = s2.lower_bound({a, 0});
int x, y;
if(i1 != s1.end() && i1->X >= a && i1->X <= b)
{
x = i1->X, y = i1->Y;
}
else x = i2->X, y = i2->Y;
x = M[x], y = M[y];
del(x, y);
}
puts("YES");
return;
} | a.cc: In function 'void RANK1()':
a.cc:258:17: error: expected ';' before 'if'
258 | if(foo.X != 1)
| ^~
|
s320743263 | p03727 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
using P = array<int, 2>;
// segment tree(不安定な形になるため配列ベースではなくポインタベース)
struct Tree {
using NP = Tree*;
NP l, r;
int sz;
set<int> v;
P mi;
Tree() {}
//size, heavy sum
Tree(int sz, int hsm[]) {
mi = P{0, -1};
this->sz = sz;
if (sz == 1) {
return;
}
int sm = hsm[sz] - hsm[0];
int md = lower_bound(hsm+1, hsm+sz-1, sm/2+hsm[0]) - hsm;
l = new Tree(md, hsm);
r = new Tree(sz - md, hsm+md);
update();
}
void update() {
mi = min(l->mi, r->mi);
mi[0] += v.size();
}
void id_set(int k, int x) {
if (sz == 1) {
mi = P{mi[0], x};
return;
}
if (k < l->sz) {
l->id_set(k, x);
} else {
r->id_set(k - l->sz, x);
}
}
int get(int k) {
if (v.size()) {
return *v.begin();
}
assert(sz >= 2);
if (k < l->sz) {
return l->get(k);
} else {
return r->get(k - l->sz);
}
}
void add(int k) {
if (sz == 1) {
mi[0] = TEN(9);
return;
}
if (k < l->sz) {
l->add(k);
} else {
r->add(k - l->sz);
}
update();
}
void era(int a, int b, int x) {
if (b <= 0 || sz <= a) return;
if (a <= 0 && sz <= b) {
assert(v.count(x));
v.erase(x);
mi[0]--;
return;
}
l->era(a, b, x);
r->era(a - l->sz, b - l->sz, x);
update();
}
void set(int a, int b, int x) {
if (b <= 0 || sz <= a) return;
if (a <= 0 && sz <= b) {
v.insert(x);
mi[0]++;
return;
}
l->set(a, b, x);
r->set(a - l->sz, b - l->sz, x);
update();
}
P get_mi(int a, int b) {
if (b <= 0 || sz <= a) return P{TEN(9), -1};
if (a <= 0 && sz <= b) {
return mi;
}
P L = l->get_mi(a, b);
P R = r->get_mi(a - l->sz, b - l->sz);
P res = min(L, R);
res[0] += v.size();
return res;
}
};
template<class Edge>
struct HLDecomp {
VV<Edge> g;
using P = pair<int, int>;
V<P> id; //vertex -> [line id, line pos]
V<V<int>> lines; //line id -> line list(top to bottom)
V<P> par; //line id -> [parent line id, parent line pos]
V<int> lineDPS; //line id -> line depth
V<Tree*> seg; //line segments
//buffer
V<int> sz; //node size
int idc;
V<int> line_buf;
HLDecomp(VV<Edge> g, int r) {
int n = int(g.size());
this->g = g;
sz = V<int>(n);
id = V<P>(n);
dfs_sz(r, -1);
idc = 0;
par.push_back(P(-1, -1));
lineDPS.push_back(0);
dfs(r, -1, 0);
int lc = int(lines.size()); //line count
seg = V<Tree*>(lc);
for (int l = 0; l < lc; l++) {
int m = int(lines[l].size());
V<int> hsm(m+1); //heavy sum
hsm[0] = 0;
for (int i = 0; i < m; i++) {
int my_sz = sz[lines[l][i]];
if (i != m-1) my_sz -= sz[lines[l][i+1]];
#ifdef LOG2
my_sz = 1;
#endif
hsm[i+1] = hsm[i] + my_sz;
}
seg[l] = new Tree(m, hsm.data());
}
}
void dfs_sz(int p, int b) {
sz[p] = 1;
for (auto e: g[p]) {
int d = e.to;
if (d == b) continue;
dfs_sz(d, p);
sz[p] += sz[d];
}
}
void dfs(int p, int b, int height) {
line_buf.push_back(p);
id[p] = P(idc, height);
int nx = -1, buf = -1;
for (auto e: g[p]) {
if (e.to == b) continue;
if (buf < sz[e.to]) {
buf = sz[e.to];
nx = e.to;
}
}
if (nx == -1) {
//make line
lines.push_back(line_buf);
line_buf.clear();
idc++;
return;
}
dfs(nx, p, height+1);
for (auto e: g[p]) {
if (e.to == b || e.to == nx) continue;
par.push_back(id[p]);
lineDPS.push_back(lineDPS[id[p].first] + 1);
dfs(e.to, p, 0);
}
}
int get_lca(int u, int v) {
P xl = id[u];
P yl = id[v];
if (lineDPS[xl.first] < lineDPS[yl.first]) swap(xl, yl);
while (lineDPS[xl.first] > lineDPS[yl.first]) {
xl = par[xl.first];
}
while (xl.first != yl.first) {
xl = par[xl.first];
yl = par[yl.first];
}
if (xl.second > yl.second) swap(xl, yl);
return lines[xl.first][xl.second];
}
struct Info {
int id; //line id
int l, r;
};
V<Info> get_line(int u, int v) {
assert(get_lca(u, v) == v);
V<Info> res;
while (id[u].first != id[v].first) {
res.push_back(Info{id[u].first, 0, id[u].second+1});
auto p = par[id[u].first];
u = lines[p.first][p.second];
}
res.push_back(Info{id[u].first, id[v].second, id[u].second+1});
return res;
}
void id_set(int i, int x) {
auto info = get_line(i, i)[0];
seg[info.id]->id_set(info.l, x);
}
int get(int i) {
auto info = get_line(i, i)[0];
return seg[info.id]->get(info.l);
}
void add(int i) {
auto info = get_line(i, i)[0];
return seg[info.id]->add(info.l);
}
void set(int u, int v, int x, bool er) {
int xl, xp; tie(xl, xp) = id[u];
int yl, yp; tie(yl, yp) = id[v];
int lca = get_lca(u, v);
//calc X
auto xinfo = get_line(u, lca);
xinfo.back().l++;
if (xinfo.back().l == xinfo.back().r) xinfo.pop_back();
for (auto info: xinfo) {
if (!er) {
seg[info.id]->set(info.l, info.r, x);
} else {
seg[info.id]->era(info.l, info.r, x);
}
}
//calc Y
auto yinfo = get_line(v, lca);
yinfo.back().l++;
if (yinfo.back().l == yinfo.back().r) yinfo.pop_back();
reverse(begin(yinfo), end(yinfo));
for (auto info: yinfo) {
if (!er) {
seg[info.id]->set(info.l, info.r, x);
} else {
seg[info.id]->era(info.l, info.r, x);
}
}
return;
}
::P get_mi(int u, int v) {
int xl, xp; tie(xl, xp) = id[u];
int yl, yp; tie(yl, yp) = id[v];
int lca = get_lca(u, v);
::P mi = ::P{TEN(9), -1};
//calc X
auto xinfo = get_line(u, lca);
xinfo.back().l++;
if (xinfo.back().l == xinfo.back().r) xinfo.pop_back();
for (auto info: xinfo) {
mi = min(mi, seg[info.id]->get_mi(info.l, info.r));
}
//calc Y
auto yinfo = get_line(v, lca);
yinfo.back().l++;
if (yinfo.back().l == yinfo.back().r) yinfo.pop_back();
reverse(begin(yinfo), end(yinfo));
for (auto info: yinfo) {
mi = min(mi, seg[info.id]->get_mi(info.l, info.r));
}
return mi;
}
};
struct Edge {
int to;
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << setprecision(20);
int n;
cin >> n;
VV<Edge> g(n);
queue<P> ev;
for (int i = 0; i < n-1; i++) {
int a, b;
cin >> a >> b;
a--; b--;
g[a].push_back(Edge{b});
g[b].push_back(Edge{a});
ev.push(P{a, b});
}
V<int> c(n-1), d(n-1);
for (int i = 0; i < n-1; i++) {
cin >> c[i] >> d[i]; c[i]--; d[i]--;
}
HLDecomp<Edge> hl(g, 0);
for (int i = 0; i < n; i++) {
hl.id_set(i, i);
}
for (int i = 0; i < n-1; i++) {
// cout << "set " << c[i] << " " << d[i] << " " << i << endl;
hl.set(c[i], d[i], i, false);
}
int ec = 0;
while (ev.size()) {
P p = ev.front(); ev.pop();
P buf = hl.get_mi(p[0], p[1]);
// cout << "check " << p[0] << " " << p[1] << " " << buf[0] << " " << buf[1] << endl;
if (buf[0] == 0) {
hl.add(buf[1]);
ev.push(p);
continue;
}
if (buf[0] != 1) continue;
ec++;
int id = hl.get(buf[1]);
// cout << "era " << c[id] << " " << d[id] << " " << id << endl;
hl.set(c[id], d[id], id, true);
ev.push(P{c[id], d[id]});
}
if (ec == n-1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| a.cc:100:10: error: declaration of 'void Tree::set(int, int, int)' changes meaning of 'set' [-Wchanges-meaning]
100 | void set(int a, int b, int x) {
| ^~~
a.cc:33:5: note: used here to mean 'class std::set<int>'
33 | set<int> v;
| ^~~~~~~~
In file included from /usr/include/c++/14/set:63,
from a.cc:14:
/usr/include/c++/14/bits/stl_set.h:96:11: note: declared here
96 | class set
| ^~~
|
s168212684 | p03727 | C++ | #include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
struct Node {
Node* c[2], *p;
int id, rev;
int v, mv;
int av;
int isr() {
return !p||(p->c[0]!=this&&p->c[1]!=this);
}
int dir() {
return p->c[1]==this;
}
void add(int vv){
av+=vv;
v+=vv;
mv+=vv;
}
void push() {
if (rev) {
swap(c[0], c[1]);
if (c[0]) c[0]->rev^=1;
if (c[1]) c[1]->rev^=1;
rev=0;
}
if (av!=0){
if (c[0]) c[0]->add(av);
if (c[1]) c[1]->add(av);
av=0;
}
}
void upd(){
push();
mv=v;
if (c[0]) mv=min(mv, c[0]->mv);
if (c[1]) mv=min(mv, c[1]->mv);
}
void setc(Node* s, int d) {
c[d]=s;
if (s) s->p=this;
upd();
}
Node(int i, int val) : id(i), v(val), mv(val) {
c[0]=0;c[1]=0;p=0;rev=0;
av=0;
}
};
struct LinkCut {
void rot(Node* x) {
Node* p=x->p;int d=x->dir();
if (!p->isr()) p->p->setc(x, p->dir());
else x->p=p->p;
p->setc(x->c[!d], d);x->setc(p, !d);
}
void pp(Node* x) {
if (!x->isr()) pp(x->p);
x->push();
}
void splay(Node* x) {
pp(x);
while (!x->isr()) {
if (x->p->isr()) rot(x);
else if(x->dir()==x->p->dir()) {
rot(x->p);rot(x);
}
else {
rot(x);rot(x);
}
}
}
Node* expose(Node* x) {
Node* q=0;
for (;x;x=x->p) {
splay(x);x->c[1]=q;x->upd();q=x;
}
return q;
}
void evert(Node* x) {
x=expose(x);x->rev^=1;x->push();
}
void link(Node* x, Node* y) {
evert(x);evert(y);splay(y);x->setc(y, 1);
}
void expose(Node* x, Node* y) {
evert(x);expose(y);splay(x);
}
void cut(Node* x, Node* y) {
expose(x, y);x->c[1]=0;x->upd();y->p=0;
}
int rootid(Node* x) {
expose(x);splay(x);
while(x->c[0]) {
x=x->c[0];x->push();
}
splay(x);
return x->id;
}
Node* getMin(Node* x) {
x->push();
if (x->v==x->mv) {
splay(x);
return x;
}
if (x->c[0]&&x->c[0]->mv==x->mv) return getMin(x->c[0]);
else return getMin(x->c[1]);
}
Node* getMinP(Node* x, Node* y) {
expose(x, y);
return getMin(x);
}
void addP(Node* x, Node* y, int v){
expose(x, y);
x->add(v);
}
};
Node* nn[101010];
int u[101010];
int v[101010];
Node* en[101010];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
LinkCut lc;
for (int i=1;i<=n;i++){
nn[i]=new Node(n+i, 10*n);
}
for (int i=0;i<n-1;i++){
cin>>u[i]>>v[i];
en[i]=new Node(i, 0);
lc.link(en[i], nn[u[i]]);
lc.link(en[i], nn[v[i]]);
}
set<pair<int, int> > ps;
for (int i=0;i<n-1;i++){
int a,b;
cin>>a>>b;
ps.insert({a, b});
lc.addP(nn[a], nn[b], 1);
}
while (1){
vector<pair<int, pair<int, int> > > nps;
int f1=0;
for (auto p:ps){
auto miv=lc.getMinP(nn[p.F], nn[p.S]);
if (miv->mv>0) nps.push_back({miv->mv, p});
if (f1>10&&nps.size()>10000) break;
}
if (nps.size()==0){
cout<<"YES"<<endl;
return 0;
}
sort(nps.begin(), nps.end());
if (nps[0].F>1){
cout<<"NO"<<endl;
return 0;
}
for (auto p:nps){
auto miv=lc.getMinP(nn[p.S.F], nn[p.S.S]);
if (miv->mv>1){
np.push_back(p.S);
}
else if(miv->mv==1){
lc.addP(nn[p.S.F], nn[p.S.S], -1);
ps.erase(p.S);
}
}
}
} | a.cc: In function 'int main()':
a.cc:171:33: error: 'np' was not declared in this scope; did you mean 'p'?
171 | np.push_back(p.S);
| ^~
| p
|
s663473285 | p03727 | C++ | #include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;
struct Node {
Node* c[2], *p;
int id, rev;
int v, mv;
int av;
int isr() {
return !p||(p->c[0]!=this&&p->c[1]!=this);
}
int dir() {
return p->c[1]==this;
}
void add(int vv){
av+=vv;
v+=vv;
mv+=vv;
}
void push() {
if (rev) {
swap(c[0], c[1]);
if (c[0]) c[0]->rev^=1;
if (c[1]) c[1]->rev^=1;
rev=0;
}
if (av!=0){
if (c[0]) c[0]->add(av);
if (c[1]) c[1]->add(av);
av=0;
}
}
void upd(){
push();
mv=v;
if (c[0]) mv=min(mv, c[0]->mv);
if (c[1]) mv=min(mv, c[1]->mv);
}
void setc(Node* s, int d) {
c[d]=s;
if (s) s->p=this;
upd();
}
Node(int i, int val) : id(i), v(val), mv(val) {
c[0]=0;c[1]=0;p=0;rev=0;
av=0;
}
};
struct LinkCut {
void rot(Node* x) {
Node* p=x->p;int d=x->dir();
if (!p->isr()) p->p->setc(x, p->dir());
else x->p=p->p;
p->setc(x->c[!d], d);x->setc(p, !d);
}
void pp(Node* x) {
if (!x->isr()) pp(x->p);
x->push();
}
void splay(Node* x) {
pp(x);
while (!x->isr()) {
if (x->p->isr()) rot(x);
else if(x->dir()==x->p->dir()) {
rot(x->p);rot(x);
}
else {
rot(x);rot(x);
}
}
}
Node* expose(Node* x) {
Node* q=0;
for (;x;x=x->p) {
splay(x);x->c[1]=q;x->upd();q=x;
}
return q;
}
void evert(Node* x) {
x=expose(x);x->rev^=1;x->push();
}
void link(Node* x, Node* y) {
evert(x);evert(y);splay(y);x->setc(y, 1);
}
void expose(Node* x, Node* y) {
evert(x);expose(y);splay(x);
}
void cut(Node* x, Node* y) {
expose(x, y);x->c[1]=0;x->upd();y->p=0;
}
int rootid(Node* x) {
expose(x);splay(x);
while(x->c[0]) {
x=x->c[0];x->push();
}
splay(x);
return x->id;
}
Node* getMin(Node* x) {
x->push();
if (x->v==x->mv) {
splay(x);
return x;
}
if (x->c[0]&&x->c[0]->mv==x->mv) return getMin(x->c[0]);
else return getMin(x->c[1]);
}
Node* getMinP(Node* x, Node* y) {
expose(x, y);
return getMin(x);
}
void addP(Node* x, Node* y, int v){
expose(x, y);
x->add(v);
}
};
Node* nn[101010];
int u[101010];
int v[101010];
Node* en[101010];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
LinkCut lc;
for (int i=1;i<=n;i++){
nn[i]=new Node(n+i, 10*n);
}
for (int i=0;i<n-1;i++){
cin>>u[i]>>v[i];
en[i]=new Node(i, 0);
lc.link(en[i], nn[u[i]]);
lc.link(en[i], nn[v[i]]);
}
set<pair<int, int> > ps;
for (int i=0;i<n-1;i++){
int a,b;
cin>>a>>b;
ps.insert({a, b});
lc.addP(nn[a], nn[b], 1);
}
while (1){
vector<pair<int, pair<int, int> > > nps;
int f1=0;
for (auto p:ps){
auto miv=lc.getMinP(nn[p.F], nn[p.S]);
if (miv->mv>0) nps.push_back({miv->mv, p});
if (f1>10&&nps.size()>1000) break;
}
if (nps.size()==0){
cout<<"YES"<<endl;
return 0;
}
sort(nps.begin(), nps.end());
if (nps[0].F>1){
cout<<"NO"<<endl;
return 0;
}
for (auto p:nps){
auto miv=lc.getMinP(nn[p.S.F], nn[p.S.S]);
if (miv->mv>1){
np.push_back(p.S);
}
else if(miv->mv==1){
lc.addP(nn[p.S.F], nn[p.S.S], -1);
ps.erase(p.S);
}
}
}
} | a.cc: In function 'int main()':
a.cc:171:33: error: 'np' was not declared in this scope; did you mean 'p'?
171 | np.push_back(p.S);
| ^~
| p
|
s366470078 | p03727 | C++ | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。 | a.cc:1:1: error: extended character 、 is not valid in an identifier
1 | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。
| ^
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:1: error: extended character 、 is not valid in an identifier
a.cc:1:273: error: extended character 、 is not valid in an identifier
1 | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。
| ^
a.cc:1:273: error: extended character 。 is not valid in an identifier
a.cc:1:273: error: extended character 。 is not valid in an identifier
a.cc:1:220: error: expected constructor, destructor, or type conversion before '(' token
1 | まず黒い木の上に赤いpathをいっぱい書いて、それぞれの辺を赤いpathが何回通ったかと言うのを持っておくと、値が1のときにそのpathを消す、という操作を最後までできれば良くて、これはもとの木がpathの形なら区間minと区間addで出来て(どのpathか?っていうのはidのsumみたいなのを別に持つ),木だとHL_decompすればいい気がしたんですけど、正しい方針がわかりません。助けてください。
| ^
|
s717597555 | p03727 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
using P = array<int, 2>;
// segment tree(不安定な形になるため配列ベースではなくポインタベース)
struct Tree {
using NP = Tree*;
NP l, r;
int sz;
set<int> v;
P mi;
Tree() {}
//size, heavy sum
Tree(int sz, int hsm[]) {
this->sz = sz;
if (sz == 1) {
return;
}
int sm = hsm[sz] - hsm[0];
int md = lower_bound(hsm+1, hsm+sz-1, sm/2+hsm[0]) - hsm;
l = new Tree(md, hsm);
r = new Tree(sz - md, hsm+md);
update();
}
void update() {
mi = min(l->mi, r->mi);
if (mi[0] == 0 && v.size()) mi[1] = *v.begin();
mi[0] += v.size();
}
void era(int a, int b, int x) {
if (b <= 0 || sz <= a) return;
if (a <= 0 && sz <= b) {
assert(v.count(x));
v.erase(x);
mi[0]--;
if (v.size()) mi[1] = *v.begin();
if (sz >= 2) {
update();
}
return;
}
l->era(a, b, x);
r->era(a - l->sz, b - l->sz, x);
update();
}
void set(int a, int b, int x) {
if (b <= 0 || sz <= a) return;
if (a <= 0 && sz <= b) {
v.insert(x);
mi[0]++;
mi[1] = x;
return;
}
l->set(a, b, x);
r->set(a - l->sz, b - l->sz, x);
update();
}
P get_mi(int a, int b) {
if (b <= 0 || sz <= a) return P{TEN(9), -1};
if (a <= 0 && sz <= b) {
if (mi[0] == 0) return P{TEN(9), -1};
return mi;
}
P L = l->get_mi(a, b);
P R = r->get_mi(a - l->sz, b - l->sz);
P res = min(L, R);
if (res[0] >= TEN(8) && v.size()) {
res[0] = 0;
res[1] = *v.begin();
}
res[0] += v.size();
return res;
}
};
template<class Edge>
struct HLDecomp {
VV<Edge> g;
using P = pair<int, int>;
V<P> id; //vertex -> [line id, line pos]
V<V<int>> lines; //line id -> line list(top to bottom)
V<P> par; //line id -> [parent line id, parent line pos]
V<int> lineDPS; //line id -> line depth
V<Tree*> seg; //line segments
//buffer
V<int> sz; //node size
int idc;
V<int> line_buf;
HLDecomp(VV<Edge> g, int r) {
int n = int(g.size());
this->g = g;
sz = V<int>(n);
id = V<P>(n);
dfs_sz(r, -1);
idc = 0;
par.push_back(P(-1, -1));
lineDPS.push_back(0);
dfs(r, -1, 0);
int lc = int(lines.size()); //line count
seg = V<Tree*>(lc);
for (int l = 0; l < lc; l++) {
int m = int(lines[l].size());
V<int> hsm(m+1); //heavy sum
hsm[0] = 0;
for (int i = 0; i < m; i++) {
int my_sz = sz[lines[l][i]];
if (i != m-1) my_sz -= sz[lines[l][i+1]];
#ifdef LOG2
my_sz = 1;
#endif
hsm[i+1] = hsm[i] + my_sz;
}
seg[l] = new Tree(m, hsm.data());
}
}
void dfs_sz(int p, int b) {
sz[p] = 1;
for (auto e: g[p]) {
int d = e.to;
if (d == b) continue;
dfs_sz(d, p);
sz[p] += sz[d];
}
}
void dfs(int p, int b, int height) {
line_buf.push_back(p);
id[p] = P(idc, height);
int nx = -1, buf = -1;
for (auto e: g[p]) {
if (e.to == b) continue;
if (buf < sz[e.to]) {
buf = sz[e.to];
nx = e.to;
}
}
if (nx == -1) {
//make line
lines.push_back(line_buf);
line_buf.clear();
idc++;
return;
}
dfs(nx, p, height+1);
for (auto e: g[p]) {
if (e.to == b || e.to == nx) continue;
par.push_back(id[p]);
lineDPS.push_back(lineDPS[id[p].first] + 1);
dfs(e.to, p, 0);
}
}
int get_lca(int u, int v) {
P xl = id[u];
P yl = id[v];
if (lineDPS[xl.first] < lineDPS[yl.first]) swap(xl, yl);
while (lineDPS[xl.first] > lineDPS[yl.first]) {
xl = par[xl.first];
}
while (xl.first != yl.first) {
xl = par[xl.first];
yl = par[yl.first];
}
if (xl.second > yl.second) swap(xl, yl);
return lines[xl.first][xl.second];
}
struct Info {
int id; //line id
int l, r;
};
V<Info> get_line(int u, int v) {
assert(get_lca(u, v) == v);
V<Info> res;
while (id[u].first != id[v].first) {
res.push_back(Info{id[u].first, 0, id[u].second+1});
auto p = par[id[u].first];
u = lines[p.first][p.second];
}
res.push_back(Info{id[u].first, id[v].second, id[u].second+1});
return res;
}
void set(int u, int v, int x, bool er) {
int xl, xp; tie(xl, xp) = id[u];
int yl, yp; tie(yl, yp) = id[v];
int lca = get_lca(u, v);
//calc X
auto xinfo = get_line(u, lca);
xinfo.back().l++;
if (xinfo.back().l == xinfo.back().r) xinfo.pop_back();
for (auto info: xinfo) {
if (!er) {
seg[info.id]->set(info.l, info.r, x);
} else {
seg[info.id]->era(info.l, info.r, x);
}
}
//calc Y
auto yinfo = get_line(v, lca);
yinfo.back().l++;
if (yinfo.back().l == yinfo.back().r) yinfo.pop_back();
reverse(begin(yinfo), end(yinfo));
for (auto info: yinfo) {
if (!er) {
seg[info.id]->set(info.l, info.r, x);
} else {
seg[info.id]->era(info.l, info.r, x);
}
}
return;
}
::P get_mi(int u, int v) {
int xl, xp; tie(xl, xp) = id[u];
int yl, yp; tie(yl, yp) = id[v];
int lca = get_lca(u, v);
::P mi = ::P{TEN(9), -1};
//calc X
auto xinfo = get_line(u, lca);
xinfo.back().l++;
if (xinfo.back().l == xinfo.back().r) xinfo.pop_back();
for (auto info: xinfo) {
mi = min(mi, seg[info.id]->get_mi(info.l, info.r));
}
//calc Y
auto yinfo = get_line(v, lca);
yinfo.back().l++;
if (yinfo.back().l == yinfo.back().r) yinfo.pop_back();
reverse(begin(yinfo), end(yinfo));
for (auto info: yinfo) {
mi = min(mi, seg[info.id]->get_mi(info.l, info.r));
}
return mi;
}
};
struct Edge {
int to;
};
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << setprecision(20);
int n;
cin >> n;
VV<Edge> g(n);
queue<P> ev;
for (int i = 0; i < n-1; i++) {
int a, b;
cin >> a >> b;
a--; b--;
g[a].push_back(Edge{b});
g[b].push_back(Edge{a});
ev.push(P{a, b});
}
V<int> c(n-1), d(n-1);
for (int i = 0; i < n-1; i++) {
cin >> c[i] >> d[i]; c[i]--; d[i]--;
}
HLDecomp<Edge> hl(g, 0);
for (int i = 0; i < n-1; i++) {
// cout << "set " << c[i] << " " << d[i] << " " << i << endl;
hl.set(c[i], d[i], i, false);
}
int ec = 0;
while (ev.size()) {
P p = ev.front(); ev.pop();
// cout << "check " << p[0] << " " << p[1] << endl;
P buf = hl.get_mi(p[0], p[1]);
int u = buf[0];
if (u != 1) continue;
ec++;
int id = buf[1];
// cout << "era " << c[id] << " " << d[id] << " " << id << endl;
hl.set(c[id], d[id], id, true);
ev.push(P{c[id], d[id]});
}
if (ec == n-1) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| a.cc:70:10: error: declaration of 'void Tree::set(int, int, int)' changes meaning of 'set' [-Wchanges-meaning]
70 | void set(int a, int b, int x) {
| ^~~
a.cc:33:5: note: used here to mean 'class std::set<int>'
33 | set<int> v;
| ^~~~~~~~
In file included from /usr/include/c++/14/set:63,
from a.cc:14:
/usr/include/c++/14/bits/stl_set.h:96:11: note: declared here
96 | class set
| ^~~
|
s544469448 | p03728 | C | #pragma GCC optimize("Ofast")
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int Max(int a, int b) {return a > b ? a : b;}
#define maxn 200005
struct T {
char mon;
int val, mx, fst;
int fix;
T *lson, *rson;
} t[maxn];
int tot;
T *new_node(int v) {
T *x = &t[++ tot];
x->mon = 1;
x->val = v; x->mx = v; x->fst = v;
x->fix = rand();
x->lson = x->rson = 0;
return x;
}
void pushup0(T *x) {
x->fst = x->lson ? x->lson->fst : x->val;
char mo = 1;
x->mx = x->val;
if (x->lson) {
x->mx = Max(x->mx, x->lson->mx);
mo &= x->lson->mon && x->lson->mx < x->val;
}
if (x->rson) {
x->mx = Max(x->mx, x->rson->mx);
mo &= x->rson->mon && x->val < x->rson->fst;
}
x->mon = mo;
}
void pushup1(T *x) {
x->mon = 1;
x->fst = x->lson ? x->lson->fst : x->val;
x->mx = x->rson ? x->rson->mx : x->val;
}
T *merge0(T *a, T *b) {
if (!a || !b) return a ? a : b;
if (a->fix < b->fix) {
a->rson = merge0(a->rson, b);
pushup0(a);
return a;
} else {
b->lson = merge0(a, b->lson);
pushup0(b);
return b;
}
}
T *merge1(T *a, T *b) {
if (!a || !b) return a ? a : b;
if (a->fix < b->fix) {
a->rson = merge1(a->rson, b);
pushup1(a);
return a;
} else {
b->lson = merge1(a, b->lson);
pushup1(b);
return b;
}
}
int split(T *x, int v, T *&a, T *&b) {
if (!x) {a = b = 0; return v;}
if (x->mx < v) {a = x; b = 0; return v;}
if (x->mon) {
if (x->fst > v) {a = 0; b = x; return b->mx;}
if (x->val < v) {
a = x; split(x->rson, v, a->rson, b);
pushup1(a); return b->mx;
} else {
b = x; split(x->lson, v, a, b->lson);
pushup1(b); return b->mx;
}
} else {
T *ls = x->lson, *rs = x->rson;
x->lson = x->rson = 0;
pushup1(x);
v = split(ls, v, a, b);
if (x->val > v) b = merge1(b, x), v = x->val;
else a = merge0(a, x);
T *c, *d;
v = split(rs, v, c, d);
a = merge0(a, c); b = merge1(b, d);
return v;
}
}
T *rt;
int main() {
// freopen("in", "r", stdin);
srand(200);
int n; scanf("%d", &n);
for (int i = 1; i <= n; ++ i) {
int p; scanf("%d", &p);
rt = merge0(rt, new_node(p));
}
int ans = 0;
while (!rt->mon) {
++ ans;
T *a, *b;
split(rt, 0, a, b);
rt = merge0(a, b);
// printf("%d\n", ans);
}
printf("%d\n", ans);
// eprintf("time used: %.3f\n", clock() * 1.0 / CLOCKS_PER_SEC);
return 0;
}
| main.c:16:9: error: unknown type name 'T'
16 | T *lson, *rson;
| ^
main.c:21:1: error: unknown type name 'T'; use 'struct' keyword to refer to the type
21 | T *new_node(int v) {
| ^
| struct
main.c: In function 'new_node':
main.c:22:9: error: unknown type name 'T'; use 'struct' keyword to refer to the type
22 | T *x = &t[++ tot];
| ^
| struct
main.c:22:16: error: initialization of 'int *' from incompatible pointer type 'struct T *' [-Wincompatible-pointer-types]
22 | T *x = &t[++ tot];
| ^
main.c:23:10: error: request for member 'mon' in something not a structure or union
23 | x->mon = 1;
| ^~
main.c:24:10: error: request for member 'val' in something not a structure or union
24 | x->val = v; x->mx = v; x->fst = v;
| ^~
main.c:24:22: error: request for member 'mx' in something not a structure or union
24 | x->val = v; x->mx = v; x->fst = v;
| ^~
main.c:24:33: error: request for member 'fst' in something not a structure or union
24 | x->val = v; x->mx = v; x->fst = v;
| ^~
main.c:25:10: error: request for member 'fix' in something not a structure or union
25 | x->fix = rand();
| ^~
main.c:26:10: error: request for member 'lson' in something not a structure or union
26 | x->lson = x->rson = 0;
| ^~
main.c:26:20: error: request for member 'rson' in something not a structure or union
26 | x->lson = x->rson = 0;
| ^~
main.c: At top level:
main.c:30:14: error: unknown type name 'T'
30 | void pushup0(T *x) {
| ^
main.c:45:14: error: unknown type name 'T'
45 | void pushup1(T *x) {
| ^
main.c:51:1: error: unknown type name 'T'; use 'struct' keyword to refer to the type
51 | T *merge0(T *a, T *b) {
| ^
| struct
main.c:51:11: error: unknown type name 'T'
51 | T *merge0(T *a, T *b) {
| ^
main.c:51:17: error: unknown type name 'T'
51 | T *merge0(T *a, T *b) {
| ^
main.c:64:1: error: unknown type name 'T'; use 'struct' keyword to refer to the type
64 | T *merge1(T *a, T *b) {
| ^
| struct
main.c:64:11: error: unknown type name 'T'
64 | T *merge1(T *a, T *b) {
| ^
main.c:64:17: error: unknown type name 'T'
64 | T *merge1(T *a, T *b) {
| ^
main.c:77:11: error: unknown type name 'T'
77 | int split(T *x, int v, T *&a, T *&b) {
| ^
main.c:77:24: error: unknown type name 'T'
77 | int split(T *x, int v, T *&a, T *&b) {
| ^
main.c:77:31: error: unknown type name 'T'
77 | int split(T *x, int v, T *&a, T *&b) {
| ^
main.c:103:1: error: unknown type name 'T'; use 'struct' keyword to refer to the type
103 | T *rt;
| ^
| struct
main.c: In function 'main':
main.c:111:22: error: implicit declaration of function 'merge0' [-Wimplicit-function-declaration]
111 | rt = merge0(rt, new_node(p));
| ^~~~~~
main.c:111:20: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
111 | rt = merge0(rt, new_node(p));
| ^
main.c:114:19: error: request for member 'mon' in something not a structure or union
114 | while (!rt->mon) {
| ^~
main.c:116:17: error: unknown type name 'T'; use 'struct' keyword to refer to the type
116 | T *a, *b;
| ^
| struct
main.c:117:17: error: implicit declaration of function 'split' [-Wimplicit-function-declaration]
117 | split(rt, 0, a, b);
| ^~~~~
main.c:118:20: error: assignment to 'int *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
118 | rt = merge0(a, b);
| ^
|
s454061206 | p03728 | C++ | oppai love | a.cc:1:1: error: 'oppai' does not name a type
1 | oppai love
| ^~~~~
|
s274387360 | p03728 | C++ | #include <bits/stdc++.h>
#include <windows.h>
using namespace std;
//#define FILE_IO
struct Value
{
int x;
Value *prv, *nxt;
Value()
{
x = 0;
prv = nxt = 0;
}
Value(int _x, Value *_prv, Value *_nxt) { x = _x; prv = _prv; nxt = _nxt; }
};
int N;
void erasePosition(Value *V)
{
Value *lft = V -> prv, *rgt = V -> nxt;
lft -> nxt = V -> nxt;
rgt -> prv = V -> prv;
delete V;
}
void insertValue(int x, Value *&V)
{
Value *newV = new Value(x, V, V -> nxt);
newV -> nxt -> prv = newV;
newV -> prv -> nxt = newV;
}
void uniteValues(Value *&lft, Value *&rgt)
{
lft -> nxt = rgt;
rgt -> prv = lft;
}
void print(Value *&S, Value *&F)
{
if(S == F) { cerr << "\n"; return; }
cerr << S -> x << " ";
print(S -> nxt, F);
}
void make_test()
{
srand(time(0));
int N = 200000;
vector <int> prm;
for(int i = 1; i <= N; i++)
prm.push_back(i);
random_shuffle(prm.begin(), prm.end());
printf("%d\n", N);
for(auto x: prm)
printf("%d ", x);
exit(0);
}
int main()
{
#ifdef FILE_IO
freopen("1.out", "r", stdin);
freopen("1.in", "w", stdout);
#endif
//make_test();
int N;
scanf("%d", &N);
Value *S, *F;
S = new Value(0, 0, 0);
F = new Value(0, 0, 0);
S -> nxt = F; F -> prv = S;
for(int i = 1; i <= N; i++)
{
int x;
scanf("%d", &x);
insertValue(x, F -> prv);
}
int ans = 0;
int K = N;
while(K)
{
while(K && F -> prv -> x == K)
{
K--;
erasePosition(F -> prv);
}
if(!K) break;
ans++;
Value *stS, *stF, *drS, *drF;
stS = new Value(0, 0, 0);
stF = new Value(0, 0, 0);
stS -> nxt = stF; stF -> prv = stS;
drS = new Value(0, 0, 0);
drF = new Value(0, 0, 0);
drS -> nxt = drF; drF -> prv = drS;
int mx = 0;
for(Value *V = S -> nxt; V != F; V = V -> nxt)
{
int x = V -> x;
if(x > mx)
{
insertValue(x, drF -> prv);
mx = x;
if(x == K)
{
Value *lft = V -> nxt;
if(lft == F) break;
uniteValues(stF -> prv, lft);
uniteValues(F -> prv, stF);
break;
}
}
else
{
insertValue(x, stF -> prv);
}
}
uniteValues(stF -> prv, drS -> nxt);
S = stS; F = drF;
//Sleep(1000);
}
printf("%d\n", ans);
return 0;
}
| a.cc:2:10: fatal error: windows.h: No such file or directory
2 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s222238082 | p03728 | C++ | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
using namespace std;
#define _int64 long long
int a[11000000];
int next1[11000000];
int pre[11000000];
int ma;
char s[100];
void out1(int head,int last)
{
int i;
for (i=head;;)
{
printf("%d ",a[i]);
if (i==last) break;
i=next1[i];
}
printf("%d\n",ma);
gets(s);
}
int main()
{
int head,last,i,n,tmp,ll,ans,cur;
scanf("%d",&n);
for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
next1[i]=i+1;
pre[i]=i-1;
}
next1[n-1]=-1;
pre[0]=-1;
last=n-1;
head=0;
ma=n;
ans=0;
for (;;)
{
//out1(head,last);
while ((ma>=1)&&(a[last]==ma))
{
ma--;
last=pre[last];
}
//out1(head,last);
if (ma==0) break;
ans++;
tmp=head;
ll=last;
cur=-1;
while(1)
{
if (a[tmp]>cur)
{
cur=a[tmp];
next1[last]=last+1;
pre[last+1]=last;
last++;
a[last]=cur;
if (tmp==head)
{
head=next1[head];
}
else
{
next1[pre[tmp]]=next1[tmp];
pre[next1[tmp]]=pre[tmp];
}
}
if (tmp==ll) break;
else tmp=next1[tmp];
}
}
printf("%d\n",ans);
return 0;
} | a.cc: In function 'void out1(int, int)':
a.cc:44:3: error: 'gets' was not declared in this scope; did you mean 'getw'?
44 | gets(s);
| ^~~~
| getw
|
s019998376 | p03729 | C++ | #include<iostream>
#include<string>
using namespace std;
int main()
{
string a,b,c;
cin>>a>>b>>c;
int d,e;
d=a.size();
e=b.size();
if(a(d-1)==b(0)&&b(e-1)==c(0)){
cout<<"YES";
}
else{
cout<<"NO";
}
} | a.cc: In function 'int main()':
a.cc:11:7: error: no match for call to '(std::string {aka std::__cxx11::basic_string<char>}) (int)'
11 | if(a(d-1)==b(0)&&b(e-1)==c(0)){
| ~^~~~~
a.cc:11:15: error: no match for call to '(std::string {aka std::__cxx11::basic_string<char>}) (int)'
11 | if(a(d-1)==b(0)&&b(e-1)==c(0)){
| ~^~~
a.cc:11:21: error: no match for call to '(std::string {aka std::__cxx11::basic_string<char>}) (int)'
11 | if(a(d-1)==b(0)&&b(e-1)==c(0)){
| ~^~~~~
a.cc:11:29: error: no match for call to '(std::string {aka std::__cxx11::basic_string<char>}) (int)'
11 | if(a(d-1)==b(0)&&b(e-1)==c(0)){
| ~^~~
|
s136168711 | p03729 | C++ | #include <iostream>
#include <algorythm>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;
int main () {
string a, b, c;
cin >> a >> b >> c;
cout << ((reverse(a.begin(),a.end()), a[0] == b[0]) && (reverse(b.begin(),b.end()), b[0] == c[0]) ? "YES" : "NO") << endl;
} | a.cc:2:10: fatal error: algorythm: No such file or directory
2 | #include <algorythm>
| ^~~~~~~~~~~
compilation terminated.
|
s303859801 | p03729 | C++ | #include <iostream>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;
int main () {
string a, b, c;
cin >> a >> b >> c;
cout << ({a.reverse(), a[0] == b[0]} && {b.reverse(), b[0] == c[0]} ? "YES" : "NO") << endl;
} | a.cc: In function 'int main()':
a.cc:12:15: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'reverse'; did you mean 'reserve'?
12 | cout << ({a.reverse(), a[0] == b[0]} && {b.reverse(), b[0] == c[0]} ? "YES" : "NO") << endl;
| ^~~~~~~
| reserve
a.cc:12:39: error: expected ')' before '&&' token
12 | cout << ({a.reverse(), a[0] == b[0]} && {b.reverse(), b[0] == c[0]} ? "YES" : "NO") << endl;
| ~ ^~~
| )
a.cc:12:8: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'void')
12 | cout << ({a.reverse(), a[0] == b[0]} && {b.reverse(), b[0] == c[0]} ? "YES" : "NO") << endl;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from 'void' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from 'void' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from 'void' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from 'void' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from 'void' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from 'void' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from 'void' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from 'void' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from 'void' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from 'void' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from 'void' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from 'void' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from 'void' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from 'void' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from 'void' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from 'void' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from 'void' to ' |
s876763517 | p03729 | C++ | #include <iostream>
#include <string>
#include <set>
#include <regex>
#include <locale>
using namespace std;
int main () {
string a, b, c;
cin >> a >> b >> c;
cout << (a.reverse()[0] == b[0] && b.reverse()[0] == c[0] ? "YES" : "NO") << endl;
} | a.cc: In function 'int main()':
a.cc:12:14: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'reverse'; did you mean 'reserve'?
12 | cout << (a.reverse()[0] == b[0] && b.reverse()[0] == c[0] ? "YES" : "NO") << endl;
| ^~~~~~~
| reserve
a.cc:12:40: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'reverse'; did you mean 'reserve'?
12 | cout << (a.reverse()[0] == b[0] && b.reverse()[0] == c[0] ? "YES" : "NO") << endl;
| ^~~~~~~
| reserve
|
s777537649 | p03729 | C | #include<stdio.h>
#include<string.h>
int main(){
char a[10],b[10],c[10];
scanf("%s %s %s",&a,&b,&c);
int d,e,f;
d=strlen(a[]);
e=strlen(b[]);
f=strlen(c[]);
if(a[d-1]==b[0]&&b[e-1]==c[0])
printf("YES");
else
printf("NO");
return 0;
}
| main.c: In function 'main':
main.c:7:14: error: expected expression before ']' token
7 | d=strlen(a[]);
| ^
main.c:8:14: error: expected expression before ']' token
8 | e=strlen(b[]);
| ^
main.c:9:14: error: expected expression before ']' token
9 | f=strlen(c[]);
| ^
|
s115153081 | p03729 | C | #include<stdio.h>
#include<string.h>
int main(){
char a[10],b[10],c[10];
scanf("%s %s %s",&a,&b,&c);
int d,e,f;
d=strlen(a[]);
e=strlen(b[]);
f=strlen(c[]);
if(a[d-1]==b[0]&&b[e-1]==c[0])
printf("YES");
else
printf("NO");
return 0;
}
| main.c: In function 'main':
main.c:7:14: error: expected expression before ']' token
7 | d=strlen(a[]);
| ^
main.c:8:14: error: expected expression before ']' token
8 | e=strlen(b[]);
| ^
main.c:9:14: error: expected expression before ']' token
9 | f=strlen(c[]);
| ^
|
s483579545 | p03729 | C++ | #include <iostream>
#include <string>
using namespace std;
int main()
{
string A, B, C;
cin >> A >> B >> C;
if ((A[A.length()-1]==B[0]) && (B[B.lengtj()-1]==C[0])) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:39: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'lengtj'; did you mean 'length'?
8 | if ((A[A.length()-1]==B[0]) && (B[B.lengtj()-1]==C[0])) {
| ^~~~~~
| length
|
s759516639 | p03729 | C++ | #include <iostream>
using namespace std;
int main(){
string a,b,c;
cin >> a >> b >> c;
if(a.at(a.size()-1)!=b.at(0)) cout << "NO";
else if(b.at(b.size()-1)!=c.at(0)))cout << "NO";
else cout << "YES";
}
| a.cc: In function 'int main()':
a.cc:9:37: error: expected primary-expression before ')' token
9 | else if(b.at(b.size()-1)!=c.at(0)))cout << "NO";
| ^
|
s284286607 | p03729 | C++ | #include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
string A,B,C;
if(A[A.size()-1]==B[0]&&B[B.size()1]==C[0]){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
} | a.cc: In function 'int main()':
a.cc:42:39: error: expected ']' before numeric constant
42 | if(A[A.size()-1]==B[0]&&B[B.size()1]==C[0]){
| ^
| ]
a.cc:42:39: error: expected ')' before numeric constant
42 | if(A[A.size()-1]==B[0]&&B[B.size()1]==C[0]){
| ~ ^
| )
a.cc:42:40: error: expected primary-expression before ']' token
42 | if(A[A.size()-1]==B[0]&&B[B.size()1]==C[0]){
| ^
|
s332411776 | p03729 | C++ | #include <iostream>
#include <string>
using namespace std;
int main() {
// your code goes here
string a, b, c; cin >> a >> b >> c;
if (a[-1] == b[0]) && (b[-1] == c[0]) {
cout << "YES";
} else {
cout << "NO";
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:8:31: error: expected identifier before '(' token
8 | if (a[-1] == b[0]) && (b[-1] == c[0]) {
| ^
|
s545560034 | p03729 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String A = sc.next();
String B = sc.next();
String C = sc.next();
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
System.out.println("YES");
}else {
System.out.println("NO");
}
}
}
| Main.java:8: error: cannot find symbol
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
^
symbol: variable a
location: class Main
Main.java:8: error: cannot find symbol
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
^
symbol: variable a
location: class Main
Main.java:8: error: cannot find symbol
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
^
symbol: variable b
location: class Main
Main.java:8: error: cannot find symbol
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
^
symbol: variable b
location: class Main
Main.java:8: error: cannot find symbol
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
^
symbol: variable b
location: class Main
Main.java:8: error: cannot find symbol
if(a.charAt(a.length()-1) == b.charAt(0) && b.charAt(b.length()-1) == c.charAt(0)) {
^
symbol: variable c
location: class Main
6 errors
|
s246715011 | p03729 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
cin>>a>>b>>c;
if(a.at(a.size()-1)==b.at(0)&&b.at(b.size()-1)==c.at(0)){
cout<<"YES"<<ednl;}
else{cout<<"NO"<<endl;}
} | a.cc: In function 'int main()':
a.cc:7:18: error: 'ednl' was not declared in this scope
7 | cout<<"YES"<<ednl;}
| ^~~~
|
s397269615 | p03729 | C++ | #include<iostream>
#include<string.h>
using namespace std;
int main()
{ char a[100],b[100],c[100];
cin>>a;
cin>>b;
cin>>c;
if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])
cout<<"Yes";
else
cout<"No";
return 0;
} | a.cc: In function 'int main()':
a.cc:14:13: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [3]')
14 | cout<"No";
| ~~~~^~~~~
| | |
| | const char [3]
| std::ostream {aka std::basic_ostream<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: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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
14 | cout<"No";
| ^~~~
/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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
14 | cout<"No";
| ^~~~
/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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
14 | cout<"No";
| ^~~~
/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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h: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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'const char*'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3901 | operator<(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2600 | operator<(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/ios_base.h:46:
/usr/include/c++/14/system_error:324:3: note: candidate: 'bool std::operator<(const error_code&, const error_code&)'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ^~~~~~~~
/usr/include/c++/14/system_error:324:31: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'const std::error_code&'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/system_error:507:3: note: candidate: 'bool std::operator<(const error_condition&, const error_condition&)'
507 | operator<(const error_condition& __lhs,
| ^~~~~~~~
/usr/include/c++/14/system_error:507:36: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'const std::error_condition&'
507 | operator<(const error_condition& __lhs,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
|
s869127227 | p03729 | C++ | #include<iostream>
#include<string.h>
using namespace std;
int main()
{ char a[100],b[100],c[100];
cin>>a;
cin>>b;
cin>>c;
if(a[strlen(a)-1]==b[0] && b[strlen(b)-1]==c[0])
cout<<"Yes";
else
cout<"No";
return 0;
} | a.cc: In function 'int main()':
a.cc:14:13: error: no match for 'operator<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'const char [3]')
14 | cout<"No";
| ~~~~^~~~~
| | |
| | const char [3]
| std::ostream {aka std::basic_ostream<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: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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
14 | cout<"No";
| ^~~~
/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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::reverse_iterator<_Iterator>'
14 | cout<"No";
| ^~~~
/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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
14 | cout<"No";
| ^~~~
/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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::move_iterator<_IteratorL>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/string:51:
/usr/include/c++/14/bits/stl_pair.h: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:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::pair<_T1, _T2>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'const char*'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
14 | cout<"No";
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3901 | operator<(const _CharT* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3901:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: mismatched types 'const _CharT*' and 'std::basic_ostream<char>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/tuple:2600:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator<(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
2600 | operator<(const tuple<_TElements...>& __t,
| ^~~~~~~~
/usr/include/c++/14/tuple:2600:5: note: template argument deduction/substitution failed:
a.cc:14:14: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'const std::tuple<_UTypes ...>'
14 | cout<"No";
| ^~~~
In file included from /usr/include/c++/14/bits/ios_base.h:46:
/usr/include/c++/14/system_error:324:3: note: candidate: 'bool std::operator<(const error_code&, const error_code&)'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ^~~~~~~~
/usr/include/c++/14/system_error:324:31: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'const std::error_code&'
324 | operator<(const error_code& __lhs, const error_code& __rhs) noexcept
| ~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/system_error:507:3: note: candidate: 'bool std::operator<(const error_condition&, const error_condition&)'
507 | operator<(const error_condition& __lhs,
| ^~~~~~~~
/usr/include/c++/14/system_error:507:36: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'const std::error_condition&'
507 | operator<(const error_condition& __lhs,
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~
|
s959513611 | p03729 | C | #include<stdio.h>
int main()
{
char a[11],b[11],c[11];
int a , b, c;
scanf("%s",x);
scanf("%s",y);
scanf("%s",z);
a=strlen(x)-1;
b=strlen(y)-1;
c=strlen(z)-1;
if((x[a]==y[0])&&(y[b]==z[0]))
{
printf("YES\n");
}
else
{
printf("NO\n");
}
return 0;
} | main.c: In function 'main':
main.c:6:9: error: conflicting types for 'a'; have 'int'
6 | int a , b, c;
| ^
main.c:5:10: note: previous declaration of 'a' with type 'char[11]'
5 | char a[11],b[11],c[11];
| ^
main.c:6:13: error: conflicting types for 'b'; have 'int'
6 | int a , b, c;
| ^
main.c:5:16: note: previous declaration of 'b' with type 'char[11]'
5 | char a[11],b[11],c[11];
| ^
main.c:6:16: error: conflicting types for 'c'; have 'int'
6 | int a , b, c;
| ^
main.c:5:22: note: previous declaration of 'c' with type 'char[11]'
5 | char a[11],b[11],c[11];
| ^
main.c:8:16: error: 'x' undeclared (first use in this function)
8 | scanf("%s",x);
| ^
main.c:8:16: note: each undeclared identifier is reported only once for each function it appears in
main.c:9:16: error: 'y' undeclared (first use in this function)
9 | scanf("%s",y);
| ^
main.c:10:16: error: 'z' undeclared (first use in this function)
10 | scanf("%s",z);
| ^
main.c:12:7: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
12 | a=strlen(x)-1;
| ^~~~~~
main.c:2:1: note: include '<string.h>' or provide a declaration of 'strlen'
1 | #include<stdio.h>
+++ |+#include <string.h>
2 | int main()
main.c:12:7: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch]
12 | a=strlen(x)-1;
| ^~~~~~
main.c:12:7: note: include '<string.h>' or provide a declaration of 'strlen'
|
s994722100 | p03729 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,N) for(int i=0; i<N; i++){ ;
int main() {
string A,B,C;
if(A.at(A.size()-1)==B.ay(0)&&B.at(B.size()-1)==C.at(0)){
cout<<"YES"<<endl;
}
else
cout<<"NO"<<endl;
} | a.cc: In function 'int main()':
a.cc:7:28: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'ay'; did you mean 'at'?
7 | if(A.at(A.size()-1)==B.ay(0)&&B.at(B.size()-1)==C.at(0)){
| ^~
| at
|
s892257001 | p03729 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
cin >> a >> b >> c;
if(a[a.size()+1]==b[0]&&b[b.size()+1]==c[0]&){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
} | a.cc: In function 'int main()':
a.cc:6:47: error: expected primary-expression before ')' token
6 | if(a[a.size()+1]==b[0]&&b[b.size()+1]==c[0]&){
| ^
|
s517482377 | p03729 | C++ | #include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF=1e18;
int main(){
cin.tie(0);ios::sync_with_stdio(false);
string a,b,c;
cin>>a>>b>>c;
if(a[s.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
//ペナルティ出しても焦らない ACできると信じろ!!!
//どうしてもわからないときはサンプルで実験 何か見えてくるかも
//頭で考えてダメなら紙におこせ!!
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ!
(適切にmodをとれ にぶたんで途中で切り上げろ)
制約をよく読め!
{
・全探索できるなら全探索しろ
・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意!(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ!
doubleを扱うときには(abs)ではなく'fabs'!!!
*/ | a.cc: In function 'int main()':
a.cc:31:10: error: 's' was not declared in this scope
31 | if(a[s.size()-1]==b[0]&&b[b.size()-1]==c[0])cout<<"YES"<<endl;
| ^
|
s873380912 | p03729 | C++ | # # Make IO faster
# import sys
# input = sys.stdin.readline
# # get single (or) multiple str
# X = input()
# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]
# from IPython import embed; embed(); exit();
# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
print("YES")
else:
print("NO")
| a.cc:1:3: error: invalid preprocessing directive ##
1 | # # Make IO faster
| ^
a.cc:2:3: warning: #import is a deprecated GCC extension [-Wdeprecated]
2 | # import sys
| ^~~~~~
a.cc:2:10: error: #import expects "FILENAME" or <FILENAME>
2 | # import sys
| ^~~
a.cc:3:3: error: invalid preprocessing directive #input
3 | # input = sys.stdin.readline
| ^~~~~
a.cc:5:3: error: invalid preprocessing directive ##
5 | # # get single (or) multiple str
| ^
a.cc:6:3: error: invalid preprocessing directive #X
6 | # X = input()
| ^
a.cc:8:3: error: invalid preprocessing directive ##
8 | # # get single int
| ^
a.cc:9:3: error: invalid preprocessing directive #N
9 | # N = int(input())
| ^
a.cc:10:3: error: invalid preprocessing directive ##
10 | # # get multiple int (e.g., 2)
| ^
a.cc:11:3: error: invalid preprocessing directive #X
11 | # X, Y = map(int, input().split())
| ^
a.cc:12:3: error: invalid preprocessing directive ##
12 | # # get multiple int (e.g., 2) for N lines
| ^
a.cc:13:3: error: invalid preprocessing directive #XY
13 | # XY = [list(map(int, input().split())) for _ in range(N)]
| ^~
a.cc:15:3: error: invalid preprocessing directive #from
15 | # from IPython import embed; embed(); exit();
| ^~~~
a.cc:17:3: error: invalid preprocessing directive #\U00005168\U000090e8\U00005165\U0000308a
17 | # 全部入り
| ^~~~~~~~
a.cc:36:13: warning: multi-character character constant [-Wmultichar]
36 | INF = float('inf')
| ^~~~~
a.cc:18:1: error: 'import' does not name a type
18 | import sys, re
| ^~~~~~
a.cc:18:1: note: C++20 'import' only available with '-fmodules-ts'
|
s491088803 | p03729 | C++ | #include <stdio.h>
#include <strings.h>
int main() {
char A[15], B[15], C[15];
scanf("%s %s %s", &A, &B, &C);
int lastCharA = strlen(A) - 1;
int lastCharB = strlen(B) - 1;
if (A[lastCharA] == B[0] && B[lastCharB] == C[0]){
printf("YES\n");
}
else {
printf("NO\n");
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:6:25: error: 'strlen' was not declared in this scope
6 | int lastCharA = strlen(A) - 1;
| ^~~~~~
a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <strings.h>
+++ |+#include <cstring>
3 | int main() {
|
s347749052 | p03729 | C++ | #include <stdio.h>
#include <string.h>
int main() {
char A[12], B[12], C[12];
A[12] = 'a' - 'z'
B[12] = 'a' - 'z'
C[12] = 'a' - 'z'
scanf ("%s %s %s", &A, &B, &C);
if (A [strlen(A) - 1] == B[0] && B [strlen(B) - 1] == C[0]) {
printf ("YES");
}
else {
printf ("NO");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:22: error: expected ';' before 'B'
6 | A[12] = 'a' - 'z'
| ^
| ;
7 | B[12] = 'a' - 'z'
| ~
|
s452533362 | p03729 | C++ | #include <stdio.h>
#include <string.h>
int main() {
char A[15], B[15], C[15];
A[15] = 'a' - 'z'
B[15] = 'a' - 'z'
C[15] = 'a' - 'z'
scanf ("%s %s %s", &A, &B, &C);
if (A [strlen(A) - 1] == B[0] && B [strlen(B) - 1] == C[0]) {
printf ("YES");
}
else {
printf ("NO");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:6:22: error: expected ';' before 'B'
6 | A[15] = 'a' - 'z'
| ^
| ;
7 | B[15] = 'a' - 'z'
| ~
|
s025618290 | p03729 | C++ | #include<stdio.h>
#include<string.h>
int main()
{
char a[255];
char b[255];
char c[255];
scanf("%s %s %s", a, b, c);
int len = strlen(a);
int n = strlen(b);
int s = strlen(c);
if (a[len - 1] == b[0] && b[n - 1] == c[0]){
puts("YES");
}
else puts("NO");
}
return 0;
} | a.cc:19:9: error: expected unqualified-id before 'return'
19 | return 0;
| ^~~~~~
a.cc:20:1: error: expected declaration before '}' token
20 | }
| ^
|
s254991715 | p03729 | C++ | #include <stdio.h>
#include <String.h>
int main(){
char A[15],B[15],C[15];
scanf("%s %s %s",&A,&B,&C);
int lenA=strlen(A);
int lenB=strlen(B);
if(A[lenA-1]==B[0]&&B[lenB-1]==C[0]){
printf("YES");
}
else{
printf("NO");
}
return 0;
} | a.cc:2:10: fatal error: String.h: No such file or directory
2 | #include <String.h>
| ^~~~~~~~~~
compilation terminated.
|
s334084911 | p03729 | C++ | #include <stdio.h>
#include <string.h>
int main (){
char A[12],B[12],C[12];
scanf("%s %s %s", A, B ,C);
}
if (A[strlen(A)-1] == B[0] && B[strlen(B)-1] == C[0]){
printf("YES\n");
}else {
printf("NO\n");
}
return 0;
} | a.cc:10:5: error: expected unqualified-id before 'if'
10 | if (A[strlen(A)-1] == B[0] && B[strlen(B)-1] == C[0]){
| ^~
a.cc:12:6: error: expected unqualified-id before 'else'
12 | }else {
| ^~~~
a.cc:17:5: error: expected unqualified-id before 'return'
17 | return 0;
| ^~~~~~
a.cc:18:1: error: expected declaration before '}' token
18 | }
| ^
|
s786736103 | p03729 | C++ | #include <stdio.h>
#include <string.h>
int main () {
char a [10];
char b[10];
char c[10];
scanf ("%s %s %s",&a,&b,&c);
int len1 = strlen(a);
int len2 = strlen(b);
int len3 = strlen(c);
if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
if (a[len1-1] == b[0] && b[len2-1] == c[0]) {
printf("YES");
}
else printf ("NO");}
else printf ("NO");
return 0;
} | a.cc: In function 'int main()':
a.cc:12:14: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
| ~^~~~~
a.cc:12:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
| ~^~~~~
a.cc:12:34: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
| ~^~~~~
a.cc:12:43: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
| ~^~~~~
a.cc:12:52: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
| ~^~~~~
a.cc:12:61: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
12 | if (a>='a' && a<='z' && b>='a' &&b<='z' &&c>='a' &&c<='z' ) {
| ~^~~~~
|
s496026307 | p03729 | C++ | #include <stdio.h>
#include<string.h>
int main(){
char A[15], B[15], C[15];
scanf("%s%s%s", &A,&B,&C);
if( A[strlen(A)-1]==B[0] && B[strlen(B)-1]==V[0]){
printf("YES");
}
else{
printf("NO");
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:53: error: 'V' was not declared in this scope
9 | if( A[strlen(A)-1]==B[0] && B[strlen(B)-1]==V[0]){
| ^
|
s822367883 | p03729 | C++ | #include<stdio.h>
#include<string.h>
int main()
{
int flag=0;
char a[10],b[10],c[10];
gets(a);
gets(b);
gets(c);
if(a[strlen(a)-1]==b[0]){flag=1;}
else {flag=0;}
if(b[strlen(b)-1]==c[0]){flag=1;}
else {flag=0;}
if(flag==0){printf("NO");}
else {printf("YES");}
}
| a.cc: In function 'int main()':
a.cc:10:4: error: 'gets' was not declared in this scope; did you mean 'getw'?
10 | gets(a);
| ^~~~
| getw
|
s706304231 | p03729 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int i,j,flag=0,x,y;
char a[10],b[10],c[10];
gets(a);
gets(b);
gets(c);
if(a[strlen(a)-1]==b[0]){flag=1;}
else {flag=0;}
if(b[strlen(b)-1]==c[0]){flag=1;}
else {flag=0;}
if(flag==0){cout<<"NO"<<endl;}
else {cout<<"YES"<<endl;}
}
| a.cc: In function 'int main()':
a.cc:9:4: error: 'gets' was not declared in this scope; did you mean 'getw'?
9 | gets(a);
| ^~~~
| getw
|
s474615572 | p03729 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
cin>>a>>b>>c;
int asize;bsize;
asize=a.size();
bsize=b.size();
if(a.at(asize-1)==b.at(0)&&b.at(bsize-1)==c.at(0))cout <<"YES"<<endl;
else cout <<"N"<endl;
} | a.cc: In function 'int main()':
a.cc:6:13: error: 'bsize' was not declared in this scope; did you mean 'asize'?
6 | int asize;bsize;
| ^~~~~
| asize
a.cc:10:18: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>')
10 | else cout <<"N"<endl;
| ~~~~~~~~~~^~~~~
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:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1224: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>&)'
1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1317: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>&)'
1317 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: couldn't deduce template parameter '_Bi_iter'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1485 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: couldn't deduce template parameter '_Bi_iter'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1660 | operator<(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
10 | else cout <<"N"<endl;
| ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h: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:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>'
10 | else cout <<"N"<endl;
| ^~~~
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:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
10 | else cout <<"N"<endl;
| ^~~~
/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:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>'
10 | else cout <<"N"<endl;
| ^~~~
/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:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
10 | else cout <<"N"<endl;
| ^~~~
/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:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>'
10 | else cout <<"N"<endl;
| ^~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: couldn't deduce template parameter '_CharT'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
a.cc:10:19: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
10 | else cout <<"N"<endl;
| ^~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, con |
s875707445 | p03729 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string A, B, C;
cin >> A >> B >> C;
if (A.[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
cout << "YES" << endl;
} else {
cout << "NO" << endl;
}
} | a.cc: In function 'int main()':
a.cc:8:9: error: expected unqualified-id before '[' token
8 | if (A.[A.size()-1] == B[0] && B[B.size()-1] == C[0]) {
| ^
|
s328336918 | p03729 | C++ | #include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;
#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans=0;llfor;///////////////////////////////////////////////////////////
int main(){
string S,T,U;
cin>>S>>T>>U;
int A=S.size();
int B=T.size();
string S="NO";
if(S[A-1]==T[0]&&T[B-1]==U[0]) S="YES";
cout<<S;
return 0;} | a.cc: In function 'int main()':
a.cc:52:10: error: redeclaration of 'std::string S'
52 | string S="NO";
| ^
a.cc:48:10: note: 'std::string S' previously declared here
48 | string S,T,U;
| ^
|
s265101587 | p03729 | Java | import java.util.Scanner;
//import java.util.Arrays;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String a = scan.next();
String b = scan.next();
String c = scan.next();
System.out.println(b.startsWith(a.charAt(a.length()-1).toString()) && c.startsWith(b.charAt(b.length()-1).toString()) ? "YES" : "NO");
}
}
| Main.java:10: error: char cannot be dereferenced
System.out.println(b.startsWith(a.charAt(a.length()-1).toString()) && c.startsWith(b.charAt(b.length()-1).toString()) ? "YES" : "NO");
^
Main.java:10: error: char cannot be dereferenced
System.out.println(b.startsWith(a.charAt(a.length()-1).toString()) && c.startsWith(b.charAt(b.length()-1).toString()) ? "YES" : "NO");
^
2 errors
|
s021116713 | p03729 | Java | import java.util.Scanner;
//import java.util.Arrays;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String a = scan.next();
String b = scan.next();
String c = scan.next();
System.out.println(b.startsWith(a.charAt(a.length()-1)) && c.startsWith(b.charAt(b.length()-1)) ? "YES" : "NO");
}
}
| Main.java:10: error: incompatible types: char cannot be converted to String
System.out.println(b.startsWith(a.charAt(a.length()-1)) && c.startsWith(b.charAt(b.length()-1)) ? "YES" : "NO");
^
Main.java:10: error: incompatible types: char cannot be converted to String
System.out.println(b.startsWith(a.charAt(a.length()-1)) && c.startsWith(b.charAt(b.length()-1)) ? "YES" : "NO");
^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
|
s287562670 | p03729 | Java | import java.util.Scanner;
//import java.util.Arrays;
public class Main{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String a = scan.next();
String b = scan.next()
String c = scan.next();
System.out.println(b.startsWith(a.charAt(a.length()-1)) && c.startsWith(b.charAt(b.length()-1)) ? "YES" : "NO");
}
}
| Main.java:7: error: ';' expected
String b = scan.next()
^
1 error
|
s525598549 | p03729 | C++ | #include <iostream>
#include <string>
int main() {
string a, b, c;
cin >> a >> b >> c;
int x = a.length(), y = b.length(), z = c.length();
if (a[x - 1] == b[0] && b[y - 1] == c[0])
cout << "YES" << endl;
else
cout << "NO" << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:5:3: error: 'string' was not declared in this scope
5 | string a, b, c;
| ^~~~~~
a.cc:5:3: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note: 'std::string'
77 | typedef basic_string<char> string;
| ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note: 'std::pmr::string'
76 | using string = basic_string<char>;
| ^~~~~~
a.cc:6:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
6 | cin >> a >> b >> c;
| ^~~
| std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:6:10: error: 'a' was not declared in this scope
6 | cin >> a >> b >> c;
| ^
a.cc:6:15: error: 'b' was not declared in this scope
6 | cin >> a >> b >> c;
| ^
a.cc:6:20: error: 'c' was not declared in this scope
6 | cin >> a >> b >> c;
| ^
a.cc:8:29: error: 'y' was not declared in this scope
8 | if (a[x - 1] == b[0] && b[y - 1] == c[0])
| ^
a.cc:9:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
9 | cout << "YES" << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:9:22: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
9 | cout << "YES" << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:11:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
11 | cout << "NO" << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:11:21: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
11 | cout << "NO" << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s752811509 | p03729 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
string a,b,c;
cin >> a >> b >> c;
if(a.at.size()==b.at(0)&&b.at.size()==c.at(0)){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
} | a.cc: In function 'int main()':
a.cc:7:8: error: invalid use of member function 'std::__cxx11::basic_string<char>::at' (did you forget the '()' ?)
7 | if(a.at.size()==b.at(0)&&b.at.size()==c.at(0)){
| ~~^~
a.cc:7:11: error: expected ')' before 'size'
7 | if(a.at.size()==b.at(0)&&b.at.size()==c.at(0)){
| ~ ^~~~
| )
|
s871374547 | p03729 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
string A,B,C;
cin >> A >> B >> C;
int D==A.size();
int E==B.size();
if(A.at(D)==B.at(0)&&B.at(E)==C.at(0)){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
}
| a.cc: In function 'int main()':
a.cc:7:8: error: expected initializer before '==' token
7 | int D==A.size();
| ^~
a.cc:8:8: error: expected initializer before '==' token
8 | int E==B.size();
| ^~
a.cc:9:11: error: 'D' was not declared in this scope
9 | if(A.at(D)==B.at(0)&&B.at(E)==C.at(0)){
| ^
a.cc:9:29: error: 'E' was not declared in this scope
9 | if(A.at(D)==B.at(0)&&B.at(E)==C.at(0)){
| ^
|
s300127615 | p03729 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
string A,B,C;
cin >> A >> B >> C;
if(A.at.size()==B.at(0)&&B.at.size()==C.at(0)){
cout << "YES" << endl;
}
else{
cout << "NO" << endl;
}
} | a.cc: In function 'int main()':
a.cc:7:8: error: invalid use of member function 'std::__cxx11::basic_string<char>::at' (did you forget the '()' ?)
7 | if(A.at.size()==B.at(0)&&B.at.size()==C.at(0)){
| ~~^~
a.cc:7:11: error: expected ')' before 'size'
7 | if(A.at.size()==B.at(0)&&B.at.size()==C.at(0)){
| ~ ^~~~
| )
|
s414026314 | p03729 | C | #include<stdio.h>
#include<string.h>
int main(){
char a,b,c;
scanf("%s%s%s",a,b,c);
if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
printf("YES");
else
printf("NO");
return 0;
} | main.c: In function 'main':
main.c:6:15: error: passing argument 1 of 'strlen' makes pointer from integer without a cast [-Wint-conversion]
6 | if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
| ^
| |
| char
In file included from main.c:2:
/usr/include/string.h:407:35: note: expected 'const char *' but argument is of type 'char'
407 | extern size_t strlen (const char *__s)
| ~~~~~~~~~~~~^~~
main.c:6:7: error: subscripted value is neither array nor pointer nor vector
6 | if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
| ^
main.c:6:23: error: subscripted value is neither array nor pointer nor vector
6 | if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
| ^
main.c:6:37: error: passing argument 1 of 'strlen' makes pointer from integer without a cast [-Wint-conversion]
6 | if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
| ^
| |
| char
/usr/include/string.h:407:35: note: expected 'const char *' but argument is of type 'char'
407 | extern size_t strlen (const char *__s)
| ~~~~~~~~~~~~^~~
main.c:6:29: error: subscripted value is neither array nor pointer nor vector
6 | if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
| ^
main.c:6:45: error: subscripted value is neither array nor pointer nor vector
6 | if(a[strlen(a)-1]==b[0]&&b[strlen(b)-1]==c[0])
| ^
|
s883828701 | p03729 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
string a,b,c;cin>>a>>b>>c;
if (a[a.length()-1] == b[0] %% b[b.length()-1] == c[0]) cout << "YES" << endl;
else cout << "NO" << endl;
}
| a.cc: In function 'int main()':
a.cc:6:32: error: expected primary-expression before '%' token
6 | if (a[a.length()-1] == b[0] %% b[b.length()-1] == c[0]) cout << "YES" << endl;
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.