# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
515274 | Mazaalai | Longest beautiful sequence (IZhO17_subsequence) | C++17 | 8 ms | 332 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int N = 1e5+1;
int n;
int nums[N], bits[N];
int bitCnt(int a) {
return bitset <20>(a).count();
}
signed main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
vector <int> ans;
for (int i = 0; i < n; i++) cin >> nums[i];
for (int i = 0; i < n; i++) cin >> bits[i];
for (int i = 0; i < (1<<n); i++) {
vector <int> cur;
for (int j = 0; j < n; j++)
if (i & (1<<j)) cur.pb(j);
bool pos = 1;
for (int j = 1; j < cur.size(); j++) {
pos &= bitCnt(nums[cur[j-1]]&nums[cur[j]]) == bits[cur[j]];
}
if (pos && cur.size() > ans.size()) ans = cur;
}
cout << ans.size() << "\n";
for (auto el : ans) cout << el+1 << ' '; cout << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |