submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s600098737
p03745
C++
#include <bits/stdc++.h> using namespace std; typedef long long int; signed main() { int N; cin >> N; vector<int> a(N), b(N - 1); for (int i = 0; i < N; i++) cin >> a[i]; for (int i = 0; i < N - 1; i++) b[i] = a[i + 1] - a[i]; int ans = 1; for (int i = 0; i < N - 2; i++) { if (b[i] * b[i + 1] < 0) { ans++; i++; } } cout << ans << endl; return 0; }
a.cc:3:19: error: declaration does not declare anything [-fpermissive] 3 | typedef long long int; | ^~~
s059591442
p03745
C++
9 1 2 1 2 1 2 1 2 1#include <iostream> #include <vector> #include <math.h> #include <cmath> #include <algorithm> #include <numeric> #include <string> #include <cstring> #include <regex> #include <bits/stdc++.h> using namespace std; using ll = long long; using dbl = double; using pii = pair<int, int>; using pl4 = pair<ll, ll>; using vi = vector<int>; using vvi = vector<vi>; using vs = vector<string>; using vvs = vector<vs>; using vll = vector<ll>; using vvll = vector<vll>; using vvvll = vector<vvll>; using vpii = vector<pii>; using vvpii = vector<vpii>; using vpl4 = vector<pl4>; using vvpl4 = vector<vpl4>; using vd = vector<dbl>; using vvd = vector<vd>; #define fi first #define se second #define mp make_pair #define pb push_back #define pob pop_back() #define pf push_front #define pof pop_front() #define sz size() #define bgn begin() #define en end() #define asn assign #define emp empty() #define fr front() #define bk back() #define clr clear() #define ins insert #define ers erase #define res resize #define tp top() #define p_q priority_queue #define FOR(i,a,b) for(int i=(a);i<=(b);i++) #define rFOR(i,a,b) for(int i=(b);i>=(a);i--) #define REP(i,a) FOR((i),0,(a)-1) #define REP0(i,a) FOR((i),0,(a)) #define REP1(i,a) FOR((i),1,(a)) #define rREP(i,a) rFOR((i),0,(a)-1) #define rREP0(i,a) rFOR((i),0,(a)) #define rREP1(i,a) rFOR((i),1,(a)) #define ROR(v,i) for(auto &(i):(v)) #define IOTA(a,n) iota((a).bgn,(a).en,(n)) #define SORT(a) sort((a).bgn,(a).en) #define rSORT(a) sort((a).rbegin(),(a).rend()) #define UNIQUE(a) (a).erase(unique((a).bgn,(a).en),(a).en) #define PREVP(a) prev_permutation((a).bgn,(a).en) #define NEXTP(a) next_permutation((a).bgn,(a).en) #define BINS(a,b) binary_search((a).bgn,(a).en,(b)) #define LOWB(a,b) (lower_bound((a).bgn,(a).en,(b))-(a).bgn) #define UPB(a,b) (upper_bound((a).bgn,(a).en,(b))-(a).bgn) #define CNT(a,b) count((a).bgn,(a).en,b) #define SUM(a) accumulate((a).bgn,(a).en,0) #define REV(a) reverse((a).bgn,(a).en) #define REGS(a,b) regex_search((a),regex(b)) #define REGM(a,b) regex_match((a),regex(b)) #define yn(a) cout <<((a)?"yes":"no")<<endl; #define Yn(a) cout <<((a)?"Yes":"No")<<endl; #define YN(a) cout <<((a)?"YES":"NO")<<endl; #define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl; #define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl; #define say(a) cout <<(a); #define sal(a) cout <<(a)<<endl; #define sak cout <<endl; #define sas cout <<" "; #define sat cout <<"\t"; #define dbg(a) cout <<(#a)<<": "<<(a)<<endl; #define c2l(a) ((ll)(a-48)) #define a2l(a) ((ll)(a-97)) #define A2l(a) ((ll)(a-65)) #define l2c(a) ((char)(a+48)) #define l2a(a) ((char)(a+97)) #define l2A(a) ((char)(a+65)) #define DigN2(a) ((llabs(a)==0)?(1):((ll)(log2(double(llabs(a))))+1)) #define DigN10(a) ((llabs(a)==0)?(1):((ll)(log10(double(llabs(a))))+1)) #define Dig2(a,b) (((a)>>(b))&1) #define Dig10(a,b) (ll)(((a)/((ll)(pow(10.0,(double)(b)))))%10) #define Pow2(a) (1<<(a)) #define Pow10(a) ((ll)(pow(10.0,double(a)))) #define LSB(a) ((a)&(-(a))) #define llin(a) ll (a);cin >>(a); #define stin(a) string (a);cin >>(a); #define vin(v) ROR((v),(i)){cin >>(i);}; #define vllin(v,N) vll (v)((N));vin(v); #define vsin(v,N) vs (v)((N));vin(v); #define rdn(a,b) ((a)/(b)) #define rou(a,b) ((((double(a)/double(b))-((a)/(b)))<0.5)?((a)/(b)):(((a)/(b))+1)) #define rup(a,b) ((((a)%(b))==0)?((a)/(b)):(((a)/(b))+1)) #define min(a,b) ((a<b)?(a):(b)) #define max(a,b) ((a>b)?(a):(b)) #define powll(a,b) (ll)(pow((double)(a),(double)(b))) #define Triangle(x1,y1,x2,y2,x3,y3) (((x1)-(x2))*((y1)-(y3))-((x1)-(x3))*((y1)-(y2))) #define int ll const ll MOD = 1e9 + 7; //const ll MOD = 998244353; //const ll MOD = 9007199254740881; const ll N = 1e5 + 20; const ll INF = 1LL << 60; const double PI = acos(-1.0); const vll DX = { 0,-1,0,1,0,-1,1,1,-1 }; const vll DY = { 0,0,-1,0,1,-1,-1,1,1 }; const string alp = "abcdefghijklmnopqrstuvwxyz"; const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; class BIT { public: vll d; vll v; ll size; BIT(ll sizeget) { size = sizeget; d.asn(size + 1, 0); v.asn(size, 0); } BIT(vll cpyvec) { copy(cpyvec); } void add(ll index, ll num) { // if (index < 0) return false; // if (index >= size) return false; v[index] += num; index++; while (index <= size) { d[index] += num; index += LSB(index); } // return true; return; } ll sum(ll index = INF) { index++; index = min(index, size); ll ans = 0; while (index) { ans += d[index]; index -= LSB(index); } return ans; } void copy(vll cpyvec) { size = cpyvec.sz; d.asn(size + 1, 0); v.asn(size, 0); REP(i, size) add(i, cpyvec[i]); } }; class UFT { public: ll size; ll mode; vll root; vll rank; UFT(ll sizeget, ll modeget = 0){ size = sizeget; mode = modeget; root.res(size, 0); if (!mode) rank.res(size, 0); IOTA(root, 0); } ll find(ll x) { return root[x] == x ? x : root[x] = find(root[x]); } bool same(ll x, ll y) { return find(x) == find(y); } void unite(ll x, ll y) { x = find(x); y = find(y); if (x == y) return; if (mode) root[y] = x; else { if (rank[x] < rank[y]) { root[x] = y; } else { root[y] = x; if (rank[x] == rank[y]) rank[x]++; } } } }; ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); } ll lcm(ll a, ll b) { return a / gcd(a, b)*b; } ll inverse[N]; void init_inverse() { inverse[1] = 1; for (int i = 2; i < N; i++) inverse[i] = (MOD - MOD / i) * inverse[MOD%i] % MOD; } pl4 Bezout(ll a, ll b) { if (b != 0) { pl4 xy; xy = Bezout(b, a%b); return mp(xy.se, xy.fi - ((a / b)*xy.se)); } if (b == 0) { return mp(1, 0); } } pl4 Bez(ll a, ll b, ll c) { pl4 xy; ll x, y, z, gc; xy = Bezout(a, b); gc = gcd(a, b); if (c%gc != 0) return mp(-1, -1); x = xy.fi*(c / gc); y = xy.se*(c / gc); if (x < 0) z = rup(-x, (b / gc)); if (x >= 0) z = -x / (b / gc); x += z * (b / gc); y -= z * (a / gc); return mp(x, y); } void salv(vll v) { say("{"); FOR(i, 0, v.sz - 1) { say(v[i]); if (i != v.sz - 1) say(","); } sal("}") } ll DigS10(ll n) { ll m = 0; FOR(i, 0, DigN10(n) - 1) { m += (ll)((llabs(n) % (ll)(pow(10.0, (double)(i + 1)))) / (ll)(pow(10.0, (double)i))); } return m; } ll isP(ll n) { if (n <= 1) return 0; FOR(i, 2, (ll)sqrt(n)) { if (n%i == 0) return 0; } return 1; } vll FactM(1, 1); vll FactMI(1, 1); ll PowM(ll a, ll b) { ll ans = 1, x = (a%MOD); FOR(i, 0, DigN2(b) - 1) { if (Dig2(b, i) == 1) ans = (ans*x) % MOD; if (i != (DigN2(b) - 1)) x = (x*x) % MOD; } return ans; } ll Mod(ll a) { a %= MOD; a = (a + MOD) % MOD; return a; } ll InvM(ll a) { a = Mod(a); a = PowM(a, MOD - 2); return a; } void CFactM(ll n) { if (FactM.sz <= n) { FOR(i, FactM.sz, n) { FactM.pb((FactM[i - 1] * (i%MOD)) % MOD); } } return; } void CFactMI(ll n) { CFactM(n); if (FactMI.sz < (n + 1)) FactMI.res(n + 1, -1); if (FactMI[n] == -1) FactMI[n] = PowM(FactM[n], MOD - 2); rFOR(i, 1, n - 1) { if (FactMI[i] != -1) break; FactMI[i] = ((FactMI[i + 1] * ((i + 1) % MOD)) % MOD); } return; } ll CombM(ll n, ll k) { if ((n < 0) || (k < 0)) return 0; if (n < k) return 0; if (n + 1 > FactMI.sz) CFactMI(n); return ((((FactMI[k] * FactMI[n - k]) % MOD)*FactM[n]) % MOD); } ll LIS(vll v, ll m = 0) { if (v.sz > 0) { ll ans = 0; vll dp(v.sz, INF); FOR(i, 0, v.sz - 1) { dp[m ? UPB(dp, v[i]) : LOWB(dp, v[i])] = v[i]; } FOR(i, 0, v.sz - 1) { if (dp[i] == INF) break; ans++; } return ans; } else { return 0; } } void cmprs(vll& v) { if (v.sz == 0) return; vll vv(v); IOTA(vv, 0); sort(vv.bgn, vv.en, [&](ll v1, ll v2) {return v[v1] < v[v2]; }); IOTA(v, 0); sort(v.bgn, v.en, [&](ll v1, ll v2) {return vv[v1] < vv[v2]; }); return; } ll BblCnt(vll v) { cmprs(v); BIT b(v.sz); ll ans = 0; REP(i, v.sz) { ans += (i - b.sum(v[i])); b.add(v[i], 1); } return ans; } signed main() { ll n,a,oa,r=1,f=0; cin >> n; REP(i,n){ cin >> a; if (f==0) { f=1; } else if (f==1) { if (a>oa) { f = 2; } else if (a<oa) { f = 3; } else { f = 1; } } else if (f==2) { if (a<oa){ r++; f=1; } } else if (f==3) { if (a>oa){ r++; f=1; } } oa=a; } cout << r; return 0; }
a.cc:2:18: error: stray '#' in program 2 | 1 2 1 2 1 2 1 2 1#include <iostream> | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 9 | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:3: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits: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: t
s028345375
p03745
C++
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N+3); for(int i=0;i<N;i++){cin >> A[i];} int count=0; for(int i=0;i<N;i++){
a.cc: In function 'int main()': a.cc:10:24: error: expected '}' at end of input 10 | for(int i=0;i<N;i++){ | ~^ a.cc:10:24: error: expected '}' at end of input a.cc:4:12: note: to match this '{' 4 | int main() { | ^
s181727614
p03745
C++
#include<bits/stdc++.h> using namespace std; #define rp(i,n) for(int i=0;i<n;i++) #define rep(i,m,n) for(int i=m;i<=n;i++) #define lrp(i,n) for(long long i=0;i<n;i++) #define lrep(i,m,n) for(long long i=m;i<=n;i++) #define sort(a) sort(a.begin(),a.end()) #define reverse(a) reverse(a.begin(),a.end()) #define pb push_back #define elif else if #define unique(a) a.erase(unique(a.begin(),a.end()),a.end()) typedef vector<int> vi; typedef vector<long long> vl; typedef vector<string> vs; typedef vector<char> vc; typedef long long ll; typedef string S; typedef queue<int> qi; int main(){ ll n; cin >> n; vl a(n); lrp(i,n){ cin >> a.at(i); } ll ans=0; lrp(i,n){ if(i<n-1&&a.at(i)<a.at(i+1)){ while(i<n-1&&a.at(i)<=a.at(i+1)){ i++; } ans++; }elif(i<n-1&&a.at(i)>a.at(i+1)){ while(i<n-1&&a.at(i)=>a.at(i+1)){ i++; } ans++; }elif(i<n-1&&a.at(i)==a.at(i+1)){ continue; }elif(i==n-1){ ans++; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:34: error: expected primary-expression before '>' token 36 | while(i<n-1&&a.at(i)=>a.at(i+1)){ | ^
s397311972
p03745
C++
#include <bits/stdc++.h> using namespace std; long long int N, L, T; long long int X[100010]; long long int W[100010], Y[100010], Z[100010],S[100010], U[100010]; long long int A[100010], B[100010]; long long int a=0, b=0; long long int pmod(long long int x, long long int a){ if (x%a<0) return x%a+a; else return x%a; } long long int modL(long long int x){ if(x%L==0) return L; else return pmod(x,L); } long long int locate_0(long long int t){ if (W[0]==1){ long long int i=0, d=0; while(d<=2*t){ if (i%2==0){ if (i==0) { d+=modL(B[0]-A[0]); } else { d+=modL(B[pmod(i/2,b)]-B[pmod(i/2-1,b)]); } } else{ d+=modL(A[pmod((i-1)/2,a)]-A[pmod((i+1)/2,a)]); } i++; } if (i%2==1) return pmod(A[pmod((i-1)/2,a)]+t,L); else return pmod(B[pmod((i-2)/2,b)]-t,L); } if (W[0]==2){ long long int i=0, d=0; while(d<=2*t){ if (i%2==0){ if (i==0) { d+=modL(B[0]-A[0]); } else { d+=modL(A[pmod((i-2)/2,a)]-A[pmod(i/2,a)]); } } else{ d+=modL(B[pmod((i+1)/2,b)]-B[pmod((i-1)/2,b)]); } i++; } if (i%2==0) return pmod(A[pmod((i-2)/2,a)]+t,L); else return pmod(B[pmod((i-1)/2,b)]-t,L); } } long long int f(long long int x){ for (long long int i=0; i<N; i++){ if (x==X[i]) return Y[i]; } } int main() { cin >> N >> L >>T; for (long long int i=0; i<N; i++){ cin >>X[i] >> W[i]; } for (long long int i=0; i<N; i++){ if(W[i]==2){ B[b]=X[i]; b++; } } for (long long int i=N; i>=1; i--){ if (W[i%N]==1){ A[a]=X[i%N]; a++; } } int e=0; for (int i=0;i<N; i++){ if (W[0]!=W[i]) e=1; } if (e){ long long int s=0; while(X[s]!=locate_0(L)){ s++; } for (long long int i=0; i<N;i++){ Y[i]=X[(i+s)%N]; } long long int c=1, d=X[0]; Z[0]=X[0]; while(f(d)!=X[0]){ d=f(d); Z[c]=d; c++; } long long int f=(T/L) long long int g=c-f%c long long int h=g%c long long int k=s*h long long int u=k%N for (long long int i=0; i<N; i++){ if (W[i]==1) S[i]=(X[i]+T)%L; else S[i]=pmod((X[i]-T),L); } sort(S, S+N); long long int v=0; while(S[v]!=locate_0(T%L)) v++; for (long long int i=0; i<N; i++){ U[i]=S[pmod(v-u+i,N)]; cout << U[i] <<endl; } } else { if (W[0]==1){ for (int i=0;i<N;i++){ U[i]=(X[i]+T)%L; cout << U[i] <<endl; } } else { for (int i=0;i<N;i++){ U[i]=pmod((X[i]-T),L); cout << U[i] <<endl; } } } }
a.cc: In function 'int main()': a.cc:103:3: error: expected ',' or ';' before 'long' 103 | long long int g=c-f%c | ^~~~ a.cc:109:27: error: 'i' was not declared in this scope 109 | for (long long int i=0; i<N; i++){ | ^ a.cc:119:23: error: 'u' was not declared in this scope 119 | U[i]=S[pmod(v-u+i,N)]; | ^ a.cc: In function 'long long int locate_0(long long int)': a.cc:56:1: warning: control reaches end of non-void function [-Wreturn-type] 56 | } | ^ a.cc: In function 'long long int f(long long int)': a.cc:61:1: warning: control reaches end of non-void function [-Wreturn-type] 61 | } | ^
s283495646
p03745
C++
5 6 1 3 1 4 2 3 1 5 3 5 2 4
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 5 6 | ^
s160756633
p03745
C
#include <iostream> using namespace std; int n, a[100000], b[100000]; int main() { int n; scanf("%d",&n); for(int i = 0;i < n; i++) cin>>a[i]; int x, y; for(int i = 0;i < n; i++) { b[i+1] = 0x3f3f3f3f; if(i>=1 && a[i-1]>a[i]) x = i; else b[i+1] = b[x]+1; if(i>=1 && a[i-1]<a[i]) y = i; else b[i+1] = min(b[i+1],b[y]+1); } cout<<b[n]<<endl; return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s005371403
p03745
C++
#include <bits/stdc++.h> using namespace std; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { int n,ans=0,f=0; cin >> n; vector<int>a(n); rep(i, n) cin >> a[i]; rep(i,n-1){ if(f==0){ if (a[i] < f[i + 1]) f = 1; else if(a[i] < f[i + 1]) f = 2; } else if (f == 1 && a[i] > f[i + 1]){ f = 0; ans++; } else if (f == 2 && a[i] < f[i + 1]){ f = 0; ans++; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:25: error: invalid types 'int[int]' for array subscript 16 | if (a[i] < f[i + 1]) | ^ a.cc:18:29: error: invalid types 'int[int]' for array subscript 18 | else if(a[i] < f[i + 1]) | ^ a.cc:21:36: error: invalid types 'int[int]' for array subscript 21 | else if (f == 1 && a[i] > f[i + 1]){ | ^ a.cc:25:36: error: invalid types 'int[int]' for array subscript 25 | else if (f == 2 && a[i] < f[i + 1]){ | ^
s254675538
p03745
C++
#include <bits/stdc++.h> using namespace std; #define forx(i, a, b) for (int i = (a); i < (b); i++) #define rep(i, n) for (int i = 0; i < (n); i++) typedef long long ll; int main() { int n,ans=0,f=0; cin >> n; vector<int>a(n); rep(i, n) cin >> a[i]; rep(i,1,n-1){ if(f==0){ if (a[i] < f[i + 1]) f = 1; else if(a[i] < f[i + 1]) f = 2; } else if (f == 1 && a[i] > f[i + 1]){ f = 0; ans++; } else if (f == 2 && a[i] < f[i + 1]){ f = 0; ans++; } } cout << ans << endl; return 0; }
a.cc:14:16: error: macro "rep" passed 3 arguments, but takes just 2 14 | rep(i,1,n-1){ | ^ a.cc:4:9: note: macro "rep" defined here 4 | #define rep(i, n) for (int i = 0; i < (n); i++) | ^~~ a.cc: In function 'int main()': a.cc:14:5: error: 'rep' was not declared in this scope 14 | rep(i,1,n-1){ | ^~~
s314905383
p03745
C++
#include<iostream> #include<string.h> #include<algorithm> #include<vector> #include<cmath> #define ll long long #define r(i,n) for(ll i=0;i<n;i++) #define rp(i,a,b) for(ll i=a;i<b;i++) #define ret return #define elif else if #define p(x) cout<<x<<endl; ll inf=100001; using namespace std; int main(){ while(1){ ll n;cin>>n;ll a[n];r(i,n)cin>>a[i]; ll a=0,s=0,ct=0; r(i,n-1){ if(a[i]<a[i+1]){a=1;} elif(a[i]>a[i+1]){s=1;} else{continue;} if((a+s)==2){ct++;a=s=0;} }p(ct+1) ret 0; } }
a.cc: In function 'int main()': a.cc:17:12: error: conflicting declaration 'long long int a' 17 | ll a=0,s=0,ct=0; | ^ a.cc:16:24: note: previous declaration as 'long long int a [n]' 16 | ll n;cin>>n;ll a[n];r(i,n)cin>>a[i]; | ^ a.cc:19:34: error: incompatible types in assignment of 'int' to 'long long int [n]' 19 | if(a[i]<a[i+1]){a=1;} | ~^~ a.cc:22:25: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 22 | if((a+s)==2){ct++;a=s=0;} | ~~~~~^~~ a.cc:22:36: error: incompatible types in assignment of 'long long int' to 'long long int [n]' 22 | if((a+s)==2){ct++;a=s=0;} | ~^~~~
s640507619
p03745
C++
#include <iostream> using namespace std; int a[100005]; #define rep(i,n) for(int (i)=0; (i)<(n); (i)++) #define CONST_RETURN(a) do{cout << (a) << endl; return 0; }while(0) int main(){ int n; cin >> n; if(n==1) CONST_RETURN(1); rep(i,n) cin >> a[i]; int ans = 1,mode = 0; int mode = 0; rep(i,n-1){ if(mode==1 && a[i+1]<a[i]){ans++;mode=0;} else if(mode == -1 && a[i+1]>a[i]){ans++;mode=0;} else if(mode == 0 && a[i+1] > a[i]) mode = 1; else if(mode == 0 && a[i+1] < a[i]) mode = -1; } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:13:7: error: redeclaration of 'int mode' 13 | int mode = 0; | ^~~~ a.cc:12:15: note: 'int mode' previously declared here 12 | int ans = 1,mode = 0; | ^~~~
s731098427
p03745
C++
n = int(input()) a = list(map(int,input().split())) i = int(0) ans = int(0) f = True while i+1 < n: if a[i] < a[i+1] : while a[i] <= a[i+1] : if i+1 >= n-1: f=False break i += 1 if f : ans += 1 elif a[i] == a[i+1] : if i+1 >= n-1: break else: while a[i] >= a[i+1] : if i+1 >= n-1: f = False break i+=1 if f : ans += 1 i += 1 print(ans+1)
a.cc:1:1: error: 'n' does not name a type 1 | n = int(input()) | ^
s119883114
p03745
C
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> #define ll long long const int maxn=100010; int a[maxn]; int main(){ int i,j,k,n,m; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); int flag=0,ans=1; for(i=2;i<=n;i++){ if(flag==1 && a[i]>=a[i-1])continue; if(flag==-1 && a[i]<=a[i-1])continue; if(flag==0){ if(a[i]>a[i-1])flag=1; else if(a[i]<a[i-1])flag=-1; else flag=0; } else{ ans++;flag=0; } } printf("%d\n",ans); return 0; }
main.c:7:5: error: variably modified 'a' at file scope 7 | int a[maxn]; | ^
s168074865
p03745
C++
#include <iostream> using namespace std; int main() { int n; cin >> n; vector<int> a(n); for (auto &e : a) { cin >> e; } vector<int> d(n - 1); for (int i = 0; i < n - 1; i++) { d[i] = a[i + 1] - a[i]; } int m = 1; for (int i = 0; i < n - 2; i++) { if (d[i + 1] == 0) { d[i + 1] = d[i]; } else if (d[i] < 0 && 0 < d[i + 1] || d[i + 1] < 0 && 0 < d[i]) { m++; } } cout << m << endl; return 0; }
a.cc: In function 'int main()': a.cc:7:9: error: 'vector' was not declared in this scope 7 | vector<int> a(n); | ^~~~~~ a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 1 | #include <iostream> +++ |+#include <vector> 2 | using namespace std; a.cc:7:16: error: expected primary-expression before 'int' 7 | vector<int> a(n); | ^~~ a.cc:8:24: error: 'a' was not declared in this scope 8 | for (auto &e : a) { | ^ a.cc:11:16: error: expected primary-expression before 'int' 11 | vector<int> d(n - 1); | ^~~ a.cc:13:17: error: 'd' was not declared in this scope 13 | d[i] = a[i + 1] - a[i]; | ^ a.cc:13:24: error: 'a' was not declared in this scope 13 | d[i] = a[i + 1] - a[i]; | ^ a.cc:17:21: error: 'd' was not declared in this scope 17 | if (d[i + 1] == 0) { | ^
s502153599
p03745
C++
#include <iostream> #include <algorithm> #include <string> #include <queue> #include <vector> #include <set> #include <bitset> #include <cmath> #define FOR(i,a,b) for(int i=a;i<b;i++) #define ROF(i,a,b) for(int i=b-1;i>=a;i--) #define FI first #define SE second #define MA(i,j) make_pair(i,j) #define PA pair<int,int> #define PB push_back #define PQ priority_queue<int> #define PGQ priority_queue<int,vector<int>,greater<int> > #define VE vector<int> #define VP vector<PA> #define YES(i) cout<<(i?"YES":"NO")<<endl #define Yes(i) cout<<(i?"Yes":"No")<<endl #define MOD 1000000007 #define INF 1000000007 #define PI 3.141592653589793238462643383279 using namespace std; // int main(){ int N; int A[100000]; cin>>N; FOR(i,0,N){ cin>>A[i]; } if(i<=2){ cout<<1<<endl; return 0; } int i=0,cnt=1; while(i<=N-3){ if(A[i]<=A[i+1]&&A[i+1]<=A[i+2]){ i++; }else if(A[i]>=A[i+1]&&A[i+1]>=A[i+2]){ i++; }else{ i+=2; cnt++; } } cout<<cnt<<endl; return 0; }
a.cc: In function 'int main()': a.cc:34:6: error: 'i' was not declared in this scope 34 | if(i<=2){ | ^
s009633607
p03745
Java
import java.util.Scanner; public class AMain { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] a = new int[n]; for(int i=0; i<n; i++){ a[i] = sc.nextInt(); } sc.close(); long ans = 1; int pos = 0; //pos: 1 zero: 0, neg: -1 for(int i=1; i<n; i++){ if(pos == 0){ if(a[i] - a[i-1] < 0){ pos = -1; }else if(a[i] - a[i-1] > 0){ pos = 1; } }else if(pos == 1){ if(a[i] - a[i-1] < 0){ ans++; pos = 0; } }else if(pos == -1){ if(a[i] - a[i-1] > 0){ ans++; pos = 0; } } } System.out.println(ans); } }
Main.java:3: error: class AMain is public, should be declared in a file named AMain.java public class AMain { ^ 1 error
s933705136
p03745
C++
#include <bits/stdc++.h> const int N=3050,mo=1e9+7; using namespace std; inline int gi(){ char ch=getchar();int x=0,q=0; while(ch<'0' || ch>'9') ch=='-'?q=1:0,ch=getchar(); while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar(); return q?(-x):x; } int f[N][N][2]; void dp(ll &x,ll y){ x+=y; if (x>=mo) x-=mo; return; } int main(){ int n=gi(),m=gi(); for (int i=0; i<=m; ++i) f[0][i][i==0]=1; for (int i=0; i<m; ++i) for (int j=0; j<=n; ++j) for (int k=0; k<=1; ++k) if (f[i][j][k]){ if (j) dp(f[i+1][j-1][k|(j==1)],f[i][j][k]); if (j) dp(f[i+1][j][k|(j==1)],f[i][j][k]); if (j<n) dp(f[i+1][j+1][k],f[i][j][k]); if (j<n) dp(f[i+1][j][k],f[i][j][k]); } ll ans=0; for (int i=0; i<=n; ++i) dp(ans,f[m][i][1]); cout<<ans; return 0; }
a.cc:11:6: error: variable or field 'dp' declared void 11 | void dp(ll &x,ll y){ | ^~ a.cc:11:9: error: 'll' was not declared in this scope 11 | void dp(ll &x,ll y){ | ^~ a.cc:11:13: error: 'x' was not declared in this scope 11 | void dp(ll &x,ll y){ | ^ a.cc:11:15: error: 'll' was not declared in this scope 11 | void dp(ll &x,ll y){ | ^~ a.cc: In function 'int main()': a.cc:23:16: error: 'dp' was not declared in this scope; did you mean 'dup'? 23 | if (j) dp(f[i+1][j-1][k|(j==1)],f[i][j][k]); | ^~ | dup a.cc:24:16: error: 'dp' was not declared in this scope; did you mean 'dup'? 24 | if (j) dp(f[i+1][j][k|(j==1)],f[i][j][k]); | ^~ | dup a.cc:25:18: error: 'dp' was not declared in this scope; did you mean 'dup'? 25 | if (j<n) dp(f[i+1][j+1][k],f[i][j][k]); | ^~ | dup a.cc:26:18: error: 'dp' was not declared in this scope; did you mean 'dup'? 26 | if (j<n) dp(f[i+1][j][k],f[i][j][k]); | ^~ | dup a.cc:28:3: error: 'll' was not declared in this scope 28 | ll ans=0; | ^~ a.cc:30:8: error: 'ans' was not declared in this scope; did you mean 'abs'? 30 | dp(ans,f[m][i][1]); | ^~~ | abs a.cc:30:5: error: 'dp' was not declared in this scope; did you mean 'dup'? 30 | dp(ans,f[m][i][1]); | ^~ | dup a.cc:31:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 31 | cout<<ans; | ^~~ | abs
s519768042
p03745
C
//set many funcs template #include<stdio.h> #include<string.h> #include<stdlib.h> #include<stdbool.h> #define inf 1072114514 #define llinf 4154118101919364364 #define mod 1000000007 #define pi 3.1415926535897932384 int max(int a,int b){if(a>b){return a;}return b;} int min(int a,int b){if(a<b){return a;}return b;} int zt(int a,int b){return max(a,b)-min(a,b);} int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;} int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;} int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;} int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;} int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} long long llmax(long long a,long long b){if(a>b){return a;}return b;} long long llmin(long long a,long long b){if(a<b){return a;}return b;} long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);} long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;} long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;} long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;} long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;} long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;} long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} double dbmax(double a,double b){if(a>b){return a;}return b;} double dbmin(double a,double b){if(a<b){return a;}return b;} double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);} int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;} int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;} int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;} int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;} int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;} int main(void){ int n,a[131072],r=1,st; scanf("%d",&n); for(i=1;i<=n;i++){scanf("%d",&a[i]);} st=0; for(i=2;i<=n;i++){ if(a[i-1]<a[i]){ if(st==0){st=1;} if(st==-1){st=0;r++;} } if(a[i-1]>a[i]){ if(st==0){st=-1;} if(st==1){st=0;r++;} } } printf("%d\n",r); return 0; }
main.c:14:5: warning: conflicting types for built-in function 'round'; expected 'double(double)' [-Wbuiltin-declaration-mismatch] 14 | int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} | ^~~~~ main.c:6:1: note: 'round' is declared in header '<math.h>' 5 | #include<stdbool.h> +++ |+#include <math.h> 6 | #define inf 1072114514 main.c:15:5: warning: conflicting types for built-in function 'ceil'; expected 'double(double)' [-Wbuiltin-declaration-mismatch] 15 | int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;} | ^~~~ main.c:15:5: note: 'ceil' is declared in header '<math.h>' main.c:20:5: warning: conflicting types for built-in function 'pow'; expected 'double(double, double)' [-Wbuiltin-declaration-mismatch] 20 | int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;} | ^~~ main.c:20:5: note: 'pow' is declared in header '<math.h>' main.c:24:11: warning: conflicting types for built-in function 'llround'; expected 'long long int(double)' [-Wbuiltin-declaration-mismatch] 24 | long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;} | ^~~~~~~ main.c:24:11: note: 'llround' is declared in header '<math.h>' main.c: In function 'main': main.c:44:9: error: 'i' undeclared (first use in this function) 44 | for(i=1;i<=n;i++){scanf("%d",&a[i]);} | ^ main.c:44:9: note: each undeclared identifier is reported only once for each function it appears in
s125555005
p03745
C++
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<cstring> #include<cctype> #include<queue> #include<stack> #include<map> #include<set> #include<iomanip> #include<sstream> #include<cstdlib> #include<ctime> #include<list> #include<deque> #include<bitset> #include<fstream> #define ld double #define ull unsigned long long #define ll long long #define pii pair<int,int > #define iiii pair<int,pii > #define mp make_pair #define INF 1000000000 #define MOD 1000000007ll #define MAXN 3100 using namespace std; ll Dp[MAXN][MAXN][2]; int n,m; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;i++)Dp[0][i][0]=1; Dp[0][0][1]=1; for(int i=1;i<=m;i++) for(int j=0;j<=n;j++) { if(j==0) { Dp[i][j][0]=0; Dp[i][j][1]=(Dp[i-1][j+1][0]+Dp[i-1][j+1][1]+Dp[i-1][j][1])%MOD; } else if(j==n) { Dp[i][j][0]=(Dp[i-1][j-1][0]+Dp[i-1][j][0])%MOD; Dp[i][j][1]=(Dp[i-1][j-1][1]+Dp[i-1][j][1])%MOD; } else { Dp[i][j][0]=(2*Dp[i-1][j][0]+Dp[i-1][j-1][0]+Dp[i-1][j+1][0])%MOD; Dp[i][j][1]=(2*Dp[i-1][j][1]+Dp[i-1][j-1][1]+Dp[i-1][j+1][1])%MOD; } } for(int i=0;i<=m;i++) for(int ) ll res=0; for(int i=0;i<=n;i++) { res=(res+Dp[m][i][1]+MOD)%MOD; } printf("%I64d\n",res); return 0; }
a.cc: In function 'int main()': a.cc:64:25: error: expected unqualified-id before ')' token 64 | for(int ) | ^ a.cc:64:24: error: expected ';' before ')' token 64 | for(int ) | ^~ | ; a.cc:64:25: error: expected primary-expression before ')' token 64 | for(int ) | ^ a.cc:64:24: error: expected ';' before ')' token 64 | for(int ) | ^~ | ; a.cc:71:17: error: 'res' was not declared in this scope 71 | res=(res+Dp[m][i][1]+MOD)%MOD; | ^~~ a.cc:74:26: error: 'res' was not declared in this scope 74 | printf("%I64d\n",res); | ^~~
s211399407
p03745
C++
gfdgasdg
a.cc:1:1: error: 'gfdgasdg' does not name a type 1 | gfdgasdg | ^~~~~~~~
s999499782
p03745
C++
#include <iostream> using namespace std; int n,a[100005],ans=1,dir; int main(){ ios::sync_with_stdio(false); cin.tie(0); cin>>n; st=n+1; for(int i=1;i<=n;i++){ cin>>a[i]; if(st==n+1 && i>1 && a[i]!=a[i-1])st=i; } dir=(a[st-1]<a[st]); for(int i=st+1;i<=n;i++){ if(a[i-1]==a[i])continue; if((a[i-1]<a[i])!=dir){ ans++; while(i<n){ if(a[i]!=a[i+1]){ dir=(a[i]<a[i+1]); break; } i++; } } } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:8:9: error: 'st' was not declared in this scope; did you mean 'std'? 8 | st=n+1; | ^~ | std
s127287044
p03745
C++
bfrwb
a.cc:1:1: error: 'bfrwb' does not name a type 1 | bfrwb | ^~~~~
s769709678
p03745
Java
import java.util.Scanner; public class SortedArrays { public static void main(String[] args) { try (Scanner scanner = new Scanner(System.in)) { int n = scanner.nextInt(); int inputNum = scanner.nextInt(); int cnt = 1; State state = State.NONE; for (int i = 1; i < n; i++) { int beforeNum = inputNum; inputNum = scanner.nextInt(); switch (state) { case NONE: if (beforeNum < inputNum) { state = State.UP; } if (beforeNum > inputNum) { state = State.DOWN; } break; case UP: if (beforeNum > inputNum) { state = State.NONE; cnt++; } break; case DOWN: if (beforeNum < inputNum) { state = State.NONE; cnt++; } break; default: break; } } System.out.println(cnt); } catch (Exception ex) { ex.printStackTrace(); } } enum State { NONE, UP, DOWN } }
Main.java:3: error: class SortedArrays is public, should be declared in a file named SortedArrays.java public class SortedArrays { ^ 1 error
s341446908
p03745
C
#include <stdio.h> 2 #include <stdlib.h> 3 4 int main(){ 5 int N; 6 scanf("%d",&N); 7 int i; 8 int A[N]; 9 for (i=0;i<N;i++){ 10 scanf("%d",&A[N]); 11 } 12 int ans = 0; 13 int state = 0;//0 none 1 up -1 down 14 int temp = 0; 15 for (i=1;i<N;i++){ 16 switch(state){ 17 case 0: 18 if (A[i]>A[i-1]){ 19 temp = 1; 20 } 21 if (A[i]<A[i-1]){ 22 temp = -1; 23 } 24 break; 25 case 1: 26 if (A[i]<A[i-1]){ 27 temp = -1; 28 ans ++; 29 } 30 break; 31 case -1: 32 if (A[1]>A[i-1]){ 33 temp = 1; 34 ans ++; 35 } 36 break; 37 } 38 state = temp; 39 } 40 printf("%d",ans); 41 puts(""); 42 }
main.c:2:3: error: expected identifier or '(' before numeric constant 2 | 2 #include <stdlib.h> | ^ main.c:2:5: error: stray '#' in program 2 | 2 #include <stdlib.h> | ^
s331344111
p03745
C++
#include <cstdio> #include <cstring> #include <iostream> using namespace std; #define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl; #define sci(x) int x;scanf("%d",&x); #define scii(x, y) int x,y;scanf("%d%d",&x,&y); #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 int long long #define %d %lld signed main() { sci(N); sci(A) int inc = 2; int ans=0; REP(i,N-1) { const int pA = A; scanf("%d",&A); if (pA < A) { if (inc==0) ans++,inc=2; else inc = true; } else if (pA > A) { if (inc==1) ans++,inc=2; else inc = false; } else inc = 2; } printf("%d\n", ++ans); }
a.cc:11:9: error: macro names must be identifiers 11 | #define %d %lld | ^
s461602560
p03745
C++
#include <iostream> #include <vector> using namespace std; int compare(int a, int b) { if (a == b) return 0; else if (a > b) return -1; else return 1; }; void main() { int N; vector<int> a; cin >> N; int temp; for (int i = 0; i < N; i++) { cin >> temp; a.push_back(temp); } int sub_num = 0; int head = 0; int tend_flag = 0; if (N == 1) cout << 1; else { for (int i = 0; i < N - 1; i++) { if (tend_flag*compare(a[i], a[i + 1]) < 0) { sub_num++; tend_flag = 0; } else tend_flag += compare(a[i], a[i + 1]); } sub_num++; cout << sub_num; } }
a.cc:15:1: error: '::main' must return 'int' 15 | void main() | ^~~~
s442600694
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; if(n<=2) cout<<1<<endl; else{ vector<int> a(2), v(n); for(int i=0; i<n; i++) cin>>v[i]; a[0]=v[0]; a[1]=v[1]; int i=2, sgn=0; if(a[0]<a[1]) sgn=1; else if(a[0]>a[1]) sgn=-1; while(i<n){ int ts=0; if(a[a.size()-1]<v[i]) ts=1; else if(a[a.size()-1]>v[i]) ts=-1; if(sgn==0){ a.push_back(v[i]); sgn=ts; i++; } else if(sgn==1){ if(ts>=0){ a.push_back(v[i]); i++; } else{ ans++; a.empty(); i++; if(i<n){ a.push_back(v[i-1]); a.push_back(v[i]); } else{ ans++; break; } i++; sgn=0; if(a[0]<a[1]) sgn=1; else if(a[0]>a[1]) sgn=-1; } } else{ if(ts<=0){ a.push_back(v[i]); i++; } else{ ans++; a.empty(); i++; if(i<n){ a.push_back(v[i-1]); a.push_back(v[i]); } else{ ans++; break; } i++; sgn=0; if(a[0]<a[1]) sgn=1; else if(a[0]>a[1]) sgn=-1; } } } ans+=(a.size()>0); cout<<ans<<endl; } }
a.cc: In function 'int main()': a.cc:34:41: error: 'ans' was not declared in this scope; did you mean 'abs'? 34 | ans++; | ^~~ | abs a.cc:35:48: warning: ignoring return value of 'bool std::vector<_Tp, _Alloc>::empty() const [with _Tp = int; _Alloc = std::allocator<int>]', declared with attribute 'nodiscard' [-Wunused-result] 35 | a.empty(); | ~~~~~~~^~ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/stl_vector.h:1090:7: note: declared here 1090 | empty() const _GLIBCXX_NOEXCEPT | ^~~~~ a.cc:57:41: error: 'ans' was not declared in this scope; did you mean 'abs'? 57 | ans++; | ^~~ | abs a.cc:58:48: warning: ignoring return value of 'bool std::vector<_Tp, _Alloc>::empty() const [with _Tp = int; _Alloc = std::allocator<int>]', declared with attribute 'nodiscard' [-Wunused-result] 58 | a.empty(); | ~~~~~~~^~ /usr/include/c++/14/bits/stl_vector.h:1090:7: note: declared here 1090 | empty() const _GLIBCXX_NOEXCEPT | ^~~~~ a.cc:75:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 75 | ans+=(a.size()>0); | ^~~ | abs
s191444021
p03745
Java
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String arrayLength = sc.nextLine(); String array = sc.nextLine(); Integer[] intArray = returnIntegerArray(array); Boolean isPlus = null; int answer = 1; for (int i = 1; i < intArray.length; i++) { if ((isPlus == null || isPlus) && intArray[i - 1] > intArray[i]) { isPlus = false; answer++; } else if ((isPlus == null || !isPlus) && intArray[i - 1] < intArray[i]) { isPlus = true; answer++; } } System.out.println(answer); } private static Integer[] returnIntegerArray(String array) { String[] strArray = array.split(" "); Integer[] intArray = new Integer[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; } }
Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:4: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s201631601
p03745
Java
Scanner sc = new Scanner(System.in); String arrayLength = sc.nextLine(); String array = sc.nextLine(); Integer[] intArray = returnIntegerArray(array); Boolean isPlus = null; int answer = 1; for (int i = 1; i < intArray.length; i++) { if ((isPlus == null || isPlus) && intArray[i] > intArray[i + 1]) { isPlus = false; answer++; } else if ((isPlus == null || !isPlus) && intArray[i] < intArray[i + 1]) { isPlus = true; answer++; } } System.out.println(answer); } private static Integer[] returnIntegerArray(String array) { String[] strArray = array.split(" "); Integer[] intArray = new Integer[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. Scanner sc = new Scanner(System.in); ^ (use --enable-preview to enable unnamed classes) Main.java:9: error: class, interface, enum, or record expected for (int i = 1; i < intArray.length; i++) { ^ Main.java:9: error: class, interface, enum, or record expected for (int i = 1; i < intArray.length; i++) { ^ Main.java:9: error: class, interface, enum, or record expected for (int i = 1; i < intArray.length; i++) { ^ Main.java:12: error: class, interface, enum, or record expected answer++; ^ Main.java:13: error: class, interface, enum, or record expected } else if ((isPlus == null || !isPlus) && intArray[i] < intArray[i + 1]) { ^ Main.java:15: error: class, interface, enum, or record expected answer++; ^ Main.java:16: error: class, interface, enum, or record expected } ^ Main.java:21: error: class, interface, enum, or record expected } ^ Main.java:26: error: class, interface, enum, or record expected for (int i = 0; i < strArray.length; i++) { ^ Main.java:26: error: class, interface, enum, or record expected for (int i = 0; i < strArray.length; i++) { ^ Main.java:26: error: class, interface, enum, or record expected for (int i = 0; i < strArray.length; i++) { ^ Main.java:29: error: class, interface, enum, or record expected } ^ Main.java:31: error: class, interface, enum, or record expected } ^ 14 errors
s693907125
p03745
Java
import java.util.Scanner; public class ASortedArray { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String arrayLength = sc.nextLine(); String array = sc.nextLine(); Integer[] intArray = returnIntegerArray(array); Boolean isPlus = null; int answer = 1; for (int i = 1; i < intArray.length; i++) { if ((isPlus == null || isPlus) && intArray[i] > intArray[i + 1]) { isPlus = false; answer++; } else if ((isPlus == null || !isPlus) && intArray[i] < intArray[i + 1]) { isPlus = true; answer++; } } System.out.println(answer); } private static Integer[] returnIntegerArray(String array) { String[] strArray = array.split(" "); Integer[] intArray = new Integer[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; } }
Main.java:3: error: class ASortedArray is public, should be declared in a file named ASortedArray.java public class ASortedArray { ^ 1 error
s390584055
p03745
Java
package grandContest013; import java.util.Scanner; public class ASortedArray { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String arrayLength = sc.nextLine(); String array = sc.nextLine(); Integer[] intArray = returnIntegerArray(array); Boolean isPlus = null; int answer = 1; for (int i = 1; i < intArray.length; i++) { if ((isPlus == null || isPlus) && intArray[i] > intArray[i + 1]) { isPlus = false; answer++; } else if ((isPlus == null || !isPlus) && intArray[i] < intArray[i + 1]) { isPlus = true; answer++; } } System.out.println(answer); } private static Integer[] returnIntegerArray(String array) { String[] strArray = array.split(" "); Integer[] intArray = new Integer[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; } }
Main.java:5: error: class ASortedArray is public, should be declared in a file named ASortedArray.java public class ASortedArray { ^ 1 error
s162410173
p03745
Java
public static void main(String[] args) { Scanner sc = new Scanner(System.in); String arrayLength = sc.nextLine(); String array = sc.nextLine(); Integer[] intArray = returnIntegerArray(array); Boolean isPlus = null; int answer = 1; for (int i = 1; i < intArray.length; i++) { if ((isPlus == null || isPlus) && intArray[i] > intArray[i + 1]) { isPlus = false; answer++; } else if ((isPlus == null || !isPlus) && intArray[i] < intArray[i + 1]) { isPlus = true; answer++; } } System.out.println(answer); } private static Integer[] returnIntegerArray(String array) { String[] strArray = array.split(" "); Integer[] intArray = new Integer[strArray.length]; for (int i = 0; i < strArray.length; i++) { intArray[i] = Integer.parseInt(strArray[i]); } return intArray; }
Main.java:1: error: unnamed classes are a preview feature and are disabled by default. public static void main(String[] args) { ^ (use --enable-preview to enable unnamed classes) 1 error
s899079654
p03745
Java
import java.io.*; import java.util.*; public class P1 { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = sc.nextInt(); int [] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = sc.nextInt(); int idx = 0; int cnt = 0; while (idx < n) { int inc = idx; while (inc + 1 < n) { if (arr[inc] > arr[inc + 1]) break; inc++; } int dec = idx; while (dec + 1 < n) { if (arr[dec] < arr[dec + 1]) break; dec++; } cnt++; idx = Math.max(inc + 1, dec + 1); } out.println(cnt); out.flush(); out.close(); } static class Scanner { StringTokenizer st; BufferedReader br; public Scanner(InputStream s) { br = new BufferedReader(new InputStreamReader(s)); } public Scanner (FileReader f) {br = new BufferedReader(f);} public String next() throws IOException { while (st == null || !st.hasMoreTokens()) st = new StringTokenizer(br.readLine()); return st.nextToken(); } public int nextInt() throws IOException { return Integer.parseInt(next()); } public long nextLong() throws IOException { return Long.parseLong(next()); } public String nextLine() throws IOException { return br.readLine(); } public double nextDouble() throws IOException { String x = next(); StringBuilder sb = new StringBuilder("0"); double res = 0, f = 1; boolean dec = false, neg = false; int start = 0; if (x.charAt(0) == '-') { neg = true; start++; } for (int i = start; i < x.length(); i++) if (x.charAt(i) == '.') { res = Long.parseLong(sb.toString()); sb = new StringBuilder("0"); dec = true; } else { sb.append(x.charAt(i)); if (dec) f *= 10; } res += Long.parseLong(sb.toString()) / f; return res * (neg ? -1 : 1); } public boolean ready() throws IOException { return br.ready(); } } }
Main.java:4: error: class P1 is public, should be declared in a file named P1.java public class P1 { ^ 1 error
s202500529
p03745
C++
//#include <bits/stdc++.h> #include <iostream> #include <vector> using namespace std; int main(void){ int N,T,L; int X[100000] = {}; int W[100000] = {}; int i; cin >> N >> L >> T; //cout << N << L << T << endl; for(i=0;i<N;i++){ cin >> X[i] >> W[i]; //cout << X[i] << W[i] << endl; } vector<int> v; for(i=0;i<N;i++){ if(W[i]==1){ v.push_back((X[i] + T) % L); } if(W[i]==2){ v.push_back((((X[i] - T) % L) + L) % L); } //cout << v[i] << endl; } int cross = 0; if(W[0]==1){ for(i=1;i<N;i++){ if(W[i]==2){ if(2*T-(X[i]-X[0])>=0){cross++;} //cout << "cross " << cross << endl; cross += (2*T-(X[i]-X[0]))/L; //cout << "cross " << cross << endl; } } } if(W[0]==2){ for(i=1;i<N;i++){ if(W[i]==1){ if(2*T-(L - X[i] + X[0])>=0){cross++;} //cout << "cross " << cross << endl; cross += (2*T-(L - X[i] + X[0]))/L; //cout << "cross " << cross << endl; } } } cross %= N; int tmp = v[0]; sort(v.begin(), v.end()); vector<int>::iterator iter = find(v.begin(), v.end(), tmp); int index = distance(v.begin(), iter); if(W[0]==1){ if(v[index] == v[(index+1+N)%N]){index++;} for(i=0;i<N;i++){ cout << v[(index-cross+i+N)%N] << endl; } } if(W[0]==2){ for(i=0;i<N;i++){ cout << v[(index+cross+i+N)%N] << endl; } } //cout << "index " << index << endl; return 0; }
a.cc: In function 'int main()': a.cc:51:5: error: 'sort' was not declared in this scope; did you mean 'short'? 51 | sort(v.begin(), v.end()); | ^~~~ | short a.cc:52:38: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, int&)' 52 | vector<int>::iterator iter = find(v.begin(), v.end(), tmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 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:2: /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> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:52:38: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>' 52 | vector<int>::iterator iter = find(v.begin(), v.end(), tmp); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s417573763
p03745
C++
#include<bits/stdc++.h> using namespace std; int n,a[100001],cnt,f; int s(int i){ for(int j=i+1;j<n-1;j++) if(a[j]<a[j+1]){f=2;cnt++;return i;} } int b(int i){ for(int j=i+1;j<n-1;j++) if(a[j]>a[j+1]){f=0;cnt++;return i;} } int main(){ cin>>n; for(int i=0;i<n;i++)cin>>a[i]; for(int i=0;i<n-1;i++){ if(a[i]>a[i+1]){f=1;i=s(i); else if(a[i]<a[i+1]){f=2;i=b(i);} } cout<<cnt+1<<endl; return 0; }
a.cc: In function 'int main()': a.cc:19:3: error: expected '}' before 'else' 19 | else if(a[i]<a[i+1]){f=2;i=b(i);} | ^~~~ a.cc:18:18: note: to match this '{' 18 | if(a[i]>a[i+1]){f=1;i=s(i); | ^ a.cc: In function 'int s(int)': a.cc:7:1: warning: control reaches end of non-void function [-Wreturn-type] 7 | } | ^ a.cc: In function 'int b(int)': a.cc:11:1: warning: control reaches end of non-void function [-Wreturn-type] 11 | } | ^
s560383430
p03745
C++
#include<iostream> #include<vector> #include<utility> #include<math.h> using namespace std; typedef long long ll; typedef vector<ll> vi; typedef vector<vi> vvi; typedef vector<pair<int, int> > vp; #define pb push_back #define mod 1000000007 #define inf 999999999 #define rep(i, n) for(int i = 0; i < (n); i++) #define For(i, a, n) for(int i = a; i < (n); i++) #define out(n) cout << n << endl; #define vut(v) rep(i, v.size()) out(v[i]); ll a[n]; int main(){ int n, b; cin >> n; rep(i, n) { cin >> a[i]; } int z = 0; int k = 0; int d = 0; int count = 0; rep(i, n) { if(a[i] + 1 == a[i + 1]) { if(!z) count++; z = 1; continue; } if(z) { z = 0; if(i == n - 2) count++; continue; } if(a[i] - 1 == a[i + 1]) { if(!k) count++; k = 1; continue; } if(k) { k = 0; if(i == n - 2) count++; continue; } if(i && a[i] == a[i - 1]) { continue; } if(i == n - 2) { count++; break; } if(d) { count++; d = 0; }else { d = 1; } } out(count) }
a.cc:21:6: error: 'n' was not declared in this scope; did you mean 'yn'? 21 | ll a[n]; | ^ | yn a.cc: In function 'int main()': a.cc:28:12: error: 'a' was not declared in this scope 28 | cin >> a[i]; | ^ a.cc:37:8: error: 'a' was not declared in this scope 37 | if(a[i] + 1 == a[i + 1]) { | ^ a.cc:49:8: error: 'a' was not declared in this scope 49 | if(a[i] - 1 == a[i + 1]) { | ^ a.cc:61:13: error: 'a' was not declared in this scope 61 | if(i && a[i] == a[i - 1]) { | ^
s191157623
p03745
C++
7 1 2 3 2 1 999999999 1000000000
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 7 | ^
s804675435
p03745
C++
#include <iostream> using namespace std; int main() { int count = 1; int x = 0; bool p = false; bool q = false; int n; cin >> n; int a[100000]; int b[100000]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 1; i < n; i++) { b[i] = a[i] - a[i - 1]; } for (int i = 1; i < n; i++) { if ((x == 0 || x == -1) && b[i] > 0) { if(x == 0){ x = 1; }else if(x == -1){ count++; x = 1; } else if ((x == 0 || x == 1) && b[i] < 0) { if(x == 0){ x = -1; }else if(x == 1){ count++; x = -1; } } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s599881379
p03745
C++
#include <iostream> using namespace std; int main() { int count = 1; int x = 0; bool p = false; bool q = false; int n; cin >> n; int a[100000]; int b[100000]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 1; i < n; i++) { b[i] = a[i] - a[i - 1]; } for (int i = 1; i < n; i++) { if ((x == 0 || x == -1) && b[i] > 0) { if(x == 0){ x = 1; }else if(x == -1){ count++; x = 1; } else if ((x == 0 || x == 1) && b[i] < 0) { if(x == 0){ x = -1; }else if(x == 1){ count++; x = -1; } } } cout << count << endl; }
a.cc: In function 'int main()': a.cc:45:2: error: expected '}' at end of input 45 | } | ^ a.cc:5:12: note: to match this '{' 5 | int main() { | ^
s952993857
p03745
C++
#include<iostream> #include<vector> using namespace std; int main(void){ int N,tmp,f,a=0; vector<int> v; cin>>N; for(int i=0;i<N;i++){ cin>>tmp; v.push_back(tmp); } f=v[1]-v[0]; for(int i=2;i<v.size();i++){ if(v[i][i-1]!=f){ a++; f=v[i]-v[i-1]; } } cout<<a<<endl; return 0; }
a.cc: In function 'int main()': a.cc:16:10: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript 16 | if(v[i][i-1]!=f){ | ^
s226514810
p03745
C++
#include <iostream> #define MAX_N 100000 using namespace std; int main(void){ int n, j; int a[MAX_N]; int cnt=0; cin >> n; for (int i=0; i<n; i++){ cin >> a[i]; } for (int i=0; i<n; i++){ if (a[i] != a[i+1]){ j = i; break; } } if (a[j] < a[j+1]){ for (int i=j; i<n; i++){ if (a[i] > a[i+1]){ cnt += 1; for (int k = i; k<n; k++){ if (a[k] < a[k+1]){ break; } i=k; } } } } else if (a[j] > a[j+1]){ for (int i=j; i<n; i++){ if (a[i] < a[i+1]){ cnt += 1; for (int k = i; k<n; k++){ if (a[k] > a[k+1]){} break; } i=k; } } } } cout << cnt + 1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:40:13: error: 'k' was not declared in this scope 40 | i=k; | ^ a.cc: At global scope: a.cc:45:3: error: 'cout' does not name a type 45 | cout << cnt + 1 << endl; | ^~~~ a.cc:47:3: error: expected unqualified-id before 'return' 47 | return 0; | ^~~~~~ a.cc:48:1: error: expected declaration before '}' token 48 | } | ^
s327620265
p03745
C++
#include<iostream> #include<vector> using namespace std; int main(void){ int N,tmp,f,a=0; vector<int> v; cin>>N; for(int i=0;i<N;i++){ cin>>tmp; v.push(tmp); } f=v[1]-v[0]; if(f==0)a++; for(int i=2;i<v.size();i++){ if((v[i]-v[i-1]>0&&f<0)||(v[i]-v[i-1]<0&&f>0))a++; else if(v[i]-v[i-1]==0)a++; } cout<<a<<endl; return 0; }
a.cc: In function 'int main()': a.cc:12:4: error: 'class std::vector<int>' has no member named 'push' 12 | v.push(tmp); | ^~~~
s055024157
p03745
C++
#include<bits/stdc++.h> #include<unordered_map> /* *▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ * ▀▀ ▀▀▀▀▀▀ ▀ ▀▀▀▀▀▀ ▀ ▀ * ▀ ▀ ▀ ▀ ▀ ▀ ▀ * ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ ▀ * ▀ ▀▀▀▀ ▀ ▀ ▀ ▀ ▀ *▀ ▀ ▀ ▀ ▀ ▀ *▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀ */ using namespace std; void afify() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } #define ll long int #define ld long double #define loopi(i,intial,n) for(ll i=ll(intial);i<n;i++) #define loopj(j,intial,n) for(ll j=ll(intial);j<n;j++) #define min3(a,b,c) min(a,min(b,c)) #define max3(a,b,c) max(a,max(b,c)) #define all(v) v.begin(),v.end() /////////////////////////////////////// #define SCD(a) scanf("%d",&a) #define SCD2(a,b) scanf("%d %d",&a,&b) #define SCLL(a) scanf("%lld",&a) #define SCLL2(a,b) scanf("%lld %lld",&a,&b) #define PRD(a) printf("%d\n",a) #define PRLL(a) printf("%lld\n",a) /////////////////////////////////////// typedef vector <int> vi; typedef vector <ll> vll; typedef vector <vi> vvi; typedef vector <vll> vvll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vpll> vvpll; typedef vector<vpii> vvpii; typedef stringstream ss; const ll oo = (ll) 1e13; //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); //ifstream ifs("input.txt"); //ofstream ofs("output.txt"); ll arr[1000005]; int main() { afify(); int n; cin>>n; loopi(i,0,n) cin>>arr[i]; bool test=0;ll res=0; loopi(i,0,n){ while (i+1<n&&arr[i]<=arr[i+1]) { i++;test=1; } if(test){res++;test=0;i++;} while (i+1<n&&arr[i]>=arr[i+1]) { i++;test=1; } if(test){res++;test=0;} } if(n==1){cout<<1<<endl;} else {cout<<res<<endl;} return 0; }
a.cc: In function 'int main()': a.cc:20:12: error: expected primary-expression before 'long' 20 | #define ll long int | ^~~~ a.cc:22:37: note: in expansion of macro 'll' 22 | #define loopi(i,intial,n) for(ll i=ll(intial);i<n;i++) | ^~ a.cc:57:4: note: in expansion of macro 'loopi' 57 | loopi(i,0,n) cin>>arr[i]; | ^~~~~ a.cc:20:12: error: expected primary-expression before 'long' 20 | #define ll long int | ^~~~ a.cc:22:37: note: in expansion of macro 'll' 22 | #define loopi(i,intial,n) for(ll i=ll(intial);i<n;i++) | ^~ a.cc:59:4: note: in expansion of macro 'loopi' 59 | loopi(i,0,n){ | ^~~~~
s845057249
p03745
Java
public class Main{ public static void main(){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int arr[] = new int[n]; for(int i=0; i<n; i++){ arr[i] = sc.nextInt(); } int count =0; int prev = arr[0]; bool flag = true; int i=1; while(i<n){ if(arr[i] > prev){ flag = true; prev = arr[i]; }else if(arr[i] < prev){ flag = false; prev = arr[i]; }else{ i++; continue; } i++; count++; for( ;i<n; i++){ if(flag == true){ if(arr[i] >= prev) prev = arr[i]; else{ prev = arr[i]; i++; break; } }else{ if(arr[i] <= prev) prev = arr[i]; else{ prev = arr[i]; i++; break; } } } } System.out.println(count); } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:13: error: cannot find symbol bool flag = true; ^ symbol: class bool location: class Main 3 errors
s374177168
p03745
C++
read = lambda: map(int, input().split()) n = int(input()) a = list(read()) cnt = 1 f = 0 for i in range(1, n): if a[i] > a[i - 1] and f == -1: f = 0 cnt += 1 elif a[i] < a[i - 1] and f == 1: f = 0 cnt += 1 elif a[i] > a[i - 1]: f = 1 elif a[i] < a[i - 1]: f = -1 print(cnt)
a.cc:1:1: error: 'read' does not name a type 1 | read = lambda: map(int, input().split()) | ^~~~
s195361670
p03745
Java
import java.util.Scanner; public class A{ public static void main(String[] args){ Scanner s = new Scanner(System.in); int n, result; n = s.nextInt(); result = devideArray(n); System.out.println(result); } public static int devideArray(int n){ Scanner s = new Scanner(System.in); int[] array = new int[n]; int count = 1; boolean flag = true; int updown = 0; for(int i = 0;i < n;i++){ array[i] = s.nextInt(); } for(int i = 0;i < n - 1;i++){ if(flag){ if(array[i] - array[i + 1] > 0){ updown = -1; flag = false; }else if(array[i] - array[i + 1] < 0){ updown = 1; flag = false; } }else{ if(array[i] - array[i + 1] > 0){ if(updown != -1){ count++; flag = true; } } if(array[i] - array[i + 1] < 0){ if(updown != 1){ count++; flag = true; } } } } return count; } }
Main.java:3: error: class A is public, should be declared in a file named A.java public class A{ ^ 1 error
s258087308
p03745
Java
import java.io.PrintWriter; import java.util.Scanner; /** * Created by shoya on 2017/04/15. */ public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter pw = new PrintWriter(System.out); int n = sc.nextInt(); int ans = 0; int prev = -1; int upFlag = -1; for (int i = 0; i < n; i++){ int curr = sc.nextInt(); //System.out.printf("Prev %d Curr %d Up %d Ans %d\n", prev, curr, upFlag, ans); if (prev == -1) { prev = curr; continue; } if (upFlag == -1){ if (curr > prev) upFlag = 1; else if (curr < prev) upFlag = 0; prev = curr; continue; } if ((upFlag == 1 && prev > curr) || (upFlag == 0 && prev < curr)){ ans++; prev = curr; upFlag = -1; continue; } prev = curr; } //System.out.printf("Up %d Ans %d\n", upFlag, ans); pw.println(ans + 1); pw.flush(); return; }
Main.java:43: error: reached end of file while parsing } ^ 1 error
s523869254
p03745
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; scanf("%d",&n); long long nt a[n]; for(int i=0;i<n;++i){ scanf("%d",&a[i]); } int res=1; for(int i=1;i<n-1;){ if(a[i]-a[i-1] < 0 && a[i+1]-a[i]>0 || a[i]-a[i-1] > 0 && a[i+1]-a[i] < 0){ ++res; i+=2; } else ++i; } printf("%d",res); return 0; }
a.cc: In function 'int main()': a.cc:6:22: error: expected initializer before 'a' 6 | long long nt a[n]; | ^ a.cc:8:29: error: 'a' was not declared in this scope 8 | scanf("%d",&a[i]); | ^ a.cc:12:20: error: 'a' was not declared in this scope 12 | if(a[i]-a[i-1] < 0 && a[i+1]-a[i]>0 || a[i]-a[i-1] > 0 && a[i+1]-a[i] < 0){ | ^
s205345779
p03745
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #include <time.h> #include <complex> #include <unordered_map> #include <unordered_set> #include <intrin.h> #include <nmmintrin.h> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b)) #define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d)) #define PW(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define RALL(x) (x).rbegin(), (x).rend() #define MODU 1000000007 #define bitcheck(a,b) ((a >> b) & 1) #define bitset(a,b) ( a |= (1 << b)) #define bitunset(a,b) (a &= ~(1 << b)) #define MP(a,b) make_pair((a),(b)) #define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second)) #define pritnf printf #define scnaf scanf #define itn int #define PI 3.141592653589 //#define Graph vector<vector<int>> #define izryt bool using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; template<typename A, size_t N, typename T> void Fill(A(&array)[N], const T &val) { std::fill((T*)array, (T*)(array + N), val); } signed main() { int n; scanf("%d", &n); vector<int> num(n); REP(i, n) { int a; scnaf("%d", &num[i]); } int ans = 1; int bef = -1; int zou = -1; rep(i, 0, n) { int cur; if (num[i] > bef) cur = 1; else if (num[i] < bef) cur = 0; else if (num[i] == bef) cur = zou; //if (bef == -1) cur = -1; if (zou != cur && zou != -1) { ans++; zou = -1; bef = num[i]; } else zou = cur, bef = num[i]; } printf("%d\n", ans); return 0; }
a.cc:20:10: fatal error: intrin.h: No such file or directory 20 | #include <intrin.h> | ^~~~~~~~~~ compilation terminated.
s449511006
p03745
C++
#include <iostream> #include <vector> #include <algorithm> #define ll long long using namespace std; typedef vector<int> VI; int main() { ios::sync_with_stdio(0); ll int n; cin >> n; ll VI A(n); for (auto& x : A) cin >> x; if (n <= 2) { cout << 1; return 0; } ll int sol = 1; ll int i = 1; while (i < n && A[i] == A[i-1]) ++i; if (i >= n-1) { cout << 1; return 0; } ll int isup = (A[i] > A[i-1] ? 1 : 0); for (; i < n; ++i) { if (A[i] == A[i-1]) continue; if (isup && A[i] > A[i-1]) continue; if (!isup && A[i] < A[i-1]) continue; ++sol; ++i; if (i < n) isup = (A[i] > A[i-1] ? 1 : 0); } cout << sol; }
a.cc: In function 'int main()': a.cc:11:15: error: expected initializer before 'A' 11 | ll VI A(n); | ^ a.cc:12:24: error: 'A' was not declared in this scope 12 | for (auto& x : A) cin >> x; | ^ a.cc:19:25: error: 'A' was not declared in this scope 19 | while (i < n && A[i] == A[i-1]) ++i; | ^ a.cc:24:24: error: 'A' was not declared in this scope 24 | ll int isup = (A[i] > A[i-1] ? 1 : 0); | ^
s271877181
p03746
C++
#include<bits/stdc++.h> #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define rep(i, x) for(ll i = 0; i < x; i++) #define rep2(i, x) for(ll i = 1; i <= x; i++) #define all(a) (a).begin(),(a).end() using ll = long long; using ld = long double; using namespace std; const ll INF = 1000000000000000000; const ll mod = 1000000007; const ld pi = 3.141592653589793238; ll visit[2345678]; signed main() { ios::sync_with_stdio(false); std::cin.tie(nullptr); ll n, m, a, b; cin >> n >> m; vector<vector<ll>> G(n + 2); rep(i, m) { cin >> a >> b; G[a].push_back(b); G[b].push_back(a); } vector<ll> start, goal; visit[a] = 1; visit[b] = 1; ll x = a, y = b; while (true) { bool ng = false; rep(i, G[x].size()) { if (visit[G[x][i]] == 0) { x = G[x][i]; visit[x] = 1; start.push_back(x); ng = true; break; } } if (!ng) { break; } } while (true) { bool ng = false; rep(i, G[y].size()) { if (visit[G[y][i]] == 0) { y = G[y][i]; visit[y] = 1; goal.push_back(y); ng = true; break; } } if (!ng) { break; } } reverse(all(start)); cout << start.size() + goal.size() + 2 << endl; rep(i, start.size()) { cout << start[i] << ' '; } cout << a << ' ' << b; rep(i, goal.size()) { cout << ' ' << goal[i]; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:27:9: error: reference to 'visit' is ambiguous 27 | visit[a] = 1; visit[b] = 1; | ^~~~~ In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80, from a.cc:1: /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:15:4: note: 'll visit [2345678]' 15 | ll visit[2345678]; | ^~~~~ a.cc:27:23: error: reference to 'visit' is ambiguous 27 | visit[a] = 1; visit[b] = 1; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:15:4: note: 'll visit [2345678]' 15 | ll visit[2345678]; | ^~~~~ a.cc:32:29: error: reference to 'visit' is ambiguous 32 | if (visit[G[x][i]] == 0) { | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:15:4: note: 'll visit [2345678]' 15 | ll visit[2345678]; | ^~~~~ a.cc:34:33: error: reference to 'visit' is ambiguous 34 | visit[x] = 1; start.push_back(x); ng = true; break; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:15:4: note: 'll visit [2345678]' 15 | ll visit[2345678]; | ^~~~~ a.cc:42:29: error: reference to 'visit' is ambiguous 42 | if (visit[G[y][i]] == 0) { | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:15:4: note: 'll visit [2345678]' 15 | ll visit[2345678]; | ^~~~~ a.cc:43:46: error: reference to 'visit' is ambiguous 43 | y = G[y][i]; visit[y] = 1; goal.push_back(y); ng = true; break; | ^~~~~ /usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)' 1855 | visit(_Visitor&& __visitor, _Variants&&... __variants) | ^~~~~ a.cc:15:4: note: 'll visit [2345678]' 15 | ll visit[2345678]; | ^~~~~
s170530504
p03746
C++
#include <bits/stdc++.h> #define int long long #define ll long long using ull = unsigned long long; using namespace std; #define dump(x) \ if (dbg) { \ cerr << #x << " = " << (x) << endl; \ } #define overload4(_1, _2, _3, _4, name, ...) name #define FOR1(n) for (ll i = 0; i < (n); ++i) #define FOR2(i, n) for (ll i = 0; i < (n); ++i) #define FOR3(i, a, b) for (ll i = (a); i < (b); ++i) #define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c)) #define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__) #define FORR(i, a, b) for (int i = (a); i <= (b); ++i) #define bit(n, k) ((n >> k) & 1) /*nのk bit目*/ namespace mydef { const int INF = 1ll << 60; const int MOD = 1e9 + 7; template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } else return 0; } template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } else return 0; } void Yes(bool flag = true) { if (flag) cout << "Yes" << endl; else cout << "No" << endl; } void No(bool flag = true) { Yes(!flag); } void YES(bool flag = true) { if (flag) cout << "YES" << endl; else cout << "NO" << endl; } void NO(bool flag = true) { YES(!flag); } template <typename A, size_t N, typename T> void Fill(A (&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); } bool dbg = false; } // namespace mydef using namespace mydef; #define pb push_back #define mp make_pair #define eb emplace_back #define lb lower_bound #define ub upper_bound #define all(v) (v).begin(), (v).end() #define SZ(x) ((int)(x).size()) #define vi vector<int> #define vvi vector<vector<int>> #define vp vector<pair<int, int>> #define vvp vector<vector<pair<int, int>>> #define pi pair<int, int> //#define P pair<int, int> //#define V vector<int> //#define S set<int> #define asn ans static struct IO { char tmp[1 << 10]; // fast input routines char cur; //#define nextChar() (cur = getc_unlocked(stdin)) //#define peekChar() (cur) inline char nextChar() { return cur = getc_unlocked(stdin); } inline char peekChar() { return cur; } inline operator bool() { return peekChar(); } inline static bool isBlank(char c) { return (c < '-' && c); } inline bool skipBlanks() { while (isBlank(nextChar())) ; return peekChar() != 0; } inline IO& operator>>(char& c) { c = nextChar(); return *this; } inline IO& operator>>(char* buf) { if (skipBlanks()) { if (peekChar()) { *(buf++) = peekChar(); while (!isBlank(nextChar())) *(buf++) = peekChar(); } *(buf++) = 0; } return *this; } inline IO& operator>>(string& s) { if (skipBlanks()) { s.clear(); s += peekChar(); while (!isBlank(nextChar())) s += peekChar(); } return *this; } inline IO& operator>>(double& d) { if ((*this) >> tmp) sscanf(tmp, "%lf", &d); return *this; } #define defineInFor(intType) \ inline IO& operator>>(intType& n) { \ if (skipBlanks()) { \ int sign = +1; \ if (peekChar() == '-') { \ sign = -1; \ n = nextChar() - '0'; \ } else \ n = peekChar() - '0'; \ while (!isBlank(nextChar())) { \ n += n + (n << 3) + peekChar() - 48; \ } \ n *= sign; \ } \ return *this; \ } defineInFor(int) defineInFor(unsigned int) // defineInFor(long long) // fast output routines //#define putChar(c) putc_unlocked((c), stdout) inline void putChar(char c) { putc_unlocked(c, stdout); } inline IO& operator<<(char c) { putChar(c); return *this; } inline IO& operator<<(const char* s) { while (*s) putChar(*s++); return *this; } inline IO& operator<<(const string& s) { for (int i = 0; i < (int)s.size(); ++i) putChar(s[i]); return *this; } char* toString(double d) { sprintf(tmp, "%lf%c", d, '\0'); return tmp; } inline IO& operator<<(double d) { return (*this) << toString(d); } #define defineOutFor(intType) \ inline char* toString(intType n) { \ char* p = (tmp + 30); \ if (n) { \ bool isNeg = 0; \ if (n < 0) \ isNeg = 1, n = -n; \ while (n) \ *--p = (n % 10) + '0', n /= 10; \ if (isNeg) \ *--p = '-'; \ } else \ *--p = '0'; \ return p; \ } \ inline IO& operator<<(intType n) { return (*this) << toString(n); } defineOutFor(signed) defineOutFor(long long) #define endl ('\n') #define cout __io__ #define cin __io__ } __io__; //https://gist.github.com/sananth12/dc6e9c1e02563b1c5004 //when int is not defined as long long, erase some comments //Don't forget to erase cin.tie(nullptr); and ios::sync_with_stdio(false); template <typename T> struct edge { int to, id; T cost; edge(int to) : to(to), id(-1), cost(1) {} edge(int to, T cost) : to(to), id(-1), cost(cost) {} edge(int to, T cost, int id) : to(to), id(id), cost(cost) {} operator int() const { return to; } /* edge& operator=(const int& x) { to = x; return *this; } */ }; template <typename T> class Graph : public vector<vector<edge<T>>> { //--------Basic-------- private: using Edge = edge<T>; int M; //M:辺の数 bool undirected = false; bool directed = false; bool unweighted = false; bool weighted = false; // public: Graph() = default; //unweighted void add_edge_undirected(int u, int v, int id = -1) { assert(!directed); assert(!weighted); undirected = true; (*this)[u].emplace_back(Edge{v, 1, id}); (*this)[v].emplace_back(Edge{u, 1, id}); } void build_undirected(int m) { assert(!(*this).empty()); assert(!directed); undirected = true; M = m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--; v--; (*this)[u].emplace_back(Edge{v, 1, i}); (*this)[v].emplace_back(Edge{u, 1, i}); } } void build_undirected(int n, int m) { (*this).resize(n); build_undirected(m); } void add_edge_directed(int u, int v, int id = -1) { assert(!undirected); directed = true; (*this)[u].emplace_back(Edge{v, 1, id}); } void build_directed(int m) { assert(!(*this).empty()); assert(!undirected); directed = true; M = m; for (int i = 0; i < m; i++) { int u, v; cin >> u >> v; u--; v--; (*this)[u].emplace_back(Edge{v, 1, i}); } } void build_directed(int n, int m) { (*this).resize(n); build_undirected(m); } //weighed void add_edge_undirected_weighed(int u, int v, T cost, int id = -1) { assert(!directed); undirected = true; (*this)[u].emplace_back(Edge{v, cost, id}); (*this)[v].emplace_back(Edge{u, cost, id}); } void build_undirected_weighted(int m) { assert(!(*this).empty()); assert(!directed); undirected = true; M = m; for (int i = 0; i < m; i++) { int u, v; T cost; cin >> u >> v >> cost; u--; v--; (*this)[u].emplace_back(Edge{v, cost, i}); (*this)[v].emplace_back(Edge{u, cost, i}); } } void build_undirected_weighted(int n, int m) { (*this).resize(n); build_undirected(m); } void add_edge_directed_weighted(int u, int v, T cost, int id = -1) { assert(!undirected); directed = true; (*this)[u].emplace_back(Edge{v, cost, id}); } void build_directed_weighted(int m) { assert(!(*this).empty()); assert(!undirected); directed = true; M = m; for (int i = 0; i < m; i++) { int u, v; T cost; cin >> u >> v >> cost; u--; v--; (*this)[u].emplace_back(Edge{v, cost, i}); } } void build_directed_weighted(int n, int m) { (*this).resize(n); build_undirected(m); } //print state void state() { cerr << endl << "Print State" << endl << "Edge :" << endl << " Directed : " << (directed ? "Yes" : "No") << endl << " Undirected : " << (undirected ? "Yes" : "No") << endl << "Usable Functions" << endl << " StronglyConnectedComponent : " << (StronglyConnectedComponent_ready ? "Yes" : "No") << endl; } // // // //--------StronglyConnectedComponent-------- //Unverified public: vector<vector<int>> SCC_R, SCC_T; // private: bool StronglyConnectedComponent_ready = false; vector<int> SCC_cmp, SCC_ord; vector<bool> SCC_used; // public: int SCC_build() { cerr << "Please Verify" << endl; assert(!undirected); assert(directed); int N = (*this).size(); SCC_R.resize(N); for (int i = 0; i < N; i++) { for (int& x : (*this)[i]) { SCC_R[x].emplace_back(i); } } SCC_cmp.resize(N); fill(SCC_cmp.begin(), SCC_cmp.end(), -1); SCC_used.resize(N); fill(SCC_used.begin(), SCC_used.end(), false); StronglyConnectedComponent_ready = true; return build_StronglyConnectedComponent_init(); } int SCC(int k) { assert(StronglyConnectedComponent_ready); return SCC_cmp[k]; } // private: void dfs(int now) { if (SCC_used[now]) return; SCC_used[now] = true; for (auto nxt : (*this)[now]) dfs(nxt); SCC_ord.emplace_back(now); } void rdfs(int now, int count) { if (SCC_cmp[now] != -1) return; SCC_cmp[now] = count; for (auto to : SCC_R[now]) rdfs(to, count); } int build_StronglyConnectedComponent_init() { int n = (int)(*this).size(); for (int i = 0; i < n; i++) dfs(i); reverse(SCC_ord.begin(), SCC_ord.end()); int group = 0; for (auto& i : SCC_ord) { if (SCC_cmp[i] == -1) { rdfs(i, group); group++; } } SCC_T.resize(group); for (int i = 0; i < n; i++) { for (auto& to : (*this)[i]) { int s = SCC_cmp[i], t = SCC_cmp[to]; if (s != t) SCC_T[s].emplace_back(t); } } return group; } // // // //--------TopologicalSort-------- //未実装 }; //グローバルでの使用のみ想定 int N, M; Graph<int> G; vi ans; int used[202020]; void f(int x) { if (!used[x]) ans.emplace_back(x); used[x] = 1; for (auto& nxt : G[x]) { if (!used[nxt]) { f(nxt); return; } } } void solve() { G.build_undirected(N, M); f(0); reverse(all(ans)); f(0); cout << ans.size() << endl; for (auto& x : ans) cout << x + 1 << " "; cout << endl; G.state(); } signed main() { cin >> N >> M; solve(); return 0; }
a.cc: In function 'void solve()': a.cc:430:10: error: ambiguous overload for 'operator<<' (operand types are 'IO' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'}) 430 | cout << ans.size() << endl; | ^~ ~~~~~~~~~~ | | | std::vector<long long int>::size_type {aka long unsigned int} a.cc:430:10: note: candidate: 'operator<<(int, std::vector<long long int>::size_type {aka long unsigned int})' (built-in) 430 | cout << ans.size() << endl; | ^ a.cc:144:16: note: candidate: 'IO& IO::operator<<(char)' 144 | inline IO& operator<<(char c) { | ^~~~~~~~ a.cc:162:16: note: candidate: 'IO& IO::operator<<(double)' 162 | inline IO& operator<<(double d) { return (*this) << toString(d); } | ^~~~~~~~ a.cc:178:16: note: candidate: 'IO& IO::operator<<(int)' 178 | inline IO& operator<<(intType n) { return (*this) << toString(n); } | ^~~~~~~~ a.cc:179:5: note: in expansion of macro 'defineOutFor' 179 | defineOutFor(signed) | ^~~~~~~~~~~~ a.cc:178:16: note: candidate: 'IO& IO::operator<<(long long int)' 178 | inline IO& operator<<(intType n) { return (*this) << toString(n); } | ^~~~~~~~ a.cc:180:9: note: in expansion of macro 'defineOutFor' 180 | defineOutFor(long long) | ^~~~~~~~~~~~
s169908367
p03746
C++
#include <iostream> #include <math.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <queue> #include <stack> #include <vector> #include <algorithm> #include <map> #include <unordered_map> #include <set> #include <deque> #include <array> #include <bitset> long long mod = 1e9 + 7; class Mint { public: long long x; Mint(){}; // 引数なしでも定義できるように引数なしコンストラクタも用意しておく Mint(long long a) { x = a % mod; while (x < 0) { x += mod; } }; Mint &operator+=(const Mint &a) { x += a.x; x %= mod; return *this; } Mint &operator-=(const Mint &a) { x += (mod - a.x); x %= mod; return *this; } Mint &operator*=(const Mint &a) { x *= a.x; x %= mod; return *this; } // a^n mod を計算する // Useaeg: Mint z = Mint(2).pow(n); Mint pow(long long n) const { if (n == 0) return Mint(1); Mint y = pow(n >> 1); // pow(n/2)を計算する y *= y; if (n % 2 == 1) y *= *this; return y; } // a^{-1} mod を計算する Mint modinv(const Mint &a) const { return a.pow(mod - 2); } Mint &operator/=(const Mint &a) { x *= modinv(a).x; x %= mod; return *this; } Mint operator+(Mint &a) const { Mint y(*this); y += a; return y; } Mint operator-(Mint &a) const { Mint y(*this); y -= a; return y; } Mint operator*(Mint &a) const { Mint y(*this); y *= a; return y; } Mint operator/(Mint &a) const { Mint y(*this); y /= a; return y.x; } // nCk @mod を計算する Mint nCk(Mint &n, const long long k) const { Mint y = Mint(1); Mint iy = Mint(1); Mint one = Mint(1); // 割り算の演算は時間がかかるので最後に1度だけ行うようにすること for (Mint i(0); (i.x) < k; i.x++) { y *= (n - i); iy *= (i + one); } return y / iy; } // nPk @mod を計算する Mint nPk(Mint &n, long long k) const { Mint y(1); for (Mint i(0); (i.x) < k; i.x++) { y *= (n - i); } return y; } }; class UnionFind { private: int n; std::vector<int> parent; public: UnionFind(int num) : n(num) { parent = std::vector<int>(n); for (int i = 0; i < n; i++) { parent[i] = i; } } int GetRoot(int i) { int n = i; while (parent[n] != n) { n = parent[n]; } parent[i] = n; return n; } bool SameGroup(int n, int m) { n = this->GetRoot(n); m = this->GetRoot(m); return n == m; } bool Unite(int n, int m) { n = this->GetRoot(n); m = this->GetRoot(m); if (n == m) return false; parent[n] = m; return true; } }; int getgcd(int a, int b) { int max = std::max(a, b); int min = std::min(a, b); if (min == 0) return max; return getgcd(min, max % min); } Mint mynCk(int n, int k) { if (2 * k > n) return mynCk(n, n - k); Mint retval(1); Mint iretval(1); for (int i = 0; i < k; i++) { retval *= Mint(n - i); } for (int i = 1; i <= k; i++) { iretval *= Mint(i); } return retval / iretval; } long long doubling[58][200004]; int main() { int N, M; std::cin >> N >> M; std::vector<int > edges[100004]; int A, B; for (int i=0; i<M; i++) { std::cin >> A >> B; A--; B--; edges[A].push_back(B); edges[B].push_back(A); } std::deque<int > ans; ans.push_front(0); std::vector<bool> group(N, false); group[0] = true; int v = 0; int tmp = edges[v][0]; ans.push_back(tmp); group[tmp] = true; while(true) { bool update = false; for (int vv : edges[v]) { if (!group[vv]) { ans.push_front(vv); v = vv; group[vv] = true; update = true; break; } } if (!update) break; } v = tmp; while(true) { bool update = false; for (int vv : edges[v]) { if (!group[vv]) { ans.push_back(vv); v = vv; group[vv] = true; update = true; break; } } if (!update) break; } std::cout << ans.size() << std:endl; for (int v : ans) { std::cout << v + 1 << std::endl; } return 0; }
a.cc: In function 'int main()': a.cc:251:33: error: found ':' in nested-name-specifier, expected '::' 251 | std::cout << ans.size() << std:endl; | ^ | ::
s771659704
p03746
C++
#include<bits/stdc++.h> #define rep(i, n) for(ll i = 0; i < (ll)(n); i++) template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } #define all(x) (x).begin(),(x).end() #pragma GCC optimize("Ofast") using namespace std; typedef long long int ll; typedef long double ld; const ll INF=(1LL<<62); const ld pi=acosl((ld)-1); const ll mod = 1000000007; // const ll mod = 1234567; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; const int ddx[8]={1,0,-1,-1,-1,0,1,1}; const int ddy[8]={1,1,1,0,-1,-1,-1,0}; #define endn "\n" #define TO_STRING(VariableName) # VariableName template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;} template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;} template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;} template<class T>void debag(const T &obj){cout<<obj<<endl;} bool solve(){ int n,m;cin>>n>>m; vector<ll>G[n]; rep(i,m){ ll a,b;cin>>a>>b;a--;b--; G[a].push_back(b); G[b].push_back(a); } vector<ll>ans; set<ll>st; int v=0; while(1){ bool isOK=true; ans.push_back(v); ll u=-1; st.insert(v); for(auto i:G[v]){ if(st.find(i)==st.end()){ isOK=false; u=i; } } if(isOK{ cout<<ans.size()<<endl; rep(i,ans.size())ans[i]++; cout<<ans<<endl; return ans.size()!=1; } else v=u; } return false; } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout<<fixed<<setprecision(30); solve(); }
a.cc: In function 'bool solve()': a.cc:48:12: error: expected ';' before '{' token 48 | if(isOK{ | ^ | ; a.cc:54:5: error: expected primary-expression before 'else' 54 | else v=u; | ^~~~ a.cc:53:6: error: expected ')' before 'else' 53 | } | ^ | ) 54 | else v=u; | ~~~~ a.cc:48:7: note: to match this '(' 48 | if(isOK{ | ^
s418244518
p03746
C++
// #pragma GCC target("avx2") #pragma GCC optimize("O3", "unroll-loops") // #include <bits/extc++.h> // using namespace __gnu_pbds; #include <bits/stdc++.h> using namespace std; #define int long long #define double long double // template <typename T> // using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; using pii = pair<int, int>; template<typename T> using prior = priority_queue<T, vector<T>, greater<T>>; template<typename T> using Prior = priority_queue<T>; // #define X first // #define Y second #define ALL(x) (x).begin(), (x).end() #define eb emplace_back #define pb push_back #define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define RANDOM() random_device __rd; \ mt19937 __gen = mt19937(__rd()); \ uniform_int_distribution<int> __dis(0, 1); \ auto rnd = bind(__dis, __gen); const int INF = 1E18; const int mod = 1E9 + 7; const int maxn = 1E5 + 5; vector<int> adj[maxn], vis(maxn, 0); deque<int> deck; void dfs(int now, int root) { vis[now] = 1; for (auto x : adj[now]) { if (!vis[x]) { vis[x] = 1, dfs(x, root); if (root == -1) deck.push_front(x); else deck.push_back(x); if (now != root) return; else root = -1; } } } int32_t main() { fastIO(); int n, m; cin >> n >> m; while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u); dfs(1); cout << deck.size() << "\n"; while (!deck.empty()) {cout << deck.front() << " "; deck.pop_front();} return 0; }
a.cc: In function 'int32_t main()': a.cc:60:24: error: 'u' was not declared in this scope 60 | while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u); | ^ a.cc:60:29: error: 'v' was not declared in this scope 60 | while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u); | ^ a.cc:62:8: error: too few arguments to function 'void dfs(long long int, long long int)' 62 | dfs(1); | ~~~^~~ a.cc:39:6: note: declared here 39 | void dfs(int now, int root) { | ^~~
s214996618
p03746
C++
// #pragma GCC target("avx2") #pragma GCC optimize("O3", "unroll-loops") // #include <bits/extc++.h> // using namespace __gnu_pbds; #include <bits/stdc++.h> using namespace std; #define int long long #define double long double // template <typename T> // using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; using pii = pair<int, int>; template<typename T> using prior = priority_queue<T, vector<T>, greater<T>>; template<typename T> using Prior = priority_queue<T>; // #define X first // #define Y second #define ALL(x) (x).begin(), (x).end() #define eb emplace_back #define pb push_back #define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define RANDOM() random_device __rd; \ mt19937 __gen = mt19937(__rd()); \ uniform_int_distribution<int> __dis(0, 1); \ auto rnd = bind(__dis, __gen); const int INF = 1E18; const int mod = 1E9 + 7; const int maxn = 1E5 + 5; vector<int> adj[maxn], vis(maxn, 0); deque<int> deck; void dfs(int now, int root) { vis[now] = 1; for (auto x : adj[now]) { if (!vis[x]) { vis[x] = 1, dfs(x, root); if (root == -1) deck.push_front(x); else deck.push_back(x); if (now != root) return; else root = -1; } } } int32_t main() { fastIO(); int n, m; cin >> n >> m; while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u); dfs(1); while (!deck.empty()) {cout << deck.front() << " "; deck.pop_front();} return 0; }
a.cc: In function 'int32_t main()': a.cc:60:24: error: 'u' was not declared in this scope 60 | while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u); | ^ a.cc:60:29: error: 'v' was not declared in this scope 60 | while (m--) cin >> u >> v, adj[u].eb(v), adj[v].eb(u); | ^ a.cc:62:8: error: too few arguments to function 'void dfs(long long int, long long int)' 62 | dfs(1); | ~~~^~~ a.cc:39:6: note: declared here 39 | void dfs(int now, int root) { | ^~~
s912412024
p03746
C++
12 18 3 5 4 12 9 11 1 10 2 5 6 10 8 11 1 3 4 10 2 4 3 7 2 10 3 12 3 9 1 7 2 3 2 11 10 11
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 12 18 | ^~
s608727381
p03746
C++
#include<bits/stdc++.h> using namespace std; int main(void) { long n, m; cin >> n >> m; vector<vector<int>> G(n); int s = 0; for(int i=0; i<m; i++) { int a,b; cin >> a >> b; a--, b--; G[a].push_back(b); G[b].push_back(a); s = a; } int ss = s; vector<int> res = {s}; set<int> st; st.insert(s); while(1) { for(auto v: G[s]) { if(st.count(v)) continue; s = v; res.push_back(s); st.insert(s); goto nxt; } break; nxt: ; } vector<int> ser; s = ss; while(1) { for(auto v: G[s]) { if(st.count(v)) continue; s = v; ser.push_back(s); st.insert(s); goto nxt; } break; nxt: ; } cout << ser.size() + res.size() << endl; for(auto x: ser) cout << x+1 << endl; for(auto x: res) cout << x+1 << endl; }
a.cc: In function 'int main()': a.cc:49:1: error: duplicate label 'nxt' 49 | nxt: | ^~~
s374021108
p03746
C++
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #include <bits/stdc++.h> using namespace std; #define pb push_back const int MAXN = 1e5 + 10; int n, m; int u, v; int d[MAXN], dd[MAXN], par[MAXN]; vector <int> adj[MAXN]; void dfs(int root) { for (auto y: adj[root]) if (!d[y]) { d[y] = d[root] + 1; dfs(y); } } void dfs_2(int root) { for (auto y: adj[root]) if (!dd[y]) { dd[y] = dd[root] + 1; par[y] = root; dfs(y); } } int main() { ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); cin >> n >> m; for (int i = 0; i < n; i++) { cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } d[1] = 1; dfs(1); int tmp, mx = 0; for (int i = 1; i <= n; i++) if (mx < d[i]) { mx = d[i]; tmp = i; } dd[tmp] = 1; par[tmp] = -1; dfs_2(tmp); mx = 0; for (int i = 1; i <= n; i++) if (mx < dd[i]) { mx = dd[i]; tmp = i; } cout << mx << '\n'; while (par[tmp] > 0) { cout << tmp << ' '; tmp = par[tmp]; } cout << tmp << '\n'; return 0; }
In file included from /usr/include/c++/14/string:43, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:4: /usr/include/c++/14/bits/allocator.h: In destructor 'std::_Vector_base<int, std::allocator<int> >::_Vector_impl::~_Vector_impl()': /usr/include/c++/14/bits/allocator.h:182:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = int]': target specific option mismatch 182 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /usr/include/c++/14/vector:66, from /usr/include/c++/14/functional:64, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53: /usr/include/c++/14/bits/stl_vector.h:132:14: note: called from here 132 | struct _Vector_impl | ^~~~~~~~~~~~
s319999551
p03746
C++
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <vector> #include <queue> #include <set> #include <map> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const ll mod = 1000000007; const int MAX_N = 100010; int a, b, visited[MAX_N]; vector<int> to[MAX_N], ret; void dfs(int v) { ret.push_back(v); visited[v] = 1; for(auto u : to[v]) { if(!visited[u]) { dfs(u); break; } } } int main() { int n, m; cin >> n >> m; rep(i, m) { cin >> a >> b; a--; b--; to[a].push_back(b); to[b].push_back(a); } visited[b] = 1; dfs(a); reverse(all(ret)); visited[b] = 0; dfs(a); cout << ret.size() << "\n"; for(auto p : ret) { cout << p << " "; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:50:17: error: 'all' was not declared in this scope; did you mean 'll'? 50 | reverse(all(ret)); | ^~~ | ll
s255843040
p03746
C++
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <vector> #include <queue> #include <set> #include <map> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const ll mod = 1000000007; const int MAX_N = 100010; int a, b; vector<int> to[MAX_N], visited[MAX_N], ret; void dfs(int v) { ret.push_back(v); visited[v] = 1; for(auto u : to[v]) { if(!visited[u]) { dfs(u); break; } } } int main() { int n, m; cin >> n >> m; rep(i, m) { cin >> a >> b; a--; b--; to[a].push_back(b); to[b].push_back(a); } visited[b] = 1; dfs(a); reverse(all(ret)); visited[b] = 0; dfs(a); cout << ret.size() << "\n"; for(auto p : ret) { cout << p << " "; } cout << endl; return 0; }
a.cc: In function 'void dfs(int)': a.cc:24:18: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') 24 | visited[v] = 1; | ^ In file included from /usr/include/c++/14/vector:72, from a.cc:7: /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/14/vector:66: /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ a.cc:27:12: error: no match for 'operator!' (operand type is 'std::vector<int>') 27 | if(!visited[u]) { | ^~~~~~~~~~~ a.cc:27:12: note: candidate: 'operator!(bool)' (built-in) a.cc:27:12: note: no known conversion for argument 1 from 'std::vector<int>' to 'bool' a.cc: In function 'int main()': a.cc:46:22: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') 46 | visited[b] = 1; | ^ /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ a.cc:50:17: error: 'all' was not declared in this scope; did you mean 'll'? 50 | reverse(all(ret)); | ^~~ | ll a.cc:52:22: error: no match for 'operator=' (operand types are 'std::vector<int>' and 'int') 52 | visited[b] = 0; | ^ /usr/include/c++/14/bits/vector.tcc:210:5: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 210 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&' 211 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:766:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&' 766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/14/bits/stl_vector.h:788:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = int; _Alloc = std::allocator<int>]' 788 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/14/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>' 788 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
s048243100
p03746
C++
#include <iostream> #include <cstdio> #include <string> #include <algorithm> #include <utility> #include <cmath> #include <vector> #include <queue> #include <set> #include <map> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; typedef long long ll; const ll mod = 1000000007; const int MAX_N = 100010; int a, b; vector<int> to(MAX_N), visited(MAX_N), ret; void dfs(int v) { ret.push_back(v); visited[v] = 1; for(auto u : to[v]) { if(!visited[u]) { dfs(u); break; } } } int main() { int n, m; cin >> n >> m; rep(i, m) { cin >> a >> b; a--; b--; to[a].push_back(b); to[b].push_back(a); } visited[b] = 1; dfs(a); reverse(all(ret)); visited[b] = 0; dfs(a); cout << ret.size() << "\n"; for(auto p : ret) { cout << p << " "; } cout << endl; return 0; }
a.cc: In function 'void dfs(int)': a.cc:26:26: error: 'begin' was not declared in this scope; did you mean 'std::begin'? 26 | for(auto u : to[v]) { | ^ | std::begin 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:114:37: note: 'std::begin' declared here 114 | template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept; | ^~~~~ a.cc:26:26: error: 'end' was not declared in this scope; did you mean 'std::end'? 26 | for(auto u : to[v]) { | ^ | std::end /usr/include/c++/14/bits/range_access.h:116:37: note: 'std::end' declared here 116 | template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept; | ^~~ a.cc: In function 'int main()': a.cc:42:23: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)a))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 42 | to[a].push_back(b); | ^~~~~~~~~ a.cc:43:15: error: request for member 'push_back' in 'to.std::vector<int>::operator[](((std::vector<int>::size_type)b))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 43 | to[b].push_back(a); | ^~~~~~~~~ a.cc:50:17: error: 'all' was not declared in this scope; did you mean 'll'? 50 | reverse(all(ret)); | ^~~ | ll
s107345377
p03746
C++
#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstring> using namespace std; int n,m; vector<int> sus[100050]; bool bio[100050]; vector<int>posjet; vector<int>sol; void input(){ cin>>n>>m; int br1,br2; for(int i=0;i<m;i++){ cin>>br1>>br2; sus[br1].push_back(br2); sus[br2].push_back(br1); } } bool func(int cv){ for(int i=0;i<sus[cv].size();i++){ if(!bio[sus[cv][i]]){ return false; break; } } return true; } void dfs(int node){ if(sol.size()>0)return; bio[node]=true; posjet.push_back(node); for(int i=0;i<sus[node].size();i++){ int x=sus[node][i]; if(bio[x])continue; dfs(x); } int prv=posjet[0]; int dr=posjet[1]; bool ok=true; ok=func(prv); if(ok)ok=func(dr); if(ok && sol.empty()){ for(int i=0;i<posjet.size();i++){ sol.push_back(posjet[i]); } } else{ bio[node]=false; posjet.pop_back(); } } void solve(){ int min_sus=9999999; for(int i=1;i<=n;i++){ int br=sus[i].size(); min_sus=min(min_sus,br); } for(int i=1;i<=n;i++){ if(sus[i].size()==min_sus){ memset(bio,0,sizeof(bio)); dfs(i); } } cout<<sol.size()<<"\n"; for(int i=0;i<sol.size();i++)cout<<sol[i]<<" "; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); input(); solve(); return 0; }#include<iostream> #include<algorithm> #include<string> #include<vector> #include<cstring> using namespace std; int n,m; vector<int> sus[100050]; bool bio[100050]; vector<int>posjet; vector<int>sol; void input(){ cin>>n>>m; int br1,br2; for(int i=0;i<m;i++){ cin>>br1>>br2; sus[br1].push_back(br2); sus[br2].push_back(br1); } } bool func(int cv){ for(int i=0;i<sus[cv].size();i++){ if(!bio[sus[cv][i]]){ return false; break; } } return true; } void dfs(int node){ if(sol.size()>0)return; bio[node]=true; posjet.push_back(node); for(int i=0;i<sus[node].size();i++){ int x=sus[node][i]; if(bio[x])continue; dfs(x); } int prv=posjet[0]; int dr=posjet[1]; bool ok=true; ok=func(prv); if(ok)ok=func(dr); if(ok && sol.empty()){ for(int i=0;i<posjet.size();i++){ sol.push_back(posjet[i]); } } else{ bio[node]=false; posjet.pop_back(); } } void solve(){ int min_sus=9999999; for(int i=1;i<=n;i++){ int br=sus[i].size(); min_sus=min(min_sus,br); } for(int i=1;i<=n;i++){ if(sus[i].size()==min_sus){ memset(bio,0,sizeof(bio)); dfs(i); } } cout<<sol.size()<<"\n"; for(int i=0;i<sol.size();i++)cout<<sol[i]<<" "; } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); input(); solve(); return 0; }
a.cc:91:2: error: stray '#' in program 91 | }#include<iostream> | ^ a.cc:91:3: error: 'include' does not name a type 91 | }#include<iostream> | ^~~~~~~ a.cc:99:5: error: redefinition of 'int n' 99 | int n,m; | ^ a.cc:9:5: note: 'int n' previously declared here 9 | int n,m; | ^ a.cc:99:7: error: redefinition of 'int m' 99 | int n,m; | ^ a.cc:9:7: note: 'int m' previously declared here 9 | int n,m; | ^ a.cc:101:13: error: redefinition of 'std::vector<int> sus [100050]' 101 | vector<int> sus[100050]; | ^~~ a.cc:11:13: note: 'std::vector<int> sus [100050]' previously declared here 11 | vector<int> sus[100050]; | ^~~ a.cc:102:6: error: redefinition of 'bool bio [100050]' 102 | bool bio[100050]; | ^~~ a.cc:12:6: note: 'bool bio [100050]' previously declared here 12 | bool bio[100050]; | ^~~ a.cc:103:12: error: redefinition of 'std::vector<int> posjet' 103 | vector<int>posjet; | ^~~~~~ a.cc:13:12: note: 'std::vector<int> posjet' previously declared here 13 | vector<int>posjet; | ^~~~~~ a.cc:104:12: error: redefinition of 'std::vector<int> sol' 104 | vector<int>sol; | ^~~ a.cc:14:12: note: 'std::vector<int> sol' previously declared here 14 | vector<int>sol; | ^~~ a.cc:106:6: error: redefinition of 'void input()' 106 | void input(){ | ^~~~~ a.cc:16:6: note: 'void input()' previously defined here 16 | void input(){ | ^~~~~ a.cc:116:6: error: redefinition of 'bool func(int)' 116 | bool func(int cv){ | ^~~~ a.cc:26:6: note: 'bool func(int)' previously defined here 26 | bool func(int cv){ | ^~~~ a.cc:126:6: error: redefinition of 'void dfs(int)' 126 | void dfs(int node){ | ^~~ a.cc:36:6: note: 'void dfs(int)' previously defined here 36 | void dfs(int node){ | ^~~ a.cc:154:6: error: redefinition of 'void solve()' 154 | void solve(){ | ^~~~~ a.cc:64:6: note: 'void solve()' previously defined here 64 | void solve(){ | ^~~~~ a.cc:170:5: error: redefinition of 'int main()' 170 | int main(){ | ^~~~ a.cc:80:5: note: 'int main()' previously defined here 80 | int main(){ | ^~~~
s904636895
p03746
C++
// i am so dumb....
/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
s216377112
p03746
C++
#include <bits/stdc++.h> using namespace std; struct edge{int from, to;}; int N, M; typedef vector<int> vi; vi G[N]; bool used[N]; int main(){ cin>>N>>M; for (int i=0;i<M;++i){ int a, b;cin >>a>>b; G[a].push_back(b);G[b].push_back(a); } int cnt=0; vector<edge> path; int pos=0; while(true){ int j=0; while(used[G[pos][j]]&&j<G[pos].size()) j++; if(j==G[pos].size()) break; int v=G[pos][j]; edge e=(edge){pos, v}; path.push_back(e); used[v]=true; pos=v; } int K=path.size(); cout << K << endl; for (int i=0;i<K;++i){ edge e=path[i];int f=e.from, t=e.to; cout << f << ' ' << t << endl; } return 0; }
a.cc:6:6: error: size of array 'G' is not an integral constant-expression 6 | vi G[N]; | ^ a.cc:7:11: error: size of array 'used' is not an integral constant-expression 7 | bool used[N]; | ^
s866903419
p03746
C++
#include<bits/stdc++.h> #include<iostream> #include<cmath> #include<vector> #include<string> #include<queue> #include<set> #include<map> #include<algorithm> #include<functional> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef pair<ll, ll> pll; typedef pair<ull, ull> pullull; typedef pair<ll, int> plli; typedef pair<int, pii> pipii; typedef vector<vector<int> > mati; typedef vector<vector<double> > matd; typedef vector<ll> vll; typedef vector<vector<ll>> vvll; typedef vector<vector<vector<ll>>> vvvll; typedef vector<bool> vb; typedef vector<vector<bool>> vvb; typedef vector<vector<vector<bool>>> vvvb; #define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i) #define REP(i,y) FOR(i, 0, y) #define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i) #define RREP(i,x) RFOR(i, x, 0) template <typename T> void vec_print(vector<T> VEC){ REP(i, VEC.size()){ cout << VEC[i] << " "; } cout << "\n"; }; template <typename T> void mat_print(vector<vector<T> > MAT){ REP(i, MAT.size()){ REP(j, MAT[i].size()){ cout << MAT[i][j] << " "; } cout << "\n"; } }; template <typename CLASS1, typename CLASS2> class HOGE{ public: CLASS1 key; CLASS2 value; HOGE(void){ return; }; HOGE(CLASS1 key, CLASS2 value){ this->key = key; this->value = value; }; ~HOGE(void){ return; }; void print(void){ cout << "key : " << key << ", value : " << value << "\n"; return; }; bool operator==(const HOGE &obj){ return (this->value == obj.value); }; bool operator<(const HOGE &obj){ return (this->value < obj.value); }; bool operator>(const HOGE &obj){ return (this->value > obj.value); }; }; constexpr int INF = (1<<30); constexpr ll INFLL = 1LL<<62; constexpr long double EPS = 1e-12; constexpr ll MOD = (ll)((1E+9)+7); vvll Path; void forward_search(deque<ll>& dq, vb& cand, ll& num_ans){ ll pos = dq.back(); for(ll i=0; i<Path[pos].size(); ++i){ if(!cand[Path[pos][i]]) continue; dq.push_back(Path[pos][i]); num_ans++; cand[Path[pos][i]] = false; forward_search(dq, cand, num_ans); break; } return; } void backward_search(deque<ll>& dq, vb& cand, ll& num_ans){ ll pos = dq.front(); for(ll i=0; i<Path[pos].size(); ++i){ if(!cand[Path[pos][i]]) continue; dq.push_front(Path[pos][i]); num_ans++; cand[Path[pos][i]] = false; backward_search(dq, cand, num_ans); break; } return; } int main(){ cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin) ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";) ll N, M; cin >> N >> M; Path.resize(N+2); ll A, B; REP(i, M){ cin >> A >> B; Path[A].push_back(B); Path[B].push_back(A); } vb cand(true, N+2); deque<ll> dq; ll ans_num = 1; dq.push_back(A); cand[A] = false; forward_search(dq, Path, cand, ans_num); backward_search(dq, Path, cand, ans_num); printf("%d\n", ans_num); printf("%d", dq.front()); dq.pop_front(); while(!dq.empty()){ printf(" %d", dq.front()); dq.pop_front(); } printf("\n"); return 0; }
a.cc: In function 'int main()': a.cc:138:22: error: invalid initialization of reference of type 'vb&' {aka 'std::vector<bool>&'} from expression of type 'vvll' {aka 'std::vector<std::vector<long long int> >'} 138 | forward_search(dq, Path, cand, ans_num); | ^~~~ a.cc:92:40: note: in passing argument 2 of 'void forward_search(std::deque<long long int>&, vb&, ll&)' 92 | void forward_search(deque<ll>& dq, vb& cand, ll& num_ans){ | ~~~~^~~~ a.cc:139:23: error: invalid initialization of reference of type 'vb&' {aka 'std::vector<bool>&'} from expression of type 'vvll' {aka 'std::vector<std::vector<long long int> >'} 139 | backward_search(dq, Path, cand, ans_num); | ^~~~ a.cc:105:41: note: in passing argument 2 of 'void backward_search(std::deque<long long int>&, vb&, ll&)' 105 | void backward_search(deque<ll>& dq, vb& cand, ll& num_ans){ | ~~~~^~~~
s994949070
p03746
C++
#include<iostream> #include<string> #include<cstdio> #include<vector> #include<cmath> #include<algorithm> #include<functional> #include<iomanip> #include<queue> #include<ciso646> #include<random> #include<map> #include<set> #include<complex> #include<bitset> #include<stack> #include<unordered_map> #include<utility> using namespace std; typedef long long ll; typedef unsigned long long ul; typedef unsigned int ui; typedef long double ld; typedef pair<int, int> P; typedef pair<ll, ll> LP; typedef pair<ld, ld> LDP; typedef complex<ld> Point; const ll mod = 1000000007; const ld INF = 1e+30; const ld eps = 1e-8; const ld pi = acos(-1.0); #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define Rep(i,sta,n) for(int i=sta;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) bool used[1 << 17]; vector<int> G[1 << 17]; void solve() { int n, m; cin >> n >> m; rep(i, m) { int a, b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int l = 0, r = 1; used[0] = used[1] = true; vector<int> le({ 0 }), ri({ 1 }); while (true) { bool f = true; rep(j, G[l].size()) { int to = G[l][j]; if (used[to])continue; else { f = false; le.push_back(to); used[to] = true; l = to; break; } } if (f)break; } while (true) { bool f = true; rep(j, G[r].size()){ int to = G[r][j]; if (used[to])continue; else { f = false; ri.push_back(to); used[to] = true; r = to; break; } } if (f)break; } reverse(le.begin(), le.end()); rep(i, ri.size())le.push_back(ri[i]); cout << le.size() << endl; rep(i, le.size()) { if (i > 0)cout << " "; cout << le[i]; } cout << endk; } int main() { cin.tie(0); ios::sync_with_stdio(false); solve(); //stop return 0; }
a.cc: In function 'void solve()': a.cc:88:17: error: 'endk' was not declared in this scope 88 | cout << endk; | ^~~~
s879505369
p03746
C++
#include <iostream> #include <vector> #include <deque> using namespace std; int main() { int n, m; vector<vector<int>> g(n+1); cin >> n >> m; for (int i = 0; i < m; i++) { int a, b; cin >> a >> b; g[a].push_back(b); g[b].push_back(a); } // dfs-like deque<int> ans; vector<bool> v(n+1, false); ans.push_back(1); v[1] = true; while (true) { auto p = ans.back(); bool finished = true; for (const auto &r : g[p]) { if (!v[r]) { ans.push_back(r); v[r] = true; finished = false; break; } } if (finished) break; } while (!ans.empty) { const auto r = ans.back(); ans.pop_back(); cout << r; if (ans.empty()) cout << endl; else cout << " "; } }
a.cc: In function 'int main()': a.cc:33:15: error: cannot convert 'std::deque<int>::empty' from type 'bool (std::deque<int>::)() const noexcept' to type 'bool' 33 | while (!ans.empty) { | ^~~~~ a.cc:33:15: error: in argument to unary ! 33 | while (!ans.empty) { | ~~~~^~~~~
s604830800
p03746
C++
#include<algorithm> #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<map> #include<queue> #include<set> #include<sstream> #include<stack> #include<string> #include<vector> using namespace std; int n,m,f,r; vector<int> g[100100]; set<int> t; int out[300000]; bool find(int x){ for(int i=0;i<g[x].size();i++){ if(t.find(g[x][i])==t.end())return false; } return true; } void fun(int x,bool fl){ while(!find(x)){ for(int i=0;i<g[x].size();i++){ if(t.find(g[x][i])==t.end()){ a=g[x][i]; t.insert(x); if(fl)out[f--]=x; else out[r++]=x; break; } } } } void func(int a,int b){ t.insert(a); out[f--]=a;out[r++]=b; t.insert(b); fun(a,1);fun(b,0); } int main(){ f=150000,r=150001; ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m; int a,b; for(int i=0;i<m;i++){ cin>>a>>b; g[a].push_back(b); g[b].push_back(a); } func(a,b); cout<<t.size()<<endl; for(int i=f+1;i<r;i++){ if(out[i]!=0) cout<<out[i]<<' '; } return 0; }
a.cc: In function 'void fun(int, bool)': a.cc:31:33: error: 'a' was not declared in this scope 31 | a=g[x][i]; | ^
s525932766
p03746
C++
#include<algorithm> #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #include<map> #include<queue> #include<set> #include<sstream> #include<stack> #include<string> #include<vector> using namespace std; int n,m; int f,r; vector<int> g[100100]; set<int> t; int out[300000]; bool find(int x){ for(int i=0;i<g[x].size();i++){ if(t.find(g[x][i])==t.end())return false; } return true; } void func(int a,int b){ t.insert(a); out[f--]=a;out[r++]=b; t.insert(b); while(!find(a)){ for(int i=0;i<g[a].size();i++){ if(t.find(g[a][i])==t.end()){ a=g[a][i]; t.insert(a); out[f--]=a; break; } } } while(!find(b)){ for(int i=0;i<g[b].size();i++){ if(t.find(g[b][i])==t.end()){ b=g[b][i]; t.insert(b); out[r++]=b; break; } } } } int mbin(){ f=150000,r=150001; ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n>>m; int a,b; for(int i=0;i<m;i++){ cin>>a>>b; g[a].push_back(b); g[b].push_back(a); } func(a,b); cout<<t.size()<<endl; for(int i=f+1;i<r;i++){ if(out[i]!=0) cout<<out[i]<<' '; } return 0; }
/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
s096756794
p03746
C++
#include<bits/stdc++.h> using namespace std; const int N = 1e5+3; vector<int> v[N]; bool vis[N]; list<int> L; int n,m; void dfs(int u, bool ok){ for(int i=0; i<v[u].size(); ++i){ if(!vis[v[u][i]]){ if(ok) L.push_front(v[u][i]); else L.push_back(v[u][i]); vis[v[u][i]] = true; dfs(e,ok); return; } } } int main(){ scanf("%d%d",&n,&m); memset(vis,false,sizeof(vis)); while(m--){ int a,b; scanf("%d%d",&a,&b); v[a].push_back(b); v[b].push_back(a); } L.push_back(1); L.push_back(v[1][0]); vis[1]=vis[v[1][0]]=true; dfs(1,true); dfs(v[1][0], false); printf("%d\n",L.size()); for(auto it=L.begin(); it!=L.end(); ++it) printf("%d ",*it); printf("\n"); return 0; }
a.cc: In function 'void dfs(int, bool)': a.cc:14:29: error: 'e' was not declared in this scope 14 | dfs(e,ok); | ^
s930411634
p03746
C++
#include<bits/stdc++.h> using namespace std; const int N = 1e5+3; vector<int> v[N]; bool vis[N]; list<int> L; int n,m; void dfs(int u, bool ok){ for(int i=0; i<v[u].size(); ++i){ if(!vis[v[u][i]]){ if(ok) L.push_front(v[u][i]); else L.push_back(v[u][i]); vis[v[u][i]] = true; dfs(e,ok); return; } } } int main(){ scanf("%d%d",&n,&m); memset(vis,false,sizeof(vis)); while(m--){ int a,b; scanf("%d%d",&a,&b); v[a].push_back(b); v[b].push_back(a); } L.push_back(1); L.push_back(v[1][0]); vis[1]=vis[v[1][0]]=true; dfs(1,true); dfs(v[1][0], false); printf("%d\n",L.size()); for(auto it=L.begin(); it!=L.end(); ++it) printf("%d ",*it); printf("\n"); return 0; }
a.cc: In function 'void dfs(int, bool)': a.cc:14:29: error: 'e' was not declared in this scope 14 | dfs(e,ok); | ^
s857846169
p03746
C++
#include<bits/stdc++.h> using namespace std; const int N = 1e5+3; vector<int> v[N]; bool vis[N]; list<int> L; int n,m; void dfs(int u, bool ok){ for(int i=0; i<v[u].size(); ++i){ if(!vis[v[u][i]]){ if(ok) L.push_front(v[u][i]); else L.push_back(v[u][i]); vis[v[u][i]] = true; dfs(e,ok); return; } } } int main(){ scanf("%d%d",&n,&m); memset(vis,false,sizeof(vis)); while(m--){ int a,b; scanf("%d%d",&a,&b); v[a].push_back(b); v[b].push_back(a); } L.push_back(1); L.push_back(v[1][0]); vis[1]=vis[v[1][0]]=true; dfs(1,true); dfs(v[1][0], false); printf("%d\n",L.size()); for(auto it=L.begin(); it!=L.end(); ++it) printf("%d ",*it); printf("\n"); return 0; }#include<bits/stdc++.h> using namespace std; const int N = 1e5+3; vector<int> v[N]; bool vis[N]; list<int> L; int n,m; void dfs(int u, bool ok){ for(int i=0; i<v[u].size(); ++i){ if(!vis[v[u][i]]){ if(ok) L.push_front(v[u][i]); else L.push_back(v[u][i]); vis[v[u][i]] = true; dfs(e,ok); return; } } } int main(){ scanf("%d%d",&n,&m); memset(vis,false,sizeof(vis)); while(m--){ int a,b; scanf("%d%d",&a,&b); v[a].push_back(b); v[b].push_back(a); } L.push_back(1); L.push_back(v[1][0]); vis[1]=vis[v[1][0]]=true; dfs(1,true); dfs(v[1][0], false); printf("%d\n",L.size()); for(auto it=L.begin(); it!=L.end(); ++it) printf("%d ",*it); printf("\n"); return 0; }
a.cc:38:2: error: stray '#' in program 38 | }#include<bits/stdc++.h> | ^ a.cc: In function 'void dfs(int, bool)': a.cc:14:29: error: 'e' was not declared in this scope 14 | dfs(e,ok); | ^ a.cc: At global scope: a.cc:38:3: error: 'include' does not name a type 38 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:40:11: error: redefinition of 'const int N' 40 | const int N = 1e5+3; | ^ a.cc:3:11: note: 'const int N' previously defined here 3 | const int N = 1e5+3; | ^ a.cc:41:13: error: redefinition of 'std::vector<int> v [100003]' 41 | vector<int> v[N]; | ^ a.cc:4:13: note: 'std::vector<int> v [100003]' previously declared here 4 | vector<int> v[N]; | ^ a.cc:42:6: error: redefinition of 'bool vis [100003]' 42 | bool vis[N]; | ^~~ a.cc:5:6: note: 'bool vis [100003]' previously declared here 5 | bool vis[N]; | ^~~ a.cc:43:11: error: redefinition of 'std::__cxx11::list<int> L' 43 | list<int> L; | ^ a.cc:6:11: note: 'std::__cxx11::list<int> L' previously declared here 6 | list<int> L; | ^ a.cc:44:5: error: redefinition of 'int n' 44 | int n,m; | ^ a.cc:7:5: note: 'int n' previously declared here 7 | int n,m; | ^ a.cc:44:7: error: redefinition of 'int m' 44 | int n,m; | ^ a.cc:7:7: note: 'int m' previously declared here 7 | int n,m; | ^ a.cc:45:6: error: redefinition of 'void dfs(int, bool)' 45 | void dfs(int u, bool ok){ | ^~~ a.cc:8:6: note: 'void dfs(int, bool)' previously defined here 8 | void dfs(int u, bool ok){ | ^~~ a.cc: In function 'void dfs(int, bool)': a.cc:51:29: error: 'e' was not declared in this scope 51 | dfs(e,ok); | ^ a.cc: At global scope: a.cc:56:5: error: redefinition of 'int main()' 56 | int main(){ | ^~~~ a.cc:19:5: note: 'int main()' previously defined here 19 | int main(){ | ^~~~
s208475357
p03746
C++
#include <iostream> #include <vector> #include <utility> #include <queue> using namespace std; vector<int> dfs(vector< vector<int> > &G, vector<bool> &visited, int v){ vector<int> ret; for(int i = 0; i < G[v].size(); ++i){ int v_ = G[v][i]; if(visited[v_]) continue; visited[v_] = true; ret = dfs(G, visited, v_); break; } ret.push_back(v); return ret; } int main(){ int N, M; cin >> N >> M; vector< vector<int> > G(N); for(int i = 0; i < M; ++i){ int a, b; cin >> a >> b; --a;--b; G[a].push_back(b); G[b].push_back(a); } vector<bool> visited(N, false); int s = 0, t = G[0][0]; visited[s] = true; visited[t] = true; vector<int> S = dfs(G, visited, s), T = dfs(G, visited, t); reverse(T.begin(), T.end()); cout << S.size() + T.size() << endl; for(int i = 0; i < S.size(); ++i) cout << S[i]+1 << " "; for(int i = 0; i < T.size()-1; ++i) cout << T[i]+1 << " "; cout << T.back()+1 << endl; return 0; }
a.cc: In function 'int main()': a.cc:36:3: error: 'reverse' was not declared in this scope 36 | reverse(T.begin(), T.end()); | ^~~~~~~
s096644611
p03746
C++
4 2 3 1 4
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 | ^
s560142494
p03746
C++
#include<iostream> #include<cstdio> #include<set> #include<vector> using namespace std; int N, M; int A, B; set<int> adj[100010]; set<int> visited; int end[2]; int end_first[2]; vector<int> path_before; vector<int> path_after; int main(){ cin >> N >> M; for(int i = 0; i < M; i++){ cin >> A >> B; adj[A].insert(B); adj[B].insert(A); } end_first[0] = end[0] = 1; end_first[1] = end[1] = *(adj[1].begin()); visited.insert(end[0]); visited.insert(end[1]); while(1){ bool all_visited = true; for(set<int>::iterator it = adj[end[0]].begin(); it != adj[end[0]].end(); it++){ if(visited.count(*it) == 0){ all_visited = false; end[0] = *it; path_before.push_back(*it); visited.insert(*it); break; } } if(all_visited == true){ break; } } while(1){ bool all_visited = true; for(set<int>::iterator it = adj[end[1]].begin(); it != adj[end[1]].end(); it++){ if(visited.count(*it) == 0){ all_visited = false; end[1] = *it; path_after.push_back(*it); visited.insert(*it); break; } } if(all_visited == true){ break; } } for(int i = 0; i < path_before.size(); i++){ if(i) cout << " "; cout << path_before[path_before.size() - 1 - i]; } if(path_before.size() != 0){ cout << " "; } cout << end_first[0] << " " << end_first[1]; for(int i = 0; i < path_after.size(); i++){ cout << " " << path_after[i]; } cout << endl; }
a.cc: In function 'int main()': a.cc:27:20: error: reference to 'end' is ambiguous 27 | end_first[0] = end[0] = 1; | ^~~ 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:12:5: note: 'int end [2]' 12 | int end[2]; | ^~~ a.cc:28:20: error: reference to 'end' is ambiguous 28 | end_first[1] = end[1] = *(adj[1].begin()); | ^~~ /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:12:5: note: 'int end [2]' 12 | int end[2]; | ^~~ a.cc:29:20: error: reference to 'end' is ambiguous 29 | visited.insert(end[0]); | ^~~ /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:12:5: note: 'int end [2]' 12 | int end[2]; | ^~~ a.cc:30:20: error: reference to 'end' is ambiguous 30 | visited.insert(end[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:12:5: note: 'int end [2]' 12 | int end[2]; | ^~~ a.cc:34:41: error: reference to 'end' is ambiguous 34 | for(set<int>::iterator it = adj[end[0]].begin(); it != adj[end[0]].end(); it++){ | ^~~ /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:12:5: note: 'int end [2]' 12 | int end[2]; | ^~~ a.cc:34:68: error: reference to 'end' is ambiguous 34 | for(set<int>::iterator it = adj[end[0]].begin(); it != adj[end[0]].end(); it++){ | ^~~ /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:12:5: note: 'int end [2]' 12 | int end[2]; | ^~~ a.cc:37:17:
s728688150
p03746
C++
#include <bits/stdc++.H> #define N 200010 using namespace std; inline int read() { int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();} return x*f; } struct edge{int v,next;}vs[N]; int st[N],ee,n,m,A[N],B[N],vis[N]; inline void addedge(int u,int v) { vs[++ee].v=v;vs[ee].next=st[u];st[u]=ee; } inline bool check(int x) { for(int i=st[x];i;i=vs[i].next) if(!vis[vs[i].v]) return 0; return 1; } int main() { n=read(); m=read(); for(int i=1;i<=m;i++) { int u=read(), v=read(); addedge(u,v); addedge(v,u); } int S=1,T=vs[st[1]].v; vis[S]=1; vis[T]=1; while(1) { if(check(S)) break; for(int i=st[S];i;i=vs[i].next) { if(vis[vs[i].v]) continue; A[++A[0]]=S; S=vs[i].v; vis[S]=1; break; } } while(1) { if(check(T)) break; for(int i=st[T];i;i=vs[i].next) { if(vis[vs[i].v]) continue; B[++B[0]]=T; T=vs[i].v; vis[T]=1; break; } } printf("%d ",S); for(int i=A[0];i>=1;i--) printf("%d ",A[i]); for(int i=1;i<=B[0];i++) printf("%d ",B[i]); printf("%d\n",T); return 0; }
a.cc:1:10: fatal error: bits/stdc++.H: No such file or directory 1 | #include <bits/stdc++.H> | ^~~~~~~~~~~~~~~ compilation terminated.
s388512685
p03746
C++
7 8 1 2 2 3 3 4 4 5 5 6 6 7 3 5 2 6
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 7 8 | ^
s439689918
p03746
C++
#include<iostream> using namespace std; int next[10001],head[10001],to[10001],cnt; int a[10001],num,N=1; int book[10001]; void add(int u,int v) { cnt++; next[cnt]=head[u]; head[u]=cnt; to[cnt]=v; } int main() { int n,m; cin>>n>>m; for(int i=1;i<=m;i++) { int x,y; cin>>x>>y; add(x,y); add(y,x); } for(int i=1;i<=n;i++) { if(head[i]!=0) { int y=i,x; num++; a[num]=y; book[y]=1; while(N==1) { N=0; for(int j=head[y];j!=0;j=next[j]) { if(book[to[j]]==0) { y=to[j];N=1;break;} } num++; a[num]=y; book[y]=1; } break; } } for(int i=1;i<=num-1;i++) cout<<a[i]<<" "; return 0; }
a.cc: In function 'void add(int, int)': a.cc:9:9: error: reference to 'next' is ambiguous 9 | next[cnt]=head[u]; | ^~~~ 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:3:5: note: 'int next [10001]' 3 | int next[10001],head[10001],to[10001],cnt; | ^~~~ a.cc: In function 'int main()': a.cc:35:58: error: reference to 'next' is ambiguous 35 | for(int j=head[y];j!=0;j=next[j]) | ^~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)' 232 | next(_InputIterator __x, typename | ^~~~ a.cc:3:5: note: 'int next [10001]' 3 | int next[10001],head[10001],to[10001],cnt; | ^~~~
s903321590
p03746
C++
7 8 1 2 2 3 3 4 4 5 5 6 6 7 3 5 2 6
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 7 8 | ^
s722128879
p03746
C++
#include <iostream> #include <set> #include <vector> #define ALL(x) x.begin(), x.end() using namespace std; typedef vector<vector<int> > G; const int inf = 1e9; int n, m; G graph; vector<int> ans; int visited[100005]; void dfs(int u){ ans.push_back(u); visited[u] = 1; for(int i=0; i<graph[u].size(); i++){ int v = graph[u][i]; if( !( visited[v] ) ){ return dfs(v); break; } return; } } int main(void){ cin >> n >> m; graph = G(n); for(int i=0; i<m; i++){ int x, y; cin >> x >> y; x--; y--; graph[x].push_back(y); graph[y].push_back(x); } dfs(0); reverse(ALL(ans)); ans.pop_back(); dfs(0); cout << ans.size() << endl; for(int i=0; i<ans.size(); i++){ cout << ans[i] << " "; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:41:5: error: 'reverse' was not declared in this scope 41 | reverse(ALL(ans)); | ^~~~~~~
s151699612
p03746
C++
#pragma GCC optimize("O3") #include<bits/stdc++.h> #define rc(x) return cout<<x<<endl,0 #define pb push_back #define in insert #define er erase #define fr first #define sc second typedef long long ll; const long long llinf=LLONG_MAX; const int inf=LONG_MAX; const int nmax=1e5+5; const int mod=1e9+7; using namespace std; int n,m,i,x,y,viz[nmax]; vector<int>a[nmax]; void dfs(int x) { if(!viz[x])ans.pb(x); viz[x]=1; for(i=0;i<a[x].size();i++) if(!viz[a[x][i]]) { dfs(a[x][i]); break; } } int main() { //freopen("sol.in","r",stdin); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); cin>>n>>m; while(m--) { cin>>x>>y; a[x].pb(y); a[y].pb(x); } dfs(1); reverse(ans.begin(),ans.end()); dfs(1); for(i=0;i<ans.size();i++)cout<<ans[i]<<" ";cout<<endl; return 0; }
a.cc:11:15: warning: overflow in conversion from 'long int' to 'int' changes value from '9223372036854775807' to '-1' [-Woverflow] 11 | const int inf=LONG_MAX; | ^~~~~~~~ a.cc: In function 'void dfs(int)': a.cc:19:20: error: 'ans' was not declared in this scope; did you mean 'abs'? 19 | if(!viz[x])ans.pb(x); | ^~~ | abs a.cc: In function 'int main()': a.cc:40:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 40 | reverse(ans.begin(),ans.end()); | ^~~ | abs
s953108759
p03746
C++
#include <bits/stdc++.h> using namespace std; //#define rep(i,n) REP(i,0,n) #define REP(i,s,e) for(int i=(s); i<(int)(e); i++) #define repr(i, n) REPR(i, n, 0) #define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--) #define pb push_back #define all(r) r.begin(),r.end() #define rall(r) r.rbegin(),r.rend() #define fi first #define se second typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll MOD = 1e9 + 7; double EPS = 1e-8; #define DEBUG_MODE #ifdef DEBUG_MODE #define dump(x) cout << #x << " : " << x << endl #define LINE cout << "line : " << __LINE__ << endl #define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl #define STOP assert(false) #else #define dump(x) ; #define LINE ; #define dumpV(v); #define STOP ; #endif #define mp make_pair namespace std{ template<class S,class T> ostream &operator <<(ostream& out,const pair<S,T>& a){ out<<'('<<a.fi<<", "<<a.se<<')'; return out; } } const int MAX_N = 1e5+10; vi es[MAX_N]; bool used[MAX_N]; int main(){ int n, m; cin >> n >> m; rep(i, m) { int a, b; cin >> a >> b; a--; b--; es[a].pb(b); es[b].pb(a); } deque<int> d; d.push_front(0); d.push_back(*es[0].begin()); rep(i, 2) used[d[i]] = true; LINE; while(1) { dump(mp(d.front(), d.back())); bool update = false; for(auto& to : es[d.front()]) { if(!used[to]) { update = true; d.push_front(to); used[to] = true; break; } } for(auto& to : es[d.back()]) { if(!used[to]) { update = true; d.push_back(to); used[to] = true; break; } } if(!update) break; } cout << d.size() << endl; rep(i, d.size()) { cout << d[i]+1; if(i + 1 != d.size()) cout <<" "; else cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:55:13: error: 'i' was not declared in this scope 55 | rep(i, m) { | ^ a.cc:55:9: error: 'rep' was not declared in this scope; did you mean 'repr'? 55 | rep(i, m) { | ^~~ | repr
s344095455
p03746
C++
#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "math.h" #include "utility" #include "string" #include "map" #include "unordered_map" #include "iomanip" #include "random" using namespace std; const long long int MOD = 1000000007; long long int power(long long int x, long long int n, long long int M) { long long int tmp = 1; if (n > 0) { tmp = power(x, n / 2, M); if (n % 2 == 0) tmp = (tmp*tmp) % M; else tmp = (((tmp*tmp) % M)*x) % M; } return tmp; } long long int N, M, K, Q, W, H, L, R; long long int ans; list<long long int> Prime(long long int num) { list<long long int>P; P.push_back(2); P.push_back(3); for (int i = 5; i <= num; i += 6) { bool flag = true; for (auto j : P) { if (i%j == 0) { flag = false; break; } } if (flag)P.push_back(i); flag = true; for (auto j : P) { if ((i + 2) % j == 0) { flag = false; break; } } if (flag)P.push_back(i + 2); } return P; } int main() { ios::sync_with_stdio(false); cin >> N >> M; list<int>edge[100001] = {}; bool used[100001] = {}; for (int i = 0; i < M; i++) { int a, b; cin >> a >> b; edge[a].push_back(b); edge[b].push_back(a); } int a, b; a = 1; b = *edge[1].begin(); used[a] = true; used[b] = true; stack<pair<int, int>>s; s.push({ a, 0 }); s.push({ b,1 }); list<int>ret; ret.push_back(a); ret.push_back(b); while (!s.empty()) { int c; int d; c = s.top().first; d = s.top().second; s.pop(); for (auto i : edge[c]) { if (!used[i]) { s.push({ i,d }); used[i] = true; if (!d)ret.push_front(i); else ret.push_back(i); break; } } } int box = 0; for (auto i : ret) { if (box)cout << " "; cout << i << ; box++; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:100:30: error: expected primary-expression before ';' token 100 | cout << i << ; | ^
s828227964
p03746
C++
#include <iostream> #include <vector> #include <algorithm> #include <stack> int main(void) { int n, m; std::cin >> n >> m; std::vector<std::vector<int> > v(n); for (int i = 0; i < m; i++) { int a, b; std::cin >> a >> b; a--; b--; v[a].push_back(b); b[b].push_back(a); } std::stack<int> s; for (int i = 0; i < n; i++) { std::vector<bool> visited(n, false); s.push(i); visited[i] = true; while (v[s.top()].size() > 0) { for (size_t j = 0; j < v[s.top()].size(); j++) { if (!visited[v[s.top()][j]]) { s.push(visited[s.top()][j]); break; } } } if (s.size() > 2) { while (!s.empty()) { std::cout << s.top() << std::endl; s.pop(); } return 0; } } }
a.cc: In function 'int main()': a.cc:21:18: error: invalid types 'int[int]' for array subscript 21 | b[b].push_back(a); | ^ a.cc:32:64: error: no match for 'operator[]' (operand types are 'std::vector<bool>::reference' and 'size_t' {aka 'long unsigned int'}) 32 | s.push(visited[s.top()][j]); | ^
s895785449
p03746
C++
/* * Author: vawait * Created Time: 六 4/22 11:59:08 2017 * File Name: a.cpp */ #include<cstdio> #include<iostream> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> #include<string> #include<map> #include<set> #include<vector> #include<queue> #include<stack> using namespace std; #define rep(i, a, b) for (int i = (a); i <= (b); ++i) #define red(i, a, b) for (int i = (a); i >= (b); --i) #define clr( x , y ) memset(x,y,sizeof(x)) #define sqr(x) ((x) * (x)) #define mp make_pair #define pb push_back #define db pop_back typedef long long lint; const int maxn = 101000; int x , y , n , m , l , r , ans[maxn*2]; int vis[maxn]; vector < int > g[maxn]; void init() { scanf("%d%d",&n,&m); rep(i,1,m) { scanf("%d%d",&x,&y); g[x].pb( y ); g[y].pb( x ); } } void dfs(int t,int ty) { int y; if ( ty > 0 ) ans[++r] = t; else ans[--l] = t; vis[t] = 1; red(i,g[t].size()-1,0) { y = g[t][i]; if ( vis[y] ) continue; dfs( y , ty ); return; } } void work() { l = r = maxn; r --; vis[x] = vis[y] = 1; dfs( x , 1 ); dfs( y , -1 ); printf("%d\n",r-l+1); rep(i,l,r) printf("%d%c",ans[i],i==r?'\n':' '); } int main() { init(); work();
a.cc: In function 'int main()': a.cc:68:12: error: expected '}' at end of input 68 | work(); | ^ a.cc:66:1: note: to match this '{' 66 | { | ^
s622382352
p03746
Java
import java.util.ArrayList; import java.util.Scanner; import javafx.util.Pair; class Node{ int id; ArrayList<Integer>side_id_list; public Node(int id){ this.id = id; this.side_id_list = new ArrayList<Integer>(); } } public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int vertex_count = sc.nextInt(); int side_count = sc.nextInt(); ArrayList<Node>node_list = new ArrayList<Node>(); ArrayList<Pair<Integer,Integer>>side_list = new ArrayList<>(); for(int i = 0;i < vertex_count;i++){ node_list.add(new Node(i + 1)); } for(int i = 0;i < side_count;i++){ int j = sc.nextInt() - 1; int k = sc.nextInt() - 1; node_list.get(j).side_id_list.add(i); node_list.get(k).side_id_list.add(i); side_list.add(new Pair<Integer,Integer>(j,k)); } ArrayList<Integer>selected_side_list = new ArrayList<Integer>(); System.out.println("1 2"); sc.close(); } }
Main.java:5: error: package javafx.util does not exist import javafx.util.Pair; ^ Main.java:25: error: cannot find symbol ArrayList<Pair<Integer,Integer>>side_list = new ArrayList<>(); ^ symbol: class Pair location: class Main Main.java:36: error: cannot find symbol side_list.add(new Pair<Integer,Integer>(j,k)); ^ symbol: class Pair location: class Main 3 errors
s000830731
p03746
C++
//#define ONLINE_JUDGE #pragma clang diagnostic warning "-Weverything" // {{{ Includes #ifndef ONLINE_JUDGE #pragma clang diagnostic warning "-Wall" #pragma clang diagnostic warning "-Wextra" #pragma clang diagnostic warning "-Wconversion" #pragma clang diagnostic ignored "-Wvla" #pragma clang diagnostic ignored "-Wvla-extension" #pragma clang diagnostic ignored "-Wshadow" #pragma clang diagnostic ignored "-Wc++98-compat-pedantic" #pragma clang diagnostic ignored "-Wunused-macros" #pragma clang diagnostic ignored "-Wmissing-prototypes" #pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wsign-compare" #pragma clang diagnostic ignored "-Wold-style-cast" #pragma clang diagnostic ignored "-Wmissing-variable-declarations" #pragma clang diagnostic ignored "-Wglobal-constructors" #pragma clang diagnostic ignored "-Wunused-const-variable" #pragma clang diagnostic ignored "-Wpadded" #pragma clang diagnostic ignored "-Wfloat-equal" // it's fine #pragma clang diagnostic ignored "-Wdouble-promotion" // also #endif #include <unordered_map> #include <random> #include <climits> #include <array> #include <fstream> #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #include <iostream> #include <iomanip> #include <cstdio> #include <cmath> #include <cstdlib> #include <ctime> #include <cassert> #include <queue> #include <cstring> #include <limits> #include <chrono> #include <unistd.h> using namespace std; // }}} // {{{ Utilities #ifdef ONLINE_JUDGE static bool debug = false; #else static bool debug = true; #endif #define db(x) #x << "=" << (x) << " " #define dprintf debug && printf #define All(x) x.begin(), x.end() #define Loop(i, n) for (int i = 0; i < int(n); ++i) template <typename T, typename Q, typename S> bool Bounded(const T &x, const Q &a, const S &b) { return a <= x && x <= b; } typedef long double Real; const Real pi = 4*atan(Real(1.0)); const Real Inf = numeric_limits<Real>::infinity(); // https://github.com/JuliaLang/julia/blob/master/base/floatfuncs.jl Real isapprox(Real x, Real y, Real rtol = sqrt(numeric_limits<Real>::epsilon()), Real atol = Real(0.0), bool nans = false) { return x == y || (nans && isnan(x) && isnan(y)) || (isfinite(x) && isfinite(y) && abs(x - y) <= atol + rtol*max(abs(x), abs(y))); } typedef long long int ll; typedef vector<Real> Vd; typedef vector<int> Vi; typedef vector<ll> Vll; typedef vector<bool> Vb; typedef pair<int,int> Pii; typedef pair<ll,ll> Pll; template <typename T> int sz(const T &x) { return (int)x.size(); } template <typename T, typename Q> bool mem(const T &s, const Q &x) { return s.find(x) != s.end(); } template <typename T> void push(vector<T>& c, const T& e) { c.push_back(e); } template <typename T> void push(queue<T>& c, const T& e) { c.push(e); } template <typename T> void push(set<T>& c, const T& e) { c.insert(e); } template <typename T, typename... Args> auto emplace(vector<T>& c, Args&&... args) -> decltype(c.emplace_back(args...)) { c.emplace_back(args...); } template <typename T, typename... Args> auto emplace(queue<T>& c, Args&&... args) -> decltype(c.emplace(args...)) { c.emplace(args...); } template <typename T, typename... Args> auto emplace(set<T>& c, Args&&... args) -> decltype(c.emplace(args...)) { c.emplace(args...); } template <typename T> void umin(T &x, const T &y) { x = min(x, y); } template <typename T> void umax(T &x, const T &y) { x = max(x, y); } template <typename T> int sign(const T &x) { return x == 0 ? 0 : x > 0 ? 1 : -1; } template <typename T> T square(const T &x) { return x * x; } // }}} // {{{ IO template <typename S, typename T> istream& operator>>(istream& in, pair<S, T>& p) { return in >> p.first >> p.second; } template <typename T> T read() { T x; cin >> x; return x; } template <typename T, typename I = typename T::iterator> void read(T &cnt) { for (auto& x : cnt) cin >> x; } template <typename S, typename T> ostream& operator<<(ostream& out, const pair<S, T>& p) { return out << "{" << p.first << ", " << p.second << "}"; } template <typename T> struct show_container { const T &container; show_container(const T &container_) : container(container_) {} }; template <typename T> ostream &operator<<(ostream &o, const show_container<T> &thing) { bool first = true; o << "{"; for (const auto &x : thing.container) { if (!first) o << ", "; first = false; o << x; } o << "}"; return o; } template <typename T> show_container<T> show(const T &container) { return show_container<T>(container); } #define dprintf debug && printf struct dout_ { } dout; template <typename T> dout_ &operator<<(dout_ &out, const T &thing) { if (debug) cout << thing; return out; } dout_ &operator<<(dout_ &out, ostream &(*thing)(ostream &)) { if (debug) cout << thing; return out; } struct outboth { ostream &a; ostream &b; outboth(ostream &a_, ostream &b_) : a(a_), b(b_) {} }; template <typename T> outboth &operator<<(outboth &both, const T &thing) { both.a << thing; both.b << thing; return both; } outboth &operator<<(outboth &both, ostream &(*thing)(ostream &)) { both.a << thing; both.b << thing; return both; } // }}} // {{{ Union-find struct UF { vector<size_t> rep, rank; UF(size_t n) : rep(n), rank(n) { for (size_t i = 0; i < n; ++i) { rep[i] = i; rank[i] = 1; } } size_t lookup(size_t a) { size_t u = a, v = rep[u], r; while (u != v) u = v, v = rep[u]; r = u; for (u = a, v = rep[u]; v != r; u = v, v = rep[u]) rep[u] = r; return r; } void merge(size_t a, size_t b) { size_t u = lookup(a), v = lookup(b); if (u == v) return; if (rank[u] > rank[v]) { rep[v] = rep[u]; rank[u] += rank[v]; } else { rep[u] = rep[v]; rank[v] += rank[u]; } } }; // }}} // {{{ Solver #ifdef ONLINE_JUDGE void solve(ostream& rout) { std::ios::sync_with_stdio(false); cin.tie(nullptr); #else void solve(outboth rout) { #endif int N; cin >> N; if (!cin) return; vector<Pii> edges(read<int>()); read(edges); for (Pii& e : edges) --e.first, --e.second; vector<Vi> adj(N); for (Pii e : edges) { push(adj[e.first], e.second); push(adj[e.second], e.first); } // dout << db(N) << show(edges) << endl; // Loop(i,N) dout << "adj[" << i << "]: " << show(adj[i]) << endl; Vb marked(N); Vi path; function<void(int)> dfs = [&](int u) { if (marked[u]) return; push(path, u); marked[u] = true; for (int v : adj[u]) { if (!marked[v]) { dfs(v); break; } } }; dfs(0); // dout << "path(0): " << show(path) << endl; reverse(All(path)); for (int u : adj[0]) { if (!marked[u]) { dfs(u); break; } } // dout << "path(1): " << show(path) << endl; rout << std::count(All(marked), true) << "\n"; Loop(i,sz(path)) rout << (i == 0 ? "" : " ") << path[i]; rout << endl; } // }}} // {{{ Main int main() { solve(cout); return 0; } // }}} // clang-format off // Local variables: // compile-command: "make B && ./B" // irony-additional-clang-options: ("-std=c++11") // End:
a.cc: In function 'int main()': a.cc:236:9: error: could not convert 'std::cout' from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'outboth' 236 | solve(cout); | ^~~~ | | | std::ostream {aka std::basic_ostream<char>}
s322025545
p03746
C++
#include <bits/stdc++.h> using namespace std; #define K 600001 #define FOE(i, s, t) for (int i = s; i <= t; i++) vector<int> nxt[K]; int n; int dfs[K]; vector<int> ans1, ans2; void DFS(int u, int f){ if (f) ans2.push_back(u); else ans1.push_back(u); dfs[u] = 1; for (auto Z : nxt[u]) if (!dfs[Z]) {DFS(Z, f); return;} } int main(){ int cx, cy; scanf("%d%d", &n, &m); FOE(i, 1, m){ int s, t; scanf("%d%d", &s, &t); nxt[s].push_back(t); nxt[t].push_back(s); cx = s; cy = t; } dfs[cy] = 1; DFS(cx, 0); DFS(cy, 1); printf("%lu\n", ans1.size() + ans2.size()); for (int i = ans1.size() - 1; i >= 0; i--) printf("%d ", ans1[i]); for (int i = 0; i < ans2.size(); i++) printf("%d%c", ans2[i], (i == ans2.size() - 1?'\n':' ')); }
a.cc: In function 'int main()': a.cc:23:28: error: 'm' was not declared in this scope; did you mean 'tm'? 23 | scanf("%d%d", &n, &m); | ^ | tm
s405512391
p03746
C++
#include<bits/stdc++.h> #define rep(i,s,t) for(int i=s;i<=t;i++) #define per(i,s,t) for(int i=s;i>=t;i--) #define p_b push_back #define N 100010 using namespace std; int n,m; int s1[N],s2[N],n1,n2; bool vis[N]; vector<int> e[N]; void dfs(int u){ vis[u]=1; for(int i=0;i<e[u].size();i++) if(!vis[e[u][i]]){ dfs(e[u][i]); s1[++n1]=e[u][i]; break; } } void dfs2(int u){ vis[u]=1; for(int i=0;i<e[u].size();i++) if(!vis[e[u][i]]){ dfs2(e[u][i]); s2[++n2]=e[u][i]; break; } } int main(){ scanf("%d%d",&n,&m); int x,y; rep(i,1,m){ scanf("%d%d",&x,&y); e[x].p_b(y); e[y].p_b(x); } vis[1]=1; dfs(1); dfs2(1); //rep(i,1,n1) printf("%d ",s1[i]); puts(""); //rep(i,1,n2) printf("%d ",s2[i]); puts(""); printf("%d\n",n1+n2+1); rep(i,1,n1) printf("%d ",s1[i]); printf("1"); per(i,n2,1) printf(" %d",s2[i]); puts(""); return 0; }#include<bits/stdc++.h> #define rep(i,s,t) for(int i=s;i<=t;i++) #define per(i,s,t) for(int i=s;i>=t;i--) #define p_b push_back #define N 100010 using namespace std; int n,m; int s1[N],s2[N],n1,n2; bool vis[N]; vector<int> e[N]; void dfs(int u){ vis[u]=1; for(int i=0;i<e[u].size();i++) if(!vis[e[u][i]]){ dfs(e[u][i]); s1[++n1]=e[u][i]; break; } } void dfs2(int u){ vis[u]=1; for(int i=0;i<e[u].size();i++) if(!vis[e[u][i]]){ dfs2(e[u][i]); s2[++n2]=e[u][i]; break; } } int main(){ scanf("%d%d",&n,&m); int x,y; rep(i,1,m){ scanf("%d%d",&x,&y); e[x].p_b(y); e[y].p_b(x); } vis[1]=1; dfs(1); dfs2(1); //rep(i,1,n1) printf("%d ",s1[i]); puts(""); //rep(i,1,n2) printf("%d ",s2[i]); puts(""); printf("%d\n",n1+n2+1); rep(i,1,n1) printf("%d ",s1[i]); printf("1"); per(i,n2,1) printf(" %d",s2[i]); puts(""); return 0; }
a.cc:52:2: error: stray '#' in program 52 | }#include<bits/stdc++.h> | ^ a.cc:52:3: error: 'include' does not name a type 52 | }#include<bits/stdc++.h> | ^~~~~~~ a.cc:60:5: error: redefinition of 'int n' 60 | int n,m; | ^ a.cc:9:5: note: 'int n' previously declared here 9 | int n,m; | ^ a.cc:60:7: error: redefinition of 'int m' 60 | int n,m; | ^ a.cc:9:7: note: 'int m' previously declared here 9 | int n,m; | ^ a.cc:61:5: error: redefinition of 'int s1 [100010]' 61 | int s1[N],s2[N],n1,n2; | ^~ a.cc:10:5: note: 'int s1 [100010]' previously declared here 10 | int s1[N],s2[N],n1,n2; | ^~ a.cc:61:11: error: redefinition of 'int s2 [100010]' 61 | int s1[N],s2[N],n1,n2; | ^~ a.cc:10:11: note: 'int s2 [100010]' previously declared here 10 | int s1[N],s2[N],n1,n2; | ^~ a.cc:61:17: error: redefinition of 'int n1' 61 | int s1[N],s2[N],n1,n2; | ^~ a.cc:10:17: note: 'int n1' previously declared here 10 | int s1[N],s2[N],n1,n2; | ^~ a.cc:61:20: error: redefinition of 'int n2' 61 | int s1[N],s2[N],n1,n2; | ^~ a.cc:10:20: note: 'int n2' previously declared here 10 | int s1[N],s2[N],n1,n2; | ^~ a.cc:62:6: error: redefinition of 'bool vis [100010]' 62 | bool vis[N]; | ^~~ a.cc:11:6: note: 'bool vis [100010]' previously declared here 11 | bool vis[N]; | ^~~ a.cc:63:13: error: redefinition of 'std::vector<int> e [100010]' 63 | vector<int> e[N]; | ^ a.cc:12:13: note: 'std::vector<int> e [100010]' previously declared here 12 | vector<int> e[N]; | ^ a.cc:65:6: error: redefinition of 'void dfs(int)' 65 | void dfs(int u){ | ^~~ a.cc:14:6: note: 'void dfs(int)' previously defined here 14 | void dfs(int u){ | ^~~ a.cc:75:6: error: redefinition of 'void dfs2(int)' 75 | void dfs2(int u){ | ^~~~ a.cc:24:6: note: 'void dfs2(int)' previously defined here 24 | void dfs2(int u){ | ^~~~ a.cc:85:5: error: redefinition of 'int main()' 85 | int main(){ | ^~~~ a.cc:34:5: note: 'int main()' previously defined here 34 | int main(){ | ^~~~
s214557533
p03746
C
#include <stdio.h> #include <string.h> #define MaxSize 100000 int neighbour[MaxSize][MaxSize]; char visited[MaxSize]; char nbCount[MaxSize]; int startPath[MaxSize]; int endPath[MaxSize]; int startPathLen = 0; int endPathLen = 0; void searchEnd(int end, int pathArr[], int * pLength) { char allNbSearched = 0; char foundNew = 0; while(!allNbSearched) { for(int i = 0; i < nbCount[end]; i++) { int newEnd = neighbour[end][i]; if(!visited[newEnd]) { end = newEnd; visited[newEnd] = 1; foundNew = 1; allNbSearched = 0; pathArr[*pLength] = newEnd; (*pLength)++; break; //for } allNbSearched = 1; } } } int main(int argc, const char * argv[]) { int N, M; // memset(neighbour, 0, MaxSize * MaxSize); memset(visited, 0, MaxSize); memset(nbCount, 0, MaxSize); scanf("%d%d", &N, &M); // N = MaxSize; // M = MaxSize ; int start = 0, end = 0; for(int i = 1; i <= M; i++) { scanf("%d%d", &start, &end); // start = i; // end = i+1; // end %= (N + 1); // if (end == 0) end = 1; neighbour[start][nbCount[start]] = end; neighbour[end][nbCount[end]] = start; nbCount[start]++; nbCount[end]++; } visited[start] = visited[end] = 1; searchEnd(start, startPath, &startPathLen); searchEnd(end, endPath, &endPathLen); printf("%d\n", startPathLen + endPathLen + 2); for(int i = 0; i < startPathLen; i++) printf("%d ", startPath[i]); printf("%d %d ", start, end); for(int i = 0; i < endPathLen; i++) printf("%d ", endPath[i]); printf("\n"); return 0; }
/tmp/cc3KCKww.o: in function `searchEnd': main.c:(.text+0x5a): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x74): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o /tmp/cc3KCKww.o: in function `main': main.c:(.text+0xff): relocation truncated to fit: R_X86_64_PC32 against symbol `visited' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x118): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x187): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x1c2): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x1fb): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x20d): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x21d): relocation truncated to fit: R_X86_64_PC32 against symbol `nbCount' defined in .bss section in /tmp/cc3KCKww.o main.c:(.text+0x22f): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s600460185
p03746
C++
#include <stdio.h> #include <string.h> #include <map> #include <vector> #include <list> #include <pair> using namespace std; int N,M; map<int,vector<int>> paths; list<int> output; int l,r; bool hasYouso(list<int> &a, int k); void chkLeft(void); void chkRight(void); void printOutput(void); void erasePath(int a,int b); void printPaths(void); int main(int argc, const char * argv[]) { scanf("%d %d",&N, &M); int a,b; scanf("%d %d",&a,&b); output.push_back(a); output.push_back(b); l=a; r=b; for(int k=0;k<N-1;k++){ scanf("%d %d",&a,&b); if(l == a){ if(!hasYouso(output, b)){ output.push_front(b); l = b; chkLeft(); continue; } }else if(l == b){ if(!hasYouso(output,a)){ output.push_front(a); l=a; chkLeft(); continue; } }else if(r == a){ if(!hasYouso(output,b)){ output.push_back(b); r=b; chkRight(); continue; } }else if(r == b){ if(!hasYouso(output,a)){ output.push_back(a); r=a; chkRight(); continue; } }else{ paths[a].push_back(b); paths[b].push_back(a); } // printOutput(); // printPaths(); } printOutput(); return 0; } void printPaths(void){ for(map<int,vector<int>>::iterator i=paths.begin();i!=paths.end();i++){ printf("%d-",(*i).first); for(auto a=(*i).second.begin();a!=(*i).second.end();a++){ printf("%d ",*a); } printf("\n"); } } void printOutput(void){ printf("%ld\n",output.size()); for(auto i=output.begin();i!=output.end();i++){ printf("%d ",*i); } printf("\n"); } void erasePath(int a,int b){ vector<int> *vec = &paths[a]; for(auto p=vec->begin();p!=vec->end();p++){ if(*p == b){ vec->erase(p); return; } } } void chkLeft(void){ jmpl: if(paths[l].size() != 0){ vector<int> *vec = &paths[l]; vector<pair<int,int>> removePath; for(auto p=vec->begin();p!=vec->end();p++){ if(!hasYouso(output, *p)){ output.push_front(*p); int remove = *p; vec->erase(p); erasePath(remove,l); // printf("%d not found\n",*p); l=*p; goto jmpl; }else{ int remove = *p; removePath.push_back(make_pair(remove, l)); } } for(auto remove = removePath.begin();remove != removePath.end();remove++){ erasePath(remove->first, remove->second); erasePath(remove->second, remove->first); } } } void chkRight(void){ jmpr: if(paths[r].size() != 0){ vector<int> *vec = &paths[r]; vector<pair<int,int>> removePath; for(auto p=vec->begin();p!=vec->end();p++){ if(!hasYouso(output, *p)){ output.push_back(*p); int remove = *p; vec->erase(p); erasePath(remove,r); r=*p; goto jmpr; }else{ int remove = *p; removePath.push_back(make_pair(remove, r)); } } for(auto remove = removePath.begin();remove != removePath.end();remove++){ erasePath(remove->first, remove->second); erasePath(remove->second, remove->first); } } } bool hasYouso(list<int> &a, int k){ for(auto p=a.begin();p!=a.end();p++){ if(k == *p){ return true; } } return false; }
a.cc:6:10: fatal error: pair: No such file or directory 6 | #include <pair> | ^~~~~~ compilation terminated.
s772491651
p03746
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; const ll INF = 1000000000000000000ll; const ll MOD = 1000000007ll; const double EPS = 1e-8; list<int> e[100005]; bool used[100005]; list<int> seq; int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; for(int i=0; i<m; i++){ int eb, ee; cin >> eb >> ee; eb--; ee--; e[eb].pb(ee); e[ee].pb(eb); } int n1 = 1; int n2 = e[1].front(); seq.pb(n1); seq.pb(n2); used[n1] = used[n2] = true; //e[0].erase(e[0].begin()); e[1].pop_front(); int cnt = 0; while(1){ cnt++; if(cnt > 100000/2) puts("aaa"); bool f = true; for(auto it = e[n1].begin(); it != e[n1].end(); it++){ if(used[*it] != true){ f = false; seq.push_front(*it); used[*it] = true; int tmp = *it; e[n1].pop_front(); n1 = tmp; break; } } if(f) break; } while(1){ cnt++; if(cnt > 100000/2) puts("aaa"); bool f = true; for(auto it = e[n2].begin(); it != e[n2].end(); it++){ if(used[*it] != true){ f = false; seq.push_back(*it); used[*it] = true; int tmp = *it; e[n2].pop_back(); n2 = tmp; break; } } if(f) break; } cout << seq.size() << endl; int cnt = 0; auto it = seq.begin(); for(; it != seq.end(); it++){ if(cnt == seq.size()-1) break; printf("%d ", (*it) + 1); cnt++; } printf("%d\n", (*it)+1); return 0; }
a.cc: In function 'int main()': a.cc:81:13: error: redeclaration of 'int cnt' 81 | int cnt = 0; | ^~~ a.cc:41:13: note: 'int cnt' previously declared here 41 | int cnt = 0; | ^~~
s794157552
p03746
C++
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; const ll INF = 1000000000000000000ll; const ll MOD = 1000000007ll; const double EPS = 1e-8; list<int> e[100005]; vector<int> used(n, 0); list<int> seq; int main(void) { //ios_base::sync_with_stdio(false); //cin.tie(0); int n, m; cin >> n >> m; for(int i=0; i<m; i++){ int eb, ee; cin >> eb >> ee; eb--; ee--; e[eb].pb(ee); e[ee].pb(eb); } int n1 = 1; int n2 = e[1].front(); seq.pb(n1); seq.pb(n2); used[n1] = used[n2] = 1; //e[0].erase(e[0].begin()); e[1].pop_front(); while(1){ /* int cnt = 0; auto it = seq.begin(); for(; it != seq.end(); it++){ if(cnt == seq.size()-1) break; printf("%d ", (*it) + 1); cnt++; } printf("%d\n", (*it)+1); */ bool f = true; for(auto it = e[n1].begin(); it != e[n1].end(); it++){ if(used[*it] != 1){ f = false; seq.push_front(*it); used[*it] = 1; int tmp = *it; e[n1].pop_front(); n1 = tmp; break; } } if(!f) continue; for(auto it = e[n2].begin(); it != e[n2].end(); it++){ if(used[*it] != 1){ f = false; seq.push_back(*it); used[*it] = 1; int tmp = *it; e[n2].pop_front(); n2 = tmp; break; } } if(!f) continue; cout << seq.size() << endl; int cnt = 0; auto it = seq.begin(); for(; it != seq.end(); it++){ if(cnt == seq.size()-1) break; printf("%d ", (*it) + 1); cnt++; } printf("%d\n", (*it)+1); break; } return 0; }
a.cc:13:18: error: 'n' was not declared in this scope; did you mean 'yn'? 13 | vector<int> used(n, 0); | ^ | yn
s147042953
p03746
C++
#include <iostream> #include <vector> #include <set> using namespace std; int N,M; vector<int> mat[100000]; vector<int> ans; bool visited[100000]; void DFS(int v) { visited[v] = 1; for(int i = 0; i < mat[v].size(); i++){ int u = mat[v][i]; if(visited[u]==0){ ans.push_back(u+1); DFS(u); break; } } } int main() { cin >> N >> M; for(int i=0;i<M;i++){ int a,b; cin >> a >> b; a--; b--; mat[a].push_back(b); mat[b].push_back(a); } ans.push_back(1); DFS(0); reverse(ans.begin(), ans.end()); DFS(0); cout << ans.size() << endl; for(int i=0;i<ans.size();i++){ cout << ans[i]; if(i!=ans.size()-1) cout << " "; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:37:9: error: 'reverse' was not declared in this scope 37 | reverse(ans.begin(), ans.end()); | ^~~~~~~
s919168472
p03746
C++
#include <iostream> #include <stdio.h> #include <string> #include <vector> #include <cmath> #include <algorithm> using namespace std; int k=0; bool back = false; void dfs(vector<vector<int> >&G, int N, int p, int s, vector<int>&visited, vector<int>&fpath, vector<int>&bpath) { visited[p] = 1; if(back == false){ fpath[k] = p; k++; }else{ bpath[k] = p; k++; } for(int i=0; i < G[p].size(); i++){ if(visited[G[p][i]] == 0 && back = false){ dfs(G,N,G[p][i],s,visited,fpath,bpath); break; } if(visited[G[p][i]] == 0 && back = true){ dfs(G,N,G[p][i],G[p][i],visited,fpath,bpath); break; } if(i == G[p].size()-1){ if(back == true) break; if(back == false) k = 0; back = true; for(int i=0; i < G[s].size(); i++){ if(visited[G[s][i]] == 0){ dfs(G,N,G[s][i],G[s][i],visited,fpath,bpath); break; } } } } return; } int main() { int N,M; cin >> N >> M; vector<vector<int> >G(N); for(int i=0; i < M; i++){ int a,b; cin >> a >> b; G[a-1].push_back(b-1); G[b-1].push_back(a-1); } vector<int>fpath(N,-1); vector<int>bpath(N,-1); vector<int>visited(N,0); dfs(G,N,0,0,visited,fpath,bpath); int bsum=0; int fsum=0; for(int i=0; i < N; i++){ if(bpath[i] == -1) break; bsum++; } for(int i=0; i < N; i++){ if(fpath[i] == -1) break; fsum++; } cout << fsum+bsum << endl; for(int i=0; i < bsum; i++){ cout << bpath[i]+1 << " "; } for(int i=0; i < fsum; i++){ cout << fpath[i]+1 << " "; } cout << endl; return 0; }
a.cc: In function 'void dfs(std::vector<std::vector<int> >&, int, int, int, std::vector<int>&, std::vector<int>&, std::vector<int>&)': a.cc:24:30: error: lvalue required as left operand of assignment 24 | if(visited[G[p][i]] == 0 && back = false){ a.cc:28:30: error: lvalue required as left operand of assignment 28 | if(visited[G[p][i]] == 0 && back = true){
s099113353
p03746
C++
#include <iostream> #include <vector> #include <map> #include <set> #include <string> using namespace std; const int N = 1e5 + 5; int a[N]; vector<int> e[N]; int in[N]; bool b[N]; int s[N]; // step vector<int> asr; int pre[N]; int mx, ed2; bool dfs1(int cur, int ed) { b[cur] = true; asr.push_back(cur); if(cur == ed) return true; for(int i = 0 ; i < e[cur].size(); i++) { int nxt = e[cur][i]; if(b[nxt]) continue; if(dfs1(nxt, ed)) return true; } return false; } void dfs2(int cur, int t) { b[cur] = true; s[cur] = t; for(int i = 0 ; i < e[cur].size(); i++) { int nxt = e[cur][i]; if(!b[nxt]) { pre[nxt] = cur; dfs2(nxt, t + 1); } else { int tmp = s[cur] - s[nxt] + 1; if(tmp > mx) { mx = tmp; ed2 = nxt; pre[ed2] = cur; } } } } int main() { int n, m; cin>>n>>m; memset(in, 0, sizeof(in)); for(int i = 0; i < m; i++) { int u,v; cin>>u>>v; e[u].push_back(v); e[v].push_back(u); in[u]++; in[v]++; } memset(b, 0, sizeof(b)); for(int i = 1; i<= n; i++ ) { if(in[i] == 1) { for(int j = i + 1; j <= n ; j++) { if(in[j] == 1) { dfs1(i, j); cout<<asr.size() << endl; cout<<asr[0]; for(int k = 1; k < asr.size(); k++) { printf(" %d",asr[k]); } cout<<endl; return 0; } } } } mx = 0; dfs2(1, 0); int cur = ed2; set<int> s1,s2; int sz = 0; do{ sz++; s1.insert(cur); cur = pre[cur]; }while(cur != ed2); for(int i = 1 ; i <= n ; i++) { if(s1.find(i) == s1.end()) { s2.insert(i); } } cur = ed2; int pr; while(1) { pr = pre[cur]; bool ok1 = true, ok2 = true; for(int i = 0; i < e[cur].size(); i++) { if(s2.find(e[cur][i]) != s2.end()) { ok1 = false; break; } } for(int i = 0; i < e[pr].size(); i++) { if(s2.find(e[pr][i]) != s2.end()) { ok2 = false; break; } } if(ok1 && ok2) { break; } cur = pr; } cout<<sz<<endl; ed2 = cur; cur = pr; cout<<cur; do{ cur = pre[cur]; printf(" %d",cur); }while(cur != ed2); cout<<endl; //system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:63:9: error: 'memset' was not declared in this scope 63 | memset(in, 0, sizeof(in)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <set> +++ |+#include <cstring> 5 | #include <string>
s864038612
p03746
C++
#include <iostream> #include <vector> #include <map> #include <set> using namespace std; const int N = 1e5 + 5; int a[N]; vector<int> e[N]; int in[N]; bool b[N]; int s[N]; // step vector<int> asr; int pre[N]; int mx, ed2; bool dfs1(int cur, int ed) { b[cur] = true; asr.push_back(cur); if(cur == ed) return true; for(int i = 0 ; i < e[cur].size(); i++) { int nxt = e[cur][i]; if(b[nxt]) continue; if(dfs1(nxt, ed)) return true; } return false; } void dfs2(int cur, int t) { b[cur] = true; s[cur] = t; for(int i = 0 ; i < e[cur].size(); i++) { int nxt = e[cur][i]; if(!b[nxt]) { pre[nxt] = cur; dfs2(nxt, t + 1); } else { int tmp = s[cur] - s[nxt] + 1; if(tmp > mx) { mx = tmp; ed2 = nxt; pre[ed2] = cur; } } } } int main() { int n, m; cin>>n>>m; memset(in, 0, sizeof(in)); for(int i = 0; i < m; i++) { int u,v; cin>>u>>v; e[u].push_back(v); e[v].push_back(u); in[u]++; in[v]++; } memset(b, 0, sizeof(b)); for(int i = 1; i<= n; i++ ) { if(in[i] == 1) { for(int j = i + 1; j <= n ; j++) { if(in[j] == 1) { dfs1(i, j); cout<<asr.size() << endl; cout<<asr[0]; for(int k = 1; k < asr.size(); k++) { printf(" %d",asr[k]); } cout<<endl; return 0; } } } } mx = 0; dfs2(1, 0); int cur = ed2; set<int> s1,s2; int sz = 0; do{ sz++; s1.insert(cur); cur = pre[cur]; }while(cur != ed2); for(int i = 1 ; i <= n ; i++) { if(s1.find(i) == s1.end()) { s2.insert(i); } } cur = ed2; int pr; while(1) { pr = pre[cur]; bool ok1 = true, ok2 = true; for(int i = 0; i < e[cur].size(); i++) { if(s2.find(e[cur][i]) != s2.end()) { ok1 = false; break; } } for(int i = 0; i < e[pr].size(); i++) { if(s2.find(e[pr][i]) != s2.end()) { ok2 = false; break; } } if(ok1 && ok2) { break; } cur = pr; } cout<<sz<<endl; ed2 = cur; cur = pr; cout<<cur; do{ cur = pre[cur]; printf(" %d",cur); }while(cur != ed2); cout<<endl; //system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:62:9: error: 'memset' was not declared in this scope 62 | memset(in, 0, sizeof(in)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <set> +++ |+#include <cstring> 5 | using namespace std;
s522817479
p03746
C++
#include <iostream> #include <vector> #include <map> #include <set> using namespace std; const int N = 1e5 + 5; int a[N]; vector<int> e[N]; int in[N]; bool b[N]; int s[N]; // step vector<int> asr; int pre[N]; int mx, ed2; bool dfs1(int cur, int ed) { b[cur] = true; asr.push_back(cur); if(cur == ed) return true; for(int i = 0 ; i < e[cur].size(); i++) { int nxt = e[cur][i]; if(b[nxt]) continue; if(dfs1(nxt, ed)) return true; } return false; } void dfs2(int cur, int t) { b[cur] = true; s[cur] = t; for(int i = 0 ; i < e[cur].size(); i++) { int nxt = e[cur][i]; if(!b[nxt]) { pre[nxt] = cur; dfs2(nxt, t + 1); } else { int tmp = s[cur] - s[nxt] + 1; if(tmp > mx) { mx = tmp; ed2 = nxt; pre[ed2] = cur; } } } } int main() { int n, m; cin>>n>>m; memset(in, 0, sizeof(in)); for(int i = 0; i < m; i++) { int u,v; cin>>u>>v; e[u].push_back(v); e[v].push_back(u); in[u]++; in[v]++; } memset(b, 0, sizeof(b)); for(int i = 1; i<= n; i++ ) { if(in[i] == 1) { for(int j = i + 1; j <= n ; j++) { if(in[j] == 1) { dfs1(i, j); cout<<asr.size() << endl; cout<<asr[0]; for(int k = 1; k < asr.size(); k++) { printf(" %d",asr[k]); } cout<<endl; return 0; } } } } mx = 0; dfs2(1, 0); int cur = ed2; set<int> s1,s2; int sz = 0; do{ sz++; s1.insert(cur); cur = pre[cur]; }while(cur != ed2); for(int i = 1 ; i <= n ; i++) { if(s1.find(i) == s1.end()) { s2.insert(i); } } cur = ed2; int pr; while(1) { pr = pre[cur]; bool ok1 = true, ok2 = true; for(int i = 0; i < e[cur].size(); i++) { if(s2.find(e[cur][i]) != s2.end()) { ok1 = false; break; } } for(int i = 0; i < e[pr].size(); i++) { if(s2.find(e[pr][i]) != s2.end()) { ok2 = false; break; } } if(ok1 && ok2) { break; } cur = pr; } cout<<sz<<endl; ed2 = cur; cur = pr; cout<<cur; do{ cur = pre[cur]; printf(" %d",cur); }while(cur != ed2); cout<<endl; //system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:62:9: error: 'memset' was not declared in this scope 62 | memset(in, 0, sizeof(in)); | ^~~~~~ a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 4 | #include <set> +++ |+#include <cstring> 5 | using namespace std;
s344892608
p03746
C++
#include <iostream> #include <string> #include <map> #include <algorithm> #include <list> #include <vector> #include <set> #include <stdio.h> #include <queue> #include <stack> #include <deque> #include <math.h> #include <sstream> #include <stdlib.h> #include <functional> using namespace std; #define rep(i,n) for(int i = 0; i < n; i++) #define rrep(i,a,n) for(int i = a; i < n; i++) #define INF (1<<29) #define INFL 0x3f3f3f3f3f3f3f3fLL #define MOD 1000000007 #define fi first #define se second #define pb push_back #define PI 3.14159265358979323846 #define all(o) (o).begin(), (o).end() #define rall(x) x.rbegin(),x.rend() typedef double ld; typedef vector<int> vi; typedef vector< vi > vvi; typedef vector<string> vs; typedef vector<char> vc; typedef vector<ld> vd; typedef vector < vc > vvc; typedef long long ll; typedef pair<int, int> pii; typedef unsigned long long int ulli; const int dx[] = { 1, 0, -1, 0 }; const int dy[] = { 0, 1, 0, -1 }; template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); } template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); } const ld eps = 1e-10, pi = acos(-1.0); #define MAX_N 100001 // combination ll fact[MAX_N], factinv[MAX_N]; ll mod_pow(ll n, ll p, ll m) { ll a = n; ll x = 1; while (p) { if (p & 1) x = (x * a) % m; a = (a * a) % m; p >>= 1; } return x; } int extgcd(int a, int b, int& x, int&y) { int d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } int mod_inverse(int a, int m) { int x, y; extgcd(a, m, x, y); return (m + x % m) % m; } ll inv(ll n) { return mod_pow(n, MOD - 2, MOD); } void combInit() { fact[0] = 1; rrep(i, 1, MAX_N) fact[i] = fact[i - 1] * i % MOD; factinv[MAX_N - 1] = inv(fact[MAX_N - 1]); for (int i = MAX_N - 2; i >= 0; i--) factinv[i] = factinv[i + 1] * (i + 1) % MOD; } // ダイクストラ /* struct edge { int to, cost; }; vector < vector < edge > > G; vi d; void dijkstra(int s) {priority_queue<pii, vector< pii >, greater<pii> > que;d[s] = 0;que.push(pii(0, s));while (!que.empty()) {pii p = que.top(); que.pop();int v = p.second;if (d[v] < p.first) continue;rep(i, G[v].size()) {edge e = G[v][i];int cost = e.cost;if (d[v] + cost < d[e.to]) {d[e.to] = d[v] + e.cost;que.push(pii(d[e.to], e.to));}}}} */ // Union-Find木 int par[MAX_N], rnk[MAX_N], unionSize[MAX_N]; // はじめは全ての頂点が根 void UnionFindTreeInit(int n) { rep(i, n) { par[i] = i; rnk[i] = 0; unionSize[i] = 1; } } //木の根元を求める int root(int x) { if (par[x] == x) return x; // 根を返す else return par[x] = root(par[x]); } // 連結成分の大きさを取得 int componentSize(int x) { return unionSize[root(x)]; } // xとyが同じ集合に属するか否か bool same(int x, int y) { return root(x) == root(y); } // xとyの属する集合を併合 void unite(int x, int y) { x = root(x); y = root(y); if (x == y) return; if (rnk[x] < rnk[y]) { par[x] = y; unionSize[y] += unionSize[x]; } else { par[y] = x; if (rnk[x] == rnk[y]) rnk[x]++; unionSize[x] += unionSize[y]; } } //----------------------------------------------------------------- //int dx[8] = { -1, 1, 0, 0, 1, 1, -1, -1 }; //int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 }; /* struct edge { int to, cost; }; vector < vector < edge > > G; vi d; void dijkstra(int s) { priority_queue<pii, vector< pii >, greater<pii> > que; d[s] = 0; que.push(pii(0, s)); while (!que.empty()) { pii p = que.top(); que.pop(); int v = p.second; if (d[v] < p.first) continue; rep(i, G[v].size()) { edge e = G[v][i]; int cost = e.cost; if (d[v] + cost < d[e.to]) { d[e.to] = d[v] + e.cost; que.push(pii(d[e.to], e.to)); } } } } */ //------------------------------------------------------- int main() { ios::sync_with_stdio(0); cin.tie(0); ll n,m; cin >> n >> m; vector <vector<ll> > G(n); rep(i,m) { ll a,b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); } rep(i,n) { sort(all(G[i])); } UnionFindTreeInit(n); vi a, b; int s = n / 2; a.push_back(s; a.push_back(G[s][0]); unite(s,G[s][0]); ll p = G[s][0]; ll q = -1; if (G[s].size() != 1) { b.push_back(G[s][1]); unite(s, G[s][1]); q = G[s][1]; } int i,j ; i = j = 0; while(G[p].size() > i || G[q].size() > j) { bool f1 = false; bool f2 = false; if (G[p].size() > i) { if (!same(p, G[p][i])) { unite(p,G[p][i]); ll t = G[p][i]; G[p].erase(G[p].begin()); p = t; a.push_back(p); f1 = true; i = 0; } } if (q > 0) { if (G[q].size() > j) { if (!same(q, G[q][j])) { unite(q,G[q][j]); ll t = G[q][j]; G[q].erase(G[q].begin()); q = t; b.push_back(q); f2 = true; j = 0; } } } if (!f1) { i++; } if (!f2) { j++; } } cout << a.size() + b.size() <<endl; reverse(all(b)); rep(i, b.size()) { cout << b[i] + 1 << " "; } rep(i, a.size()) { cout << a[i] + 1 << " "; } cout << endl; return 0; }
a.cc: In function 'int main()': a.cc:191:22: error: expected ')' before ';' token 191 | a.push_back(s; | ~ ^ | )