제출 #522572

#제출 시각아이디문제언어결과실행 시간메모리
522572dostigatorLongest beautiful sequence (IZhO17_subsequence)C++17
컴파일 에러
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<int,int> #define mii map<int,int> #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 int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},N=6e5; const ll mod=1e9+7,inf=1e18; int dp[N],pr[N],n,a[N],k[N]; int mp[(1<<9)]; void solve(){ cin>>n; vt<int>sub[(1<<9)]; for(int i=1; i<=n; ++i){ cin>>a[i]; pos[a[i]]=i; if(sub[a[i]].size())continue; sub[a[i]].pb(i); } for(int i=1; i<=n; ++i)cin>>k[i]; for(int i=1; i<=n; ++i){ for(int mask=0; mask<(1<<8); ++mask){ int h=(mask&a[i]); if(pos[mask]==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); } } } } int mx=0,ans=0; for(int i=1; i<=n; ++i){ if(mx<sub[a[i]].size()){ mx=sub[a[i]].size(); ans=a[i]; } } cout<<mx<<endl; for(int x:sub[ans])cout<<x<<' '; } int main() { IShowSpeed; int tt=1; //cin>>tt; while(tt--) solve(); }

컴파일 시 표준 에러 (stderr) 메시지

subsequence.cpp: In function 'void solve()':
subsequence.cpp:28:9: error: 'pos' was not declared in this scope; did you mean 'pow'?
   28 |         pos[a[i]]=i;
      |         ^~~
      |         pow
subsequence.cpp:36:16: error: 'pos' was not declared in this scope; did you mean 'pow'?
   36 |             if(pos[mask]==0)continue;// maybe wrong
      |                ^~~
      |                pow
subsequence.cpp:47:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         if(mx<sub[a[i]].size()){
      |            ~~^~~~~~~~~~~~~~~~~