제출 #1112955

#제출 시각아이디문제언어결과실행 시간메모리
1112955adiyerLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
306 ms262144 KiB
#pragma optimize ("g",on) #pragma GCC optimize("inline") #pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #pragma GCC optimize ("03") #include <bits/stdc++.h> #define ios ios_base::sync_with_stdio(0); cin.tie(0); #define pb push_back using namespace std; typedef int ll; const int N = 1e5 + 2; const int M = (1 << 8); ll n, pos; ll a[N], k[N], dp[N]; void sol(){ cin >> n, pos = 1; for(ll i = 1; i <= n; i++) cin >> a[i]; for(ll i = 1; i <= n; i++) cin >> k[i]; for(ll i = 1; i <= n; i++){ dp[i] = 1; for(ll j = 1; j < i; j++) if((__builtin_popcount(a[j] & a[i]) == k[i])) dp[i] = max(dp[i], dp[j] + 1); if(dp[i] > dp[pos]) pos = i; // cout << dp[i] << '\n'; } vector < ll > ans; ans.pb(pos); while(pos > 1){ for(ll i = pos - 1; i >= 1; i--){ if(__builtin_popcount(a[pos] & a[i]) == k[pos] && dp[pos] == dp[i] + 1){ pos = i; break; } } ans.pb(pos); } reverse(ans.begin(), ans.end()); cout << ans.size() << '\n'; for(ll x : ans) cout << x << ' '; } signed main(){ ios sol(); // slow(); // stress(); }

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

subsequence.cpp:1: warning: ignoring '#pragma optimize ' [-Wunknown-pragmas]
    1 | #pragma optimize ("g",on)
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...