제출 #515274

#제출 시각아이디문제언어결과실행 시간메모리
515274MazaalaiLongest beautiful sequence (IZhO17_subsequence)C++17
7 / 100
8 ms332 KiB
#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) 메시지

subsequence.cpp: In function 'int main()':
subsequence.cpp:28:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   for (int j = 1; j < cur.size(); j++) {
      |                   ~~^~~~~~~~~~~~
subsequence.cpp:34:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   34 |  for (auto el : ans) cout << el+1 << ' '; cout << '\n';
      |  ^~~
subsequence.cpp:34:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   34 |  for (auto el : ans) cout << el+1 << ' '; cout << '\n';
      |                                           ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...