제출 #1006787

#제출 시각아이디문제언어결과실행 시간메모리
1006787mohyayLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
1 ms2644 KiB
// // main1.cpp // problem1 // // Created by Mohammad Bashkail on 20/10/1445 AH. // #include <bits/stdc++.h> using namespace std; #define endl '\n' using ll = long long; #define pb push_back #define pF first #define pS second #define SP <<" "<< vector<bitset<10>> a; ll a1[112345], k[112345], dp[112345], par[112345]; map<ll,pair<ll,ll>> m; int main() { ios::sync_with_stdio(0);cout.tie(0); cin.tie(0); ll n; cin>>n; for (int i=0; i<n; i++) { ll x; cin>>x; bitset<10> b(x); a.pb(b); a1[i] = x; } for (int i=0; i<n; i++) cin>>k[i]; fill(dp, dp+n, 1); fill(par, par+n, -1); for (int i=0; i<n; i++) { for (int j=0; j<128; j++) { bitset<10> b1(j); bitset<10> b(a[i] & b1); if (b.count() == k[i]) { if (m.find(j) == m.end()) continue; if (m[j].pF+1 > dp[i]) { par[i] = m[j].pS; dp[i] = m[j].pF+1; } } } m[a1[i]] = {dp[i], i}; } //for (int i=0; i<n; i++) cout << dp[i] << ' '; //cout << endl; pair<ll,ll> mx = {-1, 0}; for (int i=0; i<n; i++) { if (dp[i] > mx.pF) { mx = {dp[i], i}; } } cout << mx.pF << endl; ll i = mx.pS; vector<ll> ans; while(i != -1) { ans.pb(i); i = par[i]; } reverse(ans.begin(), ans.end()); for (ll i : ans) cout << i+1 << " "; }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:40:27: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   40 |             if (b.count() == k[i]) {
      |                 ~~~~~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...