Submission #522580

#TimeUsernameProblemLanguageResultExecution timeMemory
522580dostigatorLongest beautiful sequence (IZhO17_subsequence)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("O3") #pragma GCC target("popcnt") #include <bits/stdc++.h> using namespace std; #define IShowSpeed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define popcnt __builtin_popcount #define all(a) a.begin(),a.end() #define pii pair<ll,ll> #define mii map<ll,ll> #define pll pair<ll,ll> #define mll map<ll,ll> #define pb push_back #define vt vector #define endl '\n' #define X first #define Y second typedef long double ld; typedef long long ll; const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},N=1e4; const ll mod=1e9+7,inf=1e18; ll n,a[N],k[N]; ll pos[(1<<9)]; void solve(){ cin>>n; vt<ll>sub[(1<<8)+1000]; for(ll i=1; i<=n; ++i){ cin>>a[i]; if(sub[a[i]].size())continue; sub[a[i]].pb(i); } for(ll i=1; i<=n; ++i)cin>>k[i]; for(ll i=1; i<=n; ++i){ pos[a[i]]=1; for(ll mask=0; mask<(1<<8)+100; ++mask){ ll h=(mask&a[i]); if(pos[mask]==0 || sub[mask].size()==0)continue;// maybe wrong if(popcnt(h)==k[i]){ if(sub[a[i]].size()<=sub[mask].size()){ sub[a[i]]=sub[mask]; sub[a[i]].pb(i); } } } } unsigned ll mx=0,ans=0; for(ll i=1; i<=n; ++i){ if(mx<sub[a[i]].size()){ mx=sub[a[i]].size(); ans=a[i]; } } cout<<mx<<endl; if(!mx)return; for(ll x:sub[ans])cout<<x<<' '; } int main() { IShowSpeed; ll tt=1; //cin>>tt; while(tt--) solve(); }

Compilation message (stderr)

subsequence.cpp: In function 'void solve()':
subsequence.cpp:45:17: error: expected initializer before 'mx'
   45 |     unsigned ll mx=0,ans=0;
      |                 ^~
subsequence.cpp:47:12: error: 'mx' was not declared in this scope; did you mean 'dx'?
   47 |         if(mx<sub[a[i]].size()){
      |            ^~
      |            dx
subsequence.cpp:49:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   49 |             ans=a[i];
      |             ^~~
      |             abs
subsequence.cpp:52:11: error: 'mx' was not declared in this scope; did you mean 'dx'?
   52 |     cout<<mx<<endl;
      |           ^~
      |           dx
subsequence.cpp:54:18: error: 'ans' was not declared in this scope; did you mean 'abs'?
   54 |     for(ll x:sub[ans])cout<<x<<' ';
      |                  ^~~
      |                  abs