submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s239017600
p03856
C++
#include<bits/stdc++.h> using namespace std; #define int long long string divide[4] = {"dream", "dreamer", "erase", "eraser"}; bool dp[100010]; signed main(){ string s; cin >> s; dp[0] = 1; for(int i = 0; i < S.size(); ++i){ if(!dp[i]) continue; for(string s : divide){ if(S.substr(i, s.size()) == s){ dp[i + s.size()] = 1; } } } cout << (dp[S.size()] ? "YES" : "NO") << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:24: error: 'S' was not declared in this scope 13 | for(int i = 0; i < S.size(); ++i){ | ^ a.cc:23:17: error: 'S' was not declared in this scope 23 | cout << (dp[S.size()] ? "YES" : "NO") << endl; | ^
s303846847
p03856
C++
#include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> //deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector //#include<bits/stdc++.h> #define ll long long using namespace std; //string a="dream",b="dreamer",c="erase",d="eraser"; int main() { ios::sync_with_stdio(false); char s[100010]; gets(s); int a=0; int b=strlen(s); int flag=1; while(a<b) { if(s[a]=='d'){ a=a+5; if(s[a+1]=='e'&&s[a+3]!='a') a=a+2; } else if(s[a]=='e'){ a=a+5; if(s[a]=='r') a++; } else { flag=0; } } if(flag==1&&a==b) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 16 | gets(s); | ^~~~ | getw
s551962233
p03856
C
#include<stdio.h> #include<string.h> int main() { char s[100000]; scanf("%s",s); int a[strlen(s)]= {0},i,j; for(i=0; i<strlen(s); i++) { if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m') { a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1; } if(s[i]=='d'&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m'&&s[i+5]=='e'&&s[i+6]=='r') { a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1,a[i+5]=1,a[i+6]=1; } if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e') { a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1; } if(s[i]=='e'&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r') { a[i]=1,a[i+1]=1,a[i+2]=1,a[i+3]=1,a[i+4]=1,a[i+5]=1; } } int f=0; for(i=0; i<strlen(s); i++) { if(a[i]==0) { f=1; break; } } if(f==1) printf("NO"); else printf("YES"); }
main.c: In function 'main': main.c:6:27: error: variable-sized object may not be initialized except with an empty initializer 6 | int a[strlen(s)]= {0},i,j; | ^
s581610326
p03856
C
char A[4][8] = { { 'r','e','m','a','e','r','d'}, { 'm','a','e','r','d' }, { 'r','e','s','a','r','e' }, { 'e','s','a','r','e' } }; int AL[4] = { 7, 5, 6, 5 }; char S[10002];
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s408302045
p03856
C++
#include <bits/stdc++.h> using namespace std; #define forn(i, n) for (ll i = 0; i < (ll) (n); ++i) #define sz(a) static_cast<int>((a).size()) #define pb emplace_back #define mp make_pair #define endl '\n' #define f first #define s second #ifdef SEREZHKA #define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__) #else #define dbg(...) #endif template<typename T> void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; } template<typename T, typename... Ts> void _dbg(const char*_s, T _h, Ts... _t) { int _b = 0; while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',') cerr << *_s++; cerr << " = " << _h << ","; _dbg(_s + 1, _t...); } using ll = long long; const ll INF = static_cast<ll>(1e9) + 7ll; const ll LINF = INF * INF; const int MAXN = static_cast<int>(1e6) + 17; int n; string s; bool read() { if (!(cin >> s)) return false; return true; } void solve() { n = sz(s); vector<string> L = {"dream", "dreamer", "erase", "eraser"}; while (n > 0) { bool ok = false; for (auto i : L) if (sz(s) >= sz(i) && s.substr(sz(s) - sz(i), sz(i)) == i) { ok = true; forn (j, sz(i)) s.pop_back(); break; } if (!ok) break; } cout << ({"YES", "NO"})[s.empty()] << endl; } int main() { cin.tie(nullptr); std::ios_base::sync_with_stdio(false); while (read()) solve(); return 0; }
a.cc: In function 'void solve()': a.cc:67:26: error: expected ';' before '}' token 67 | cout << ({"YES", "NO"})[s.empty()] << endl; | ^ | ;
s710516412
p03856
C++
#include<cstdio> #include<map> #include<algorithm> using namespace std; int fa[200005],fb[200005]; map<int,map<int,int> >mp; int fd1(int x) { if(fa[x]==x) return x; return fa[x]=fd1(fa[x]); } int fd2(int x) { if(fb[x]==x) return x; return fb[x]=fd2(fb[x]); } void U1(int x,int y) fa[fd1(x)]=fd1(y); void U2(int x,int y) fb[fd2(x)]=fd2(y); int main() { int n,k,l; scanf("%d %d %d",&n,&k,&l); for(int i=1; i<=n; i++) fa[i]=fb[i]=i; for(int i=1; i<=k; i++) { int x,y; scanf("%d %d",&x,&y); U1(x,y); } for(int i=1;i<=l;i++) { int x,y; scanf("%d %d",&x,&y); U2(x,y); } for(int i=1; i<=n; i++) mp[fd1(i)][fd2(i)]++; for(int i=1; i<=n; i++) printf("%d ",mp[fd1(i)][fd2(i)]); return 0; }
a.cc:18:22: error: expected initializer before 'fa' 18 | void U1(int x,int y) fa[fd1(x)]=fd1(y); | ^~ a.cc:19:22: error: expected initializer before 'fb' 19 | void U2(int x,int y) fb[fd2(x)]=fd2(y); | ^~ a.cc: In function 'int main()': a.cc:28:17: error: 'U1' was not declared in this scope 28 | U1(x,y); | ^~ a.cc:33:17: error: 'U2' was not declared in this scope 33 | U2(x,y); | ^~
s208220693
p03856
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<cstring> #include<string> #include<cmath> #include<vector> #include<queue> #include<stack> #include<map> #include<set> using namespace std; const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1}; string s,word[]={"dream","erase","dreamer","eraser"}; pair<int,int> p[4]={{5,0},{5,1},{7,2},{6,3}}; void dfs(int x) { if(x==s.size()-1) { cout<<"YES"; exit(0); } for(int d=0;d<4;d++) { int len=p[d].first,wd=p[d].second; if(s.substr(x,len)==word[wd]) dfs(x+len); } } int main(){ cin>>s; mp["dream"]=true; mp["dreamer"]=true; mp["erase"]=true; mp["eraser"]=true; dfs(0); cout<<"NO"; return 0; }
a.cc: In function 'int main()': a.cc:32:9: error: 'mp' was not declared in this scope; did you mean 'p'? 32 | mp["dream"]=true; | ^~ | p
s142316666
p03856
C++
#include<iostream> #include<iomanip> #include<algorithm> #include<cstring> #include<string> #include<cmath> #include<vector> #include<queue> #include<stack> #include<map> #include<set> using namespace std; const int inf=1e9,dx[]={-1,0,1,0},dy[]={0,-1,0,1}; string s,word[]={"dream","erase","dreamer","eraser"}; pair<int,int> p[4]={{5,0},{5,1},{7,2},{6,3}}; void dfs(int x) { if(x==s.size()-1) { cout<<"YES"; exit(0); } for(int d=0;d<4;d++) { int len=p[d].first,wd=p[d].second; if(s.substr(x,len)==word[wd]) dfs(x+len); } } int main(){ cin>>s; mp["dream"]=true; mp["dreamer"]=true; mp["erase"]=true; mp["eraser"]=true; dfs(0); cout<<"NO"; return 0; }
a.cc: In function 'int main()': a.cc:32:9: error: 'mp' was not declared in this scope; did you mean 'p'? 32 | mp["dream"]=true; | ^~ | p
s208077390
p03856
C++
#include<bits/stdc++.h> using namespace std; int main(){ map<string,int> mp; mp["maerd"]=5; mp["remae"]=7; mp["esare"]=5; mp["resar"]=6; string s; cin>>s; while(s!=""){ bool ok=false; for(auto p:mp){ if(ok|=(s.substr(0,5)==p.first)) s=s.substr(mp.second); } if(!ok)break; } if(s=="")cout<<"YES"<<endl; else cout<<"NO"<<endl; }
a.cc: In function 'int main()': a.cc:15:64: error: 'class std::map<std::__cxx11::basic_string<char>, int>' has no member named 'second' 15 | if(ok|=(s.substr(0,5)==p.first)) s=s.substr(mp.second); | ^~~~~~
s805762294
p03856
C++
int main() { std::string s; std::cin >> s; int cou=0; for (int i = 0; i < s.size(); i++){ if (s[i + 0] == 'd'&&s[i + 1] == 'r'&&s[i + 2] == 'e'&&s[i + 3] == 'a'&&s[i + 4] == 'm') { if (s[i + 5] == 'e'&&s[i + 6] == 'r'&&!(s[i + 7] == 'a'&&s[i + 8] == 's'&&s[i + 9] == 'e')) { cou += 7; i += 6; } else { cou += 5; i += 4; } } if (s[i + 0] == 'e'&&s[i + 1] == 'r'&&s[i + 2] == 'a'&&s[i + 3] == 's'&&s[i + 4] == 'e') { if (s[i + 5] == 'r') { cou += 6; i += 5; } else { cou += 5; i += 4; } } } if (cou >= s.size()) { std::cout << "YES" << std::endl; } else { std::cout << "NO" << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:2:14: error: 'string' is not a member of 'std' 2 | std::string s; | ^~~~~~ a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' +++ |+#include <string> 1 | int main() { a.cc:3:14: error: 'cin' is not a member of 'std' 3 | std::cin >> s; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | int main() { a.cc:3:21: error: 's' was not declared in this scope 3 | std::cin >> s; | ^ a.cc:28:22: error: 'cout' is not a member of 'std' 28 | std::cout << "YES" << std::endl; | ^~~~ a.cc:28:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:28:44: error: 'endl' is not a member of 'std' 28 | std::cout << "YES" << std::endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | int main() { a.cc:31:22: error: 'cout' is not a member of 'std' 31 | std::cout << "NO" << std::endl; | ^~~~ a.cc:31:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:43: error: 'endl' is not a member of 'std' 31 | std::cout << "NO" << std::endl; | ^~~~ a.cc:31:43: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s616639283
p03856
C++
int main() { std::string s; std::cin >> s; int cou=0; for (int i = 0; i < s.size(); i++){ if (s[i + 0] == 'd'&&s[i + 1] == 'r'&&s[i + 2] == 'e'&&s[i + 3] == 'a'&&s[i + 4] == 'm') { if (s[i + 5] == 'e'&&s[i + 6] == 'r'&&!(s[i + 7] == 'a'&&s[i + 8] == 's'&&s[i + 9] == 'e')) { cou += 7; i += 6; } else { cou += 5; i += 4; } } if (s[i + 0] == 'e'&&s[i + 1] == 'r'&&s[i + 2] == 'a'&&s[i + 3] == 's'&&s[i + 4] == 'e') { if (s[i + 5] == 'r') { cou += 6; i += 5; } else { cou += 5; i += 4; } } } if (cou >= s.size()) { std::cout << "YES" << std::endl; } else { std::cout << "NO" << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:2:14: error: 'string' is not a member of 'std' 2 | std::string s; | ^~~~~~ a.cc:1:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' +++ |+#include <string> 1 | int main() { a.cc:3:14: error: 'cin' is not a member of 'std' 3 | std::cin >> s; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | int main() { a.cc:3:21: error: 's' was not declared in this scope 3 | std::cin >> s; | ^ a.cc:28:22: error: 'cout' is not a member of 'std' 28 | std::cout << "YES" << std::endl; | ^~~~ a.cc:28:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:28:44: error: 'endl' is not a member of 'std' 28 | std::cout << "YES" << std::endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | int main() { a.cc:31:22: error: 'cout' is not a member of 'std' 31 | std::cout << "NO" << std::endl; | ^~~~ a.cc:31:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:43: error: 'endl' is not a member of 'std' 31 | std::cout << "NO" << std::endl; | ^~~~ a.cc:31:43: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s828784986
p03856
C++
S = input() keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') for key in keys: S = S.replace(key, '') if S == '': print('YES') else: print('NO')
a.cc:3:9: warning: multi-character literal with 11 characters exceeds 'int' size of 4 bytes 3 | keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') | ^~~~~~~~~~~~~ a.cc:3:24: warning: multi-character literal with 12 characters exceeds 'int' size of 4 bytes 3 | keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') | ^~~~~~~~~~~~~~ a.cc:3:40: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 3 | keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') | ^~~~~~~ a.cc:3:49: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 3 | keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') | ^~~~~~~ a.cc:3:58: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes 3 | keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') | ^~~~~~~~~ a.cc:3:69: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes 3 | keys = ('dreameraser', 'dreamererase', 'erase', 'dream', 'dreamer', 'eraser') | ^~~~~~~~ a.cc:6:24: error: empty character constant 6 | S = S.replace(key, '') | ^~ a.cc:8:9: error: empty character constant 8 | if S == '': | ^~ a.cc:9:11: warning: multi-character character constant [-Wmultichar] 9 | print('YES') | ^~~~~ a.cc:11:11: warning: multi-character character constant [-Wmultichar] 11 | print('NO') | ^~~~ a.cc:1:1: error: 'S' does not name a type 1 | S = input() | ^
s165031124
p03856
C
#include <stdio.h> #include <string.h> int main(void) { int i,j,k,l,lens,m,n,sum,dl,tmp,flag; flag=0; char s[100000]; char d[4][8]={"maerd","renaerd","esare","resare"}; scanf("%s",s); lens=strlen(s); for(i=0;i<=3;i++){ dl=strlen(d[i]); printf("%d",dl); for(j=lens;j>lens-dl;j--){ if(j<0){ flag=1; break;} if(s[j-1]!=d[i][lens-j]){ flag=1; break;} if(flag==0){ if(i==0){ lens-=5;} else if(i==1) lens-=7; else if(i==2) lens-=5; else if(i==3) lens-=6; continue;} else if(flag==1) break;} if(flag==1) printf("No"); else if(flag==0) printf("Yes"); return 0; }
main.c: In function 'main': main.c:39:1: error: expected declaration or statement at end of input 39 | } | ^
s806885454
p03856
C++
s=input() while 1: if s[-5:] in ["dream","erase"]: s=s[:-5] elif s[-6:] == "eraser": s=s[:-6] elif s[-7:] == "dreamer": s=s[:-7] elif s == "": print("YES") exit() else: print("NO") exit()
a.cc:1:1: error: 's' does not name a type 1 | s=input() | ^
s025259473
p03856
C++
#ifndef __INTMOD_H__0001__ #define __INTMOD_H__0001__ #include <vector> #include <iostream> #include <cassert> #include <iostream> /* Modulus must be less than 0x80000000, and not be 0. */ template <uint32_t Modulus> class IntMod { typedef int32_t Int; typedef uint32_t UInt; typedef int64_t Long; typedef uint64_t ULong; public: template <unsigned int Modulus_> friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); template <unsigned int Modulus_> friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); template <unsigned int Modulus_> friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); template <unsigned int Modulus_> friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); template <unsigned int Modulus_> friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); template <unsigned int Modulus_> friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); private: UInt value_m; public: IntMod() { value_m = 0; } IntMod(UInt value) { value_m = value % Modulus; } IntMod(ULong value) { value_m = value % Modulus; } IntMod(Int value) { Int tmp = value % (Int)Modulus; value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp); } IntMod(Long value) { Int tmp = value % (Long)Modulus; value_m = tmp >= 0 ? tmp : Modulus - (unsigned int)(-tmp); } IntMod(const IntMod& other) : value_m(other.value_m) {} IntMod& operator=(const IntMod& other) { value_m = other.value_m; return *this; } const IntMod& operator+() const { return *this; } IntMod operator-() const { return IntMod(Modulus - value_m); } IntMod& operator++() { ++value_m; if (value_m == Modulus) value_m = 0; return *this; } IntMod& operator--() { if (value_m == 0) value_m = Modulus; --value_m; return *this; } IntMod operator++(int dummy) { IntMod tmp(*this); ++(*this); return tmp; } IntMod operator--(int dummy) { IntMod tmp(*this); --(*this); return tmp; } IntMod& operator+=(const IntMod& right) { value_m += right.value_m; // value_m < 0x80000000 if (value_m >= Modulus) value_m -= Modulus; return *this; } IntMod& operator-=(const IntMod& right) { if (value_m < right.value_m) value_m += Modulus; value_m -= right.value_m; return *this; } IntMod& operator*=(const IntMod& right) { value_m = ((ULong)value_m * right.value_m) % Modulus; return *this; } IntMod& operator/=(const IntMod& right) { (*this) *= (right.Inverse()); return *this; } // for power IntMod operator[](unsigned int exp) const { return Pow(exp); } /* Modulus must be a prime. */ IntMod Inverse() const { return (*this).Pow(Modulus - 2); } IntMod Pow(UInt exp) const { IntMod product = 1; IntMod factor(*this); while (exp > 0) { if (exp & 1) product *= factor; factor *= factor; exp >>= 1; } return product; } UInt Get_value() const { return value_m; } static IntMod Fact(UInt num) { static std::vector<IntMod> table(1, 1); if (table.size() > num) return table[num]; int old_size = table.size(); table.resize(num + 1); for (int i = old_size; i <= num; i++) { table[i] = table[i - 1] * i; } return table[num]; } static IntMod Combi(UInt n, UInt r) { if (n < r) throw "okashii"; return IntMod::Fact(n) / (IntMod::Fact(n - r) * IntMod::Fact(r)); } static std::vector<IntMod> Inverse_list(int size) { assert(size < Modulus); std::vector<IntMod> ret_arr(size + 1); ret_arr[1] = 1; for (int i = 2; i <= size; ++i) { ret_arr[i] = ((ULong)(Modulus - Modulus / i) * ret_arr[Modulus % i].Get_value()) % Modulus; } return ret_arr; } }; template <unsigned int Modulus> IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) { IntMod<Modulus> ret(left); ret += right; return ret; } template <unsigned int Modulus> IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { IntMod<Modulus> ret(left); ret -= right; return ret; } template <unsigned int Modulus> IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { IntMod<Modulus> ret(left); ret *= right; return ret; } template <unsigned int Modulus> IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { IntMod<Modulus> ret(left); ret /= right; return ret; } template <unsigned int Modulus> bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; } template <unsigned int Modulus> bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; } /* for set/map */ template <unsigned int Modulus> bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; } template <unsigned int Modulus> bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; } template <unsigned int Modulus> bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; } template <unsigned int Modulus> bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator+(const IntMod<Modulus>& left, Integer right) { return left + IntMod<Modulus>(right); } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator+(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) + right; } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator-(const IntMod<Modulus>& left, Integer right) { return left - IntMod<Modulus>(right); } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator-(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) - right; } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator*(const IntMod<Modulus>& left, Integer right) { return left * IntMod<Modulus>(right); } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator*(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) * right; } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator/(const IntMod<Modulus>& left, Integer right) { return left / IntMod<Modulus>(right); } template <unsigned int Modulus, class Integer> IntMod<Modulus> operator/(Integer left, const IntMod<Modulus>& right) { return IntMod<Modulus>(left) / right; } template <unsigned int Modulus> std::istream& operator<<(std::istream& ist, const IntMod<Modulus>& val) { uint64_t tmp; ist >> tmp; val = tmp; return ist; } template <unsigned int Modulus> std::ostream& operator<<(std::ostream& ost, const IntMod<Modulus>& val) { ost << val.Get_value(); return ost; } typedef IntMod<1000000007> MInt; #if 1 MInt operator"" _m(unsigned long long num) { return MInt(num); } #endif #endif #include <cstdio> #include <cstdlib> #include <cstring> #include <iostream> #include <string> #include <vector> #include <utility> #include <algorithm> #include <functional> #include <cmath> #include <stack> #include <queue> #include <set> #include <map> #include <iomanip> #include <sstream> #include <numeric> #include <list> #include <bitset> using namespace std; #define REP(i,a,n) for(int i = (a); i < (int)(n); ++i) #define REPM(i,n,a) for(int i = ((n) - 1); i >= (a); --i) #define EPS 0.0001 #define INF 0x3FFFFFFF #define INFLL 0x3FFFFFFF3FFFFFFF #define INFD 1.0e+308 #define FLOAT setprecision(16) typedef long long LL; typedef unsigned long long ULL; typedef pair<LL, LL> PP; template <class T, class U> istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; } template <class T, class U> ostream& operator<<(ostream& ost, pair<T, U>& right) { return ost << right.first << ' ' << right.second; } template <class T, class TCompatible, size_t N> void Fill(T(&dest)[N], const TCompatible& val) { fill(begin(dest), end(dest), val); } template <class T, class TCompatible, size_t M, size_t N> void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); } //sum, 累積和 // 負のときの割り算に注意 #if 1 #include <array> #include <unordered_set> #include <unordered_map> template<class T> using PriorityQ = priority_queue<T, vector<T>, greater<T> >; // コスト小を優先 #endif struct CompBySecond { bool operator()(const PP& a, const PP& b) const { return a.second < b.second || (a.second == b.second && a.first < b.first); } }; template<class T> class Array { T* ptr_m; size_t size_m; }; //#include "Union_Find.h" int N, M; string S; vector<int> L, R; int X[3000]; int W[3000]; int O[3000]; bool flg[3000]; MInt DP[3001][3001]; MInt C(int n, int r) return MInt::Combi(n, r); } int main() { cin >> N >> M >> S; REP(i, 0, M) { int l, r; cin >> l >> r; --l; L.push_back(l); R.push_back(r); } REP(i, 1, L.size()) { if (R[i - 1] >= R[i]) { L.erase(L.begin() + i); R.erase(R.begin() + i); --i; } } REP(i, 1, L.size()) { if (R[i - 1] < L[i]) { L.insert(L.begin() + i, R[i - 1]); R.insert(R.begin() + i, R[i - 1] + 1); } } M = L.size(); REP(i, 0, M) { X[i] = i == M - 1 ? R[M - 1] - L[M - 1] : L[i + 1] - L[i]; W[i] = R[i] - L[i]; O[i] = count(S.begin(), S.begin() + R[i], '1'); } DP[0][count(S.begin(), S.begin() + L[0], '1')] = 1; REP(i, 1, M + 1) { REP(j, max(0, X[i - 1] + O[i - 1] - W[i - 1]), min(N, O[i - 1]) + 1) { REP(k, 0, min(j, X[i - 1]) + 1) { DP[i][j] += DP[i - 1][j - k] * C(X[i - 1], k); } } } cout << DP[M][O[M - 1]].Get_value() << endl; return 0; }
a.cc:10:11: error: 'uint32_t' has not been declared 10 | template <uint32_t Modulus> | ^~~~~~~~ a.cc:13:17: error: 'uint32_t' does not name a type 13 | typedef uint32_t UInt; | ^~~~~~~~ a.cc:7:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 6 | #include <cassert> +++ |+#include <cstdint> 7 | #include <iostream> a.cc:15:17: error: 'uint64_t' does not name a type 15 | typedef uint64_t ULong; | ^~~~~~~~ a.cc:15:17: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:19:21: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type 19 | friend bool operator==(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); | ^~~~~~~~ a.cc:21:21: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type 21 | friend bool operator!=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); | ^~~~~~~~ a.cc:23:21: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type 23 | friend bool operator<(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); | ^~~~~~~~ a.cc:25:21: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type 25 | friend bool operator<=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); | ^~~~~~~~ a.cc:27:21: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type 27 | friend bool operator>(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); | ^~~~~~~~ a.cc:29:21: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type 29 | friend bool operator>=(const IntMod<Modulus_>& left, const IntMod<Modulus_>& right); | ^~~~~~~~ a.cc:32:9: error: 'UInt' does not name a type; did you mean 'Int'? 32 | UInt value_m; | ^~~~ | Int a.cc:36:20: error: expected ')' before 'value' 36 | IntMod(UInt value) { value_m = value % Modulus; } | ~ ^~~~~~ | ) a.cc:37:21: error: expected ')' before 'value' 37 | IntMod(ULong value) { value_m = value % Modulus; } | ~ ^~~~~~ | ) a.cc:96:20: error: 'UInt' has not been declared 96 | IntMod Pow(UInt exp) const { | ^~~~ a.cc:106:9: error: 'UInt' does not name a type; did you mean 'Int'? 106 | UInt Get_value() const { | ^~~~ | Int a.cc:110:28: error: 'UInt' has not been declared 110 | static IntMod Fact(UInt num) { | ^~~~ a.cc:122:29: error: 'UInt' has not been declared 122 | static IntMod Combi(UInt n, UInt r) { | ^~~~ a.cc:122:37: error: 'UInt' has not been declared 122 | static IntMod Combi(UInt n, UInt r) { | ^~~~ a.cc:139:17: error: 'int operator+(const int&, int)' must have an argument of class or enumerated type 139 | IntMod<Modulus> operator+(const IntMod<Modulus>& left, const IntMod<Modulus> right) { | ^~~~~~~~ a.cc:146:17: error: 'int operator-(const int&, const int&)' must have an argument of class or enumerated type 146 | IntMod<Modulus> operator-(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { | ^~~~~~~~ a.cc:153:17: error: 'int operator*(const int&, const int&)' must have an argument of class or enumerated type 153 | IntMod<Modulus> operator*(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { | ^~~~~~~~ a.cc:160:17: error: 'int operator/(const int&, const int&)' must have an argument of class or enumerated type 160 | IntMod<Modulus> operator/(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { | ^~~~~~~~ a.cc:168:6: error: 'bool operator==(const int&, const int&)' must have an argument of class or enumerated type 168 | bool operator==(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m == right.value_m; } | ^~~~~~~~ a.cc:170:6: error: 'bool operator!=(const int&, const int&)' must have an argument of class or enumerated type 170 | bool operator!=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m != right.value_m; } | ^~~~~~~~ a.cc:173:6: error: 'bool operator<(const int&, const int&)' must have an argument of class or enumerated type 173 | bool operator<(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m < right.value_m; } | ^~~~~~~~ a.cc:175:6: error: 'bool operator<=(const int&, const int&)' must have an argument of class or enumerated type 175 | bool operator<=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m <= right.value_m; } | ^~~~~~~~ a.cc:177:6: error: 'bool operator>(const int&, const int&)' must have an argument of class or enumerated type 177 | bool operator>(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m > right.value_m; } | ^~~~~~~~ a.cc:179:6: error: 'bool operator>=(const int&, const int&)' must have an argument of class or enumerated type 179 | bool operator>=(const IntMod<Modulus>& left, const IntMod<Modulus>& right) { return left.value_m >= right.value_m; } | ^~~~~~~~ a.cc: In function 'std::istream& operator<<(std::istream&, const int&)': a.cc:200:9: error: 'uint64_t' was not declared in this scope 200 | uint64_t tmp; | ^~~~~~~~ a.cc:200:9: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' a.cc:201:16: error: 'tmp' was not declared in this scope; did you mean 'tm'? 201 | ist >> tmp; | ^~~ | tm a.cc: In function 'std::ostream& operator<<(std::ostream&, const int&)': a.cc:208:20: error: request for member 'Get_value' in 'val', which is of non-class type 'const int' 208 | ost << val.Get_value(); | ^~~~~~~~~ a.cc: In function 'MInt C(int, int)': a.cc:295:9: error: named return values are no longer supported 295 | return MInt::Combi(n, r); | ^~~~~~ a.cc:337:33: error: request for member 'Get_value' in 'DP[M][O[(M - 1)]]', which is of non-class type 'MInt' {aka 'int'} 337 | cout << DP[M][O[M - 1]].Get_value() << endl; | ^~~~~~~~~
s985303855
p03856
C++
include<bits/stdc++.h> std::string S; int d1 = 5; int d2 = 7; int e1 = 5; int e2 = 6; int len = 0; bool parse(int i) { if(i >= len) return true; if(S[i] == 'd') { if(S.substr(i, d1) == "dream") { bool r1 = parse(i + d1); if(r1) { return true; } else if(S.substr(i, d2) == "dreamer") { bool r2 = parse(i + d2); if(r2) { return true; } } } } else if(S[i] == 'e') { if(S.substr(i, e1) == "erase") { bool r3 = parse(i + e1); if(r3) { return true; } else if(S.substr(i, e2) == "eraser") { bool r4 = parse(i + e2); if(r4) { return true; } } } } return false; } int main() { std::cin >> S; len = S.length(); bool res = parse(0); if(res) { std::cout << "YES" << std::endl; } else { std::cout << "NO" << std::endl; } }
a.cc:1:1: error: 'include' does not name a type 1 | include<bits/stdc++.h> | ^~~~~~~ a.cc: In function 'bool parse(int)': a.cc:12:8: error: 'S' was not declared in this scope 12 | if(S[i] == 'd') { | ^ a.cc: In function 'int main()': a.cc:41:10: error: 'cin' is not a member of 'std' 41 | std::cin >> S; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | include<bits/stdc++.h> a.cc:41:17: error: 'S' was not declared in this scope 41 | std::cin >> S; | ^ a.cc:46:14: error: 'cout' is not a member of 'std' 46 | std::cout << "YES" << std::endl; | ^~~~ a.cc:46:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:46:36: error: 'endl' is not a member of 'std' 46 | std::cout << "YES" << std::endl; | ^~~~ a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' +++ |+#include <ostream> 1 | include<bits/stdc++.h> a.cc:48:14: error: 'cout' is not a member of 'std' 48 | std::cout << "NO" << std::endl; | ^~~~ a.cc:48:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:48:35: error: 'endl' is not a member of 'std' 48 | std::cout << "NO" << std::endl; | ^~~~ a.cc:48:35: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s431840526
p03856
C++
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using static System.Math; using static System.Console; using static CS_Contest.Utils; namespace CS_Contest { using Li = List<int>; using LLi = List<List<int>>; class Program { static void Main(string[] args) { new Calc().Solve(); return; } private class Calc { public void Solve() { string S = ReadLine(); string[] tag = new string[] { "dream", "dreamer", "erase", "eraser" }; while (S.Length>5) { var l = S.Length; if (S.Substring(l-5, 5) == tag[0] || S.Substring(l-5, 5) == tag[2]) { S = S.Remove(l-5, 5); } else if (S.Substring(l-7, 7) == tag[1]) S = S.Remove(l-7, 7); else if (S.Substring(l-6, 6) == tag[3]) S = S.Remove(l-6, 6); else break; } if (tag.Contains(S)) YES(); else NO(); return; } } } public static class Utils { public static int INF = (int)(1e9); public static void WL(this object obj) => WriteLine(obj); public static void WL(this string obj) => WriteLine(obj); public static void WL<T>(this IEnumerable<T> list) => list.ToList().ForEach(x => x.WL()); public static int ReadInt() => int.Parse(ReadLine()); public static List<int> ReadInt(char s) => ReadLine().Split(s).Select(int.Parse).ToList(); public static long ReadLong() => long.Parse(ReadLine()); public static List<long> ReadLong(char s) => ReadLine().Split(s).Select(long.Parse).ToList(); public static void REP(int n,Action<int> act) { for (int i = 0; i < n; i++) { act(i); } } public static void RREP(int n,Action<int> act) { for (int i = n-1; i >=0; i--) { act(i); } } public static void REP(long n, Action<int> act) => REP((int)n, act); public static void RREP(long n, Action<int> act) => RREP((int)n, act); public static void Yes() => "Yes".WL(); public static void No() => "No".WL(); public static void YES() => "YES".WL(); public static void NO() => "NO".WL(); public static int ManhattanDistance(int x1, int y1, int x2, int y2) => Abs(x2 - x1) + Abs(y2 - y1); public class Tree { public LLi Graph; public Tree(int nodes) { Graph = new LLi(); REP(nodes, x => { Graph.Add(new Li()); }); } public void Add(int x,int y) { Graph[x].Add(y); Graph[y].Add(x); } } } }
a.cc:1:7: error: expected nested-name-specifier before 'System' 1 | using System; | ^~~~~~ a.cc:2:7: error: expected nested-name-specifier before 'System' 2 | using System.Collections.Generic; | ^~~~~~ a.cc:3:7: error: expected nested-name-specifier before 'System' 3 | using System.Linq; | ^~~~~~ a.cc:4:7: error: expected nested-name-specifier before 'System' 4 | using System.Text; | ^~~~~~ a.cc:5:7: error: expected nested-name-specifier before 'System' 5 | using System.Threading.Tasks; | ^~~~~~ a.cc:6:7: error: expected nested-name-specifier before 'static' 6 | using static System.Math; | ^~~~~~ a.cc:7:7: error: expected nested-name-specifier before 'static' 7 | using static System.Console; | ^~~~~~ a.cc:8:7: error: expected nested-name-specifier before 'static' 8 | using static CS_Contest.Utils; | ^~~~~~ a.cc:11:20: error: 'List' does not name a type 11 | using Li = List<int>; | ^~~~ a.cc:12:21: error: 'List' does not name a type 12 | using LLi = List<List<int>>; | ^~~~ a.cc:14:26: error: 'string' has not been declared 14 | static void Main(string[] args) { | ^~~~~~ a.cc:14:35: error: expected ',' or '...' before 'args' 14 | static void Main(string[] args) { | ^~~~ a.cc:19:24: error: expected ':' before 'class' 19 | private class Calc { | ^~~~~~ | : a.cc:20:31: error: expected ':' before 'void' 20 | public void Solve() { | ^~~~~ | : a.cc:40:18: error: expected ';' after class definition 40 | } | ^ | ; a.cc:41:6: error: expected ';' after class definition 41 | } | ^ | ; a.cc: In static member function 'static void CS_Contest::Program::Main(int*)': a.cc:15:35: error: expected ';' before '.' token 15 | new Calc().Solve(); | ^ a.cc: In member function 'void CS_Contest::Program::Calc::Solve()': a.cc:21:33: error: 'string' was not declared in this scope 21 | string S = ReadLine(); | ^~~~~~ a.cc:22:40: error: expected primary-expression before ']' token 22 | string[] tag = new string[] { "dream", "dreamer", "erase", "eraser" }; | ^ a.cc:24:40: error: 'S' was not declared in this scope 24 | while (S.Length>5) { | ^ a.cc:25:41: error: 'var' was not declared in this scope 25 | var l = S.Length; | ^~~ a.cc:26:57: error: 'l' was not declared in this scope 26 | if (S.Substring(l-5, 5) == tag[0] || S.Substring(l-5, 5) == tag[2]) { | ^ a.cc:26:68: error: 'tag' was not declared in this scope 26 | if (S.Substring(l-5, 5) == tag[0] || S.Substring(l-5, 5) == tag[2]) { | ^~~ a.cc:36:37: error: 'tag' was not declared in this scope 36 | if (tag.Contains(S)) YES(); | ^~~ a.cc:36:50: error: 'S' was not declared in this scope 36 | if (tag.Contains(S)) YES(); | ^ a.cc:36:54: error: 'YES' was not declared in this scope 36 | if (tag.Contains(S)) YES(); | ^~~ a.cc:37:38: error: 'NO' was not declared in this scope 37 | else NO(); | ^~ a.cc: At global scope: a.cc:45:5: error: expected unqualified-id before 'public' 45 | public static class Utils { | ^~~~~~
s816753931
p03856
C++
#include<iostream> #include<string> #include<vector> using namespace std; int main(){ string S; cin>>S; int len; bool t=true; for(int i=0 ; i<S.size() ; i+=len){ if(S.substr(i,1)=="e" || S.substr(i,1)=="d" ){ else if(S.substr(i,5)=="erase"){ if(S.substr(i+5,1)=="e")len=5; else if(S.substr(i+5,1)=="r")len=6; else len=5; } else if(S.substr(i,5)=="dream"){ if(S.substr(i+5,2)=="er"){ if(S.substr(i+7,2)=="er")len=7; else len=5; } else len=5; } else{ t=false; break; } } else{ t=false; break; } } cout<<(t?"YES\n" : "NO\n"); return 0; }
a.cc: In function 'int main()': a.cc:15:25: error: expected '}' before 'else' 15 | else if(S.substr(i,5)=="erase"){ | ^~~~ a.cc:14:62: note: to match this '{' 14 | if(S.substr(i,1)=="e" || S.substr(i,1)=="d" ){ | ^ a.cc:32:17: error: 'else' without a previous 'if' 32 | else{ | ^~~~ a.cc:34:25: error: break statement not within loop or switch 34 | break; | ^~~~~ a.cc: At global scope: a.cc:37:9: error: 'cout' does not name a type 37 | cout<<(t?"YES\n" : "NO\n"); | ^~~~ a.cc:39:9: error: expected unqualified-id before 'return' 39 | return 0; | ^~~~~~ a.cc:40:1: error: expected declaration before '}' token 40 | } | ^
s365588348
p03856
C
#include <stdio.h> #include <stdlib.h> #define N 100001 #define YES 1 #define NO 0 char *t[4] = {"dream", "dreamer", "erase", "eraser"}; char *ans[2] = {"NO", "YES"}; int match(char *); int strncmp(char *, char *, int); int strlen(char*); int main(void){ char str[N]; int r; scanf("%s", str); r=match(str); printf("%s\n", ans[r]); return 0; } int match(char *str){ int len, r=NO, flg, i; if(*str == '\0') return YES; for(i=0; i<4; i++){ len = strlen(t[i]); if(strncmp(str, t[i], len) == 0){ r = match(str+len); if(r == YES) return r; } } return NO; } int strlen(char *p){ int cnt=0; while(p[cnt++] != '\0'); cnt--; return cnt; } int strncmp(char *a, char *b, int size){ int i; for(i=0; i<size; i++){ if(a[i] > b[i]) return -1; else if(a[i] < b[i]) return 1; } return 0;
main.c:12:5: warning: conflicting types for built-in function 'strncmp'; expected 'int(const char *, const char *, long unsigned int)' [-Wbuiltin-declaration-mismatch] 12 | int strncmp(char *, char *, int); | ^~~~~~~ main.c:3:1: note: 'strncmp' is declared in header '<string.h>' 2 | #include <stdlib.h> +++ |+#include <string.h> 3 | main.c:13:5: warning: conflicting types for built-in function 'strlen'; expected 'long unsigned int(const char *)' [-Wbuiltin-declaration-mismatch] 13 | int strlen(char*); | ^~~~~~ main.c:13:5: note: 'strlen' is declared in header '<string.h>' main.c: In function 'strncmp': main.c:58:9: error: expected declaration or statement at end of input 58 | return 0; | ^~~~~~
s269066461
p03856
C++
#include<iostream> #include<cstdio> #include<cstring> using namespace std; #define M 100005 char c[M]; int main() { scanf("%s",c); char d1[7]={'d','r','e','a','m','e','r'},e1[6]={'e','r','a','s','e','r'}; int flag=1; for(int i=0;i<strlen(c);) { if(c[i]=='d') { for(int k=0;k<8;k++) { if(k<5) { if(c[i+k]!=d1[k]) { flag=0; break; } } if(k<7) { if(c[i+k]!=d1[k]) { i+=5; break;} } if(k==7) { if(c[i+k]=='a') i+=5; else i+=7; } } } else { for(int g=0;g<7;g++) { if(g<5) { if(c[i+g]!=e1[g]) { flag=0; break; } } if(g<6) { if(c[i+g]!=e1[g]) { i+=5; break;} } if(k==6) { if(c[i+g]=='a') i+=5; else i+=6; } } } } if(flag) printf("YES\n"); else printf("NO\n"); return 0; }
a.cc: In function 'int main()': a.cc:54:20: error: 'k' was not declared in this scope 54 | if(k==6) | ^
s050946858
p03856
C++
#include <stdio.h> typedef struct Item { struct Item *next; int to; } Item; #define MAX_NODE (200000) Item *train[MAX_NODE] = {0}, *road[MAX_NODE] = {0}; int parent[MAX_NODE], sizes[MAX_NODE] = {0}; int setted[MAX_NODE] = {0}, resetted[MAX_NODE] = {0}; int ans[MAX_NODE] = {0}; void add(Item* list[], int from, int to){ Item *p = (Item*)malloc(sizeof(Item)); p->next = list[from]; p->to = to; list[from] = p; } void setParent(int p, int n){ Item *it; int next; for(it=road[n]; it!=NULL; it=it->next){ next = it->to; if(parent[next]!=next || p==next){ continue; } parent[next] = p; setParent(p, next); } } void setSize(int n){ Item *it; int next; setted[n] = 1; sizes[parent[n]]++; for(it=train[n]; it!=NULL; it=it->next){ next = it->to; if(setted[next]){ continue; } setSize(next); } } void getSize(int n){ Item *it; int next; ans[n] = sizes[parent[n]]; for(it=train[n]; it!=NULL; it=it->next){ next = it->to; if(ans[next]){ continue; } getSize(next); } } void resetSize(int n){ Item *it; int next; resetted[n] = 1; sizes[parent[n]] = 0; for(it=train[n]; it!=NULL; it=it->next){ next = it->to; if(resetted[next]){ continue; } resetSize(next); } } int main(void){ int i, j; int N, K, L, from, to; scanf("%d%d%d", &N, &K, &L); for(i=0;i<N;i++){ parent[i] = i; } for(i=0;i<K;i++){ scanf("%d%d", &from, &to); from--; to--; add(road, from, to); add(road, to, from); } for(i=0;i<N;i++){ if(parent[i]==i){ setParent(i, i); } } for(i=0;i<L;i++){ scanf("%d%d", &from, &to); from--; to--; add(train, from, to); add(train, to, from); } for(i=0;i<N;i++){ if(ans[i]){ continue; } setSize(i); getSize(i); resetSize(i); } printf("%d", ans[0]); for(i=1;i<N;i++){ printf(" %d", ans[i]); } puts(""); return 0; }
a.cc: In function 'void add(Item**, int, int)': a.cc:14:26: error: 'malloc' was not declared in this scope 14 | Item *p = (Item*)malloc(sizeof(Item)); | ^~~~~~ a.cc:2:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>' 1 | #include <stdio.h> +++ |+#include <cstdlib> 2 |
s623380304
p03856
Java
//package com.regular.arc065; import java.util.Scanner; public class Main1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String input = sc.next(); String []PARTS = {"dream","dreamer","erase","eraser"}; boolean flag = true; boolean able = true; while(flag) { flag = false; for (int i = 0; i < PARTS.length; i++) { if (input.endsWith(PARTS[i])) { //input = input.substring(0, input.length() - PARTS[i].length()); input = input.substring(input.length()-6); flag= true; } } if (input.length()==0) able =true; else able = false; } if(able){ System.out.println("YES"); } else{ System.out.println("NO"); } sc.close(); } }
Main.java:6: error: class Main1 is public, should be declared in a file named Main1.java public class Main1 { ^ 1 error
s474355411
p03856
C++
#include<iostream> using namespace std; int main(){ string S; cin>> S; string t; for(int i=S.size()-1; i>=0; i--){ t=S[i]+t; if(t.size()==5){ if(t=="raser"||t=="eamer"){ ;; }else if(t!="dream"&&t!="erase"){ cout<< "NO"<< endl; return 0; }else{ t=""; } }else if(t.size()==6){ if(t=="reamer"){ ;; }else if(t!="eraser"){ cout<< "NO"<< endl; return 0; }else{ t=""; } }else if(t.size()==7){ if(t!="dreamer"){ cout<< "NO"<< endl; return 0; } t=""; } cout<< (t.empty()? "YES": "NO")<< endl; return 0; }
a.cc: In function 'int main()': a.cc:41:2: error: expected '}' at end of input 41 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s464735580
p03856
C++
#include<iostream> using namespace std; int main(){ string S; cin>> S; string t; for(int i=S.size()-1; i>=0; i--){ t=S[i]+t; if(t.size()==5){ if(t=="raser"||t=="eamer"){ ;; }else if(t!="dream"%%t!="erase"){ cout<< "NO"<< endl; return 0; }else{ t=""; } }else if(t.size()==6){ if(t=="reamer"){ ;; }else if(t!="eraser"){ cout<< "NO"<< endl; return 0; }else{ t=""; } }else if(t.size()==7){ if(t!="dreamer"){ cout<< "NO"<< endl; return 0; } t=""; } cout<< (t.empty()? "YES": "NO")<< endl; return 0; }
a.cc: In function 'int main()': a.cc:15:45: error: expected primary-expression before '%' token 15 | }else if(t!="dream"%%t!="erase"){ | ^ a.cc:41:2: error: expected '}' at end of input 41 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s073266297
p03856
C++
#include <iostream> #include <algorithm> #include <map> #include <vector> #include <cstring> using namespace std; typedef long long ll; const int N=1e6+20; const int M=30; char s[M][M]={{"dream"},{"dreamer"},{"erase"},{"eraser"}}; int len[5]; int root,num=0; int Next_n[N][M],end[N];//trie Next[u][id] u结点编号 void insert(int x) { int u=0,l=len[x]; for(int i=0;i<l;i++) { char t=s[x][i]; int id=t-'a'; if(!Next_n[u][id]) { Next_n[u][id]=++num; } u=Next_n[u][id]; } end[u]=x;//单词结束标记 } char str[N],n; bool flag=false; void dfs(int pos) { if(pos==n) { flag=true; return; } if(!flag) { int u=root; for(int i=pos+1;i<=n;i++) { int id=str[i]-'a'; u=Next_n[u][id]; if(!u) break; if(end[u]!=-1) { dfs(pos+len[end[u]]);// } } } } int main() { memset(Next_n,0,sizeof(Next_n)); memset(end,-1,sizeof(end)); root=0; scanf("%s",str+1); n=strlen(str+1); for(int i=0;i<4;i++)//dictionary { len[i]=strlen(s[i]); insert(i); } dfs(0);//暴力匹配 if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }
a.cc: In function 'void insert(int)': a.cc:28:9: error: reference to 'end' is ambiguous 28 | end[u]=x;//单词结束标记 | ^~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /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:14:18: note: 'int end [1000020]' 14 | int Next_n[N][M],end[N];//trie Next[u][id] u结点编号 | ^~~ a.cc: In function 'void dfs(int)': a.cc:51:28: error: reference to 'end' is ambiguous 51 | if(end[u]!=-1) | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:18: note: 'int end [1000020]' 14 | int Next_n[N][M],end[N];//trie Next[u][id] u结点编号 | ^~~ a.cc:53:45: error: reference to 'end' is ambiguous 53 | dfs(pos+len[end[u]]);// | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:18: note: 'int end [1000020]' 14 | int Next_n[N][M],end[N];//trie Next[u][id] u结点编号 | ^~~ a.cc: In function 'int main()': a.cc:62:16: error: reference to 'end' is ambiguous 62 | memset(end,-1,sizeof(end)); | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:18: note: 'int end [1000020]' 14 | int Next_n[N][M],end[N];//trie Next[u][id] u结点编号 | ^~~ a.cc:62:30: error: reference to 'end' is ambiguous 62 | memset(end,-1,sizeof(end)); | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:18: note: 'int end [1000020]' 14 | int Next_n[N][M],end[N];//trie Next[u][id] u结点编号 | ^~~
s192290769
p03856
C++
#include<iostream> using namespace std; int main(){ string S; cin>> S; string t; for(int i_S.size()-1; i>=0; i--){ t=S[i]+t; if(t.size()==5){ if(t=="raser"||t=="eamer"){ ;; }else if(t!="dream"%%t!="erase"){ cout<< "NO"<< endl; return 0; }else{ t=""; } }else if(t.size()==6){ if(t=="reamer"){ ;; }else if(t!="eraser"){ cout<< "NO"<< endl; return 0; }else{ t=""; } }else if(t.size()==7){ if(t!="dreamer"){ cout<< "NO"<< endl; return 0; } t=""; } cout<< (t.empty()? "YES": "NO")<< endl; return 0; }
a.cc: In function 'int main()': a.cc:10:20: error: expected ';' before '.' token 10 | for(int i_S.size()-1; i>=0; i--){ | ^ | ; a.cc:10:20: error: expected primary-expression before '.' token a.cc:10:31: error: 'i' was not declared in this scope 10 | for(int i_S.size()-1; i>=0; i--){ | ^ a.cc:10:35: error: expected ')' before ';' token 10 | for(int i_S.size()-1; i>=0; i--){ | ~ ^ | ) a.cc:10:37: error: 'i' was not declared in this scope 10 | for(int i_S.size()-1; i>=0; i--){ | ^ a.cc:41:2: error: expected '}' at end of input 41 | } | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s760012474
p03856
C++
#include <iostream> #include <algorithm> #include <map> #include <vector> #include <cstring> using namespace std; typedef long long ll; const int N=1e6+20; const int M=30; char s[M][M]={{"dream"},{"dreamer"},{"erase"},{"eraser"}}; int len[5]; int root,num=0; int Next[N][M],end[N];//trie next[u][id] u结点编号 void insert(int x) { int u=0,l=len[x]; for(int i=0;i<l;i++) { char t=s[x][i]; int id=t-'a'; if(!Next[u][id]) { Next[u][id]=++num; } u=Next[u][id]; } end[u]=x;//单词结束标记 } char str[N],n; bool flag=false; void dfs(int pos) { if(pos==n) { flag=true; return; } if(!flag) { int u=root; for(int i=pos+1;i<=n;i++) { int id=str[i]-'a'; u=Next[u][id]; if(!u) break; if(end[u]!=-1) { dfs(pos+len[end[u]]);// } } } } int main() { memset(Next,0,sizeof(Next)); memset(end,-1,sizeof(end)); root=0; scanf("%s",str+1); n=strlen(str+1); for(int i=0;i<4;i++)//dictionary { len[i]=strlen(s[i]); insert(i); } dfs(0);//暴力匹配 if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }
a.cc: In function 'void insert(int)': a.cc:28:9: error: reference to 'end' is ambiguous 28 | end[u]=x;//单词结束标记 | ^~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /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:14:16: note: 'int end [1000020]' 14 | int Next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc: In function 'void dfs(int)': a.cc:51:28: error: reference to 'end' is ambiguous 51 | if(end[u]!=-1) | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:16: note: 'int end [1000020]' 14 | int Next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc:53:45: error: reference to 'end' is ambiguous 53 | dfs(pos+len[end[u]]);// | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:16: note: 'int end [1000020]' 14 | int Next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc: In function 'int main()': a.cc:62:16: error: reference to 'end' is ambiguous 62 | memset(end,-1,sizeof(end)); | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:16: note: 'int end [1000020]' 14 | int Next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc:62:30: error: reference to 'end' is ambiguous 62 | memset(end,-1,sizeof(end)); | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:16: note: 'int end [1000020]' 14 | int Next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~
s354289971
p03856
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int main() { char S[1000000]; scanf("%s", S); int i; for(i = 0; i < strlen(S); i++) { if (S[i] == 'd') { if(S[++i] != 'r') { printf("NO"); return 0; } if(S[++i] != 'e') { printf("NO"); return 0; } if(S[++i] != 'a') { printf("NO"); return 0; } if(S[++i] != 'm') { printf("NO"); return 0; } if(S[i+1] == 'e') { if(S[i+2] == 'r') { if(S[i+3] != 'a') { i += 2; } } } } else if (S[i] == 'e') { if(S[++i] != 'r') { printf("NO"); return 0; } if(S[++i] != 'a') { printf("NO"); return 0; } if(S[++i] != 's') { printf("NO"); return 0; } if(S[++i] != 'e') { printf("NO"); return 0; } if(S[i + 1] == 'r') i++; } else { printf("NO"); return 0; } printf("YES"); return 0; }
main.c: In function 'main': main.c:62:1: error: expected declaration or statement at end of input 62 | } | ^
s221112233
p03856
C++
#include <iostream> #include <algorithm> #include <map> #include <vector> #include <cstring> using namespace std; typedef long long ll; const int N=1e6+20; const int M=30; char s[M][M]={{"dream"},{"dreamer"},{"erase"},{"eraser"}}; int len[5]; int root,num=0; int next[N][M],end[N];//trie next[u][id] u结点编号 void insert(int x) { int u=0,l=len[x]; for(int i=0;i<l;i++) { char t=s[x][i]; int id=t-'a'; if(!next[u][id]) { next[u][id]=++num; } u=next[u][id]; } end[u]=x;//单词结束标记 } char str[N],n; bool flag=false; void dfs(int pos) { if(pos==n) { flag=true; return; } if(!flag) { int u=root; for(int i=pos+1;i<=n;i++) { int id=str[i]-'a'; u=next[u][id]; if(!u) break; if(end[u]!=-1) { dfs(pos+len[end[u]]);// } } } } int main() { memset(next,0,sizeof(next)); memset(end,-1,sizeof(end)); root=0; scanf("%s",str+1); n=strlen(str+1); for(int i=0;i<4;i++)//dictionary { len[i]=strlen(s[i]); insert(i); } dfs(0);//暴力匹配 if(flag) cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }
a.cc: In function 'void insert(int)': a.cc:22:21: error: reference to 'next' is ambiguous 22 | if(!next[u][id]) | ^~~~ 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:14:5: note: 'int next [1000020][30]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~~ a.cc:24:25: error: reference to 'next' is ambiguous 24 | next[u][id]=++num; | ^~~~ /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:5: note: 'int next [1000020][30]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~~ a.cc:26:19: error: reference to 'next' is ambiguous 26 | u=next[u][id]; | ^~~~ /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:5: note: 'int next [1000020][30]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~~ a.cc:28:9: error: reference to 'end' is ambiguous 28 | end[u]=x;//单词结束标记 | ^~~ In file included from /usr/include/c++/14/string:53: /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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()) | ^~~ In file included from /usr/include/c++/14/bits/range_access.h:36: /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:14:16: note: 'int end [1000020]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc: In function 'void dfs(int)': a.cc:46:27: error: reference to 'next' is ambiguous 46 | u=next[u][id]; | ^~~~ /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:5: note: 'int next [1000020][30]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~~ a.cc:51:28: error: reference to 'end' is ambiguous 51 | if(end[u]!=-1) | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:16: note: 'int end [1000020]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc:53:45: error: reference to 'end' is ambiguous 53 | dfs(pos+len[end[u]]);// | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:14:16: note: 'int end [1000020]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~ a.cc: In function 'int main()': a.cc:61:16: error: reference to 'next' is ambiguous 61 | memset(next,0,sizeof(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:14:5: note: 'int next [1000020][30]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~~ a.cc:61:30: error: reference to 'next' is ambiguous 61 | memset(next,0,sizeof(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:14:5: note: 'int next [1000020][30]' 14 | int next[N][M],end[N];//trie next[u][id] u结点编号 | ^~~~ a.cc:62:16: error: reference to 'end' is ambiguous 62 | memset(end,-1,sizeof(end)); | ^~~ /usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ /usr/include/c++/14/bits/range_access.h:115:31: note: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 115 | template<typename _Tp> _Tp* end(valarray<_Tp>&) 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:
s974303668
p03856
C++
#include <cstdio> #include <cstring> const int maxn=100005; char s[maxn],S[5][10]; int len; bool flag=true; inline bool check(int l,int r,int k){ int lim=r-l; for(int i=0,j=l;i<=lim;i++,j++) if(S[k][i]!=s[j]) return false; return true; } int main() { scanf("%s",s); len=strlen(s); S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; for(int i=len-1;i>0;){ if(s[i]=='m'){ if(i<4||check(i-4,i,1)) {flag=false;break;} i-=4; } else if(s[i]=='e'){ if(i<4||check(i-4,i,2)) {flag=false;break;} i-=4; } else if(s[i]=='r'){ if(i>=5&&check(i-5,i,3)) i-=5; else if(i>=6&&check(i-6,i,4)) i-=6; else {flag=false;break;} } else {flag=false;break;} i--; } if(flag)printf("YES"); else printf("NO"); return 0; }
a.cc:18:14: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ^~~~~~~ a.cc:18:27: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ^~~~~~~ a.cc:18:40: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ^~~~~~~~ a.cc:18:54: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ^~~~~~~~~ a.cc: In function 'int main()': a.cc:18:13: error: incompatible types in assignment of 'int' to 'char [10]' 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ~~~~^~~~~~~~ a.cc:18:26: error: incompatible types in assignment of 'int' to 'char [10]' 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ~~~~^~~~~~~~ a.cc:18:39: error: incompatible types in assignment of 'int' to 'char [10]' 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ~~~~^~~~~~~~~ a.cc:18:53: error: incompatible types in assignment of 'int' to 'char [10]' 18 | S[1]='dream';S[2]='erase';S[3]='eraser';S[4]='dreamer'; | ~~~~^~~~~~~~~~
s370333085
p03856
C++
#include <string> #include <vector> #include <cmath> #include <list> #include <set> #include <algorithm> #include <map> #include <iostream> #include <sstream> #include <queue> #include <iomanip> using namespace std; bool dfs(const char* str) { if(strlen(str) == 0) { return true; } else if(str[0] != 'd' && str[0] != 'e') { return false; } else if(strncmp(str, "dreamer", sizeof("dreamer")-1) == 0) { return dfs(str+5) || dfs(str+7); } else if(strncmp(str, "dream", sizeof("dream")-1) == 0) { return dfs(str+5); } else if(strncmp(str, "eraser", sizeof("eraser")-1) == 0) { return dfs(str+5) || dfs(str+6); } else if(strncmp(str, "erase", sizeof("erase")-1) == 0) { return dfs(str+5); } return false; } int main() { string s; cin >> s; const char *str = s.c_str(); if(strlen(str) > 0 && dfs(str)) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
a.cc: In function 'bool dfs(const char*)': a.cc:19:12: error: 'strlen' was not declared in this scope 19 | if(strlen(str) == 0) | ^~~~~~ a.cc:13:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 12 | #include <iomanip> +++ |+#include <cstring> 13 | a.cc:29:17: error: 'strncmp' was not declared in this scope 29 | else if(strncmp(str, "dreamer", sizeof("dreamer")-1) == 0) | ^~~~~~~ a.cc:29:17: note: 'strncmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' a.cc: In function 'int main()': a.cc:58:12: error: 'strlen' was not declared in this scope 58 | if(strlen(str) > 0 && dfs(str)) | ^~~~~~ a.cc:58:12: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s472285093
p03856
C++
#include <algorithm> #include <complex> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) using namespace std; typedef long long int lli; typedef pair<lli, lli> P; lli MOD = 1000000007; bool flag = true; string ok(string s) { if (s == "dream" || s == "dreamer" || s == "erase" || s == "eraser") { return ""; } if (s.size() <= 7) { flag = false; return "NO"; } else { string a = ""; rep(i, 5) { a += s[s.size() - 5 + i]; } if (a == "dream" || a == "erase") { string r = ""; rep(i, s.size() - 5) { r += s[i]; } return r; } a = ""; rep(i, 6) { a += s[s.size() - 6 + i]; } if (a == "eraser") { string r = ""; rep(i, s.size() - 6) { r += s[i]; } return r; } a = ""; rep(i, 7) { a += s[s.size() - 7 + i]; } if (a == "dreamer") { string r = ""; rep(i, s.size() - 7) { r += s[i]; } return r; } } return s; }; int main() { string s; cin >> s; queue<string> que; que.push(s); s = ok(s); //cout << s << endl; int cnt = 0; while (s != "NO" && s != "") { //cout << s << endl; s = ok(s); cnt++; if (cnt >= 100000) { s = "NO"; break; } } cout << ((s == "") ? "YES" : "NO") << endl; } #include <algorithm> #include <complex> #include <iostream> #include <map> #include <queue> #include <set> #include <string> #include <vector> #define rep(i, n) for (int i = 0; i < (n); i++) #define rrep(i, n) for (int i = (n)-1; i >= 0; i--) using namespace std; typedef long long int lli; typedef pair<lli, lli> P; lli MOD = 1000000007; bool flag = true; string ok(string s) { if (s == "dream" || s == "dreamer" || s == "erase" || s == "eraser") { return ""; } if (s.size() <= 7) { flag = false; return "NO"; } else { string a = ""; rep(i, 5) { a += s[s.size() - 5 + i]; } if (a == "dream" || a == "erase") { string r = ""; rep(i, s.size() - 5) { r += s[i]; } return r; } a = ""; rep(i, 6) { a += s[s.size() - 6 + i]; } if (a == "eraser") { string r = ""; rep(i, s.size() - 6) { r += s[i]; } return r; } a = ""; rep(i, 7) { a += s[s.size() - 7 + i]; } if (a == "dreamer") { string r = ""; rep(i, s.size() - 7) { r += s[i]; } return r; } } return s; }; int main() { string s; cin >> s; queue<string> que; que.push(s); s = ok(s); //cout << s << endl; int cnt = 0; while (s != "NO" && s != "") { //cout << s << endl; s = ok(s); cnt++; if (cnt >= 100000) { s = "NO"; break; } } cout << ((s == "") ? "YES" : "NO") << endl; }
a.cc:103:5: error: redefinition of 'lli MOD' 103 | lli MOD = 1000000007; | ^~~ a.cc:14:5: note: 'lli MOD' previously defined here 14 | lli MOD = 1000000007; | ^~~ a.cc:104:6: error: redefinition of 'bool flag' 104 | bool flag = true; | ^~~~ a.cc:15:6: note: 'bool flag' previously defined here 15 | bool flag = true; | ^~~~ a.cc:105:8: error: redefinition of 'std::string ok(std::string)' 105 | string ok(string s) | ^~ a.cc:16:8: note: 'std::string ok(std::string)' previously defined here 16 | string ok(string s) | ^~ a.cc:159:5: error: redefinition of 'int main()' 159 | int main() | ^~~~ a.cc:70:5: note: 'int main()' previously defined here 70 | int main() | ^~~~
s938790824
p03856
C++
#include <cstdio> #include <cstring> char c[120000]; int f[120000]; int i,l; int main() { gets(c+1); l=strlen(c+1); f[0]=1; for (i=1;i<=l;i++) if (((f[i-5]) && (c[i-4]=='d') && (c[i-3]=='r') && (c[i-2]=='e') && (c[i-1]=='a') && (c[i]=='m')) || ((f[i-7]) && (c[i-6]=='d') && (c[i-5]=='r') && (c[i-4]=='e') && (c[i-3]=='a') && (c[i-2]=='m') && (c[i-1]=='e') && (c[i]=='r')) || ((f[i-5]) && (c[i-4]=='e') && (c[i-3]=='r') && (c[i-2]=='a') && (c[i-1]=='s') && (c[i]=='e')) || ((f[i-6]) && (c[i-5]=='e') && (c[i-4]=='r') && (c[i-3]=='a') && (c[i-2]=='s') && (c[i-1]=='e') && (c[i]=='r'))) f[i]=1; if (f[l]) puts("YES"); else puts("NO"); return 0; }
a.cc: In function 'int main()': a.cc:10:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 10 | gets(c+1); | ^~~~ | getw
s861393632
p03856
C++
#include <iostream> #include <string> using namespace std; int main(int argc, char* argv[]) { string S; cin>>S; char *p=(char*)S.c_str(); while (*p!='\0'){ if (!memcmp(p,"dreamer",6)){ p+=6; continue; }else if (!memcmp(p,"eraser",6)){ p+=6; continue; }else if (!memcmp(p,"dream",5)){ p+=5; continue; }else if (!memcmp(p,"erase",5)){ p+=5; continue; } cout<<"NO"<<endl; return 0; } cout<<"YES"<<endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:10:22: error: 'memcmp' was not declared in this scope 10 | if (!memcmp(p,"dreamer",6)){ | ^~~~~~ a.cc:2:1: note: 'memcmp' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s949473863
p03856
C++
import java.util.Arrays; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void run() { String s = sc.next(); int n = s.length(); boolean[] f = new boolean[n + 1]; String[] g = { "dream", "dreamer ", "erase", "eraser" }; f[0] = true; for (int i = 0; i < n; i++) { if (f[i]) { if (i + 5 <= n) { String cut = s.substring(i, i + 5); for (int j = 0; j < 4; j++) { if (cut.equals(g[j])) f[i + 5] = true; } } if (i + 6 <= n) { String cut = s.substring(i, i + 6); for (int j = 0; j < 4; j++) { if (cut.equals(g[j])) f[i + 6] = true; } } if (i + 7 <= n) { String cut = s.substring(i, i + 7); for (int j = 0; j < 4; j++) { if (cut.equals(g[j])) f[i + 7] = true; } } } } System.out.println(f[n] ? "YES" : "NO"); } public static void main(String[] args) { new Main().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(int[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } boolean inner(int h, int w, int limH, int limW) { return 0 <= h && h < limH && 0 <= w && w < limW; } void swap(int[] x, int a, int b) { int tmp = x[a]; x[a] = x[b]; x[b] = tmp; } // find minimum i (k <= a[i]) int lower_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k <= a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } // find minimum i (k < a[i]) int upper_bound(int a[], int k) { int l = -1; int r = a.length; while (r - l > 1) { int mid = (l + r) / 2; if (k < a[mid]) r = mid; else l = mid; } // r = l + 1 return r; } int gcd(int a, int b) { return a % b == 0 ? b : gcd(b, a % b); } int lcm(int a, int b) { return a * b / gcd(a, b); } boolean palindrome(String s) { for (int i = 0; i < s.length() / 2; i++) { if (s.charAt(i) != s.charAt(s.length() - 1 - i)) { return false; } } return true; } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } long nextLong() { return Long.parseLong(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } int[] nextIntArray(int n) { int[] in = new int[n]; for (int i = 0; i < n; i++) { in[i] = nextInt(); } return in; } int[][] nextInt2dArray(int n, int m) { int[][] in = new int[n][m]; for (int i = 0; i < n; i++) { in[i] = nextIntArray(m); } return in; } double[] nextDoubleArray(int n) { double[] in = new double[n]; for (int i = 0; i < n; i++) { in[i] = nextDouble(); } return in; } long[] nextLongArray(int n) { long[] in = new long[n]; for (int i = 0; i < n; i++) { in[i] = nextLong(); } return in; } char[][] nextCharField(int n, int m) { char[][] in = new char[n][m]; for (int i = 0; i < n; i++) { String s = sc.next(); for (int j = 0; j < m; j++) { in[i][j] = s.charAt(j); } } return in; } } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Arrays; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.Scanner; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:5:1: error: expected unqualified-id before 'public' 5 | public class Main { | ^~~~~~
s989897625
p03856
C++
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<set> #include<map> #include<assert.h> using namespace std; #define sz(x) (int)(x.size()) #define fi(a, b) for(int i=a;i<b;++i) #define fj(a, b) for(int j=a;j<b;++j) #define mp make_pair #define pb push_back //////////////////// int const N = 1e5 +41; char s[N]; vector<int> q; int can[N], n; string str[4] = {"dream", "dreamer", "erase", "eraser"}; void read(){ scanf("%s",&s); } bool canPos(string a, int p){ if(sz(a) + p > n){ return false; } fi(0, sz(a)){ if(a[i] != s[i+p]){ return false; } } return true; } void solve(){ n = strlen(s); q.pb(0); can[0] = 1; while(sz(q)){ int pos = q.back(); if(pos == n){ printf("YES\n"); exit(0); } q.pop_back(); fi(0, 4){ if(canPos(str[i], pos) && !can[pos+sz(str[i])]){ q.pb(pos + sz(str[i])); can[pos + sz(str[i])] = 1; } } } if(can[n]){ assert(false); }else{ printf("NO\n"); } } void prepare(){ #ifdef _DEBUG freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif } int main(){ prepare(); read(); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:42:13: error: 'strlen' was not declared in this scope 42 | n = strlen(s); | ^~~~~~ a.cc:8:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include<assert.h> +++ |+#include <cstring> 8 | using namespace std;
s134959957
p03856
C++
#include <iostream> #include <string> using namespace std; const string ss[] = {"dream", "dreamer", "erase", "eraser"}; bool dp[100005]; int main() { string S; cin >> S; memset(dp, 0, sizeof(dp)); dp[0] = true; for (int pos = 0; pos < S.size(); pos++) { if (!dp[pos]) continue; for (int i = 0; i < 4; i++) { if (S.compare(pos, ss[i].size(), ss[i]) == 0) { dp[pos + ss[i].size()] = true; } } } if (dp[S.size()]) { cout << "YES" << endl; } else { cout << "NO" << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:9: error: 'memset' was not declared in this scope 12 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s761869479
p03856
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; char str[123456]; int length; bool f(int i) { if (length == i)return true; if (length - i < 5)return false; if (length - i >= 7 && str[i] == 'd' && str[i + 1] == 'r' &&str[i + 2] == 'e' &&str[i + 3] == 'a' &&str[i + 4] == 'm' &&str[i + 5] == 'e' &&str[i + 6] == 'r') { if (f(i + 7))return true; } if (length - i >= 6 && str[i] == 'e' && str[i + 1] == 'r' &&str[i + 2] == 'a' &&str[i + 3] == 's' &&str[i + 4] == 'e' &&str[i + 5] == 'r') { return f(i + 6); } if (str[i] == 'd' && str[i + 1] == 'r' &&str[i + 2] == 'e' &&str[i + 3] == 'a' &&str[i + 4] == 'm') { return f(i + 5); } if (length - i >= 6 && str[i] == 'e' && str[i + 1] == 'r' &&str[i + 2] == 'a' &&str[i + 3] == 's' &&str[i + 4] == 'e') { return f(i + 5); } return false; } int main(void) { scanf("%s", str); length = strlen(str); if (f(0)) { printf("YES"); } else { printf("NO"); } return 0; }
a.cc: In function 'int main()': a.cc:51:18: error: 'strlen' was not declared in this scope 51 | length = strlen(str); | ^~~~~~ a.cc:20:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 19 | #include <queue> +++ |+#include <cstring> 20 | using namespace std;
s896652916
p03856
C++
#include<bits/stdc++.h> using namespace std; string X[] = { "dream","dreamer","erase","eraser" }; bool check( string &S ) { if( S == "" ) { return true; } for( size_t i = 0; i < 4; i++ ) { if( S.substr( 0, X[i].size() ) == X[i] && check( S.substr( X[i].size() ) ) ) { return true; } } return false; } int main() { string S; cin >> S; cout << (check( S ) ? "YES" : "NO") << endl; }
a.cc: In function 'bool check(std::string&)': a.cc:12:74: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>' 12 | if( S.substr( 0, X[i].size() ) == X[i] && check( S.substr( X[i].size() ) ) ) { | ~~~~~~~~^~~~~~~~~~~~~~~ a.cc:7:21: note: initializing argument 1 of 'bool check(std::string&)' 7 | bool check( string &S ) { | ~~~~~~~~^
s664302599
p03856
C++
#define _USE_MATH_DEFINES #include <algorithm> #include <cstdio> #include <functional> #include <iostream> #include <cfloat> #include <climits> #include <cstdlib> #include <cstring> #include <cmath> #include <map> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <time.h> #include <vector> #include <random> #include "testlib.h" using namespace std; #define rep(i, N) for (int i = 0; i < N; i++) #define pb push_back typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> i_i; typedef pair<ll, int> ll_i; typedef pair<double, int> d_i; typedef pair<ll, ll> ll_ll; typedef pair<double, double> d_d; struct edge { int u, v; ll w; }; ll MOD = 1000000007; ll _MOD = 1000000009; int INF = INT_MAX / 2; double EPS = 1e-10; int main() { string s; cin >> s; int N = s.length(); vector<bool> dp(N + 1); dp[0] = true; for (int i = 0; i <= N; i++) { if (!dp[i]) continue; if (i + 5 <= N && s.substr(i, 5) == "dream") dp[i + 5] = true; if (i + 7 <= N && s.substr(i, 7) == "dreamer") dp[i + 7] = true; if (i + 5 <= N && s.substr(i, 5) == "erase") dp[i + 5] = true; if (i + 6 <= N && s.substr(i, 6) == "eraser") dp[i + 6] = true; } cout << (dp[N] ? "YES" : "NO") << endl; }
a.cc:20:10: fatal error: testlib.h: No such file or directory 20 | #include "testlib.h" | ^~~~~~~~~~~ compilation terminated.
s380808293
p03857
C++
//////////////////////////////////////////////////////////////////////////////// // Give me AC!!! // //////////////////////////////////////////////////////////////////////////////// #include <iostream> #include <random> #include <cmath> #include <limits> #include <iostream> #include <bits/stdc++.h> #include <boost/multiprecision/cpp_int.hpp> using namespace std; namespace mp = boost::multiprecision; using namespace mp; using ull = __int128; using ll = long long; using cll = cpp_int; using Graph = vector<vector<int>>; #define REP(i,n) for(ll i=0;i<(ll)(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++) #define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--) #define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい #define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく #define MAX(x) *max_element(ALL(x)) //最大値を求める #define MIN(x) *min_element(ALL(x)) //最小値を求める #define PQ priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>> #define INF 1000000000000 //10^12:極めて大きい値,∞ #define PB push_back //vectorヘの挿入 #define MP make_pair //pairのコンストラクタ #define F first //pairの一つ目の要素 #define S second //pairの二つ目の要素 #define coutY cout<<"YES"<<endl #define couty cout<<"Yes"<<endl #define coutN cout<<"NO"<<endl #define coutn cout<<"No"<<endl #define coutdouble(a,b) cout << fixed << setprecision(a) << double(b) ; #define vi(a,b) vector<int> a(b) #define vl(a,b) vector<ll> a(b) #define vs(a,b) vector<string> a(b) #define vll(a,b,c) vector<vector<ll>> a(b, vector<ll>(c)); #define intque(a) queue<int> a; #define llque(a) queue<ll> a; #define intque2(a) priority_queue<int, vector<int>, greater<int>> a; #define llque2(a) priority_queue<ll, vector<ll>, greater<ll>> a; #define pushback(a,b) a.push_back(b) #define mapii(M1) map<int, int> M1; #define cou(v,x) count(v.begin(), v.end(), x) #define mapll(M1) map<ll,ll> M1; #define mapls(M1) map<ll, string> M1; #define mapsl(M1) map<string, ll> M1; #define twolook(a,l,r,x) lower_bound(a+l, a+r, x) - a #define sor(a) sort(a.begin(), a.end()) #define rever(a) reverse(a.begin(),a.end()) #define rep(i,a) for(ll i=0;i<a;i++) #define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i] #define vcout(n) for(ll i=0;i<ll(n.size());i++) cout<<n[i] #define vcin2(n) rep(i,ll(n.size())) rep(j,ll(n.at(0).size())) cin>>n[i][j] //const ll mod = 998244353; //const ll MOD = 998244353; const ll MOD = 1000000007; const ll mod = 1000000007; constexpr ll MAX = 5000000; //const ll _max = 9223372036854775807; const ll _max = 1223372036854775807; ll fac[MAX],finv[MAX],inv[MAX]; // テーブルを作る前処理 void COMinit() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++){ fac[i] = fac[i - 1] * i % MOD; inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD; finv[i] = finv[i - 1] * inv[i] % MOD; } } // 二項係数計算 long long COM(int n, int k){ if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD; } template< int mod > struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int) (1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return ModInt(u); } ModInt pow(int64_t n) const { ModInt ret(1), mul(x); while(n > 0) { if(n & 1) ret *= mul; mul *= mul; n >>= 1; } return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); } static int get_mod() { return mod; } }; using mint = ModInt< mod >; int modPow(long long a, long long n, long long p) { if (n == 0) return 1; // 0乗にも対応する場合 if (n == 1) return a % p; if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p; long long t = modPow(a, n / 2, p); return (t * t) % p; } ll clocks(ll a,ll b,ll c){ return a*3600+b*60+c; } ll divup(ll b,ll d){ if(b%d==0){ return b/d; } else{ return b/d+1; } } struct UnionFind { vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2 UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化 for(int i = 0; i < N; i++) par[i] = i; } int root(int x) { // データxが属する木の根を再帰で得る:root(x) = {xの木の根} if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { // xとyの木を併合 int rx = root(x); //xの根をrx int ry = root(y); //yの根をry if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時:xの根rxをyの根ryにつける } bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す int rx = root(x); int ry = root(y); return rx == ry; } }; struct Edge { int to; // 辺の行き先 int weight; // 辺の重み Edge(int t, int w) : to(t), weight(w) { } }; using Graphw = vector<vector<Edge>>; ll zero(ll a){ return max(ll(0),a); } template< typename T > struct FormalPowerSeries : vector< T > { using vector< T >::vector; using P = FormalPowerSeries; using MULT = function< P(P, P) >; static MULT &get_mult() { static MULT mult = nullptr; return mult; } static void set_fft(MULT f) { get_mult() = f; } void shrink() { while(this->size() && this->back() == T(0)) this->pop_back(); } P operator+(const P &r) const { return P(*this) += r; } P operator+(const T &v) const { return P(*this) += v; } P operator-(const P &r) const { return P(*this) -= r; } P operator-(const T &v) const { return P(*this) -= v; } P operator*(const P &r) const { return P(*this) *= r; } P operator*(const T &v) const { return P(*this) *= v; } P operator/(const P &r) const { return P(*this) /= r; } P operator%(const P &r) const { return P(*this) %= r; } P &operator+=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < r.size(); i++) (*this)[i] += r[i]; return *this; } P &operator+=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] += r; return *this; } P &operator-=(const P &r) { if(r.size() > this->size()) this->resize(r.size()); for(int i = 0; i < r.size(); i++) (*this)[i] -= r[i]; shrink(); return *this; } P &operator-=(const T &r) { if(this->empty()) this->resize(1); (*this)[0] -= r; shrink(); return *this; } P &operator*=(const T &v) { const int n = (int) this->size(); for(int k = 0; k < n; k++) (*this)[k] *= v; return *this; } P &operator*=(const P &r) { if(this->empty() || r.empty()) { this->clear(); return *this; } assert(get_mult() != nullptr); return *this = get_mult()(*this, r); } P &operator%=(const P &r) { return *this -= *this / r * r; } P operator-() const { P ret(this->size()); for(int i = 0; i < this->size(); i++) ret[i] = -(*this)[i]; return ret; } P &operator/=(const P &r) { if(this->size() < r.size()) { this->clear(); return *this; } int n = this->size() - r.size() + 1; return *this = (rev().pre(n) * r.rev().inv(n)).pre(n).rev(n); } P pre(int sz) const { return P(begin(*this), begin(*this) + min((int) this->size(), sz)); } P operator>>(int sz) const { if(this->size() <= sz) return {}; P ret(*this); ret.erase(ret.begin(), ret.begin() + sz); return ret; } P operator<<(int sz) const { P ret(*this); ret.insert(ret.begin(), sz, T(0)); return ret; } P rev(int deg = -1) const { P ret(*this); if(deg != -1) ret.resize(deg, T(0)); reverse(begin(ret), end(ret)); return ret; } P diff() const { const int n = (int) this->size(); P ret(max(0, n - 1)); for(int i = 1; i < n; i++) ret[i - 1] = (*this)[i] * T(i); return ret; } P integral() const { const int n = (int) this->size(); P ret(n + 1); ret[0] = T(0); for(int i = 0; i < n; i++) ret[i + 1] = (*this)[i] / T(i + 1); return ret; } // F(0) must not be 0 P inv(int deg = -1) const { assert(((*this)[0]) != T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1) / (*this)[0]}); for(int i = 1; i < deg; i <<= 1) { ret = (ret + ret - ret * ret * pre(i << 1)).pre(i << 1); } return ret.pre(deg); } // F(0) must be 1 P log(int deg = -1) const { assert((*this)[0] == 1); const int n = (int) this->size(); if(deg == -1) deg = n; return (this->diff() * this->inv(deg)).pre(deg - 1).integral(); } P sqrt(int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; if((*this)[0] == T(0)) { for(int i = 1; i < n; i++) { if((*this)[i] != T(0)) { if(i & 1) return {}; if(deg - i / 2 <= 0) break; auto ret = (*this >> i).sqrt(deg - i / 2) << (i / 2); if(ret.size() < deg) ret.resize(deg, T(0)); return ret; } } return P(deg, 0); } P ret({T(1)}); T inv2 = T(1) / T(2); for(int i = 1; i < deg; i <<= 1) { ret = (ret + pre(i << 1) * ret.inv(i << 1)) * inv2; } return ret.pre(deg); } // F(0) must be 0 P exp(int deg = -1) const { assert((*this)[0] == T(0)); const int n = (int) this->size(); if(deg == -1) deg = n; P ret({T(1)}); for(int i = 1; i < deg; i <<= 1) { ret = (ret * (pre(i << 1) + T(1) - ret.log(i << 1))).pre(i << 1); } return ret.pre(deg); } P pow(int64_t k, int deg = -1) const { const int n = (int) this->size(); if(deg == -1) deg = n; for(int i = 0; i < n; i++) { if((*this)[i] != T(0)) { T rev = T(1) / (*this)[i]; P C(*this * rev); P D(n - i); for(int j = i; j < n; j++) D[j - i] = C[j]; D = (D.log() * k).exp() * (*this)[i].pow(k); P E(deg); if(i * k > deg) return E; auto S = i * k; for(int j = 0; j + S < deg && j < D.size(); j++) E[j + S] = D[j]; return E; } } return *this; } T eval(T x) const { T r = 0, w = 1; for(auto &v : *this) { r += w * v; w *= x; } return r; } }; //aはbの何乗以下かを満たす数の内最大の物,(a,10)はaの桁数 ll expless(ll a,ll b){ ll k=0; ll o=1; while(a>=o){ k++; o=o*b; } return k; } //aをb進法で表す ll base(ll a,ll b){ ll ans=0; ll k; while(a>0){ k=a%b; ans+=k; a=a/b; } return ans; } //b進法のaを10進法に直す ll tenbase(ll a,ll b){ ll c=expless(a,10); ll ans=0; ll k=1; for(int i=0;i<c;i++){ ans+=(a%10)*k; k=k*b; a=a/10; } return ans; } vector<pair<long long, long long> > prime_factorize(long long N) { vector<pair<long long, long long> > res; for (long long a = 2; a * a <= N; ++a) { if (N % a != 0) continue; long long ex = 0; // 指数 // 割れる限り割り続ける while (N % a == 0) { ++ex; N /= a; } // その結果を push res.push_back({a, ex}); } // 最後に残った数について if (N != 1) res.push_back({N, 1}); return res; } ll atll(ll a,ll b){ b++; ll c=expless(a,10); ll d=c-b; ll f=1; for(int i=0;i<d;i++){ f=f*10; } a=(a/f); return a%10; } //aがbで何回割り切るか ll exp(ll a,ll b){ ll ans=0; while(a%b==0){ a=a/b; ans++; } return ans; } const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, 1, 0, -1}; const int X[6]={1,1,0,-1,-1,0}; const int Y[6]={0,1,1,0,-1,-1}; template<typename T> vector<T> smallest_prime_factors(T n) { vector<T> spf(n + 1); for (int i = 0; i <= n; i++) spf[i] = i; for (T i = 2; i * i <= n; i++) { // 素数だったら if (spf[i] == i) { for (T j = i * i; j <= n; j += i) { // iを持つ整数かつまだ素数が決まっていないなら if (spf[j] == j) { spf[j] = i; } } } } return spf; } vector<pair<ll,ll>> factolization(ll x, vector<ll> &spf) { vector<pair<ll,ll>> ret; ll p; ll z; while (x != 1) { p=(spf[x]); z=0; while(x%p==0){ z++; x /= p; } ret.push_back({p, z}); } return ret; } vector<bool> is; vector<long long int> prime_(ll n){ is.resize(n+1, true); is[0] = false; is[1] = false; vector<long long int> primes; for (int i=2; i<=n; i++) { if (is[i] == true){ primes.push_back(i); for (int j=i*2; j<=n; j+=i){ is[j] = false; } } } return primes; } vector<ll> dijkstra(ll f,ll n,vector<vector<vector<ll>>>& edge){ //最短経路としてどの頂点が確定済みかをチェックする配列 vector<ll> confirm(n,false); //それぞれの頂点への最短距離を保存する配列 //始点は0,始点以外はINFで最短距離を初期化する vector<ll> mincost(n,INF);mincost[f]=0; //確定済みの頂点の集合から伸びる辺を伝ってたどり着く頂点の始点からの距離を短い順に保存するPriority queue PQ mincand;mincand.push({mincost[f],f}); //mincandの要素がゼロの時、最短距離を更新できる頂点がないことを示す while(!mincand.empty()){ //最短距離でたどり着くと思われる頂点を取り出す vector<ll> next=mincand.top();mincand.pop(); //すでにその頂点への最短距離が確定済みの場合は飛ばす if(confirm[next[1]]) continue; //確定済みではない場合は確定済みにする confirm[next[1]]=true; //その確定済みの頂点から伸びる辺の情報をとってくる(参照の方が速い)、lは辺の本数 vector<vector<ll>>& v=edge[next[1]];ll l=SIZE(v); REP(i,l){ //辺の先が確定済みなら更新する必要がない((✳︎2)があれば十分なので(✳︎1)は実はいらない) if(confirm[v[i][0]]) continue; //(✳︎1) //辺の先のmincost以上の場合は更新する必要がない(辺の先が確定済みの時は満たす) if(mincost[v[i][0]]<=next[0]+v[i][1]) continue; //(✳︎2) //更新 mincost[v[i][0]]=next[0]+v[i][1]; //更新した場合はその頂点が(確定済みでない頂点の中で)最短距離になる可能性があるのでmincandに挿入 mincand.push({mincost[v[i][0]],v[i][0]}); } } return mincost; } int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout << fixed << setprecision(10); int n, q,r; cin >> n >> q>>r; UnionFind tree(n); UnionFind tree2(n); for(int i = 0; i < q; i++) { int x, y; cin >> x >> y; x--;y--; // if(tree.root(x)!=tree.root(y)){ tree.unite(x, y); // xの木とyの木を併合する // } } for(int i = 0; i < r; i++) { int x, y; cin >> x >> y; x--;y--; // if(tree2.root(x)!=tree2.root(y)){ tree2.unite(x, y); // xの木とyの木を併合する // } } vector<pair<ll,ll>> k(n); vector<pair<ll,ll>> data(n); for(int i=0;i<n;i++){ k.at(i).first=tree.root(i); k.at(i).second=tree2.root(i); push_back(data.at(<(k.at(i).first),(k.at(i).second)>); data.at(<(k.at(i).first),(k.at(i).second)>)++; } for(int i=0;i<n;i++){ cout<< data.at(<(k.at(i).first),(k.at(i).second)>); if(i!=n-1){ cout<<" "; } } cout<<endl; }
a.cc:10:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory 10 | #include <boost/multiprecision/cpp_int.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s970435664
p03857
C++
#include <bits/stdc++.h> using namespace std; struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; int main() { int N,K,L;cin>>N>>K>>L; UnionFind A(N); UnionFind B(N); for(int I=0;I<K;I++){ int X,Y;cin>>X>>Y;X--;Y--; A.merge(X,Y); } for(int I=0;I<L;I++){ int X,Y;cin>>X>>Y;X--;Y--; B.marge(X,Y); } for(int X=0;X<N;X++){ int M=0; for(int Y=0;Y<N;Y++){ if(X==Y)continue; if(A.issame(X,Y)&&B.issame(X,Y))M++; } cout<<M<<endl; } }
a.cc: In function 'int main()': a.cc:41:7: error: 'struct UnionFind' has no member named 'marge'; did you mean 'merge'? 41 | B.marge(X,Y); | ^~~~~ | merge
s900063549
p03857
C++
#include <iostream> #include<map> using namespace std; const int maxn = 2e6 + 10; typedef pair<int, int> P; int fa[maxn], ma[maxn],ans[maxn]; void init(int n) { for (int i = 0; i <= n; ++i) { fa[i] = i; ma[i] = i; } } int find(int* fa, int x)//找到根节点 { if (fa[x] == x) { return fa[x]; } return fa[x] = find(fa, fa[x]); } void unin(int a, int b, int* fa) { a = find(fa, a);//找到a根节点 b = find(fa, b);//找到b跟节点 fa[a] = b;//a为b的父节点 } int main() { int n, k, l; while (scanf_s("%d%d%d", &n, &k, &l) != EOF) { init(n); for (int i = 0; i < k; ++i) { int a, b; scanf_s("%d%d", &a, &b); unin(a, b, ma); } for (int i = 0; i < l; ++i) { int a, b; scanf_s("%d%d", &a, &b); { unin(a, b, fa); } } for (int i = 1; i <= n; ++i) { if (fa[i] == ma[i]) ans[i]++; } for (int i = 1; i <= n; ++i) { if (i != n) cout << ans[i] + 1 << " "; else cout << ans[i] + 1<<endl; } } return 0; }
a.cc: In function 'int main()': a.cc:32:16: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 32 | while (scanf_s("%d%d%d", &n, &k, &l) != EOF) | ^~~~~~~ | scanf
s984894137
p03857
C++
#include<bits./stdc++.h> using namespace std; struct hi{ int a,b; } cnt[200005]; int id[200005],id2[2000005],p[200005] ,n,k,l,i,j,m; int find(int x){ while (x!=id[x]){ id[x]=id[id[x]]; x=id[x]; } return x; } int find2(int x){ while (x!=id2[x]){ id2[x]=id2[id2[x]]; x=id2[x]; } return x; } void connect(int x,int y){ x=find(x);y=find(y); if (x!=y) id[x]=y; } void connect2(int x,int y){ x=find2(x);y=find2(y); if (x!=y) id2[x]=y; } bool cmp(hi a,hi b){ return a.a<b.a; } int main(){ scanf("%d%d%d",&n,&k,&l); for (i=1;i<=n;i++){ id[i]=i;id2[i]=i; } for (i=1;i<=k;i++){ scanf("%d%d",&j,&m); connect(j,m); } for (i=1;i<=l;i++){ scanf("%d%d",&j,&m); connect2(j,m); } for (i=1;i<=n;i++){ id[i]=find(id[i]);id2[i]=find2(id2[i]); cnt[i].a=id[i]*200001+id2[i];cnt[i].b=i; } sort(cnt+1,cnt+n+1,cmp); j=0;k=0; for (i=1;i<=n;i++){ if (cnt[i].a!=cnt[i-1].a) j++; p[j]++; id[cnt[i].b]=j; } for (i=1;i<n;i++) printf("%d ",p[id[i]]); printf("%d\n",p[id[n]]); }
a.cc:1:9: fatal error: bits./stdc++.h: No such file or directory 1 | #include<bits./stdc++.h> | ^~~~~~~~~~~~~~~~ compilation terminated.
s696469442
p03857
C++
#include<cstdio> #include<vector> #include<queue> #include<string> #include<algorithm> #include<functional> #include<cstring> using namespace std; /**** Type Define ****/ typedef long long ll; typedef pair<ll, ll> P; /**** Const List ****/ const ll INF = ((ll)1 << 31) - 1; const ll DINF = (ll)1e20; const ll UNION_FIND_MAX = 100000; const ll SEGMENT_TREE_MAX = (1 << 18) - 1; const ll MAX_FLOW_MAX_V = 10000; const ll MIN_COST_FLOW_MAX_V = 10000; const ll BIPARTITE_MATCHING_MAX_V = 10000; const ll DIJKSTRA_MAX_V = 1000000; /**** General Functions ****/ template <typename T> T tmin(T a, T b) { return a > b ? b : a; }; template <typename T> T tmax(T a, T b) { return a > b ? a : b; }; template <typename T> T tadd(T a, T b) { return a + b; }; template <typename T> T tmul(T a, T b) { return a * b; }; template <typename T> T tpow(T a, T b) { return a * b; }; ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); } ll lmin(ll a, ll b) { return a > b ? b : a; }; ll lmax(ll a, ll b) { return a > b ? a : b; }; /**** Dijkstra ****/ class Dijkstra { // double は無理!! public: struct edge { ll to, cost; }; ll V; vector<edge> G[DIJKSTRA_MAX_V]; ll d[DIJKSTRA_MAX_V]; priority_queue<P, vector<P>, greater<P> > que; Dijkstra() {} Dijkstra(ll v) { init(v); } void init(ll v) { V = v; for (ll i = 0; i < v; i++) { G[i].clear(); } } void search(ll from) { for (ll i = 0; i < V; i++) d[i] = INF; d[from] = 0; que.push(P(0, from)); while (!que.empty()) { P p = que.top(); que.pop(); ll b = p.second; ll c = p.first; if (d[b] <= c) continue; for (ll i = 0; i < G[b].size(); i++) { edge e = G[b][i]; ll nc = c + e.cost; ll nt = e.to; if (d[nt] > nc) que.push(P(nc, nt)), d[nt] = nc; } } } }; /**** Matrix ****/ template <typename T> struct Matrix { typedef vector<T> vec; typedef vector<vec> mat; ll x, y; // x: horizon y: vertical mat d; Matrix(ll _y, ll _x = -1) { if (_x == -1) _x = _y; x = _x, y = _y; for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) d[i][j] = 0; } void unit() { for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) d[i][j] = i == j ? 1 : 0; } Matrix copy() { Matrix m(y, x); for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) m.d[i][j] = d[i][j]; return m; } Matrix<T> operator + (Matrix<T>& t) { // No error check! Don't forget to check Matrix size!! Matrix<T> m(y, x); for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) m.d[i][j] = d[i][j] + t.d[i][j]; return m; } Matrix<T> operator - (Matrix<T>& t) { Matrix<T> m(y, x); for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) m.d[i][j] = d[i][j] - t.d[i][j]; return m; } Matrix<T> operator * (T t) { Matrix<T> m(y, x); for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) m.d[i][j] = d[i][j] * t; return m; } Matrix<T> det(Matrix<T>& t) { // x need to correspond to t.y Matrix<T> m(y, x); for (int i = 0; i < y; i++) for (int j = 0; j < x; j++) for (int k = 0; k < t.x; k++) m.d[i][j] += d[i][k] * t.d[k][j]; ////////////// mod??? return m; } }; /**** Zip ****/ template <typename T> class Zip { vector<T> d; bool flag; public: Zip() { flag = false; } void add(T x) { d.push_back(x); flag = true; } ll getNum(T x) { // T need to have operator < !! if (flag) { sort(d.begin(), d.end()); d.erase(unique(d.begin(), d.end()), d.end()); flag = false; } return lower_bound(d.begin(), d.end(), x) - d.begin(); } ll size() { return (ll)d.size(); } }; /**** Union Find ****/ class UnionFind { ll par[UNION_FIND_MAX]; ll rank[UNION_FIND_MAX]; public: void init(ll n) { for (ll i = 0; i < n; i++) par[i] = i, rank[i] = 0; } UnionFind(ll n) { init(n); } ll findRoot(ll x) { if (par[x] == x) return x; return par[x] = findRoot(par[x]); } void merge(ll x, ll y) { x = findRoot(x); y = findRoot(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; } else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } bool isSame(ll x, ll y) { return findRoot(x) == findRoot(y); } }; template <typename T> class UnionFindT { ll par[UNION_FIND_MAX]; ll rank[UNION_FIND_MAX]; T weight[UNION_FIND_MAX]; public: void init(ll n, T w) { for (ll i = 0; i < n; i++) par[i] = i, rank[i] = 0, weight[i] = w; } UnionFindT(ll n, T w) { init(n, w); } ll findRoot(ll x) { if (par[x] == x) return x; weight[x] += weight[par[x]]; return par[x] = findRoot(par[x]); } T getWeight(ll x) { findRoot(x); return weight[x]; } bool merge(ll x, ll y, T w) { // weight(y) = weight(x) + wにする w += weight(x); w -= weight(y); x = findRoot(x); y = findRoot(y); if (x == y) return false; if (rank[x] < rank[y]) { par[x] = y; weight[x] = -w; } else { par[y] = x; weight[y] = w; if (rank[x] == rank[y]) rank[x]++; } return true; } T diff(ll x, ll y) { // xが基準でyの重み return weight(y) - weight(x); } bool isSame(ll x, ll y) { return findRoot(x) == findRoot(y); } }; /**** Segment Tree ****/ template <typename T> struct SegmentTree { ll n; T dat[SEGMENT_TREE_MAX]; function<T(T, T)> acc; T out; SegmentTree(function<T(T, T)> func, T overNum) { acc = func; out = overNum; } void init(ll _n) { n = 1; while (n < _n) n *= 2; for (ll i = 0; i < 2 * n - 1; i++) dat[i] = out; } void nodeUpdate(ll k, T d) { // k番目をdに変える k += n - 1; dat[k] = d; while (k > 0) { k = (k - 1) / 2; dat[k] = acc(dat[k * 2 + 1], dat[k * 2 + 2]); } } T rangeQuery(ll a, ll b) { return tempRangeQuery(a, b, 0, 0, n); } private: T tempRangeQuery(const ll& a, const ll& b, ll k, ll l, ll r) { if (r <= a || b <= l) return out; if (a <= l && r <= b) return dat[k]; T vl = tempRangeQuery(a, b, k * 2 + 1, l, (l + r) / 2); T vr = tempRangeQuery(a, b, k * 2 + 2, (l + r) / 2, r); return acc(vl, vr); } }; /**** Network Flow ****/ class MaxFlow { public: struct edge { ll to, cap, rev; }; vector<edge> G[MAX_FLOW_MAX_V]; bool used[MAX_FLOW_MAX_V]; ll level[MAX_FLOW_MAX_V]; ll iter[MAX_FLOW_MAX_V]; void init() { for (ll i = 0; i < MAX_FLOW_MAX_V; i++) { G[i].clear(); } } void add_edge(ll from, ll to, ll cap) { G[from].push_back((edge){to, cap, (ll)G[to].size()}); G[to].push_back((edge){from, 0, (ll)G[from].size() - 1}); } void add_undirected_edge(ll e1, ll e2, ll cap) { G[e1].push_back((edge){e2, cap, (ll)G[e2].size()}); G[e2].push_back((edge){e1, cap, (ll)G[e1].size() - 1}); } ll dfs(ll v, ll t, ll f) { if (v == t) return f; used[v] = true; for (ll i = 0; i < (ll)G[v].size(); i++) { edge &e = G[v][i]; if (!used[e.to]&& e.cap > 0) { ll d = dfs(e.to, t, min(f, e.cap)); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll max_flow(ll s, ll t) { ll flow = 0; while (1) { memset(used, 0, sizeof(used)); ll f = dfs(s, t, INF); if (f == 0) return flow; flow += f; } } void bfs(ll s) { memset(level, -1, sizeof(level)); queue<ll> que; level[s] = 0; que.push(s); while (!que.empty()) { ll v = que.front(); que.pop(); for (ll i = 0; i < (ll)G[v].size(); i++) { edge &e = G[v][i]; if (e.cap > 0 && level[e.to] < 0) { level[e.to] = level[v] + 1; que.push(e.to); } } } } ll dinic_dfs(ll v, ll t, ll f) { if (v == t) return f; for (ll &i= iter[v]; i < (ll)G[v].size(); i++) { edge &e = G[v][i]; if (e.cap > 0 && level[v] < level[e.to]) { ll d = dinic_dfs(e.to, t, min(f, e.cap)); if (d > 0) { e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll dinic(ll s, ll t) { ll flow = 0; while (1) { bfs(s); if (level[t] < 0) return flow; memset(iter, 0, sizeof(iter)); ll f; while ((f = dinic_dfs(s, t, INF)) > 0) { flow += f; } } } }; /**** bipartite matching ****/ class BipartiteMatching { public: ll V; vector<ll> G[BIPARTITE_MATCHING_MAX_V]; ll match[BIPARTITE_MATCHING_MAX_V]; bool used[BIPARTITE_MATCHING_MAX_V]; BipartiteMatching(ll v) { V = v; } void init(ll v) { V = v; for (ll i = 0; i < BIPARTITE_MATCHING_MAX_V; i++) { G[i].clear(); } } void add_edge(ll u, ll v) { G[u].push_back(v); G[v].push_back(u); } bool dfs(ll v) { used[v] = true; for (ll i = 0; i < (ll)G[v].size(); i++) { ll u = G[v][i], w = match[u]; if (w < 0 || !used[w] && dfs(w)) { match[v] = u; match[u] = v; return true; } } return false; } ll max_matching() { ll res = 0; memset(match, -1, sizeof(match)); for (ll v = 0; v < V;v++) { if (match[v] < 0) { memset(used, 0, sizeof(used)); if (dfs(v)) { res++; } } } return res; } }; class MinCostFlow { public: struct edge { ll to, cap, cost, rev; }; ll V; vector<edge> G[MIN_COST_FLOW_MAX_V]; ll dist[MIN_COST_FLOW_MAX_V]; ll prevv[MIN_COST_FLOW_MAX_V]; ll preve[MIN_COST_FLOW_MAX_V]; ll h[MIN_COST_FLOW_MAX_V]; MinCostFlow(ll v) { V = v; } void init() { for (ll i = 0; i < MAX_FLOW_MAX_V; i++) { G[i].clear(); } } void add_edge(ll from, ll to, ll cap, ll cost) { G[from].push_back((edge){to, cap, cost, (ll)G[to].size()}); G[to].push_back((edge){from, 0, -cost, (ll)G[from].size() - 1}); } void add_undirected_edge(ll e1, ll e2, ll cap, ll cost) { add_edge(e1, e2, cap, cost); add_edge(e2, e1, cap, cost); } ll min_cost_flow(ll s, ll t, ll f) { // minas ll res = 0; while (f > 0) { fill(dist, dist + V, INF); dist[s] = 0; bool update = true; while (update) { update = false; for (ll v = 0; v < V; v++) { if (dist[v] == INF) continue; for (ll i = 0; i < (ll)G[v].size(); i++) { edge &e = G[v][i]; if (e.cap > 0 && dist[e.to] > dist[v] + e.cost) { dist[e.to] = dist[v] + e.cost; prevv[e.to] = v; preve[e.to] = i; update = true; } } } } if (dist[t] == INF) { return -1; } ll d = f; for (ll v = t; v != s; v = prevv[v]) { d = min(d, G[prevv[v]][preve[v]].cap); } f -= d; res += d * dist[t]; for (ll v = t; v != s; v = prevv[v]) { edge &e = G[prevv[v]][preve[v]]; e.cap -= d; G[v][e.rev].cap += d; } } return res; } ll min_cost_flow_dijkstra(ll s, ll t, ll f) { ll res = 0; fill(h, h + V, 0); while (f > 0) { priority_queue<P, vector<P>, greater<P> > que; fill(dist, dist + V, 0); dist[s] = 0; que.push(P(0, s)); while (!que.empty()) { P p = que.top(); que.pop(); int v = p.second; if (dist[v] < p.first) continue; for (int i = 0; i < G[v].size(); i++) { edge &e = G[v][i]; if (e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) { dist[e.to] = dist[v] + e.cost + h[v] - h[e.to]; prevv[e.to] = v; preve[e.to] = i; que.push(P(dist[e.to], e.to)); } } } if (dist[t] == INF) { return -1; } for (int v = 0; v < V; v++) h[v] += dist[v]; int d = f; for (int v = t; v != s; v = prevv[v]) { d = tmin<ll>(d, G[prevv[v]][preve[v]].cap); } f -= d; res += d * h[t]; for (int v = t; v != s; v = prevv[v]) { edge &e = G[prevv[v]][preve[v]]; e.cap -= d; G[v][e.rev].cap += d; } return res; } return 0; } }; /**** main function ****/ ll int main() { scanf("%lld", & }
a.cc:537:1: error: two or more data types in declaration of 'main' 537 | ll | ^~
s241389489
p03857
C++
#include<bits/stdc++.h> #include<math.h> #include <stdio.h> #include<vector> #include<deque> #include<stdlib.h> #include <algorithm> #include<set> #include<map> #include <limits> #include<iomanip> #include<string> #define rep(i,n) for(int i = 0; i < n; i++) typedef long long ll; using namespace std; #define llMAX numeric_limits<long long>::max() #define intMAX numeric_limits<int>::max() #define ll long long #define d_2 100000 #define d9_7 1000000007 struct edge{ struct treev* to; ll length; int type;//0が道路、1が鉄道 }; struct treev{ int num; vector<edge> nexts; }; //UNION FIND //構造体 struct uunion{ int num; int size; }; uunion par1[200000];//親の番号 vector<bool> record(200000,false); //n要素で初期化 void init1(int n){ rep(i,n){ par1[i].num=i; par1[i].size=1; } } //木の根を求める int root1(int x){ if(par1[x].num==x){ return x; }else{ return par1[x].num=root1(par1[x].num);//経路圧縮 } } //属する集合の要素数を求める int size1(int x){ return par1[root1(x)].size; } //x,yが同じ集合に属するか否か bool same1(int x,int y){ return (root1(x)==root1(y)); } //x,yの属する集合を併合 void unite1(int x,int y){ x=root1(x); y=root1(y); if(x==y)return; par1[y].size += par1[x].size; par1[x].num = y; } uunion par2[200000];//親の番号 //n要素で初期化 void init2(int n){ rep(i,n){ par2[i].num=i; par2[i].size=1; } } //木の根を求める int root2(int x){ if(par2[x].num==x){ return x; }else{ return par2[x].num=root2(par2[x].num);//経路圧縮 } } //属する集合の要素数を求める int size2(int x){ return par2[root2(x)].size; } //x,yが同じ集合に属するか否か bool same2(int x,int y){ return (root2(x)==root2(y)); } //x,yの属する集合を併合 void unite2(int x,int y){ x=root2(x); y=root2(y); if(x==y)return; par2[y].size += par2[x].size; par2[x].num = y; } uunion par3[200000];//親の番号 //n要素で初期化 void init3(int n){ rep(i,n){ par3[i].num=i; par3[i].size=1; } return; } //木の根を求める int root3(int x){ if(par3[x].num==x){ return x; }else{ return par3[x].num=root3(par3[x].num);//経路圧縮 } } //属する集合の要素数を求める int size3(int x){ return par3[root3(x)].size; } //x,yが同じ集合に属するか否か bool same3(int x,int y){ return (root3(x)==root3(y)); } //x,yの属する集合を併合 void unite3(int x,int y){ x=root3(x); y=root3(y); if(x==y)return; par3[y].size += par3[x].size; par3[x].num = y; } //木構造グラフ struct input{ int u; int v; }; bool cmp(const input &a, const input &b)//ソート用 { if(a.u!=b.u){ return a.u<b.u; }else{ return a.v<b.v; } } vector<treev*> vs; treev* createtreenode(int num){ treev* newt=new treev; if(newt==NULL){ cout << "memory error" << endl; while(1){ num=1;//メモリエラー対策 } } newt->num=num; newt->nexts={}; //cout << "fff" << endl; return newt; } void insertree(ll len,int Va,int Vb,int type){//結ぶ頂点を vs[Va]->nexts.push_back({vs[Vb],len,type}); vs[Vb]->nexts.push_back({vs[Va],len,type}); return; } void search1(int root,ll depth,int pre){ record[root]=true; //cout << "eee" << endl; //ここにやりたい処理を書く if(pre!=-1){ unite1(root,pre); } for(auto i:vs[root]->nexts){ if(pre==i.to->num || i.type==1||record[i.to->num]==true){ continue; } search1(i.to->num,depth+i.length,root); } return; } void search2(int root,ll depth,int pre){ record[root]=true; //cout << "eee" << endl; //ここにやりたい処理を書く if(pre!=-1){ unite2(root,pre); } for(auto i:vs[root]->nexts){ if(pre==i.to->num || i.type==0||record[i.to->num]==true){ continue; } search2(i.to->num,depth+i.length,root); } return; } void search3(int root,ll depth,int pre){ record[root]=true; if(pre!=-1){ if(same1(root,pre)&&same2(root,pre)){ unite3(root,pre); } } //ここにやりたい処理を書く for(auto i:vs[root]->nexts){ if(pre==i.to->num||record[i.to->num]==true){ continue; } search3(i.to->num,depth+i.length,root); } return; } int main(void){ int n,k,l,p,q,r,s; cin >> n>>k>>l; rep(i,n){ vs.push_back(createtreenode(i)); } rep(i,k){ cin>>p>>q; p--;q--; insertree(1,p,q,0); } rep(i,l){ cin>>r>>s; r--;s--; insertree(1,r,s,1); } init1(n); rep(i,n){ if(record[i]==false){ search1(i,0,-1); } } init2(n); rep(i,n){ record[i]=false; } rep(i,n){ if(record[i]==false){ search2(i,0,-1); //cout<<i<<endl; } } /*rep(i,n){ record[i]=false; } init3(n); rep(i,n){ if(record[i]==false){ search3(i,0,-1); } }*/ /*rep(i,n){ cout<<par1[i].num<<" "; } cout<<endl; rep(i,n){ cout<<par2[i].num<<" "; } cout<<endl;*/ multimap<pair<int,int>,int> m; rep(i,n){ m.insert((root1(i),root2(i)),1); } rep(i,n){ auto c=m.count({root1(i),root2(i)}); cout<<c<<" "; } cout<<endl; return 0; }
In file included from /usr/include/c++/14/map:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:1: /usr/include/c++/14/bits/stl_multimap.h: In instantiation of 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]': a.cc:269:13: required from here 269 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_multimap.h:620:37: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_insert_range_equal(int&, int&)' 620 | { _M_t._M_insert_range_equal(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/map:62: /usr/include/c++/14/bits/stl_tree.h:1113:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_equal(_InputIterator, _InputIterator) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1113 | _M_insert_range_equal(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1113:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<std::pair<const std::pair<int, int>, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_insert_range_equal(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_multimap.h:620:30: required from 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 620 | { _M_t._M_insert_range_equal(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:269:13: required from here 269 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1095:58: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1095 | __enable_if_t<__same_value_type<_InputIterator>::value> | ^~~~~ /usr/include/c++/14/bits/stl_multimap.h: In instantiation of 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]': a.cc:269:13: required from here 269 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1122:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_equal(_InputIterator, _InputIterator) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1122 | _M_insert_range_equal(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1122:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<std::pair<const std::pair<int, int>, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value)), void> std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_insert_range_equal(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_multimap.h:620:30: required from 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 620 | { _M_t._M_insert_range_equal(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:269:13: required from here 269 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1104:59: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1104 | __enable_if_t<!__same_value_type<_InputIterator>::value> | ^~~~~
s963985984
p03857
C++
#include<bits/stdc++.h> #include<math.h> #include <stdio.h> #include<vector> #include<deque> #include<stdlib.h> #include <algorithm> #include<set> #include<map> #include <limits> #include<iomanip> #include<string> #define rep(i,n) for(int i = 0; i < n; i++) typedef long long ll; using namespace std; #define llMAX numeric_limits<long long>::max() #define intMAX numeric_limits<int>::max() #define ll long long #define d_2 100000 #define d9_7 1000000007 struct edge{ struct treev* to; ll length; int type;//0が道路、1が鉄道 }; struct treev{ int num; vector<edge> nexts; }; //UNION FIND //構造体 struct uunion{ int num; int size; }; uunion par1[200000];//親の番号 vector<bool> record(200000,false); //n要素で初期化 void init1(int n){ rep(i,n){ par1[i].num=i; par1[i].size=1; } } //木の根を求める int root1(int x){ if(par1[x].num==x){ return x; }else{ return par1[x].num=root1(par1[x].num);//経路圧縮 } } //属する集合の要素数を求める int size1(int x){ return par1[root1(x)].size; } //x,yが同じ集合に属するか否か bool same1(int x,int y){ return (root1(x)==root1(y)); } //x,yの属する集合を併合 void unite1(int x,int y){ x=root1(x); y=root1(y); if(x==y)return; par1[y].size += par1[x].size; par1[x].num = y; } uunion par2[200000];//親の番号 //n要素で初期化 void init2(int n){ rep(i,n){ par2[i].num=i; par2[i].size=1; } } //木の根を求める int root2(int x){ if(par2[x].num==x){ return x; }else{ return par2[x].num=root2(par2[x].num);//経路圧縮 } } //属する集合の要素数を求める int size2(int x){ return par2[root2(x)].size; } //x,yが同じ集合に属するか否か bool same2(int x,int y){ return (root2(x)==root2(y)); } //x,yの属する集合を併合 void unite2(int x,int y){ x=root2(x); y=root2(y); if(x==y)return; par2[y].size += par2[x].size; par2[x].num = y; } uunion par3[200000];//親の番号 //n要素で初期化 void init3(int n){ rep(i,n){ par3[i].num=i; par3[i].size=1; } return; } //木の根を求める int root3(int x){ if(par3[x].num==x){ return x; }else{ return par3[x].num=root3(par3[x].num);//経路圧縮 } } //属する集合の要素数を求める int size3(int x){ return par3[root3(x)].size; } //x,yが同じ集合に属するか否か bool same3(int x,int y){ return (root3(x)==root3(y)); } //x,yの属する集合を併合 void unite3(int x,int y){ x=root3(x); y=root3(y); if(x==y)return; par3[y].size += par3[x].size; par3[x].num = y; } //木構造グラフ struct input{ int u; int v; }; bool cmp(const input &a, const input &b)//ソート用 { if(a.u!=b.u){ return a.u<b.u; }else{ return a.v<b.v; } } vector<treev*> vs; treev* createtreenode(int num){ treev* newt=new treev; if(newt==NULL){ cout << "memory error" << endl; while(1){ num=1;//メモリエラー対策 } } newt->num=num; newt->nexts={}; //cout << "fff" << endl; return newt; } void insertree(ll len,int Va,int Vb,int type){//結ぶ頂点を vs[Va]->nexts.push_back({vs[Vb],len,type}); vs[Vb]->nexts.push_back({vs[Va],len,type}); return; } void search1(int root,ll depth,int pre){ record[root]=true; //cout << "eee" << endl; //ここにやりたい処理を書く if(pre!=-1){ unite1(root,pre); } for(auto i:vs[root]->nexts){ if(pre==i.to->num || i.type==1||record[i.to->num]==true){ continue; } search1(i.to->num,depth+i.length,root); } return; } void search2(int root,ll depth,int pre){ record[root]=true; //cout << "eee" << endl; //ここにやりたい処理を書く if(pre!=-1){ unite2(root,pre); } for(auto i:vs[root]->nexts){ if(pre==i.to->num || i.type==0||record[i.to->num]==true){ continue; } search2(i.to->num,depth+i.length,root); } return; } void search3(int root,ll depth,int pre){ record[root]=true; if(pre!=-1){ if(same1(root,pre)&&same2(root,pre)){ unite3(root,pre); } } //ここにやりたい処理を書く for(auto i:vs[root]->nexts){ if(pre==i.to->num||record[i.to->num]==true){ continue; } search3(i.to->num,depth+i.length,root); } return; } int main(void){ int n,k,l,p,q,r,s; cin >> n>>k>>l; rep(i,n){ vs.push_back(createtreenode(i)); } rep(i,k){ cin>>p>>q; p--;q--; insertree(1,p,q,0); } rep(i,l){ cin>>r>>s; r--;s--; insertree(1,r,s,1); } init1(n); rep(i,n){ if(record[i]==false){ search1(i,0,-1); } } init2(n); rep(i,n){ record[i]=false; } rep(i,n){ if(record[i]==false){ search2(i,0,-1); //cout<<i<<endl; } } /*rep(i,n){ record[i]=false; } init3(n); rep(i,n){ if(record[i]==false){ search3(i,0,-1); } }*/ /*rep(i,n){ cout<<par1[i].num<<" "; } cout<<endl; rep(i,n){ cout<<par2[i].num<<" "; } cout<<endl;*/ multimap<pair<int,int>,int> m; rep(i,n){ m.insert((root1(i),root2(i)),1); } rep(i,n){ auto c=m.count((root1(i),root2(i))); cout<<c<<" "; } cout<<endl; return 0; }
a.cc: In function 'int main()': a.cc:273:19: error: no matching function for call to 'std::multimap<std::pair<int, int>, int>::count(int)' 273 | auto c=m.count((root1(i),root2(i))); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/map:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:152, from a.cc:2: /usr/include/c++/14/bits/stl_multimap.h:897:9: note: candidate: 'template<class _Kt> decltype (((const std::multimap<_Key, _Tp, _Compare, _Alloc>*)this)->std::multimap<_Key, _Tp, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::multimap<_Key, _Tp, _Compare, _Alloc>::count(const _Kt&) const [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 897 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ^~~~~ /usr/include/c++/14/bits/stl_multimap.h:897:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_multimap.h: In substitution of 'template<class _Kt> decltype (((const std::multimap<std::pair<int, int>, int>*)this)->std::multimap<std::pair<int, int>, int>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::multimap<std::pair<int, int>, int>::count(const _Kt&) const [with _Kt = int]': a.cc:273:19: required from here 273 | auto c=m.count((root1(i),root2(i))); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_multimap.h:897:65: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_count_tr(const int&) const' 897 | count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x)) | ~~~~~~~~~~~~~~~~^~~~~ In file included from /usr/include/c++/14/map:62: /usr/include/c++/14/bits/stl_tree.h:1311:9: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Req = _Kt; _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1311 | _M_count_tr(const _Kt& __k) const | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1311:9: note: template argument deduction/substitution failed: In file included from /usr/include/c++/14/string:49, 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/stl_function.h: In substitution of 'template<class _Func, class _SfinaeType> using std::__has_is_transparent_t = typename std::__has_is_transparent<_Func, _SfinaeType>::type [with _Func = std::less<std::pair<int, int> >; _SfinaeType = int]': /usr/include/c++/14/bits/stl_tree.h:1309:9: required by substitution of 'template<class _Kt> decltype (((const std::multimap<std::pair<int, int>, int>*)this)->std::multimap<std::pair<int, int>, int>::_M_t.std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_count_tr<_Kt, _Req>(__x)) std::multimap<std::pair<int, int>, int>::count(const _Kt&) const [with _Kt = int]' 1309 | typename _Req = __has_is_transparent_t<_Compare, _Kt>> | ^~~~~~~~ a.cc:273:19: required from here 273 | auto c=m.count((root1(i),root2(i))); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:1427:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<std::pair<int, int> >, int, void>' 1427 | using __has_is_transparent_t | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_multimap.h:891:7: note: candidate: 'std::multimap<_Key, _Tp, _Compare, _Alloc>::size_type std::multimap<_Key, _Tp, _Compare, _Alloc>::count(const key_type&) const [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; size_type = long unsigned int; key_type = std::pair<int, int>]' 891 | count(const key_type& __x) const | ^~~~~ /usr/include/c++/14/bits/stl_multimap.h:891:29: note: no known conversion for argument 1 from 'int' to 'const std::multimap<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'} 891 | count(const key_type& __x) const | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_multimap.h: In instantiation of 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]': a.cc:270:13: required from here 270 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_multimap.h:620:37: error: no matching function for call to 'std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_insert_range_equal(int&, int&)' 620 | { _M_t._M_insert_range_equal(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1113:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_equal(_InputIterator, _InputIterator) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1113 | _M_insert_range_equal(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1113:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<std::pair<const std::pair<int, int>, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_insert_range_equal(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_multimap.h:620:30: required from 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 620 | { _M_t._M_insert_range_equal(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:270:13: required from here 270 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1095:58: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1095 | __enable_if_t<__same_value_type<_InputIterator>::value> | ^~~~~ /usr/include/c++/14/bits/stl_multimap.h: In instantiation of 'void std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]': a.cc:270:13: required from here 270 | m.insert((root1(i),root2(i)),1); | ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1122:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_equal(_InputIterator, _InputIterator) [with _Key = std::pair<int, int>; _Val = std::pair<const std::pair<int, int>, int>; _KeyOfValue = std::_Select1st<std::pair<const std::pair<int, int>, int> >; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >]' 1122 | _M_insert_range_equal(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1122:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<std::pair<const std::pair<int, int>, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value)), void> std::_Rb_tree<std::pair<int, int>, std::pair<const std::pair<int, int>, int>, std::_Select1st<std::pair<const std::pair<int, int>, int> >, std::less<std::pair<int, int> >, std::allocator<std::pair<const std::pair<int, int>, int> > >::_M_insert_range_equal(_InputIterator, _InputIterator) [
s569368935
p03857
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef long double f80; // #define int long long #define pii pair<int,int> #define fi first #define se second #define all(x) x.begin(), x.end() #define sz(x) (int)x.size() #define fr(i, a, b) for(int i = a; i <= b; i++) #define pb push_back #define eb emplace_back #define pf push_front #define ef emplace_front #ifndef LOCAL #define endl '\n' #endif const int mod = 1e9 + 7; ll pwr(ll a, ll b) { ll ans = 1; while(b) { if(b & 1) ans = (ans * a) % mod; a = (a * a) % mod; b >>= 1; } return ans; } const int N = 2e5 + 5; bitset<N> b[N][2]; int comp[N][2]; bool vis[N]; vector<pii> g[N]; void dfs(int u,int k,int c) { vis[u] = 1; comp[u][k] = c; b[c][k][u] = 1; for(pii v : g[u]) { if(!vis[v.fi] && v.se == k) { dfs(v.fi, k, c); } } } signed main() { ios::sync_with_stdio(0), cin.tie(0), cout.tie(0); #ifdef LOCAL freopen("inp.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif int n, k, l; cin >> n >> k >> l; fr(i, 1, k) { int u, v; cin >> u >> v; g[u].pb({v, 0}); g[v].pb({u, 0}); } fr(i ,1, l) { int u, v; cin >> u >> v; g[u].pb({v, 1}); g[v].pb({u, 1}); } fill(vis + 1, vis + n + 1, 0); int c = 0; fr(i, 1, n) { if(!vis[i]) { c++; dfs(i, 0, c); } } fill(vis + 1, vis + n + 1, 0); c = 0; fr(i, 1, n) { if(!vis[i]) { c++; dfs(i, 1, c); } } fr(i, 1, n) { cout << (b[comp[i][0]][0] & b[comp[i][1]][1]).count() << " "; } return 0; }
/tmp/ccPXEFAS.o: in function `dfs(int, int, int)': a.cc:(.text+0xe0): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `comp' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x17c): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x1c4): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o /tmp/ccPXEFAS.o: in function `main': a.cc:(.text+0x2e8): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x345): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x3ef): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x44c): relocation truncated to fit: R_X86_64_PC32 against symbol `g' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x4bc): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x4c7): relocation truncated to fit: R_X86_64_PC32 against symbol `vis' defined in .bss section in /tmp/ccPXEFAS.o a.cc:(.text+0x4f5): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s775676889
p03857
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Objects; import java.util.StringTokenizer; public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); DreamTask solver = new DreamTask(); solver.solve(1, in, out); out.close(); } static class DreamTask{ public void solve(int testcaseNumber, InputReader in, PrintWriter out) { int n = in.nextInt(), k= in.nextInt(), l = in.nextInt(); UF road = new UF(n); UF rail = new UF(n); int x,y; for(int i = -1; ++i < k;) { x = in.nextInt(); y = in.nextInt(); road.union(x,y); } for(int i = -1; ++i < l;) { x = in.nextInt(); y = in.nextInt(); rail.union(x,y); } HashMap<pair, Integer> map = new HashMap<Dreamer.pair, Integer>(); pair[] vp = new pair[n+1]; for(int i = 0; ++i <= n;) { pair p = new pair(road.root(i), rail.root(i)); vp[i] = p; if(map.containsKey(p)) map.put(p, map.get(p)+1); else map.put(p, 1); } for(int i = 0; ++i <= n;) { out.print(map.get(vp[i])+" "); } } } /* 4 3 6 9 10 */ static class pair{ int f,s; public pair(int f, int s) { this.f = f; this.s = s; } @Override public boolean equals(Object o) { if(o==null||getClass()!=o.getClass()) return false; if(this == o) return true; pair p = (pair) o; return f == p.f && s == p.s; } @Override public int hashCode() { return Objects.hash(f,s); } } static class UF{ int[] u; public UF(int n) { u = new int[n+5]; Arrays.fill(u,-1); } public int root(int x) {return u[x] <0?x:(u[x] = root(u[x]));} public void union(int x, int y) { x = root(x); y=root(y); if(x!=y) {u[x]+=u[y];u[y] = x;} } } static class InputReader{ public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while(tokenizer==null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Main.java:40: error: package Dreamer does not exist HashMap<pair, Integer> map = new HashMap<Dreamer.pair, Integer>(); ^ 1 error
s439095280
p03857
Java
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashMap; import java.util.Objects; import java.util.StringTokenizer; public class Dreamer { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); DreamTask solver = new DreamTask(); solver.solve(1, in, out); out.close(); } static class DreamTask{ public void solve(int testcaseNumber, InputReader in, PrintWriter out) { int n = in.nextInt(), k= in.nextInt(), l = in.nextInt(); UF road = new UF(n); UF rail = new UF(n); int x,y; for(int i = -1; ++i < k;) { x = in.nextInt(); y = in.nextInt(); road.union(x,y); } for(int i = -1; ++i < l;) { x = in.nextInt(); y = in.nextInt(); rail.union(x,y); } HashMap<pair, Integer> map = new HashMap<Dreamer.pair, Integer>(); pair[] vp = new pair[n+1]; for(int i = 0; ++i <= n;) { pair p = new pair(road.root(i), rail.root(i)); vp[i] = p; if(map.containsKey(p)) map.put(p, map.get(p)+1); else map.put(p, 1); } for(int i = 0; ++i <= n;) { out.print(map.get(vp[i])+" "); } } } /* 4 3 6 9 10 */ static class pair{ int f,s; public pair(int f, int s) { this.f = f; this.s = s; } @Override public boolean equals(Object o) { if(o==null||getClass()!=o.getClass()) return false; if(this == o) return true; pair p = (pair) o; return f == p.f && s == p.s; } @Override public int hashCode() { return Objects.hash(f,s); } } static class UF{ int[] u; public UF(int n) { u = new int[n+5]; Arrays.fill(u,-1); } public int root(int x) {return u[x] <0?x:(u[x] = root(u[x]));} public void union(int x, int y) { x = root(x); y=root(y); if(x!=y) {u[x]+=u[y];u[y] = x;} } } static class InputReader{ public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while(tokenizer==null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } } }
Main.java:12: error: class Dreamer is public, should be declared in a file named Dreamer.java public class Dreamer { ^ 1 error
s526368714
p03857
C++
u#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define mp make_pair #define all(a) begin(a),end(a) #define FOR(x,val,to) for(int x=(val);x<int((to));++x) #define FORE(x,val,to) for(auto x=(val);x<=(to);++x) #define FORR(x,arr) for(auto &x: arr) #define FORS(x,plus,arr) for(auto x = begin(arr)+(plus); x != end(arr); ++x) #define FORREV(x,plus,arr) for(auto x = (arr).rbegin()+(plus); x !=(arr).rend(); ++x) #define REE(s_) {cout<<s_<<'\n';exit(0);} #define GET(arr) for(auto &i: (arr)) sc(i) #define whatis(x) cerr << #x << " is " << (x) << endl; #define e1 first #define e2 second #define INF 0x7f7f7f7f typedef std::pair<int,int> pi; typedef std::vector<int> vi; typedef std::vector<std::string> vs; typedef int64_t ll; typedef uint64_t ull; #define umap unordered_map #define uset unordered_set using namespace std; using namespace __gnu_pbds; #ifdef _WIN32 #define getchar_unlocked() _getchar_nolock() #define _CRT_DISABLE_PERFCRIT_LOCKS #endif template<class L, class R> ostream& operator<<(ostream &os, map<L, R> P) { for(auto const &vv: P)os<<"("<<vv.first<<","<<vv.second<<")"; return os; } template<class T> ostream& operator<<(ostream &os, set<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; } template<class T> ostream& operator<<(ostream &os, vector<T> V) { os<<"[";for(auto const &vv:V)os<<vv<<","; os<<"]"; return os; } template<class L, class R> ostream& operator<<(ostream &os, pair<L, R> P) { os<<"("<<P.first<<","<<P.second<<")"; return os; } inline int fstoi(const string &str){auto it=str.begin();bool neg=0;int num=0;if(*it=='-')neg=1;else num=*it-'0';++it;while(it<str.end()) num=num*10+(*it++-'0');if(neg)num*=-1;return num;} inline void getch(char &x){while(x = getchar_unlocked(), x < 33){;}} inline void getstr(string &str){str.clear(); char cur;while(cur=getchar_unlocked(),cur<33){;}while(cur>32){str+=cur;cur=getchar_unlocked();}} template<typename T> inline bool sc(T &num){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){if(c == EOF) return false;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; return true;}template<typename T, typename ...Args> inline void sc(T &num, Args &...args){ bool neg=0; int c; num=0; while(c=getchar_unlocked(),c<33){;} if(c=='-'){ neg=1; c=getchar_unlocked(); } for(;c>47;c=getchar_unlocked()) num=num*10+c-48; if(neg) num*=-1; sc(args...); } template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //s.find_by_order(), s.order_of_key() <- works like lower_bound template<typename T> using ordered_map = tree<T, int, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define N 1000001 vi adj[2][N]; int vis[N]; int vit; int wh[2][N]; void d1(int v){ vis[v] = vit; wh[0][v] = vit; FORR(i,adj[0][v]){ if(vis[i] != vit) d1(i); } } void d2(int v){ vis[v] = vit; wh[1][v] = vit; FORR(i,adj[1][v]){ if(vis[i] != vit) d2(i); } } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n,k,l; sc(n,k,l); int f,s; while(k--){ sc(f,s); --f,--s; adj[0][f].pb(s); adj[0][s].pb(f); } while(l--){ sc(f,s); --f,--s; adj[1][f].pb(s); adj[1][s].pb(f); } FOR(i,0,n){ if(!vis[i]){ ++vit; d1(i); } } memset(vis,0,n<<2); FOR(i,0,n){ if(!vis[i]){ ++vit; d2(i); } } map<pi,int> st; FOR(i,0,n){ ++st[mp(wh[0][i],wh[1][i])]; } FOR(i,0,n){ cout << st[mp(wh[0][i],wh[1][i])] << ' '; } }
a.cc:1:2: error: stray '#' in program 1 | u#include <bits/stdc++.h> | ^ a.cc:1:1: error: 'u' does not name a type 1 | u#include <bits/stdc++.h> | ^ In file included from /usr/include/c++/14/ext/typelist.h:46, from /usr/include/c++/14/ext/pb_ds/assoc_container.hpp:45, from a.cc:2: /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/utility:69, from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:46, from /usr/include/c++/14/ext/pb_ds/tag_and_trait.hpp:46, from /usr/include/c++/14/ext/pb_ds/assoc_container.hpp:46: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'; did you mean 'nullptr_t'? 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ In file included from /usr/include/c++/14/cstddef:50, from /usr/include/c++/14/ext/pb_ds/detail/type_utils.hpp:45: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:443:29: note: 'nullptr_t' declared here 443 | typedef decltype(nullptr) 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)> | ^~~~~~ /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/ext/pb_ds/detail/type_utils.hpp:47: /usr/include/c++/14/tr1/type_traits:153:26: error: 'std::size_t' has not been declared 153 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/tr1/type_traits:154:25: error: '_Size' was not declared in this scope 154 | struct is_array<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/tr1/type_traits:154:31: error: template argument 1 is invalid 154 | struct is_array<_Tp[_Size]> | ^ /usr/include/c++/14/tr1/type_traits:354:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 354 | : public integral_constant<std::size_t, __alignof__(_Tp)> { }; | ^~~~~~ /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/tr1/type_traits:354:61: error: template argument 1 is invalid 354 | : public integral_constant<std::size_t, __alignof__(_Tp)> { }; | ^ /usr/include/c++/14/tr1/type_traits:354:61: note: invalid template non-type parameter /usr/include/c++/14/tr1/type_traits:359:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 359 | : 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/tr1/type_traits:359:46: error: template argument 1 is invalid 359 | : public integral_constant<std::size_t, 0> { };
s965360913
p03857
C++
#include<bits/stdc++.h> using namespace std; int par1[200001],par2[200001]; vector<pair<int,int>> idx; map<pair<int,int>,int> cnt; int rep1(int n) { if(par1[n]==n) return n; return par1[n]=rep1(par1[n]); } int rep2(int n) { if(par2[n]==n) return n; return par2[n]=rep2(par2[n]); } int main() { int i,j; int n,k,l; int a,b,res=0; scanf("%d %d %d",&n,&k,&l); for(i=1;i<=n;i++){ par1[i]=i; par2[i]=i; } for(i=0;i<k;i++){ scanf("%d %d",&a,&b); swap(a,b); int r1=rep1(a); int r2=rep1(b); par1[r1]=r2; } for(i=0;i<l;i++){ scanf("%d %d",&a,&b); int r1=rep2(a); int r2=rep2(b); par2[r1]=r2; } for(i=1;i<=n;i++){ idx.push_back(make_pair(rep1(i),rep2(i))); } for(i=0;i<idx.size();i++){ assert(idx[i].fi == idx[i].se); cnt[idx[i]]++; //printf("%d %d\n",idx[i].first,idx[i].second); } for(i=0;i<idx.size();i++) printf("%d ",cnt[idx[i]]); }
In file included from /usr/include/c++/14/cassert:44, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:106, from a.cc:1: a.cc: In function 'int main()': a.cc:47:27: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'fi' 47 | assert(idx[i].fi == idx[i].se); | ^~ a.cc:47:40: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'se' 47 | assert(idx[i].fi == idx[i].se); | ^~
s076199250
p03857
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <functional> #include <queue> #include <string> #include <cstring> #include <numeric> #include <cstdlib> #include <cmath> #include <map> using namespace std; typedef long long ll; #define INF 10e17 // 4倍しても(4回足しても)long longを溢れない #define rep(i,n) for(int i=0; i<n; i++) #define rep_r(i,n,m) for(int i=m; i<n; i++) #define END cout << endl #define MOD 1000000007 #define pb push_back #define sorti(x) sort(x.begin(), x.end()) #define sortd(x) sort(x.begin(), x.end(), std::greater<int>()) #define debug(x) std::cerr << (x) << std::endl; #define roll(x) for (auto itr : x) { debug(itr); } template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;} template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;} /* Union-Find-Tree */ /* 必ず要素数をコンストラクタに入れること */ template <class T = long long> class Union_Find { using size_type = std::size_t; using _Tp = T; public: vector<_Tp> par; vector<_Tp> rnk; // 親の根を返す。値の変更は認めない。 const _Tp & operator[] (size_type child) const { return find(child); } Union_Find (_Tp n) { par.resize(n), rnk.resize(n); for (int i = 0; i < n; ++i) { par[i] = i; rnk[i] = 0; } } // 木の根を求める _Tp find(_Tp x) const { if (par[x] == x) return x; else return par[x] = find(par[x]); } // xとyの属する集合を併合 void merge(_Tp x, _Tp y) { x = find(x); y = find(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; } } // xとyが同じ集合に属するか否か bool same(_Tp x, _Tp y) { return find(x) == find(y); } }; int main() { int n,k,l; cin >> n >> k >> l; Union_Find uf_road(n+1), uf_train(n+1); int r,s; rep(i,k) { cin >> r >> s; uf_road.merge(r, s); } rep(i,l) { cin >> r >> s; uf_train.merge(r, s); } /*for (int i = 1; i <= n; ++i) { cout << uf_train.find(i) << " "; } END;*/ vector<pair<int,int> > com; map<pair<int,int>, int> mp; for (int i = 1; i <= n; ++i) { int a, b; a = uf_road.find(i); b = uf_train.find(i); com.push_back(make_pair(a,b)); mp[make_pair(a,b)] += 1; } for (int i = 0; i < n; ++i) { cout << mp[com[i]] << " "; } END; }
a.cc: In instantiation of 'Union_Find<T>::_Tp Union_Find<T>::find(_Tp) const [with T = int; _Tp = int]': a.cc:110:21: required from here 110 | a = uf_road.find(i); | ~~~~~~~~~~~~^~~ a.cc:60:21: error: assignment of read-only location '((const Union_Find<int>*)this)->Union_Find<int>::par.std::vector<int, std::allocator<int> >::operator[](((std::vector<int, std::allocator<int> >::size_type)x))' 60 | return par[x] = find(par[x]); | ~~~~~~~^~~~~~~~~~~~~~
s170571652
p03857
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define tr(container, it) \ for (auto it = container.begin(); it != container.end(); it++) #define scontains(c, x) ((c).find(x) != (c).end()) //O(log n) #define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n) #define pll pair<ll,ll> #define pii pair<int,int> #define mll map<ll,ll> #define intv(x, a, b)((x)>=a && (x)<=b) #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) #define _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1) #define all(x) (x).begin(),(x).end() //#define len(array) (sizeof(array)/sizeof((array)[0])) #define what_is(x) cerr << #x << " is " << x << endl; #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); } #define mod(x, m) ((((x) % (m)) + (m)) % (m)) const double PI = 2 * acos(.0); const int INF = 0x3f3f3f3f; const ll LLINF = 1000000000000000005LL;; const ll MOD = (ll) (1e9) + 7; void _mod(ll &x){x = mod(x, MOD);} //const ll MOD = (ll) 998244353 ; const double EPS = 1e-10; //#define int ll int N, K, L; set<int> adj1[202020]; set<int> adj2[202020]; int cnt[202020]; vector<set<int>> S1; vector<set<int>> SS; bool visited1[202020],visited2[202020]; class DConnectivity { public: void dfs1(int s,set<int> &v){ if(visited1[s])return ; v.insert(s); visited1[s] = 1; for(int node : adj1[s])dfs1(node,v); } void dfs2(int s, set<int> connected,set<int>& ac){ if(visited2[s] || !connected.count(s))return ; ac.insert(s); visited2[s] = 1; for(int node: adj2[s])dfs2(node, connected,ac); } void solve(std::istream& cin, std::ostream& cout) { cin >> N >> K >> L; memset(cnt,0,sizeof(cnt)); _for(i,K){ int a,b; cin >> a >> b; adj1[a].insert(b); adj1[b].insert(a); } _for(i,L){ int a,b; cin >> a >> b; adj2[a].insert(b); adj2[b].insert(a); } _for(i,N){ set<int> v = {}; dfs1(i+1,v); if(!v.empty())S1.push_back(v); } for(auto connected1 : S1){ for(auto node : connected1){ set<int> s = {}; dfs2(node, connected1, s); SS.emplace_back(s); } } for(auto ac : SS)for(auto node : ac)cnt[node] = ac.size(); _for(i,N)cout << cnt[i+1] << " \n"[i==N-1]; } };
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s758147844
p03857
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define MAXN 200010 vector<ll> c(MAXN,1); ll par[MAXN]; // 親 ll deep[MAXN]; // 深さ // in要素で初期化 ll init(ll in){ for(int i=0;i<=in;i++){ par[i]=i; deep[i]=0; } } // 木の根を求める ll find(ll x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } // xとyの集合を併合 void unite(ll x,ll y){ x=find(x); y=find(y); if(x==y) return; if(deep[x]<deep[y]){ par[x]=y; }else{ par[y]=x; if(deep[x]==deep[y]) deep[x]++; } } // xとyが同じ集合に属するか否か bool same(ll x,ll y){ return find(x)==find(y); } ll pard[MAXN]; // 親 ll deepd[MAXN]; // 深さ // in要素で初期化 ll initd(ll in){ for(int i=0;i<=in;i++){ pard[i]=i; deepd[i]=0; } } // 木の根を求める ll findd(ll x){ if(pard[x]==x){ return x; }else{ return pard[x]=findd(pard[x]); } } // xとyの集合を併合 void united(ll x,ll y){ x=findd(x); y=findd(y); if(x==y) return; if(deepd[x]<deepd[y]){ c[y]+=c[x]; pard[x]=y; }else{ c[x]+=c[y]; pard[y]=x; if(deepd[x]==deepd[y]) deepd[x]++; } } // xとyが同じ集合に属するか否か bool samed(ll x,ll y){ return findd(x)==findd(y); } int main(){ ll n,k,l,p,q; cin>>n>>k>>l; init(n); initd(n); for(int i=0;i<k;i++){ cin>>p>>q; unite(p,q); } for(int i=0;i<l;i++){ cin>>p>>q; if(same(p,q)){ unitd(p,q); } } for(int i=1;i<=n;i++){ cout<<c[findd(i)]<<" "; } }
a.cc: In function 'long long int init(long long int)': a.cc:15:1: warning: no return statement in function returning non-void [-Wreturn-type] 15 | } | ^ a.cc: In function 'long long int initd(long long int)': a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type] 53 | } | ^ a.cc: In function 'int main()': a.cc:95:7: error: 'unitd' was not declared in this scope; did you mean 'united'? 95 | unitd(p,q); | ^~~~~ | united
s007509880
p03857
C++
#include<bits/stdc++.h> using namespace std; #define ll long long #define MAXN 200010 vector<ll> c(MAXN,1); ll par[MAXN]; // 親 ll deep[MAXN]; // 深さ // in要素で初期化 ll init(ll in){ for(int i=0;i<=in;i++){ par[i]=i; deep[i]=0; } } // 木の根を求める ll find(ll x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } // xとyの集合を併合 void unite(ll x,ll y){ x=find(x); y=find(y); if(x==y) return; if(deep[x]<deep[y]){ par[x]=y; }else{ par[y]=x; if(deep[x]==deep[y]) deep[x]++; } } // xとyが同じ集合に属するか否か bool same(ll x,ll y){ return find(x)==find(y); } ll pard[MAXN]; // 親 ll deepd[MAXN]; // 深さ // in要素で初期化 ll initd(ll in){ for(int i=0;i<=in;i++){ pard[i]=i; deepd[i]=0; } } // 木の根を求める ll findd(ll x){ if(pard[x]==x){ return x; }else{ return pard[x]=findd(pard[x]); } } // xとyの集合を併合 void united(ll x,ll y){ x=findd(x); y=findd(y); if(x==y) return; if(deepd[x]<deepd[y]){ c[y]+=c[x]; pard[x]=y; }else{ c[x]+=c[y]; pard[y]=x; if(deepd[x]==deepd[y]) deepd[x]++; } } // xとyが同じ集合に属するか否か bool samed(ll x,ll y){ return findd(x)==findd(y); } int main(){ ll n,k,l,p,q; cin>>n>>k>>l; init(n); initd(n) for(int i=0;i<k;i++){ cin>>p>>q; unite(p,q); } for(int i=0;i<l;i++){ cin>>p>>q; if(same(p,q)){ unitd(p,q); } } for(int i=1;i<=n;i++){ cout<<c[findd(i)]<<" "; } }
a.cc: In function 'long long int init(long long int)': a.cc:15:1: warning: no return statement in function returning non-void [-Wreturn-type] 15 | } | ^ a.cc: In function 'long long int initd(long long int)': a.cc:53:1: warning: no return statement in function returning non-void [-Wreturn-type] 53 | } | ^ a.cc: In function 'int main()': a.cc:87:20: error: expected ';' before 'for' 87 | init(n); initd(n) | ^ | ; 88 | for(int i=0;i<k;i++){ | ~~~ a.cc:88:15: error: 'i' was not declared in this scope 88 | for(int i=0;i<k;i++){ | ^ a.cc:95:7: error: 'unitd' was not declared in this scope; did you mean 'united'? 95 | unitd(p,q); | ^~~~~ | united
s388698988
p03857
C++
#include <bits/stdc++.h> using namespace std; int main() { cin >> ; cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:16: error: expected primary-expression before ';' token 8 | cin >> ; | ^
s728759681
p03857
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<map> using namespace std; typedef long long ll; const int N=1000000; int road[N]; int raw[N]; int ans[N]; map<pair<int,int>,int> s; int xz(int x,char c) { if(c=='a') while(road[x]!=x) x=road[x]; if(c=='b') while(raw[x]!=x) x=raw[x]; return x; } bool judge(int x,int y,char c) { x=xz(x,c); y=xz(y,c); if(x==y) return 1; else return 0; } void hb(int x,int y,char c) { x=xz(x,c); y=xz(y,c); if(c=='a') road[y]=x; if(c=='b') raw[y]=x; } int main() { int n,a0,b0; int from,to; for(int i=1;i<=n;i++) road[i]=i,raw[i]=i; for(int i=1;i<=a0;i++) { cin>>from>>to; hb(from,to,a); } for(int i=1;i<=b0;i++) { cin>>from>>to; hb(from,to,b); } for(int i=1;i<=n;i++) { s[{road[i],raw[i]}]++; } for(int i=1;i<=n;i++) cout<<s[{road[i],raw[i]}]<<" "; return 0; }
a.cc: In function 'int main()': a.cc:44:28: error: 'a' was not declared in this scope 44 | hb(from,to,a); | ^ a.cc:49:28: error: 'b' was not declared in this scope 49 | hb(from,to,b); | ^
s873146640
p03857
C++
N,K,L=map(int,input().split()) len = [[[] for s in range(N)] for t in range (2)] i=1 j=1 while i <= K: a,b=map(int,input().split()) len[0][a-1].append(b-1) len[0][b-1].append(a-1) i+=1 while j <= L: a,b=map(int,input().split()) len[1][a-1].append(b-1) len[1][b-1].append(a-1) j+=1 def add(z,n): for num1 in len[z][n]: for num2 in len[z][num1]: if num2 != n and num2 not in len[z][n]: len[z][n].append(num2) add(z,num2) n=0 while n < N: add(0,n) add(1,n) n+=1 n=0 answer=[1]*N while n < N: for point in len[0][n]: if point in len[1][n]: answer[n]+=1 n+=1 n=0 while n<N-1: print(answer[n],end=' ') n+=1 print(answer[N-1])
a.cc:2:1: error: 'N' does not name a type 2 | N,K,L=map(int,input().split()) | ^
s758135362
p03857
C++
#include<iostream> #include<algorithm> #include<vector> #include<queue> #include<functional> #include<numeric> #include <unordered_map> using namespace std; long long find(long long x, std::vector<long long>& par) { if (par[x] == x) return x; return par[x] = find(par[x],par); } long long main() { cin.tie(0); ios::sync_with_stdio(false); long long n, k, l; cin >> n >> k >> l; vector<long long> rpar(n); iota(rpar.begin(), rpar.end(), 0); vector<long long>rnk(n, 0); long long p, q; // 道路 for (long long i = 0; i < k; i++) { cin >> p >> q; --p; --q; p = find(p,rpar); q = find(q,rpar); if (p == q) continue; if (rnk[p] < rnk[q]) { rpar[p] = q; } else { rpar[q] = p; if (rnk[p] == rnk[q]) rnk[p]++; } } // 線路 vector<long long> lpar(n); vector<long long> ans(n, 1); iota(lpar.begin(), lpar.end(), 0); fill(rnk.begin(), rnk.end(), 0); for (long long i = 0; i < l; i++) { cin >> p >> q; --p; --q; if (find(p, rpar) != find(q, rpar))continue; p = find(p, lpar); q = find(q, lpar); if (p == q) continue; if (rnk[p] < rnk[q]) { lpar[p] = q; ans[q] += ans[p]; } else { lpar[q] = p; ans[p] += ans[q]; if (rnk[p] == rnk[q]) rnk[p]++; } } for (long long i = 0; i < n-1; i++) { cout << to_string(ans[lpar[i]]) << " "; } cout << to_string(ans[lpar[n - 1]]) << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s794754177
p03857
C++
#include <iostream> #include <string> #include <algorithm> #include <cstdio> #include <vector> #include <queue> #include <map> #include <numeric> #include <cmath> using namespace std; typedef long long int ll; #define all(x) x.begin(),x.end() const ll mod = 1e9+7; const ll INF = 1e9; const ll MAXN = 1e9; struct union_find{ vector<int> par,r; union_find(int n){ par.resize(n); r.resize(n); for(int i = 0; i < n; i++) par[i] = i,r[i] = 0; } int find(int x){ if(par[x] == x) return x; else return find(par[x]); } void unite(int x,int y){ x = find(x); y = find(y); if(r[x] < r[y]){ par[x] = y; }else{ par[y] = x; if(r[x] == r[y]) r[x]++; } } bool same(int x,int y){ return find(x) == find(y); } }; int main() { int n,k,l; cin >> n >> k >> l; union_find road(n),train(n); for(int i = 0; i < k; i++){ int a,b; cin >> a >> b; a--,b--; if(!road.same(a,b)) road.unite(a,b); } for(int i = 0; i < l; i++){ int a,b; cin >> a >> b; a--,b--; if(!train.same(a,b)) train.unite(a,b); } vector<pair<int,int> > com(n); map<pair<int,int> ,int> s; for(int i = 0; i < n; i++){ com[i].first = road.find(i); com[i].second = train.find(i); s[com[i]]++; } for(int i = 0; i < n; i++){ cout << s[com[i]] << " " }printf("\n"); return 0; }
a.cc: In function 'int main()': a.cc:79:41: error: expected ';' before '}' token 79 | cout << s[com[i]] << " " | ^ | ; 80 | }printf("\n"); | ~
s599793395
p03857
C++
#include<iostream> using namespace std; const static int MAX_N = 2 * 100000; int N, K, L; bool roads[MAX_N + 1][MAX_N + 1]; int c_roads[MAX_N + 1]; int c_rails[MAX_N + 1]; void rec_roads(int p, int c) { for (int q = p; q <= N; q++) { if (roads[p][q] == 1) { c_roads[q] = c; roads[p][q] = 0; roads[q][p] = 0; rec_roads(q, c); } } } void rec_rails(int r, int c) { for (int s = r; s <= N; s++) { if (roads[r][s] == 1) { c_rails[s] = c; roads[r][s] = 0; roads[s][r] = 0; rec_rails(s, c); } } } int main() { cin >> N >> K >> L; for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int p, q; for (int i = 1; i <= K; i++) { cin >> p >> q; roads[p][q] = 1; roads[q][p] = 1; } for (p = 1; p <= N; p++) { rec_roads(p, p); } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { roads[i][j] = 0; } } for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int r, s; for (int i = 1; i <= L; i++) { cin >> r >> s; roads[r][s] = 1; roads[s][r] = 1; } for (r = 1; r <= N; r++) { rec_rails(r, r); } for (int i = 1; i <= N; i++) { int cnt = 0; for (int j = 1; j <= N; j++) { if (c_roads[i] == c_roads[j] && c_rails[i] == c_rails[j]) cnt += 1; } cout << cnt; if (i != N) cout << " "; } cout << endl; return 0; }
/tmp/ccmJYFZ5.o: in function `rec_roads(int, int)': a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccmJYFZ5.o /tmp/ccmJYFZ5.o: in function `rec_rails(int, int)': a.cc:(.text+0x11a): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccmJYFZ5.o /tmp/ccmJYFZ5.o: in function `main': a.cc:(.text+0x419): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccmJYFZ5.o a.cc:(.text+0x430): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccmJYFZ5.o a.cc:(.text+0x44b): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccmJYFZ5.o a.cc:(.text+0x462): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccmJYFZ5.o collect2: error: ld returned 1 exit status
s502553952
p03857
C++
#include<iostream> using namespace std; const static int MAX_N = 2 * 100000; int N, K, L; short roads[MAX_N + 1][MAX_N + 1]; int c_roads[MAX_N + 1]; int c_rails[MAX_N + 1]; void rec_roads(int p, int c) { for (int q = p; q <= N; q++) { if (roads[p][q] == 1) { c_roads[q] = c; roads[p][q] = 0; roads[q][p] = 0; rec_roads(q, c); } } } void rec_rails(int r, int c) { for (int s = r; s <= N; s++) { if (roads[r][s] == 1) { c_rails[s] = c; roads[r][s] = 0; roads[s][r] = 0; rec_rails(s, c); } } } int main() { cin >> N >> K >> L; for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int p, q; for (int i = 1; i <= K; i++) { cin >> p >> q; roads[p][q] = 1; roads[q][p] = 1; } for (p = 1; p <= N; p++) { rec_roads(p, p); } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { roads[i][j] = 0; } } for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int r, s; for (int i = 1; i <= L; i++) { cin >> r >> s; roads[r][s] = 1; roads[s][r] = 1; } for (r = 1; r <= N; r++) { rec_rails(r, r); } for (int i = 1; i <= N; i++) { int cnt = 0; for (int j = 1; j <= N; j++) { if (c_roads[i] == c_roads[j] && c_rails[i] == c_rails[j]) cnt += 1; } cout << cnt; if (i != N) cout << " "; } cout << endl; return 0; }
/tmp/ccECphvz.o: in function `rec_roads(int, int)': a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccECphvz.o /tmp/ccECphvz.o: in function `rec_rails(int, int)': a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccECphvz.o /tmp/ccECphvz.o: in function `main': a.cc:(.text+0x449): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccECphvz.o a.cc:(.text+0x460): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccECphvz.o a.cc:(.text+0x47b): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccECphvz.o a.cc:(.text+0x492): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccECphvz.o collect2: error: ld returned 1 exit status
s609228235
p03857
C++
#include<iostream> using namespace std; const static int MAX_N = 2 * 100000; int N, K, L; short roads[MAX_N + 1][MAX_N + 1]; int c_roads[MAX_N + 1]; int c_rails[MAX_N + 1]; void rec_roads(int p, int c) { for (int q = p; q <= N; q++) { if (roads[p][q] == 1) { c_roads[q] = c; roads[p][q] = 0; roads[q][p] = 0; rec_roads(q, c); } } } void rec_rails(int r, int c) { for (int s = r; s <= N; s++) { if (roads[r][s] == 1) { c_rails[s] = c; roads[r][s] = 0; roads[s][r] = 0; rec_rails(s, c); } } } int main() { cin >> N >> K >> L; for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int p, q; for (int i = 1; i <= K; i++) { cin >> p >> q; roads[p][q] = 1; roads[q][p] = 1; } for (p = 1; p <= N; p++) { rec_roads(p, p); } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { roads[i][j] = 0; } } for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int r, s; for (int i = 1; i <= L; i++) { cin >> r >> s; roads[r][s] = 1; roads[s][r] = 1; } for (r = 1; r <= N; r++) { rec_rails(r, r); } for (int i = 1; i <= N; i++) { int cnt = 0; for (int j = 1; j <= N; j++) { if (c_roads[i] == c_roads[j] && c_rails[i] == c_rails[j]) cnt += 1; } cout << cnt; if (i != N) cout << " "; } cout << endl; return 0; }
/tmp/cc2K85s9.o: in function `rec_roads(int, int)': a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/cc2K85s9.o /tmp/cc2K85s9.o: in function `rec_rails(int, int)': a.cc:(.text+0x122): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/cc2K85s9.o /tmp/cc2K85s9.o: in function `main': a.cc:(.text+0x449): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/cc2K85s9.o a.cc:(.text+0x460): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/cc2K85s9.o a.cc:(.text+0x47b): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/cc2K85s9.o a.cc:(.text+0x492): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/cc2K85s9.o collect2: error: ld returned 1 exit status
s140407256
p03857
C++
#include<iostream> using namespace std; const static int MAX_N = 2 * 100000; int N, K, L; int roads[MAX_N + 1][MAX_N + 1]; int c_roads[MAX_N + 1]; int c_rails[MAX_N + 1]; void rec_roads(int p, int c) { for (int q = p; q <= N; q++) { if (roads[p][q] == 1) { c_roads[q] = c; roads[p][q] = 0; roads[q][p] = 0; rec_roads(q, c); } } } void rec_rails(int r, int c) { for (int s = r; s <= N; s++) { if (roads[r][s] == 1) { c_rails[s] = c; roads[r][s] = 0; roads[s][r] = 0; rec_rails(s, c); } } } int main() { cin >> N >> K >> L; for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int p, q; for (int i = 1; i <= K; i++) { cin >> p >> q; roads[p][q] = 1; roads[q][p] = 1; } for (p = 1; p <= N; p++) { rec_roads(p, p); } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { roads[i][j] = 0; } } for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int r, s; for (int i = 1; i <= L; i++) { cin >> r >> s; roads[r][s] = 1; roads[s][r] = 1; } for (r = 1; r <= N; r++) { rec_rails(r, r); } for (int i = 1; i <= N; i++) { int cnt = 0; for (int j = 1; j <= N; j++) { if (c_roads[i] == c_roads[j] && c_rails[i] == c_rails[j]) cnt += 1; } cout << cnt; if (i != N) cout << " "; } cout << endl; return 0; }
/tmp/ccm2UEBA.o: in function `rec_roads(int, int)': a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccm2UEBA.o /tmp/ccm2UEBA.o: in function `rec_rails(int, int)': a.cc:(.text+0x130): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccm2UEBA.o /tmp/ccm2UEBA.o: in function `main': a.cc:(.text+0x482): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccm2UEBA.o a.cc:(.text+0x499): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccm2UEBA.o a.cc:(.text+0x4b4): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccm2UEBA.o a.cc:(.text+0x4cb): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccm2UEBA.o collect2: error: ld returned 1 exit status
s913088412
p03857
C++
`#include<iostream> using namespace std; const static int MAX_N = 2 * 100000; int N, K, L; int roads[MAX_N + 1][MAX_N + 1]; int c_roads[MAX_N + 1]; int c_rails[MAX_N + 1]; void rec_roads(int p, int c) { for (int q = p; q <= N; q++) { if (roads[p][q] == 1) { c_roads[q] = c; roads[p][q] = 0; roads[q][p] = 0; rec_roads(q, c); } } } void rec_rails(int r, int c) { for (int s = r; s <= N; s++) { if (roads[r][s] == 1) { c_rails[s] = c; roads[r][s] = 0; roads[s][r] = 0; rec_rails(s, c); } } } int main() { cin >> N >> K >> L; for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int p, q; for (int i = 1; i <= K; i++) { cin >> p >> q; roads[p][q] = 1; roads[q][p] = 1; } for (p = 1; p <= N; p++) { rec_roads(p, p); } for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { roads[i][j] = 0; } } for (int i = 1; i <= N; i++) { roads[i][i] = 1; } int r, s; for (int i = 1; i <= L; i++) { cin >> r >> s; roads[r][s] = 1; roads[s][r] = 1; } for (r = 1; r <= N; r++) { rec_rails(r, r); } for (int i = 1; i <= N; i++) { int cnt = 0; for (int j = 1; j <= N; j++) { if (c_roads[i] == c_roads[j] && c_rails[i] == c_rails[j]) cnt += 1; } cout << cnt; if (i != N) cout << " "; } cout << endl; return 0; }
a.cc:1:1: error: stray '`' in program 1 | `#include<iostream> | ^ a.cc:1:2: error: stray '#' in program 1 | `#include<iostream> | ^ a.cc:1:3: error: 'include' does not name a type 1 | `#include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:35:3: error: 'cin' was not declared in this scope 35 | cin >> N >> K >> L; | ^~~ a.cc:80:5: error: 'cout' was not declared in this scope 80 | cout << cnt; | ^~~~ a.cc:84:3: error: 'cout' was not declared in this scope 84 | cout << endl; | ^~~~ a.cc:84:11: error: 'endl' was not declared in this scope 84 | cout << endl; | ^~~~
s755753946
p03857
C++
#include<iostream> using namespace std; const static int MAX_N = 2 * 100000; int N, K, L; int roads[MAX_N + 1][MAX_N + 1]; int rails[MAX_N + 1][MAX_N + 1]; int c_roads[MAX_N + 1]; int c_rails[MAX_N + 1]; void rec_roads(int p, int c) { for (int q = p; q<=N; q++) { if (roads[p][q] == 1) { c_roads[q] = c; roads[p][q] = 0; roads[q][p] = 0; rec_roads(q, c); } } } void rec_rails(int r, int c) { for (int s = r; s<=N; s++) { if (rails[r][s] == 1) { c_rails[s] = c; rails[r][s] = 0; rails[s][r] = 0; rec_rails(s, c); } } } int main() { cin >> N >> K >> L; for (int i = 1; i <= N; i++) { roads[i][i] = 1; rails[i][i] = 1; } int p, q; for (int i = 1; i <= K; i++) { cin >> p >> q; roads[p][q] = 1; roads[q][p] = 1; } int r, s; for (int i = 1; i <= L; i++) { cin >> r >> s; rails[r][s] = 1; rails[s][r] = 1; } for (p = 1; p <= N; p++) { rec_roads(p, p); } for (r = 1; r <= N; r++) { rec_rails(r, r); } for (int i = 1; i <= N; i++) { int cnt = 0; for (int j = 1; j <= N; j++) { if (c_roads[i] == c_roads[j] && c_rails[i] == c_rails[j]) cnt += 1; } cout << cnt; if (i != N) cout << " "; } cout << endl; return 0; }
/tmp/ccnK1n7S.o: in function `rec_roads(int, int)': a.cc:(.text+0x55): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccnK1n7S.o /tmp/ccnK1n7S.o: in function `rec_rails(int, int)': a.cc:(.text+0x114): relocation truncated to fit: R_X86_64_PC32 against symbol `rails' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x130): relocation truncated to fit: R_X86_64_PC32 against symbol `c_rails' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x15a): relocation truncated to fit: R_X86_64_PC32 against symbol `rails' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x185): relocation truncated to fit: R_X86_64_PC32 against symbol `rails' defined in .bss section in /tmp/ccnK1n7S.o /tmp/ccnK1n7S.o: in function `main': a.cc:(.text+0x233): relocation truncated to fit: R_X86_64_PC32 against symbol `rails' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x33e): relocation truncated to fit: R_X86_64_PC32 against symbol `rails' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x369): relocation truncated to fit: R_X86_64_PC32 against symbol `rails' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x40f): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x426): relocation truncated to fit: R_X86_64_PC32 against symbol `c_roads' defined in .bss section in /tmp/ccnK1n7S.o a.cc:(.text+0x441): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s231590463
p03857
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1e9+7 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) #define loop(i,x,n) for(int i=(x);i<(n);i++) #define all(v) (v).begin(),(v).end() #define int long long using namespace std; struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) { } bool unite(int x, int y) { x = root(x); y = root(y); if(x==y)return false; if(par[y]<par[x])swap(x,y); par[x]+=par[y];par[y]=x; return true; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -par[root(x)]; } int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); } };; map<ll,ll>mama; signed main(){ ll n,k,l; cin>>n>>k>>l; UnionFind uni(n); UnionFind uni2(n); for(int i=0;i<k;i++){ int p,q;cin>>p>>q;p--;q--; uni.unite(p,q); } for(int i=0;i<l;i++){ int p,q;cin>>p>>q;p--;q--; uni2.unite(p,q); } vector<pair<int,int> >num1(n); vector<pair<int,int> >num2(n); for(int i=0;i<n;i++){ num1[i]=mp(uni.root(i),uni2.root(i)); num2[i].mp(uni.root(i),uni2.root(i)); } sort(num1.begin(),num1.end()); int cnt=1; for(int i=0;i<n-1;i++){ while(num1[i].F==num1[i+1].F&&num1[i].S==num1[i+1].S&&i!=n-2){ cnt++; i++; } if(i==n-2&&num1[i].F==num1[i+1].F&&num1[i].S==num1[i+1].S) mama[num1[i].F*(1e6)+num1[i].S]=(cnt+1); else mama[num1[i].F*(1e6)+num1[i].S]=(cnt); } for(int i=0;i<n;i++){ cout<<mama[num2[i].F*(1e6)+num2[i].S]; if(i!=n-1) cout<<" "; } cout<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:12: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<long long int, long long int> >, std::pair<long long int, long long int> >::value_type' {aka 'struct std::pair<long long int, long long int>'} has no member named 'make_pair' 7 | #define mp make_pair | ^~~~~~~~~ a.cc:61:13: note: in expansion of macro 'mp' 61 | num2[i].mp(uni.root(i),uni2.root(i)); | ^~
s326539308
p03857
C++
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1e9+7 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long using namespace std; #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) #define loop(i,x,n) for(int i=(x);i<(n);i++) #define all(v) (v).begin(),(v).end() #define int long long using namespace std; const int MOD=1e9+7; const int INF=1e10; struct UnionFind { vector<int> par; UnionFind(int n) : par(n, -1) { } bool unite(int x, int y) { x = root(x); y = root(y); if(x==y)return false; if(par[y]<par[x])swap(x,y); par[x]+=par[y];par[y]=x; return true; } bool same(int x, int y) { return root(x) == root(y); } int size(int x) { return -par[root(x)]; } int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); } }; map<ll,ll>mama; int main(){ ll n,k,l; cin>>n>>k>>l; UnionFind uni(n); UnionFind uni2(n); for(int i=0;i<k;i++){ int p,q;cin>>p>>q;p--;q--; uni.unite(p,q); } for(int i=0;i<l;i++){ int p,q;cin>>p>>q;p--;q--; uni2.unite(p,q); } vector<pair<int,int> >num1(n); for(int i=0;i<n;i++){ num1[i]=mp(uni.root(i),uni2.root(i)); } sort(num1.begin(),num1.end()); int cnt=1; for(int i=0;i<n-1;i++){ while(num1[i].F==num1[i+1].F&&num1[i].S==num1[i+1].S&&i!=n-2){ cnt++; i++; } if(i==n-2&&num1[i].F==num1[i+1].F&&num1[i].S==num1[i+1].S) mama[num1[i].F*(1e6)+num1[i].S]=(cnt+1); else mama[num1[i].F*(1e6)+num1[i].S]=(cnt); } for(int i=0;i<n;i++){ cout<<mama[num1[i].F*(1e6)+num1[i].S]; f(i!=n-1) cout<<" "; } cout<<endl; return 0; }
a.cc:5:13: error: expected unqualified-id before numeric constant 5 | #define MOD 1e9+7 | ^~~ a.cc:18:11: note: in expansion of macro 'MOD' 18 | const int MOD=1e9+7; | ^~~ a.cc:3:13: error: expected unqualified-id before numeric constant 3 | #define INF 1e9 | ^~~ a.cc:19:11: note: in expansion of macro 'INF' 19 | const int INF=1e10; | ^~~ cc1plus: error: '::main' must return 'int' a.cc: In function 'int main()': a.cc:76:5: error: 'f' was not declared in this scope 76 | f(i!=n-1) | ^
s109377309
p03857
C++
#include <bits/stdc++.h> using namespace std; vector<int> R, T; int find_node_r(int now){ if(now == R[now]) return now; else{ int ans = find_node_r(R[now]); R[now] = ans; return ans; } } int find_node_t(int now){ if(now == T[now]) return now; else{ int ans = find_node_t(T[now]); T[now] = ans; return ans; } } int main(){ int n, k, l; cin >> n >> k >> l; R.resize(n); T.resize(n); for(int i = 0; i < n; i++){ R[i] = i; T[i] = i; } for(int i = 0; i < k; i++){ int p, q; cin >> p >> q; p--; q--; R[find_node_r(p)] = find_node_r(q); } for(int i = 0; i < l; i++){ int r, s; cin >> r >> s; r--; s--; T[find_node_t(r)] = find_node_t(s); } int A[n] = {}; for(int i = 0; i < n; i++){ if(D[]) } return 0; }
a.cc: In function 'int main()': a.cc:49:12: error: 'D' was not declared in this scope 49 | if(D[]) | ^ a.cc:49:14: error: expected primary-expression before ']' token 49 | if(D[]) | ^ a.cc:50:5: error: expected primary-expression before '}' token 50 | } | ^
s314529051
p03857
C++
#include <map> #include <cmath> #include <queue> #include <stack> #include <vector> #include <cstdio> #include <string> #include <cstring> #include <sstream> #include <algorithm> using namespace std; int ro[200005], ra[200005], n, k, l; int Find(int *r, int x) { return r[x]==x ? x : r[x]=Find(r, r[x]); } void init() { for(int i=1;i<=n;i++) { ┊ ra[i]=ro[i]=i; } } vector <int> ve[200005]; map <int, int> ma; int ans[200005]; int main () { int u, v; scanf("%d%d%d", &n, &k, &l); init(); for(int i=1;i<=k;i++) { ┊ scanf("%d%d", &u, &v); ┊ u=Find(ro, u), v=Find(ro, v); ┊ if(u!=v) { ┊ ┊ ro[u]=v; ┊ } } for(int i=1;i<=l;i++) { ┊ scanf("%d%d", &u, &v); ┊ u=Find(ra, u), v=Find(ra, v); ┊ if(u!=v) { ┊ ┊ ra[u]=v; ┊ } } for(int i=1;i<=n;i++) { ┊ ve[Find(ro, i)].push_back(i); } for(int i=1;i<=n;i++) { ┊ ma.clear(); ┊ for(int j=0;j<(int)ve[i].size();j++) { ┊ ┊ ma[Find(ra, ve[i][j])]++; ┊ } ┊ for(int j=0;j<(int)ve[i].size();j++) { ┊ ┊ ans[ve[i][j]]+=ma[Find(ra, ve[i][j])]; ┊ } } for(int i=1;i<=n;i++) { ┊ printf("%d%c", ans[i], i==n ? '\n' : ' '); } return 0; }
a.cc:22:5: error: extended character ┊ is not valid in an identifier 22 | ┊ ra[i]=ro[i]=i; | ^ a.cc:35:5: error: extended character ┊ is not valid in an identifier 35 | ┊ scanf("%d%d", &u, &v); | ^ a.cc:36:5: error: extended character ┊ is not valid in an identifier 36 | ┊ u=Find(ro, u), v=Find(ro, v); | ^ a.cc:37:5: error: extended character ┊ is not valid in an identifier 37 | ┊ if(u!=v) { | ^ a.cc:38:5: error: extended character ┊ is not valid in an identifier 38 | ┊ ┊ ro[u]=v; | ^ a.cc:38:9: error: extended character ┊ is not valid in an identifier 38 | ┊ ┊ ro[u]=v; | ^ a.cc:39:5: error: extended character ┊ is not valid in an identifier 39 | ┊ } | ^ a.cc:43:5: error: extended character ┊ is not valid in an identifier 43 | ┊ scanf("%d%d", &u, &v); | ^ a.cc:44:5: error: extended character ┊ is not valid in an identifier 44 | ┊ u=Find(ra, u), v=Find(ra, v); | ^ a.cc:45:5: error: extended character ┊ is not valid in an identifier 45 | ┊ if(u!=v) { | ^ a.cc:46:5: error: extended character ┊ is not valid in an identifier 46 | ┊ ┊ ra[u]=v; | ^ a.cc:46:9: error: extended character ┊ is not valid in an identifier 46 | ┊ ┊ ra[u]=v; | ^ a.cc:47:5: error: extended character ┊ is not valid in an identifier 47 | ┊ } | ^ a.cc:51:5: error: extended character ┊ is not valid in an identifier 51 | ┊ ve[Find(ro, i)].push_back(i); | ^ a.cc:55:5: error: extended character ┊ is not valid in an identifier 55 | ┊ ma.clear(); | ^ a.cc:56:5: error: extended character ┊ is not valid in an identifier 56 | ┊ for(int j=0;j<(int)ve[i].size();j++) { | ^ a.cc:57:5: error: extended character ┊ is not valid in an identifier 57 | ┊ ┊ ma[Find(ra, ve[i][j])]++; | ^ a.cc:57:9: error: extended character ┊ is not valid in an identifier 57 | ┊ ┊ ma[Find(ra, ve[i][j])]++; | ^ a.cc:58:5: error: extended character ┊ is not valid in an identifier 58 | ┊ } | ^ a.cc:60:5: error: extended character ┊ is not valid in an identifier 60 | ┊ for(int j=0;j<(int)ve[i].size();j++) { | ^ a.cc:61:5: error: extended character ┊ is not valid in an identifier 61 | ┊ ┊ ans[ve[i][j]]+=ma[Find(ra, ve[i][j])]; | ^ a.cc:61:9: error: extended character ┊ is not valid in an identifier 61 | ┊ ┊ ans[ve[i][j]]+=ma[Find(ra, ve[i][j])]; | ^ a.cc:62:5: error: extended character ┊ is not valid in an identifier 62 | ┊ } | ^ a.cc:66:5: error: extended character ┊ is not valid in an identifier 66 | ┊ printf("%d%c", ans[i], i==n ? '\n' : ' '); | ^ a.cc: In function 'void init()': a.cc:22:5: error: '\U0000250a' was not declared in this scope 22 | ┊ ra[i]=ro[i]=i; | ^ a.cc: In function 'int main()': a.cc:35:5: error: '\U0000250a' was not declared in this scope 35 | ┊ scanf("%d%d", &u, &v); | ^ a.cc:36:6: error: expected ';' before 'u' 36 | ┊ u=Find(ro, u), v=Find(ro, v); | ^ ~ | ; a.cc:37:6: error: expected ';' before 'if' 37 | ┊ if(u!=v) { | ^ ~~ | ; a.cc:43:5: error: '\U0000250a' was not declared in this scope 43 | ┊ scanf("%d%d", &u, &v); | ^ a.cc:44:6: error: expected ';' before 'u' 44 | ┊ u=Find(ra, u), v=Find(ra, v); | ^ ~ | ; a.cc:45:6: error: expected ';' before 'if' 45 | ┊ if(u!=v) { | ^ ~~ | ; a.cc:51:5: error: '\U0000250a' was not declared in this scope 51 | ┊ ve[Find(ro, i)].push_back(i); | ^ a.cc:55:5: error: '\U0000250a' was not declared in this scope 55 | ┊ ma.clear(); | ^ a.cc:56:6: error: expected ';' before 'for' 56 | ┊ for(int j=0;j<(int)ve[i].size();j++) { | ^ ~~~ | ; a.cc:56:21: error: 'j' was not declared in this scope 56 | ┊ for(int j=0;j<(int)ve[i].size();j++) { | ^ a.cc:60:6: error: expected ';' before 'for' 60 | ┊ for(int j=0;j<(int)ve[i].size();j++) { | ^ ~~~ | ; a.cc:66:5: error: '\U0000250a' was not declared in this scope 66 | ┊ printf("%d%c", ans[i], i==n ? '\n' : ' '); | ^
s298729644
p03857
C++
#include<bits/stdc++.h> using namespace std; const int N = 2*1e5; int n; int Find(int *f, int x) { if(f[x] == x) return x; else { f[x] = Find(f, f[x]); return f[x]; } } void Merge(int *f, int x, int y) { x = Find(f, x); y = Find(f, y); if(x != y) f[y] = x; } int f[N], g[N], vis[N]; vector<int> vec[N]; map<int, int> q; void init() { for(int i = 0; i <= n; i++) f[i] = g[i] = i; } int main() { int k, l, u, v; scanf("%d %d %d", &n, &k, &l) init(); while(k--) { scanf("%d %d", &u, &v); Merge(f, u, v); } while(l--) { scanf("%d %d", &u, &v); Merge(g, u, v); } memset(vis, 0, sizeof(vis)); for(int i = 1; i <= n; i++) vec[Find(f, i)].push_back(i); for(int i = 1; i <= n; i++) { q.clear(); for(int j = 0; j < vec[i].size(); j++) { q[Find(g, vec[i][j])]++; } for(int j = 0; j < vec[i].size(); j++) { vis[vec[i][j]] += q[Find(g, vec[i][j])]; } } for(int i = 1; i <= n; i++) { printf("%d", vis[i]); if(i == n) printf("\n"); else printf(" "); } return 0; }
a.cc: In function 'int main()': a.cc:33:34: error: expected ';' before 'init' 33 | scanf("%d %d %d", &n, &k, &l) | ^ | ; 34 | init(); | ~~~~
s920089436
p03857
C++
#include <iostream> #include <math.h> #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f #define maxn 310000 using namespace std; struct node { int x,y; }; map<pair<int,int>,int>mp; NIT(int a[],int n) { for(int i=1; i<=n; i++) a[i]=i; } int Find(int a[],int x) { return a[x]==x?x:a[x]=Find(a,a[x]); } void marge(int a[],int x,int y) { int fx=Find(a,x); int fy=Find(a,y); if(fx!=fy) { a[fx]=fy; } } int main() { int a[200100],b[200100]; int n,k,l,i,j,u,v; scanf("%d%d%d",&n,&k,&l); NIT(a,n); NIT(b,n); for(int i=1; i<=k; i++) { scanf("%d%d",&u,&v); marge(a,u,v); } for(int i=1; i<=l; i++) { scanf("%d%d",&u,&v); marge(b,u,v); } node tp; for(int i=1; i<=n; i++) { tp.x=Find(a,i); tp.y=Find(b,i); mp[ {tp.x,tp.y}]++; } int first=1; for(int i=1; i<=n; i++) { if(!first) printf(" "); tp.x=Find(a,i); tp.y=Find(b,i); printf("%d",mp[ {tp.x,tp.y}]); first=0; } printf("\n"); return 0; }
a.cc:13:1: error: ISO C++ forbids declaration of 'NIT' with no type [-fpermissive] 13 | NIT(int a[],int n) | ^~~ a.cc: In function 'int NIT(int*, int)': a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type] 17 | } | ^
s170190599
p03857
C++
#include<iostream> #include <math.h> #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f #define maxn 310000 using namespace std; struct node { int x,y; }; map<pair<int,int>,int>mp; Init(int a[],int n) { for(int i=1;i<=n;i++) a[i]=i; } int Find(int a[],int x) { return a[x]==x?x:a[x]=Find(a,a[x]); } void marge(int a[],int x,int y) { int fx=Find(a,x); int fy=Find(a,y); if(fx!=fy) { a[fx]=fy; } } int main() { int a[200100],b[200100]; int n,k,l,i,j,u,v; scanf("%d%d%d",&n,&k,&l); Init(a,n); Init(b,n); for(int i=1;i<=k;i++) { scanf("%d%d",&u,&v); marge(a,u,v); } for(int i=1;i<=l;i++) { scanf("%d%d",&u,&v); marge(b,u,v); } node tp; for(int i=1;i<=n;i++) { tp.x=Find(a,i); tp.y=Find(b,i); mp[{tp.x,tp.y}]++; } int first=1; for(int i=1;i<=n;i++) { if(!first) printf(" "); tp.x=Find(a,i); tp.y=Find(b,i); printf("%d",mp[{tp.x,tp.y}]); first=0; } printf("\n"); return 0; }
a.cc:13:1: error: ISO C++ forbids declaration of 'Init' with no type [-fpermissive] 13 | Init(int a[],int n) | ^~~~ a.cc: In function 'int Init(int*, int)': a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type] 17 | } | ^
s217386469
p03857
C++
#include<iostream> #include <math.h> #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f #define maxn 310000 using namespace std; struct node { int x,y; }; map<pair<int,int>,int>mp; Init(int a[],int n) { for(int i=1;i<=n;i++) a[i]=i; } int Find(int a[],int x) { return a[x]==x?x:a[x]=Find(a,a[x]); } void marge(int a[],int x,int y) { int fx=Find(a,x); int fy=Find(a,y); if(fx!=fy) { a[fx]=fy; } } int main() { int a[200100],b[200100]; int n,k,l,i,j,u,v; scanf("%d%d%d",&n,&k,&l); Init(a,n); Init(b,n); for(int i=1;i<=k;i++) { scanf("%d%d",&u,&v); marge(a,u,v); } for(int i=1;i<=l;i++) { scanf("%d%d",&u,&v); marge(b,u,v); } node tp; for(int i=1;i<=n;i++) { tp.x=Find(a,i); tp.y=Find(b,i); mp[{tp.x,tp.y}]++; } int first=1; for(int i=1;i<=n;i++) { if(!first) printf(" "); tp.x=Find(a,i); tp.y=Find(b,i); printf("%d",mp[{tp.x,tp.y}]); first=0; } printf("\n"); return 0; }
a.cc:13:1: error: ISO C++ forbids declaration of 'Init' with no type [-fpermissive] 13 | Init(int a[],int n) | ^~~~ a.cc: In function 'int Init(int*, int)': a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type] 17 | } | ^
s849420513
p03857
C++
#include<iostream> #include <math.h> #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f #define maxn 310000 using namespace std; struct node { int x,y; }; map<pair<int,int>,int>mp; Init(int a[],int n) { for(int i=1;i<=n;i++) a[i]=i; } int Find(int a[],int x) { return a[x]==x?x:a[x]=Find(a,a[x]); } void marge(int a[],int x,int y) { int fx=Find(a,x); int fy=Find(a,y); if(fx!=fy) { a[fx]=fy; } } int main() { int a[200100],b[200100]; int n,k,l,i,j,u,v; scanf("%d%d%d",&n,&k,&l); Init(a,n); Init(b,n); for(int i=1;i<=k;i++) { scanf("%d%d",&u,&v); marge(a,u,v); } for(int i=1;i<=l;i++) { scanf("%d%d",&u,&v); marge(b,u,v); } node tp; for(int i=1;i<=n;i++) { tp.x=Find(a,i); tp.y=Find(b,i); mp[{tp.x,tp.y}]++; } int first=1; for(int i=1;i<=n;i++) { if(!first) printf(" "); tp.x=Find(a,i); tp.y=Find(b,i); printf("%d",mp[{tp.x,tp.y}]); first=0; } printf("\n"); return 0; }
a.cc:13:1: error: ISO C++ forbids declaration of 'Init' with no type [-fpermissive] 13 | Init(int a[],int n) | ^~~~ a.cc: In function 'int Init(int*, int)': a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type] 17 | } | ^
s537999187
p03857
C++
#include<iostream> #include <math.h> #include <bits/stdc++.h> #define ll long long #define inf 0x3f3f3f3f #define maxn 310000 using namespace std; struct node { int x,y; }; map<pair<int,int>,int>mp; init(int a[],int n) { for(int i=1;i<=n;i++) a[i]=i; } int Find(int a[],int x) { return a[x]==x?x:a[x]=Find(a,a[x]); } void marge(int a[],int x,int y) { int fx=Find(a,x); int fy=Find(a,y); if(fx!=fy) { a[fx]=fy; } } int main() { int a[200100],b[200100]; int n,k,l,i,j,u,v; scanf("%d%d%d",&n,&k,&l); init(a,n); init(b,n); for(int i=1;i<=k;i++) { scanf("%d%d",&u,&v); marge(a,u,v); } for(int i=1;i<=l;i++) { scanf("%d%d",&u,&v); marge(b,u,v); } node tp; for(int i=1;i<=n;i++) { tp.x=Find(a,i); tp.y=Find(b,i); mp[{tp.x,tp.y}]++; } int first=1; for(int i=1;i<=n;i++) { if(!first) printf(" "); tp.x=Find(a,i); tp.y=Find(b,i); printf("%d",mp[{tp.x,tp.y}]); first=0; } printf("\n"); return 0; }
a.cc:13:1: error: ISO C++ forbids declaration of 'init' with no type [-fpermissive] 13 | init(int a[],int n) | ^~~~ a.cc: In function 'int init(int*, int)': a.cc:17:1: warning: no return statement in function returning non-void [-Wreturn-type] 17 | } | ^
s154393389
p03857
C++
#include <assert.h> #include <cmath> #include <cstdio> #include <cstdlib> #include <cstring> #include <climits> #include <algorithm> #include <numeric> #include <functional> #include <iostream> #include <string> #include <array> #include <vector> #include <stack> #include <queue> #include <set> #include <map> #include <complex> #include <bitset> typedef long long ll; typedef unsigned long long ull; #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define DEBUG(vec) for (auto v : vec) { cout << v << " "; } cout << endl; using namespace std; // Union-Find木 template <typename T> struct UnionFind { int n; // vector<T> par; vector<T> rank; public: explicit UnionFind(int n) { this->n = n; par = vector<T>(n, 0); iota(par.begin(), par.end(), 0); rank = vector<T>(n, 0); } // 木の根を求める T root(T x) { if (par[x] == x) { return x; } else { return par[x] = root(par[x]); } } // x と y が同じ集合に属するか調べる bool same(T x, T y) { return root(x) == root(y); } // x と y が属する集合を併合する void unite(T x, T y) { x = root(x); y = root(y); if (x == y) return; if (rank[x] < rank[y]) { par[x] = y; } else { par[y] = x; if (rank[x] == rank[y]) rank[x]++; } } // 連結成分の数を数える int groups() { int ans = 0; for (int i = 0; i < n; i++) { // グループには根が自分と同じものが一つずつある if (par[i] == i) ans++; } return ans; } }; // カウンター template <typename T> struct Counter { map<T, ull> cnt; void add(T key) { if (cnt.count(key)) { cnt[key]++; } else { cnt[key] = 1; } } void add(vector<T> keys) { for (auto key : keys) { add(key); } } ll get(T key) { if (cnt.count(key)) { return cnt[key]; } else { return 0; } } pair<T, ull> max() { T key; ull mx = 0; for (auto kv : cnt) { if (kv.second > mx) { mx = kv.second; key = kv.first; } } return make_pair(key, mx); } typename map<T, ll>::iterator begin() { return cnt.begin(); } typename map<T, ll>::iterator end() { return cnt.end(); } typename map<T, ll>::reverse_iterator rbegin() { return cnt.rbegin(); } typename map<T, ll>::reverse_iterator rend() { return cnt.rend(); } }; int main() { cin.tie(0); ios::sync_with_stdio(false); int N, K, L; cin >> N >> K >> L; UnionFind<int> road(N); UnionFind<int> rail(N); REP(i, K) { int p, q; cin >> p >> q; p--; q--; road.unite(p, q); } REP(i, L) { int r, s; cin >> r >> s; r--; s--; rail.unite(r, s); } Counter<pair<int, int>> c; REP(i, N) { c.add(make_pair(road.root(i), rail.root(i))); } REP(i, N) { cout << c.get(make_pair(road.root(i), rail.root(i))); if (i < N - 1) { cout << " "; } } cout << endl; return 0; }
a.cc: In constructor 'UnionFind<T>::UnionFind(int)': a.cc:39:5: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 39 | par = vector<T>(n, 0); | ^~~ | __pstl::execution::v1::par In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15, from /usr/include/c++/14/algorithm:86, from a.cc:7: /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc: In member function 'T UnionFind<T>::root(T)': a.cc:45:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 45 | if (par[x] == x) { | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc: In member function 'void UnionFind<T>::unite(T, T)': a.cc:61:7: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 61 | par[x] = y; | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc:63:7: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 63 | par[y] = x; | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc: In member function 'int UnionFind<T>::groups()': a.cc:72:11: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 72 | if (par[i] == i) ans++; | ^~~ | __pstl::execution::v1::par /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~
s785646120
p03857
C++
#include <map> #include <algorithm> #include <cstdio> #include <iostream> #include <vector> using namespace std; #define REP(i,y) for(int i=0;i<(int)(y);i++) int N,K,L; class UnionFind { vector<int> p; // rank public: UnionFind (int n) : p(n, -1) {} int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); } bool same(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (p[y] < p[x]) swap(x, y); if (p[x] == p[y]) --p[x]; p[y] = x; return true; } }; multimap<int, int> mp1; multimap<int, int> mp2; //int memo[200010][200010]; map<pair<int,int>,int> memo; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K >> L; UnionFind uf1(N), uf2(N); REP(i,K) { int p,q; cin>>p>>q; p--,q--; uf1.unite(p,q); } REP(i,L) { int r,s; cin>>r>>s; r--,s--; uf2.unite(r,s); } REP(i,N) { mp1.emplace(uf1.root(i), i); mp2.emplace(uf2.root(i), i); } REP(i,N) { int r1 = uf1.root(i), r2 = uf2.root(i); if (memo[r1][r2]) cout << memo[r1][r2] << " "; else { int cnt=0; auto p1 = mp1.equal_range(r1); auto p2 = mp2.equal_range(r2); auto it1 = p1.first; auto it2 = p2.first; while (it1!=p1.second && it2!=p2.second) { int s = it1->second; int t = it2->second; if (s==t) cnt++, it2++; if (s<t) it1++; if (s>t) it2++; } cout << cnt << " "; } } cout << endl; }
a.cc: In function 'int main()': a.cc:54:13: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int') 54 | if (memo[r1][r2]) | ^ In file included from /usr/include/c++/14/map:63, from a.cc:1: /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~ a.cc:55:19: error: no match for 'operator[]' (operand types are 'std::map<std::pair<int, int>, int>' and 'int') 55 | cout << memo[r1][r2] << " "; | ^ /usr/include/c++/14/bits/stl_map.h:504:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 504 | operator[](const key_type& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:504:34: note: no known conversion for argument 1 from 'int' to 'const std::map<std::pair<int, int>, int>::key_type&' {aka 'const std::pair<int, int>&'} 504 | operator[](const key_type& __k) | ~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_map.h:524:7: note: candidate: 'std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](key_type&&) [with _Key = std::pair<int, int>; _Tp = int; _Compare = std::less<std::pair<int, int> >; _Alloc = std::allocator<std::pair<const std::pair<int, int>, int> >; mapped_type = int; key_type = std::pair<int, int>]' 524 | operator[](key_type&& __k) | ^~~~~~~~ /usr/include/c++/14/bits/stl_map.h:524:29: note: no known conversion for argument 1 from 'int' to 'std::map<std::pair<int, int>, int>::key_type&&' {aka 'std::pair<int, int>&&'} 524 | operator[](key_type&& __k) | ~~~~~~~~~~~^~~
s830697613
p03857
C++
#include <map> #include <algorithm> #include <cassert> #include <climits> #include <complex> #include <cstdio> #include <string> #include <iostream> #include <queue> #include <string> #include <tuple> #include <vector> using namespace std; #define FOR(i,x,y) for(int i=(x);i<(int)(y);i++) #define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++) #define REP(i,y) for(int i=0;i<(int)(y);i++) #define REPP(i,y) for(int i=1;i<=(int)(y);i++) #define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--) int N,K,L; class UnionFind { vector<int> p; // rank public: UnionFind (int n) : p(n, -1) {} int root(int x) { return p[x] < 0 ? x : p[x] = root(p[x]); } bool same(int x, int y) { return root(x) == root(y); } bool unite(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (p[y] < p[x]) swap(x, y); if (p[x] == p[y]) --p[x]; p[y] = x; return true; } }; unordered_multimap<int, int> mp1; unordered_multimap<int, int> mp2; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K >> L; UnionFind uf1(N), uf2(N); REP(i,K) { int p,q; cin>>p>>q; p--,q--; uf1.unite(p,q); } REP(i,L) { int r,s; cin>>r>>s; r--,s--; uf2.unite(r,s); } REP(i,N) { mp1.emplace(uf1.root(i), i); mp2.emplace(uf2.root(i), i); } REP(i,N) { int cnt=0; auto p1 = mp1.equal_range(uf1.root(i)); auto p2 = mp2.equal_range(uf2.root(i)); auto it1 = p1.first; auto it2 = p2.first; while (it1!=p1.second && it2!=p2.second) { int s = it1->second; int t = it2->second; if (s==t) cnt++, it2++; if (s<t) it1++; if (s>t) it2++; } cout << cnt << " "; } cout << endl; }
a.cc:42:1: error: 'unordered_multimap' does not name a type 42 | unordered_multimap<int, int> mp1; | ^~~~~~~~~~~~~~~~~~ a.cc:43:1: error: 'unordered_multimap' does not name a type 43 | unordered_multimap<int, int> mp2; | ^~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:58:5: error: 'mp1' was not declared in this scope 58 | mp1.emplace(uf1.root(i), i); | ^~~ a.cc:59:5: error: 'mp2' was not declared in this scope 59 | mp2.emplace(uf2.root(i), i); | ^~~ a.cc:63:15: error: 'mp1' was not declared in this scope; did you mean 'p1'? 63 | auto p1 = mp1.equal_range(uf1.root(i)); | ^~~ | p1 a.cc:64:15: error: 'mp2' was not declared in this scope; did you mean 'p2'? 64 | auto p2 = mp2.equal_range(uf2.root(i)); | ^~~ | p2
s703407347
p03857
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; typedef pair<long long, long long> pii; typedef pair<long long, pair<int, int> > triple; #define REP(i, n) for(int i=0; i<n; i++) int const max_n = 100000; int n, k, l; int c[max_n]; bool road[max_n][max_n]; int par1[max_n], par2[max_n]; int r1[max_n], r2[max_n]; void init(int n, int (&par)[max_n], int (&r)[max_n]){ REP(i, n){ par[i] = i; r[i] = 0; } } int find(int x, int (&par)[max_n]){ if(par[x] == x){ return x; } else { return par[x] = find(par[x], par); } } void unite(int x, int y, int (&par)[max_n], int (&r)[max_n]){ x = find(x, par); y = find(y, par); if(x == y) return; if(r[x] < r[y]){ par[x] = y; } else { par[y] = x; if(r[x] == r[y]) r[x]++; } } bool same(int x, int y, int (&par)[max_n]){ return find(x, par) == find(y, par); } int main(){ cin >> n >> k >> l; init(n, par1, r1); REP(i, k){ int p, q; cin >> p >> q; unite(p-1, q-1, par1, r1); } init(n, par2, r2); REP(i, l){ int r, s; cin >> r >> s; if(same(r-1, s-1, par1)){ unite(r-1, s-1, par2, r2); } } REP(i, n) c[i] = 0; REP(i, n) c[find(i, par2)] += 1; REP(i, n){ cout << c[find(i, par2)]; if(i<n-1){ cout << " "; } else { cout << endl; } } }
/tmp/ccMnmC38.o: in function `main': a.cc:(.text+0x202): relocation truncated to fit: R_X86_64_PC32 against symbol `r1' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x209): relocation truncated to fit: R_X86_64_PC32 against symbol `par1' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x257): relocation truncated to fit: R_X86_64_PC32 against symbol `r1' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `par1' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x284): relocation truncated to fit: R_X86_64_PC32 against symbol `r2' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x28b): relocation truncated to fit: R_X86_64_PC32 against symbol `par2' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x2d9): relocation truncated to fit: R_X86_64_PC32 against symbol `par1' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x2f9): relocation truncated to fit: R_X86_64_PC32 against symbol `r2' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x303): relocation truncated to fit: R_X86_64_PC32 against symbol `par2' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x35f): relocation truncated to fit: R_X86_64_PC32 against symbol `par2' defined in .bss section in /tmp/ccMnmC38.o a.cc:(.text+0x3b7): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s083482605
p03857
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<functional> #include<algorithm> #include<cstdio> #include<unordered_map> using namespace std; //--------------------------------------------------- //ライブラリゾーン!!!! #define int long long #define str string #define rep(i,j) for(int i=0;i<(int)(j);i++) typedef long long ll; typedef long double ld; const ll inf = 999999999999999999; const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989; struct P { ll pos, cost; }; bool operator<(P a, P b) { return a.cost < b.cost; } bool operator>(P a, P b) { return a.cost > b.cost; } struct B {//隣接リスト表現 ll to, cost; }; struct S {//辺の情報を入れる変数 int from, to, cost; }; ll gcm(ll i, ll j) {//最大公約数 if (i > j) swap(i, j); if (i == 0) return j; return gcm(j%i, i); } //--------------------------------------------------- //+++++++++++++++++++++++++++++++++++++++++++++++++++ int n,k,l; int pa[200001],pb[200001]; int root1(int x){ if(pa[x]==x) return x; return pa[x]=root1(pa[x]); } int root2(int x){ if(pb[x]==x) return x; return pb[x]=root2(x); } void unite1(int a,int b){ pa[root1(a)]=root1(b); } void unite2(int a,int b){ pb[root2(a)]=root2(b); } struct A{ int a,b; }; signed main() { cin>>n>>k>>l; for(int i=1;i<=n;i++){ pa[i]=i,pb[i]=i; } for(int i=0;i<k;i++){ int u1,u2; cin>>u1>>u2; unite(u1,u2); } for(int i=0;i<l;i++){ int u1,u2; cin>>u1>>u2; unite(u1,u2); } getchar(); getchar(); }
a.cc: In function 'int main()': a.cc:69:17: error: 'unite' was not declared in this scope; did you mean 'unite2'? 69 | unite(u1,u2); | ^~~~~ | unite2 a.cc:74:17: error: 'unite' was not declared in this scope; did you mean 'unite2'? 74 | unite(u1,u2); | ^~~~~ | unite2
s771396985
p03857
C++
#include <assert.h> #include <ctype.h> #include <errno.h> #include <float.h> #include <fstream> #include <iomanip> #include <iostream> #include <set> #include <queue> #include <limits> #include <deque> #include <locale> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <wchar.h> #include <wctype.h> #include <algorithm> #include <bitset> #include <map> #include <iomanip> #include <ios> #include <iostream> #include <vector> #include <cwchar> #include <cwctype> #define mp make_pair #define fs first #define se second #define memset(a,t) memset(a,t,sizeof(a)) #define all(v) v.begin(),v.end() #define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr) #define MN 0LL #define Mx 200000005 #define Mn -Mx #define MX 20000000000000005 using namespace std; int readint(){ char c; while(c=getchar(),(c<'0'||c>'9')&&c!='-'); bool flag=(c=='-'); if(flag)c=getchar(); int x=0; while(c>='0'&&c<='9'){ x=x*10+c-48; c=getchar(); } return flag?-x:x; } inline string tos(int x){ string s; while(x) s=(char)(x%10+'0')+s,x/=10; return s; } int cnave[200005][200005]; int a[200005],b[200005]; inline int finda(int t){ if(a[t]==t) return a[t]; int x=finda(a[t]); a[t]=x; return x; } inline int findb(int t){ if(b[t]==t) return b[t]; int x=findb(b[t]); b[t]=x; return x; } int main(){ ios_base::sync_with_stdio(false); int n,p,q,i,j,x,y; cin>>n>>p>>q; for(i=0;i<n;i++) a[i]=b[i]=i; for(i=0;i<p;i++){ cin>>x>>y; x--,y--; a[finda(x)]=finda(y); } for(i=0;i<q;i++){ cin>>x>>y; x--,y--; b[findb(x)]=findb(y); } for(i=0;i<n;i++){ finda(i); findb(i); cnave[a[i]][b[i]]++; } for(i=0;i<n;i++) cout<<cnave[a[i]][b[i]]<<" "; cout<<endl; return 0; }
/tmp/ccGtka3L.o: in function `main': a.cc:(.text+0xfa): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x114): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x12c): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x1a5): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x21e): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x261): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x279): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x2ef): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text+0x306): relocation truncated to fit: R_X86_64_PC32 against symbol `b' defined in .bss section in /tmp/ccGtka3L.o /tmp/ccGtka3L.o: in function `finda(int)': a.cc:(.text._Z5findai[_Z5findai]+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccGtka3L.o a.cc:(.text._Z5findai[_Z5findai]+0x37): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s578227929
p03857
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; #define pii pair<int,int> map<pii, int> Map; int n,m,k; int UF[2][201000]; int Find(int pv, int a) { if(UF[pv][a] = a) return a; return UF[pv][a] = Find(pv, UF[pv][a]); } void Merge(int pv, int a, int b) { a = Find(pv, a); b = Finf(pv, b); if(a != b) UF[pv][a] = b; } int main(){ int i, a, b; scanf("%d%d%d",&n,&m,&k); for(i=1;i<=n;i++)UF[0][i]=UF[1][i]=i; for(i=0;i<m;i++){ cin>>a>>b; Merge(0,a,b); } for(i=0;i<k;i++){ cin>>a>>b; Merge(1,a,b); } for(i=1;i<=n;i++){ Map[pii(Find(0,i),Find(1,i))]++ } for(i=1;i<=n;i++){ printf("%d%c",Map[pii(Find(0,i),Find(1,i))],i==n-1?'\n':' '); } return 0; }
a.cc: In function 'void Merge(int, int, int)': a.cc:28:7: error: 'Finf' was not declared in this scope; did you mean 'sinf'? 28 | b = Finf(pv, b); | ^~~~ | sinf a.cc: In function 'int main()': a.cc:44:36: error: expected ';' before '}' token 44 | Map[pii(Find(0,i),Find(1,i))]++ | ^ | ; 45 | } | ~
s460626896
p03857
C++
#include<stdio.h> #include<algorithm> #include<map> using namespace std; #define pii pair<int,int> map<pii, int> Map; int n,m,k; int UF[2][201000]; int Find(int pv, int a) { if(UF[pv][a] = a) return a; return UF[pv][a] = Find(pv, UF[pv][a]); } void Merge(int pv, int a, int b) { a = Find(pv, a); b = Finf(pv, b); if(a != b) UF[pv][a] = b; } int main(){ int i, a, b; scanf("%d%d%d",&n,&m,&k); for(i=1;i<=n;i++)UF[0][i]=UF[1][i]=i; for(i=0;i<m;i++){ cin>>a>>b; Merge(0,a,b); } for(i=0;i<k;i++){ cin>>a>>b; Merge(1,a,b); } for(i=1;i<=n;i++){ MAP[pii(Find(0,i),Find(1,i))]++ } for(i=1;i<=n;i++){ printf("%d%c",MAP[pii(Find(0,i),Find(1,i))],i==n-1?'\n':' '); } return 0; }
a.cc: In function 'void Merge(int, int, int)': a.cc:15:7: error: 'Finf' was not declared in this scope; did you mean 'Find'? 15 | b = Finf(pv, b); | ^~~~ | Find a.cc: In function 'int main()': a.cc:23:5: error: 'cin' was not declared in this scope 23 | cin>>a>>b; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include<map> +++ |+#include <iostream> 4 | using namespace std; a.cc:27:5: error: 'cin' was not declared in this scope 27 | cin>>a>>b; | ^~~ a.cc:27:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:5: error: 'MAP' was not declared in this scope; did you mean 'Map'? 31 | MAP[pii(Find(0,i),Find(1,i))]++ | ^~~ | Map a.cc:34:19: error: 'MAP' was not declared in this scope; did you mean 'Map'? 34 | printf("%d%c",MAP[pii(Find(0,i),Find(1,i))],i==n-1?'\n':' '); | ^~~ | Map
s089134502
p03857
C++
#include<stdio.h> #include<algorithm> #include<map> using namespace std; #define pii pair<int,int> map<pii, int> Map; int n,m,k; int UF[2][201000]; int Find(int pv, int x) { if(UF[pv][a] = a) return a; return UF[pv][a] = Find(pv, UF[pv][a]); } void Merge(int pv, int a, int b) { a = Find(pv, a); b = Finf(pv, b); if(a != b) UF[pv][a] = b; } int main(){ int i, a, b; scanf("%d%d%d",&n,&m,&k); for(i=1;i<=n;i++)UF[0][i]=UF[1][i]=i; for(i=0;i<m;i++){ cin>>a>>b; Merge(0,a,b); } for(i=0;i<k;i++){ cin>>a>>b; Merge(1,a,b); } for(i=1;i<=n;i++){ MAP[pii(Find(0,i),Find(1,i))]++ } for(i=1;i<=n;i++){ printf("%d%c",MAP[pii(Find(0,i),Find(1,i))],i==n-1?'\n':' '); } return 0; }
a.cc: In function 'int Find(int, int)': a.cc:10:13: error: 'a' was not declared in this scope 10 | if(UF[pv][a] = a) return a; | ^ a.cc:11:17: error: 'a' was not declared in this scope 11 | return UF[pv][a] = Find(pv, UF[pv][a]); | ^ a.cc: In function 'void Merge(int, int, int)': a.cc:15:7: error: 'Finf' was not declared in this scope; did you mean 'Find'? 15 | b = Finf(pv, b); | ^~~~ | Find a.cc: In function 'int main()': a.cc:23:5: error: 'cin' was not declared in this scope 23 | cin>>a>>b; | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include<map> +++ |+#include <iostream> 4 | using namespace std; a.cc:27:5: error: 'cin' was not declared in this scope 27 | cin>>a>>b; | ^~~ a.cc:27:5: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:31:5: error: 'MAP' was not declared in this scope; did you mean 'Map'? 31 | MAP[pii(Find(0,i),Find(1,i))]++ | ^~~ | Map a.cc:34:19: error: 'MAP' was not declared in this scope; did you mean 'Map'? 34 | printf("%d%c",MAP[pii(Find(0,i),Find(1,i))],i==n-1?'\n':' '); | ^~~ | Map
s639199889
p03857
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; const int nmax = 2 * 100005; typedef pair<int, int> P; map<P, int> MAP; int N, K, L; // union - find tree !!!!!!!!!!!!!!!!!!!!!!!!! vector<int> par[2]; //oya vector<int> rnk[2]; //ki no hu ka sa // n要素で初期化 void init(int n){ FOR(i,0,2){ par[i].resize(n);rnk[i].resize(n); FOR(j, 0, n){par[i][j] = j;rnk[i][j] = 0;} } } //木の根を求める int find(int i, int x){ if(par[i][x] == x) return x; else return par[i][x] = find(par[i][x]); } //xとyの属する集合を併合 void unite(int i, int x, int y){ x = find(x);y = find(y); if(x == y) return; if(rnk[i][x] < rnk[i][y]) par[i][x] = y; else{par[i][y] = x;if(rnk[i][x] == rnk[i][y]) rnk[i][x]++;} return; } bool isSame(int x, int y){return find(x) == find(y);} int main(){ cin >> N >> K >> L; init(N); // 道路で同じ組みかどうか FOR(i,0,N) visit[i] = false; FOR(i,0,K){ int a, b; cin >> a >> b; a--;b--; unite(0,a,b); } // 鉄道で同じかどうか FOR(i,0,N) visit[i] = false; FOR(i,0,L){ int a, b; cin >> a >> b; a--;b--; unite(1,a,b); } FOR (i,0,N) MAP[P(find(0,i),find(1,i))]++; FOR(i,0,N){ printf("%d%c", MAP[P(find(0,i),find(1,i))], i == N - 1 ? '\n' : ' '); } return 0; }
a.cc: In function 'int find(int, int)': a.cc:37:33: error: no matching function for call to 'find(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 37 | else return par[i][x] = find(par[i][x]); | ~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc: In function 'void unite(int, int, int)': a.cc:41:13: error: no matching function for call to 'find(int&)' 41 | x = find(x);y = find(y); | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc:41:25: error: no matching function for call to 'find(int&)' 41 | x = find(x);y = find(y); | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc: In function 'bool isSame(int, int)': a.cc:47:38: error: no matching function for call to 'find(int&)' 47 | bool isSame(int x, int y){return find(x) == find(y);} | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc:47:49: error: no matching function for call to 'find(int&)' 47 | bool isSame(int x, int y){return find(x) == find(y);} | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc: In function 'int main()': a.cc:53:14: error: 'visit' was not declared in this scope 53 | FOR(i,0,N) visit[i] = false; | ^~~~~ a.cc:15:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>' 14 | #include <bitset> +++ |+#include <variant> 15 | using namespace std; a.cc:61:14: error: 'visit' was not declared in this scope 61 | FOR(i,0,N) visit[i] = false; | ^~~~~ a.cc:61:14: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
s454371728
p03857
C++
#include <algorithm> #include <cstdio> #include <iostream> #include <map> #include <cmath> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <vector> #include <stdlib.h> #include <stdio.h> #include <bitset> using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; const int nmax = 2 * 100005; typedef pair<int, int> P; map<P, int> MAP; int N, K, L; // union - find tree !!!!!!!!!!!!!!!!!!!!!!!!! vector<int> par[2]; //oya vector<int> rnk[2]; //ki no hu ka sa // n要素で初期化 void init(int n){ FOR(i,0,2){ par[i].resize(n);rnk[i].resize(n); FOR(j, 0, n){par[i][j] = j;rnk[i][j] = 0;} } } //木の根を求める int find(int i, int x){ if(par[0][x] == x) return x; else return par[0][x] = find(par[0][x]); } //xとyの属する集合を併合 void unite(int i, int x, int y){ x = find(x);y = find(y); if(x == y) return; if(rnk[i][x] < rnk[i][y]) par[i][x] = y; else{par[i][y] = x;if(rnk[i][x] == rnk[i][y]) rnk[i][x]++;} return; } bool isSame(int x, int y){return find(x) == find(y);} int main(){ cin >> N >> K >> L; init(N); // 道路で同じ組みかどうか FOR(i,0,N) visit[i] = false; FOR(i,0,K){ int a, b; cin >> a >> b; a--;b--; unite(0,a,b); } // 鉄道で同じかどうか FOR(i,0,N) visit[i] = false; FOR(i,0,L){ int a, b; cin >> a >> b; a--;b--; unite(1,a,b); } FOR (i,0,N) MAP[P(find(0,par[0][i]),find(1,par[1][i]))]++; FOR(i,0,N){ printf("%d%c", MAP[P(find(0,par[0][i]),find(1,par[1][i]))], i == N - 1 ? '\n' : ' '); } return 0; }
a.cc: In function 'int find(int, int)': a.cc:37:33: error: no matching function for call to 'find(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)' 37 | else return par[0][x] = find(par[0][x]); | ~~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:1: /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc: In function 'void unite(int, int, int)': a.cc:41:13: error: no matching function for call to 'find(int&)' 41 | x = find(x);y = find(y); | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc:41:25: error: no matching function for call to 'find(int&)' 41 | x = find(x);y = find(y); | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc: In function 'bool isSame(int, int)': a.cc:47:38: error: no matching function for call to 'find(int&)' 47 | bool isSame(int x, int y){return find(x) == find(y);} | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc:47:49: error: no matching function for call to 'find(int&)' 47 | bool isSame(int x, int y){return find(x) == find(y);} | ~~~~^~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate: 'template<class _IIter, class _Tp> _IIter std::find(_IIter, _IIter, const _Tp&)' 3842 | find(_InputIterator __first, _InputIterator __last, | ^~~~ /usr/include/c++/14/bits/stl_algo.h:3842:5: note: candidate expects 3 arguments, 1 provided /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)' 60 | find(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value); | ^~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:60:1: note: candidate expects 4 arguments, 1 provided /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT, std::char_traits<_CharT> > >::__type std::find(istreambuf_iterator<_CharT, char_traits<_CharT> >, istreambuf_iterator<_CharT, char_traits<_CharT> >, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate expects 3 arguments, 1 provided a.cc:35:5: note: candidate: 'int find(int, int)' 35 | int find(int i, int x){ | ^~~~ a.cc:35:5: note: candidate expects 2 arguments, 1 provided a.cc: In function 'int main()': a.cc:53:14: error: 'visit' was not declared in this scope 53 | FOR(i,0,N) visit[i] = false; | ^~~~~ a.cc:15:1: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>' 14 | #include <bitset> +++ |+#include <variant> 15 | using namespace std; a.cc:61:14: error: 'visit' was not declared in this scope 61 | FOR(i,0,N) visit[i] = false; | ^~~~~ a.cc:61:14: note: 'std::visit' is defined in header '<variant>'; this is probably fixable by adding '#include <variant>'
s498684124
p03857
C++
#include <bits/stdc++.h> #define REP(i,n) for(int i=0;i<(int)(n);i++) #define ALL(x) (x).begin(),(x).end() #define LL long long using namespace std; bool sortpair(const pair<int,int>& a,const pair<int,int>& b){ return a.first==b.first ? a.second<b.second : a.first<b.first; } int pare[2*100000+1]; int rank[2*100000+1]; int num[2*100000+1]; int find(int p){ if(p==pare[p])return p; return pare[p]=find(pare[p]); } void unite(int p,int q){ p=find(p); q=find(q); if(p==q)return; if(rank[p]>rank[q]){ pare[q]=p; p[num]+=q[num]; }else{ pare[p]=q; q[num]+=p[num]; if(rank[p]==rank[q]){ rank[q]++; } } } int main(){ int N,K,L; cin>>N>>K>>L; REP(i,N){ pare[i+1]=i+1; rank[i+1]=0; } REP(i,K){ int p,q; cin>>p>>q; unite(p,q); } REP(i,N){ num[i+1]=1; } REP(i,L){ int r,s; cin>>r>>s; if(find(r)==find(s)){ num[r]+=num[s]; num[s]=num[r]; } } REP(i,N){ cout<<num[i+1]<<endl; } return 0; }
a.cc: In function 'void unite(int, int)': a.cc:25:8: error: reference to 'rank' is ambiguous 25 | if(rank[p]>rank[q]){ | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:13:5: note: 'int rank [200001]' 13 | int rank[2*100000+1]; | ^~~~ a.cc:25:16: error: reference to 'rank' is ambiguous 25 | if(rank[p]>rank[q]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:13:5: note: 'int rank [200001]' 13 | int rank[2*100000+1]; | ^~~~ a.cc:31:12: error: reference to 'rank' is ambiguous 31 | if(rank[p]==rank[q]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:13:5: note: 'int rank [200001]' 13 | int rank[2*100000+1]; | ^~~~ a.cc:31:21: error: reference to 'rank' is ambiguous 31 | if(rank[p]==rank[q]){ | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:13:5: note: 'int rank [200001]' 13 | int rank[2*100000+1]; | ^~~~ a.cc:32:13: error: reference to 'rank' is ambiguous 32 | rank[q]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:13:5: note: 'int rank [200001]' 13 | int rank[2*100000+1]; | ^~~~ a.cc: In function 'int main()': a.cc:45:9: error: reference to 'rank' is ambiguous 45 | rank[i+1]=0; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:13:5: note: 'int rank [200001]' 13 | int rank[2*100000+1]; | ^~~~
s097409021
p03857
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; #define mp make_pair #define RANK rank map <P,int> ans; int N, K, L; int p[200002]; int rank[200002]; int A[200001]; int B[200001]; void init(int n) { for(int i = 0; i < n; i++) { p[i] = i; rank[i] = 0; } } int Find (int x) { if(p[x] == x) return x; return p[x] = Find(p[x]); } void Union(int x, int y) { int a = Find(x); int b = Find(y); if(a == b) return; else if(rank[a] > rank[b]) { p[a] = b; } else { p[b] = a; if(rank[a] == rank[b]) rank[b]++; } return; } int main() { cin >> N >> K >> L; init(N); for(int i = 0; i < K; i++) { int p,q; cin >> p >> q; p--; q--; Union(p,q); } for(int i = 0; i < N; i++) A[i] = Find(i); init(N); for(int i = 0; i < L; i++) { int r,s; cin >> r >> s; r--; s--; Union(r,s); } for(int i = 0; i < N; i++) B[i] = Find(i); for(int i = 0; i < N; i++) { ans[mp(A[i],B[i])]++; } for(int i = 0; i < N; i++) { cout << ans[mp(A[i],B[i])] <<endl; } }
a.cc: In function 'void init(int)': a.cc:19:5: error: reference to 'rank' is ambiguous 19 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:12:5: note: 'int rank [200002]' 12 | int rank[200002]; | ^~~~ a.cc: In function 'void Union(int, int)': a.cc:33:11: error: reference to 'rank' is ambiguous 33 | else if(rank[a] > rank[b]) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:12:5: note: 'int rank [200002]' 12 | int rank[200002]; | ^~~~ a.cc:33:21: error: reference to 'rank' is ambiguous 33 | else if(rank[a] > rank[b]) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:12:5: note: 'int rank [200002]' 12 | int rank[200002]; | ^~~~ a.cc:38:8: error: reference to 'rank' is ambiguous 38 | if(rank[a] == rank[b]) rank[b]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:12:5: note: 'int rank [200002]' 12 | int rank[200002]; | ^~~~ a.cc:38:19: error: reference to 'rank' is ambiguous 38 | if(rank[a] == rank[b]) rank[b]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:12:5: note: 'int rank [200002]' 12 | int rank[200002]; | ^~~~ a.cc:38:28: error: reference to 'rank' is ambiguous 38 | if(rank[a] == rank[b]) rank[b]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:12:5: note: 'int rank [200002]' 12 | int rank[200002]; | ^~~~
s469037338
p03857
C++
#include <bits/stdc++.h> using namespace std; typedef pair<int,int> P; #define mp make_pair map <P,int> ans; int N, K, L; int p[200002]; int rank[200002]; int A[200001]; int B[200001]; void init(int n) { for(int i = 0; i < n; i++) { p[i] = i; rank[i] = 0; } } int Find (int x) { if(p[x] == x) return x; return p[x] = Find(p[x]); } void Union(int x, int y) { int a = Find(x); int b = Find(y); if(a == b) return; else if(rank[a] > rank[b]) { p[a] = b; } else { p[b] = a; if(rank[a] == rank[b]) rank[b]++; } return; } int main() { cin >> N >> K >> L; init(N); for(int i = 0; i < K; i++) { int p,q; cin >> p >> q; p--; q--; Union(p,q); } for(int i = 0; i < N; i++) A[i] = Find(i); init(N); for(int i = 0; i < L; i++) { int r,s; cin >> r >> s; r--; s--; Union(r,s); } for(int i = 0; i < N; i++) B[i] = Find(i); for(int i = 0; i < N; i++) { ans[mp(A[i],B[i])]++; } for(int i = 0; i < N; i++) { cout << ans[mp(A[i],B[i])] <<endl; } }
a.cc: In function 'void init(int)': a.cc:18:5: error: reference to 'rank' is ambiguous 18 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [200002]' 11 | int rank[200002]; | ^~~~ a.cc: In function 'void Union(int, int)': a.cc:32:11: error: reference to 'rank' is ambiguous 32 | else if(rank[a] > rank[b]) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [200002]' 11 | int rank[200002]; | ^~~~ a.cc:32:21: error: reference to 'rank' is ambiguous 32 | else if(rank[a] > rank[b]) { | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [200002]' 11 | int rank[200002]; | ^~~~ a.cc:37:8: error: reference to 'rank' is ambiguous 37 | if(rank[a] == rank[b]) rank[b]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [200002]' 11 | int rank[200002]; | ^~~~ a.cc:37:19: error: reference to 'rank' is ambiguous 37 | if(rank[a] == rank[b]) rank[b]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [200002]' 11 | int rank[200002]; | ^~~~ a.cc:37:28: error: reference to 'rank' is ambiguous 37 | if(rank[a] == rank[b]) rank[b]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:11:5: note: 'int rank [200002]' 11 | int rank[200002]; | ^~~~
s553269930
p03857
C++
#include <bits/stdc++.h> using namespace std; int N,K,L; int p[200001]; int rank[200001]; map <pair<int,int>,int> ans; int a[200001]; int b[200001]; void init() { for(int i = 0; i < N; i++) { p[i] = i; rank[i] = 0; } } int Find (int x) { if(p[x] == x) return x; return p[x] = Find(p[x]); } void Union (int a, int b) { int x = Find(a); int y = Find(b); if(x == y) return; else { if(rank[x] > rank[y]) p[y] = x; else p[x] = y; if(rank[x] == rank[y]) rank[x]++; } } int main () { cin >> N >> K >> L; init(); for(int i = 0; i < K; i++){ int a,b; cin >> a >> b; a--; b--; Union(a,b); } for(int i = 0; i < N; i++) a[i] = Find(i); init(); for(int i = 0; i < L; i++) { int a,b; cin >> a >> b; a--; b--; Union(a,b); } for(int i = 0; i < N; i++) b[i] = Find(i); for(int i = 0; i < N; i++) ans[make_pair(a[i],b[i])]++; for(int i = 0; i < N; i++) cout << ans[make_pair(a[i],b[i])] <<endl; }
a.cc: In function 'void init()': a.cc:15:5: error: reference to 'rank' is ambiguous 15 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:5: note: 'int rank [200001]' 7 | int rank[200001]; | ^~~~ a.cc: In function 'void Union(int, int)': a.cc:29:8: error: reference to 'rank' is ambiguous 29 | if(rank[x] > rank[y]) p[y] = x; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:5: note: 'int rank [200001]' 7 | int rank[200001]; | ^~~~ a.cc:29:18: error: reference to 'rank' is ambiguous 29 | if(rank[x] > rank[y]) p[y] = x; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:5: note: 'int rank [200001]' 7 | int rank[200001]; | ^~~~ a.cc:31:8: error: reference to 'rank' is ambiguous 31 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:5: note: 'int rank [200001]' 7 | int rank[200001]; | ^~~~ a.cc:31:19: error: reference to 'rank' is ambiguous 31 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:5: note: 'int rank [200001]' 7 | int rank[200001]; | ^~~~ a.cc:31:28: error: reference to 'rank' is ambiguous 31 | if(rank[x] == rank[y]) rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:7:5: note: 'int rank [200001]' 7 | int rank[200001]; | ^~~~
s441229330
p03857
C++
#include <iostream> #include <string> #include <vector> #include <queue> #include <stack> #include <map> #include <algorithm> #include <sstream> #include <cmath> #include <set> #include <iomanip> #include <deque> using namespace std; typedef long long ll; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--) #define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++) #define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end()) #define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end()) #define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val)) #define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val)) struct UnionFind { vector<int> node; UnionFind(int n) : node(n,-1) {} bool union(int x, int y) { x = root(x); y = root(y); if (x != y) { if (node[y] < node[x]) swap(x, y); node[x] += node[y]; node[y] = x; } return x != y; } bool isSame(int x, int y) { return root(x) == root(y); } int root(int x) { return node[x] < 0 ? x : node[x] = root(node[x]); } int size(int x) { return -node[root(x)]; } }; int main(){ int N,K,L; cin>>N>>K>>L; UnionFind inst1(200010); UnionFind inst2(200010); REP(i,K){ int p,q; cin>>p>>q; inst1.union(p,q); } REP(i,L){ int r,s; cin>>r>>s; inst2.union(r,s); } map<int,vector<int> > same_g; for(int i=1;i<=N;i++){ same_g[inst1.root(i)].push_back(i); } int ans[200010]={}; FOREACH(i,same_g){ vector<int> t=i->second; map<int,int> root; REP(j,t.size()){ int r=inst2.root(t[j]); if(root.find(r)==root.end())root[r]=1; else root[r]++; } REP(j,t.size())ans[t[j]]=root[inst2.root(t[j])]; } for(int i=1;i<N;i++){ cout<<ans[i]<<" "; } cout<<ans[N]<<endl; return 0; }
a.cc:27:14: error: expected identifier before '(' token 27 | bool union(int x, int y) { | ^ a.cc:27:15: error: expected unqualified-id before 'int' 27 | bool union(int x, int y) { | ^~~ a.cc:27:15: error: expected ')' before 'int' 27 | bool union(int x, int y) { | ~^~~ | ) a.cc: In function 'int main()': a.cc:55:15: error: expected unqualified-id before 'union' 55 | inst1.union(p,q); | ^~~~~ a.cc:59:15: error: expected unqualified-id before 'union' 59 | inst2.union(r,s); | ^~~~~
s945834946
p03857
C++
#pragma region include #include <iostream> #include <iomanip> #include <stdio.h> #include <sstream> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <cstring> #include <vector> #include <tuple> #include <bitset> #include <queue> #include <complex> #include <set> #include <map> #include <stack> #include <list> #include <fstream> #include <random> //#include <time.h> #include <ctime> #pragma endregion //#include ///////// #define REP(i, x, n) for(int i = x; i < n; ++i) #define rep(i,n) REP(i,0,n) ///////// #pragma region typedef typedef long long LL; typedef long double LD; typedef unsigned long long ULL; #pragma endregion //typedef ////定数 const int INF = (int)1e9; const LL MOD = (LL)1e9+7; const LL LINF = (LL)1e18; const double PI = acos(-1.0); const double EPS = 1e-9; ///////// using namespace::std; void solve(){ int N,K,L; cin >> N >> K >> L; UnionFind ufA(N),ufB(N); for(int i=0;i<K;++i){ int x,y; cin >> x >> y; --x;--y; ufA.add(x,y); } for(int i=0;i<L;++i){ int x,y; cin >> x >> y; --x;--y; ufB.add(x,y); } map<pair<LL,LL>,int> pmap; for(int i=0;i<N;++i){ pair<LL,LL> temp; temp.first = ufA.find(i); temp.second = ufB.find(i); pmap[temp]++; } for(int i=0;i<N;++i){ if( i!=0 ){ cout << " "; } pair<LL,LL> temp; temp.first = ufA.find(i); temp.second = ufB.find(i); cout << pmap[ temp ]; } cout << endl; } #pragma region main signed main(void){ std::cin.tie(0); std::ios::sync_with_stdio(false); std::cout << std::fixed;//小数を10進数表示 cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別 solve(); } #pragma endregion //main()
a.cc: In function 'void solve()': a.cc:50:9: error: 'UnionFind' was not declared in this scope 50 | UnionFind ufA(N),ufB(N); | ^~~~~~~~~ a.cc:55:17: error: 'ufA' was not declared in this scope 55 | ufA.add(x,y); | ^~~ a.cc:61:17: error: 'ufB' was not declared in this scope 61 | ufB.add(x,y); | ^~~ a.cc:67:30: error: 'ufA' was not declared in this scope 67 | temp.first = ufA.find(i); | ^~~ a.cc:68:31: error: 'ufB' was not declared in this scope 68 | temp.second = ufB.find(i); | ^~~ a.cc:76:30: error: 'ufA' was not declared in this scope 76 | temp.first = ufA.find(i); | ^~~ a.cc:77:31: error: 'ufB' was not declared in this scope 77 | temp.second = ufB.find(i); | ^~~
s046939779
p03857
C++
#include <bits/stdc++.h> using namespace std; const int MAXN = 200001; typedef pair<int,int> pii; #define mp make_pair int par[MAXN]; int rank[MAXN]; int N, K, L; int A[MAXN], B[MAXN]; map <pii, int> ans; void init(int n) { for(int i = 0; i < n; i++) { par[i] = i; rank[i] = 0; } } int find(int x) { if(par[x] == x) return x; else return par[x] = find(par[x]); } void unit(int x, int y) { if(find(x) == find(y)) return; if(rank[x] < rank[y]) par[x] = y; else { par[y] = x; if(rank[x] == rank[y])rank[x]++; } } int main() { cin >> N >> K >> L; init(N); for(int i = 0; i < K; i++) { int p, q; cin >> p >> q; p--; q--; unit(p,q); } for(int i = 0; i < N; i++) A[i] = find(i); init(N); for(int i = 0; i < L; i++) { int r, s; cin >> r >> s; r--; s--; unit(r,s); } for(int i = 0; i < N; i++) B[i] = find(i); for(int i = 0; i < N; i++) { ans[mp(A[i],B[i])]++; } for(int i = 0; i < N; i++) { cout << ans[mp(A[i],B[i])]<<endl; } return 0; }
a.cc: In function 'void init(int)': a.cc:17:5: error: reference to 'rank' is ambiguous 17 | rank[i] = 0; | ^~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'int rank [200001]' 9 | int rank[MAXN]; | ^~~~ a.cc: In function 'void unit(int, int)': a.cc:29:8: error: reference to 'rank' is ambiguous 29 | if(rank[x] < rank[y]) | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'int rank [200001]' 9 | int rank[MAXN]; | ^~~~ a.cc:29:18: error: reference to 'rank' is ambiguous 29 | if(rank[x] < rank[y]) | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'int rank [200001]' 9 | int rank[MAXN]; | ^~~~ a.cc:33:10: error: reference to 'rank' is ambiguous 33 | if(rank[x] == rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'int rank [200001]' 9 | int rank[MAXN]; | ^~~~ a.cc:33:21: error: reference to 'rank' is ambiguous 33 | if(rank[x] == rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'int rank [200001]' 9 | int rank[MAXN]; | ^~~~ a.cc:33:29: error: reference to 'rank' is ambiguous 33 | if(rank[x] == rank[y])rank[x]++; | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidates are: 'template<class> struct std::rank' 1437 | struct rank | ^~~~ a.cc:9:5: note: 'int rank [200001]' 9 | int rank[MAXN]; | ^~~~
s031223727
p03857
C++
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; const int size=234567; int N,K,L; int p[size],q[size],r[size],s[size],g1[size],g2[size]; int par[size],rank[size],G[size],H[size]; vector<int> cnt[size]; void init(int n){ for(int i=1; i<=n; i++){ par[i]=i; rank[i]=0; } } int find(int x){ if(par[x]==x){ return x; }else{ return par[x]=find(par[x]); } } void unite(int x,int y){ x=find(x); y=find(y); if(x==y) return; if(rank[x]<rank[y]){ par[x]=y; }else{ par[y]=x; if(rank[x]==rank[y]) rank[x]++; } } bool same(int x,int y){ return find(x)==find(y); } int main(){ cin>>N>>K>>L; init(N); for(int i=0; i<K; i++){ scanf("%d %d",&p[i],&q[i]); unite(p[i],q[i]); } for(int i=1; i<=N; i++) G[i]=find(i); init(N); for(int i=0; i<L; i++){ scanf("%d %d",&r[i],&s[i]); if(G[r[i]]==G[s[i]]) unite(r[i],s[i]); } for(int i=1; i<=N; i++) H[i]=find(i); for(int i=1; i<=N; i++) cnt[H[i]].push_back(i); for(int i=1; i<=N; i++) printf("%d ",cnt[H[i]].size()); return 0; }
a.cc:8:7: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size],g1[size],g2[size]; | ^~~~ 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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:15: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size],g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:23: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size],g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:31: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size],g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:40: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size],g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:49: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size],g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:9:9: error: reference to 'size' is ambiguous 9 | int par[size],rank[size],G[size],H[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:9:20: error: reference to 'size' is ambiguous 9 | int par[size],rank[size],G[size],H[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:9:28: error: reference to 'size' is ambiguous 9 | int par[size],rank[size],G[size],H[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:9:36: error: reference to 'size' is ambiguous 9 | int par[size],rank[size],G[size],H[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:10:17: error: reference to 'size' is ambiguous 10 | vector<int> cnt[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc: In function 'void init(int)': a.cc:14:9: error: 'par' was not declared in this scope; did you mean '__pstl::execution::v1::par'? 14 | par[i]=i; | ^~~ | __pstl::execution::v1::par In file included from /usr/include/c++/14/pstl/glue_algorithm_defs.h:15, from /usr/include/c++/14/algorithm:86, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/pstl/execution_defs.h:43:45: note: '__pstl::execution::v1::par' declared here 43 | _GLIBCXX17_INLINE constexpr parallel_policy par{}; | ^~~ a.cc:15:14: error: redeclaration of 'auto i' 15 | rank[i]=0; | ^ a.cc:13:13: note: 'int i' previously declared here 13 | for(int i=1; i<=n; i++){ | ^ a.cc:15:17: error: class template argument deduction failed: 15 | rank[i]=0; | ^ a.cc:15:17: error: no matching function for call to 'rank(int)' In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60: /usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank()-> std::rank< <template-parameter-1-1> >' 1437 | struct rank | ^~~~ /usr/include/c++/14/type_traits:1437:12: note: candidate expects 0 arguments, 1 provided /usr/include/c++/14/type_traits:1437:12: note: candidate: 'template<class> rank(std::rank< <template-parameter-1-1> >)-> std::rank< <template-parameter-1-1> >' /usr/include/c++/14/type_traits:1437:12: note: template argument deduction/substitution failed: a.cc:15:17: note: mismatched types 'std::rank< <template-parameter-1-1> >' and 'int' 15 | rank[i]=0; | ^ a.cc: In function 'int find(int)': a.cc:19:8: error: 'par' was not declared in this scope; did you mean
s331274534
p03857
C++
#include <bits/stdc++.h> #define MOD 1000000007 using namespace std; const int size=234567; int N,K,L,I; int p[size],q[size],r[size],s[size]; vector<int> road[size]; vector<int> rail[size]; vector<int> group[size]; vector<int> Group[size]; int g1[size],g2[size]; bool flag; void dfsroad(int i,int j){ g1[i]=j; if(road[i].size()==0) return; for(int k=0; k<road[i].size(); k++){ if(flag==0&&road[i][k]>i+1){ I=i+1; flag=1; } dfsroad(road[i][k],j); } return; } void dfsrail(int i,int h){ g2[i]=h; if(rail[i].size()==0) return; for(int k=0; k<rail[i].size(); k++){ if(g1[i]==g1[rail[i][k]]) dfsrail(rail[i][k],h); } return; } int main(){ cin>>N>>K>>L; for(int i=0; i<K; i++){ scanf("%d %d",&p[i],&q[i]); road[p[i]].push_back(q[i]); } for(int i=0; i<L; i++){ scanf("%d %d",&r[i],&s[i]); rail[r[i]].push_back(s[i]); } int J=1; I=1; while(1){ flag=0; if(I==N) break; if(g1[I]==0){ dfsroad(I,J); J++; } I++ } for(int i=1; i<=N; i++) group[g1[i]].push_back(i); int H=1; for(int i=1; i<J; i++){ for(int k=0; k<group[i].size(); k++){ if(g2[group[i][k]]==0){ dfsrail(group[i][k],H); H++; } } } for(int i=1; i<=N; i++) Group[g2[i]].push_back(i); for(int i=1; i<=N; i++) printf("%d ",Group[g2[i]].size()); return 0; }
a.cc:8:7: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size]; | ^~~~ 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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:15: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:23: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:8:31: error: reference to 'size' is ambiguous 8 | int p[size],q[size],r[size],s[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:9:18: error: reference to 'size' is ambiguous 9 | vector<int> road[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:10:18: error: reference to 'size' is ambiguous 10 | vector<int> rail[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:11:19: error: reference to 'size' is ambiguous 11 | vector<int> group[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:12:19: error: reference to 'size' is ambiguous 12 | vector<int> Group[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:13:8: error: reference to 'size' is ambiguous 13 | int g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc:13:17: error: reference to 'size' is ambiguous 13 | int g1[size],g2[size]; | ^~~~ /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:6:11: note: 'const int size' 6 | const int size=234567; | ^~~~ a.cc: In function 'void dfsroad(int, int)': a.cc:17:5: error: 'g1' was not declared in this scope; did you mean 'y1'? 17 | g1[i]=j; | ^~ | y1 a.cc:18:8: error: 'road' was not declared in this scope; did you mean 'read'? 18 | if(road[i].size()==0) return; | ^~~~ | read a.cc:19:20: error: 'road' was not declared in this scope; did you mean 'read'? 19 | for(int k=0; k<road[i].size(); k++){ | ^~~~ | read a.cc: In function 'void dfsrail(int, int)': a.cc:28:5: error: 'g2' was not declared in this scope 28 | g2[i]=h; | ^~ a.cc:29:8: error: 'rail' was not declared in this scope 29 | if(rail[i].size()==0) return; | ^~~~ a.cc:30:20: error: 'rail' was not declared in this scope 30 | for(int k=0; k<rail[i].size(); k++){ | ^~~~ a.cc:31:12: error: 'g1' was not declared in this scope; did you mean 'y1'? 31 | if(g1[i]==g1[rail[i][k]]) dfsrail(rail[i][k],h); | ^~ | y1 a.cc: In function 'int main()': a.cc:41:20: error: 'p' was not declared in this scope 41 | scanf("%d %d",&p[i],&q[i]); | ^ a.cc:41:26: error: 'q' was not declared in this scope 41 | scanf("%d %d",&p[i],&q[i]); | ^ a.cc:42:5: error: 'road' was not declared in this scope; did you mean 'read'? 42 | road[p[i]].push_back(q[i]); | ^~~~ | read a.cc:45:20: error: 'r' was not declared in this scope 45 | scanf("%d %d",&r[i],&s[i]); | ^ a.cc:45:26: error: 's' was not declared in this scope 45 | scanf("%d %d",&r[i],&s[i]); | ^ a.cc:46:5: error: 'rail' was not declared in this scope 46 | rail[r[i]].push_back(s[i]); | ^~~~ a.cc:52:8: error: 'g1' was not declared in this scope; did you mean 'y1'? 52 | if(g1[I]==0){ | ^~ | y1 a.cc:55:8: error: expected ';' before '}' token 55 | I++ | ^ | ; 56 | } | ~ a.cc:57:25: error: 'group' was not declared in this scope 57 | for(int i=1; i<=N; i++) group[g1[i]].push_back(i); | ^~~~~ a.cc:57:31: error: 'g1' was not declared in this scope; did you mean 'y1'? 57 | for(int i=1; i<=N; i++) group[g1[i]].push_back(i); | ^~ | y1 a.cc:61:20: error: 'group' was not declared in this scope 61 | for(int k=0; k<group[i].size(); k++){ | ^~~~~ a.cc:62:12: error: 'g2' was not declared in this scope 62 | if(g2[group[i][k]]==0){ | ^~ a.cc:68:25: error: 'Group' was not declared in this scope 68 | for(int i=1; i<=N; i++) Group[g2[i]].push_back(i); | ^~~~~ a.cc:68:31: error
s867591906
p03857
C++
#include <iostream> #include <cmath> #include <algorithm> #include <vector> using namespace std; typedef long long int ll; const MOD (1e9+7); const INF (2e9); const MAX_N (20001); int par_road[MAX_N]; int rank_road[MAX_N]; int par_train[MAX_N]; int rank_train[MAX_N]; struct PARENT{ int num;//num 番目の都市は(問題上では1番目~n番目だが、0番目~n-1番目と表記することにする) int road;//道に関するUnion-Find木でroad番目の都市を親に持ち int train;//線路に関するUnion-Find木でtrain番目の都市を親に持つ }; bool cmp(const PARENT a,const PARENT b){//sort用関数 roadで昇順ソート、roadが等しかったらtrainで昇順 if(a.road==b.road){ return a.train<b.train; }else{ return a.road<b.road; } } void init(int n,int *par,int *rank){//Unioo-Find木を生成 for(int i=0;i<n;i++){ par[i]=i; rank[i]=0; } } int find(int x,int *par){//根探し if(par[x]==x){ return x; }else{ return par[x]=find(par[x],par); } } void unite(int x, int y,int *par,int *rank){//連結 x=find(x,par); y=find(y,par); if(x==y) return; if(rank[x]<rank[y]){ par[x]=y; }else{ par[y]=x; if(rank[x]==rank[y]){ rank[x]++; } } } bool same(int x,int y,int *par){//根が等しいか判定 return find(x,par)==find(y,par); } int main(void) { int n,k,l; cin>>n>>k>>l; init(n,par_road,rank_road);//道についてのUnion-Find木を生成 init(n,par_train,rank_train);//線路についてのUnion-Find木を生成 int p,q,r,s; for(int i=0;i<k;i++){//道の情報によって連結していく cin>>p>>q; unite(p-1,q-1,par_road,rank_road);//0~n-1番目の道 としたので p-1 q-1 } for(int i=0;i<l;i++){//線路の情報によって連結していく cin>>r>>s; unite(r-1,s-1,par_train,rank_train); } PARENT *parent=new PARENT[n]; for(int i=0;i<n;i++){//num番目の都市は road番目の都市を道根に持ち、train番目の都市を線路根に持つ parent[i].num=i; parent[i].road=find(i,par_road); parent[i].train=find(i,par_train); } sort(parent,parent+n,cmp); int *answer=new int[n]; int memo_start=0,count=1; int i; for(i=1;i<n;i++){ if(parent[i].road==parent[i-1].road && parent[i].train==parent[i-1].train){ count++; }else{ for(memo_start;memo_start<i;memo_start++){//memo_startは現在の位置を指して終わる answer[(parent[memo_start]).num]=count; } count=1; } } for(memo_start;memo_start<i;memo_start++){ answer[parent[memo_start].num]=count; } for(int i=0;i<n;i++){ cout<<answer[i]<<" "; } cout<<endl; return 0; }
a.cc:7:7: error: ISO C++ forbids declaration of 'MOD' with no type [-fpermissive] 7 | const MOD (1e9+7); | ^~~ a.cc:8:7: error: ISO C++ forbids declaration of 'INF' with no type [-fpermissive] 8 | const INF (2e9); | ^~~ a.cc:9:7: error: ISO C++ forbids declaration of 'MAX_N' with no type [-fpermissive] 9 | const MAX_N (20001); | ^~~~~
s656571434
p03857
C++
z#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; #define rep(i, n) for (int i = 0; i < (int)n; i++) #define vec vector #define ll long long class UnionFind { public: vec<int> p; vec<int> Rank; UnionFind(int n) : p(n), Rank(n, 0) { rep(i, n) p[i] = i; } void init(int n) { p.resize(n); rep(i, n) p[i] = i; Rank.resize(n); rep(i, n) Rank[i] = 0; } int root(int a) { if (p[a] == a) return a; p[a] = root(p[a]); return p[a]; } void unite(int a, int b) { int ra = root(a); int rb = root(b); if (Rank[ra] > Rank[rb]) p[rb] = ra; else p[ra] = rb; if (Rank[ra] == Rank[rb]) Rank[rb]++; } int is_same_group(int a, int b) { return (root(a) == root(b)); } }; int main(void) { int n, k, l; cin >> n >> k >> l; UnionFind road(n), train(n); rep(i, k) { int a, b; cin >> a >> b; a--; b--; road.unite(road.root(a), road.root(b)); } rep(i, l) { int a, b; cin >> a >> b; a--; b--; train.unite(train.root(a), train.root(b)); } vec<pair<pair<int, int>, int>> set(n); rep(i, n) { set[i].first.first = road.p[i]; set[i].first.second = train.p[i]; set[i].second = i; } sort(set.begin(), set.end()); vec<int> ans(n); int cur = 0; while(cur < n) { int prev = cur; for (; cur <= n; cur++) { if (cur < n && set[prev].first == set[cur].first) continue; break; } for (int i = prev; i < cur; i++) ans[set[i].second] = cur - prev; } rep(i, n - 1) cout << ans[i] << " "; cout << ans[n - 1] << endl; return 0; }
a.cc:1:2: error: stray '#' in program 1 | z#include <iostream> | ^ a.cc:1:1: error: 'z' does not name a type 1 | z#include <iostream> | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /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:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /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:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /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' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /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' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 |
s769609513
p03857
C++
#include<iostream> #include<unordered_map> #include<cstdio> using namespace std; int par0[200000], rank0[200000], par1[200000], rank1[200000]; int find0(int a) { if (par0[a] == a)return a; return par0[a] = find0(par0[a]); } void unite0(int a, int b) { a = find0(a); b = find0(b); if (rank0[a]>rank0[b]) { par0[b] = a; } else if (rank0[a]<rank0[b]) { par0[a] = b; } else { par0[b] = a; rank0[a]++; } } int find1(int a) { if (par1[a] == a)return a; return par1[a] = find1(par1[a]); } void unite1(int a, int b) { a = find1(a); b = find1(b); if (rank1[a]>rank1[b]) { par1[b] = a; } else if (rank1[a]<rank1[b]) { par1[a] = b; } else { par1[b] = a; rank1[a]++; } } int main() { int a, b, c; cin >> a >> b >> c; for (int d = 0; d< a; d++) { par0[d] = d; par1[d] = d; } for (int d = 0; d< b; d++) { int e, f; scanf("%d%d", &e, &f); e--; f--; unite0(e, f); } for (int d = 0; d< c; d++) { int e, f; scanf("%d%d", &e, &f); e--; f--; unite1(e, f); } unordered_map<int, unordered_map<int,int>>U; for (int d = 0; d< a; d++) { U[find0(d)][find1(d)]++; } for (int i = 0; i < a; i++) { if (i)printf(" "); printf("%d", U[find0(d)][find1(d)]); } puts(""); }
a.cc: In function 'int main()': a.cc:63:38: error: 'd' was not declared in this scope 63 | printf("%d", U[find0(d)][find1(d)]); | ^