(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 #541112

#TimeUsernameProblemLanguageResultExecution timeMemory
541112Bunny_manLongest beautiful sequence (IZhO17_subsequence)C++17
7 / 100
8 ms468 KiB
#include <bits/stdc++.h> #define ll long long int #define pb push_back #define ui unsigned int #define ld long double #define buster ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0); using namespace std; vector<ll> ans; ll a[101]; ll b[101]; ll bitcount(ll k) { ll cnt = 0; while(k) { cnt += k&1; k >>= 1; } return cnt; } int main() { buster; ll tt = 1; //cin >> tt; while(tt--) { ll n; cin >> n; for(ll i = 1; i <= n; i++) { cin >> a[ i ]; } for(ll i = 1; i <= n; i++) { cin >> b[ i ]; } for(ll mask = 1; mask < (1 << n); mask++) { vector <ll> cur; for(ll i = 0; i < n; i++) { if(mask & (1 << i)) { cur.pb(i + 1); } } bool flag = 0; for(ll i = 0; i < cur.size(); i++) { for(ll j = i + 1; j < cur.size(); j++) { if(bitcount(a[ cur[ i ] ] & a[ cur[ j ] ]) != b[ cur[ j ] ]) { flag = 1; break; } } if(flag) { break; } } if(flag) { continue; } if(cur.size() > ans.size()) { ans = cur; } } cout << ans.size() << "\n"; for(auto it : ans) { cout << it << ' '; } } }

Compilation message (stderr)

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