(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

Submission #541066

#TimeUsernameProblemLanguageResultExecution timeMemory
541066creepedLongest beautiful sequence (IZhO17_subsequence)C++14
7 / 100
8 ms340 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll n; ll a[20], k[20]; vector<ll> ans; ll popcount(ll x) { ll res = 0; while(x) { res += x&1; x >>= 1; } return res; } int main() { cin>>n; if(n > 15) { cout<<0; return 0; } 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<(1<<n); i++) { vector<ll> cur; for(ll j=0;j<n;j++) if(i&(1<<j)) cur.push_back(j+1); bool flag = 0; for(ll j=0;j<cur.size();j++) { for(ll h=j+1;h<cur.size();h++) if(popcount(a[cur[j]] & a[cur[h]]) != k[cur[h]]) { flag = 1; break; } if(flag) break; } if(flag) continue; //cout<<1<<endl; if(cur.size() > ans.size()) ans = cur; } cout<<ans.size()<<endl; for(auto it:ans) cout<<it<<" "; }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:42:21: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(ll j=0;j<cur.size();j++)
      |                    ~^~~~~~~~~~~
subsequence.cpp:44:27: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             for(ll h=j+1;h<cur.size();h++)
      |                          ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...