Submission #397704

#TimeUsernameProblemLanguageResultExecution timeMemory
397704AmineWeslatiAncient Machine (JOI21_ancient_machine)C++17
Compilation error
0 ms0 KiB
#include "Anna.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int>vi; #define sz(v) (int)v.size() #define pb push_back #define all(x) begin(x),end(x) typedef string str; #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--) //-------------------------------------------------------// const int n=63,m=44; ll f[n]; void compute(){ f[0]=1; f[1]=2; FOR(i,2,n) f[i]=f[i-1]+f[i-2]; } ll encode(vi vec){ reverse(all(vec)); ll ans=0; FOR(i,0,n) if(vec[i]) ans+=f[i]; return ans; } void Anna(int N, vector<char>S) { vi a(N,0); int fir=-1; FOR(i,0,N){ if(S[i]=='X' && fir==-1){ a[i]=1; fir=i; } else if(S[i]=='Z' && fir!=-1 && i!=fir+1){ a[i]=1; } } while(sz(a)%n) a.pb(0); compute(); for(int i=0; i<sz(a); i+=n){ vi cur; FOR(j,i,i+n) cur.pb(a[j]); ll x=encode(cur); ROF(j,0,m){ Send((x>>j)&1); } } }
#include "Bruno.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef vector<int>vi; #define sz(v) (int)v.size() #define pb push_back #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--) //-------------------------------------------------------------// const int n=63,m=44; ll ff[n]; vi decode(ll val){ vi vec; ROF(i,0,n){ if(ff[i]<=val){ vec.pb(1); val-=ff[i]; } else vec.pb(0); } return vec; } void Bruno(int N, int L, vi a){ ff[0]=1; ff[1]=2; FOR(i,2,n) ff[i]=ff[i-1]+ff[i-2]; vi vec; for(int i=0; i<sz(a); i+=m){ ll cur=0; FOR(j,i,i+m){ cur*=2; cur+=a[j]; } vi v=decode(cur); for(int x: v) vec.pb(x); } int i=0; while(vec[i]==0){ Remove(i); i++; } int l=i,f=i; i++; for(;i<N; i++){ if(vec[i]){ int r=i; ROF(j,l+1,i){ Remove(j); } Remove(i); l=i; } else if(i==N-1){ FOR(j,l+1,i+1) remove(j); } } Remove(f); }

Compilation message (stderr)

Bruno.cpp: In function 'void Bruno(int, int, vi)':
Bruno.cpp:55:8: warning: unused variable 'r' [-Wunused-variable]
   55 |    int r=i;
      |        ^
Bruno.cpp:64:13: error: no matching function for call to 'remove(int&)'
   64 |     remove(j);
      |             ^
In file included from /usr/include/c++/10/cstdio:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:46,
                 from Bruno.cpp:2:
/usr/include/stdio.h:146:12: note: candidate: 'int remove(const char*)' (near match)
  146 | extern int remove (const char *__filename) __THROW;
      |            ^~~~~~
/usr/include/stdio.h:146:12: note:   conversion of argument 1 would be ill-formed:
Bruno.cpp:64:12: error: invalid conversion from 'int' to 'const char*' [-fpermissive]
   64 |     remove(j);
      |            ^
      |            |
      |            int
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:2:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:224:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::remove(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  224 | remove(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~~~
/usr/include/c++/10/pstl/glue_algorithm_defs.h:224:1: note:   template argument deduction/substitution failed:
Bruno.cpp:64:13: note:   candidate expects 4 arguments, 1 provided
   64 |     remove(j);
      |             ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from Bruno.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:870:5: note: candidate: 'template<class _FIter, class _Tp> _FIter std::remove(_FIter, _FIter, const _Tp&)'
  870 |     remove(_ForwardIterator __first, _ForwardIterator __last,
      |     ^~~~~~
/usr/include/c++/10/bits/stl_algo.h:870:5: note:   template argument deduction/substitution failed:
Bruno.cpp:64:13: note:   candidate expects 3 arguments, 1 provided
   64 |     remove(j);
      |             ^