제출 #1014976

#제출 시각아이디문제언어결과실행 시간메모리
1014976ThunnusLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
0 ms348 KiB
#include<bits/stdc++.h> using namespace std; using i64 = long long; #define int i64 #define vi vector<int> #define vvi vector<vi> #define vb vector<bool> #define pii pair<int, int> #define fi first #define se second #define sz(x) (int)(x).size() void setIO(string s){ ios_base::sync_with_stdio(false); cin.tie(0); freopen((s+".in").c_str(), "r", stdin); freopen((s+".out").c_str(), "w", stdout); } signed main() { //setIO("sequence"); ios_base::sync_with_stdio(false); cin.tie(0); int n; pii best = {1, 0}; cin >> n; vi a(n), k(n); for(int &i : a) cin >> i; for(int &i : k) cin >> i; vi prev(n), dp(n, 1), ans; iota(prev.begin(), prev.end(), 0); for(int i = 1; i < n; i++){ for(int j = 0; j < n; j++){ if(__builtin_popcount(a[j] & a[i]) == k[i] && dp[j] + 1 > dp[i]){ dp[i] = dp[j] + 1; prev[i] = j; if(dp[i] > best.fi) best = {dp[i], i}; } } } while(prev[best.se] != best.se){ ans.emplace_back(best.se + 1); best.se = prev[best.se]; } ans.emplace_back(best.se + 1); reverse(ans.begin(), ans.end()); cout << best.fi << "\n"; for(int i : ans){ cout << i << " "; } return 0; }

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

subsequence.cpp: In function 'void setIO(std::string)':
subsequence.cpp:15:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp:16:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...