제출 #700966

#제출 시각아이디문제언어결과실행 시간메모리
700966messiuuuuuLongest beautiful sequence (IZhO17_subsequence)C++14
0 / 100
27 ms41368 KiB
/// #include<bits/stdc++.h> #define task "C" #define ll long long #define ld long double #define fi first #define se second #define pb push_back using namespace std; const int MAXN = 1e5 + 5; const ll INF = 1e18 + 5; int n; int a[MAXN], k[MAXN]; void Input() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) cin >> k[i]; } int f[1 << 10][1 << 10][11], dp[MAXN], trace[MAXN]; void Solve() { for (int i = 1; i <= n; i++) { int prei = a[i] & 1023; int sufi = a[i] >> 10; for (int suf = 0; suf < (1 << 10); suf++) { if (dp[f[prei][suf][k[i] - __builtin_popcount(suf & sufi)]] + 1 > dp[i]) { dp[i] = dp[f[prei][suf][k[i] - __builtin_popcount(suf & sufi)]] + 1; trace[i] = f[prei][suf][k[i] - __builtin_popcount(suf & sufi)]; } } for (int pre = 0; pre < (1 << 10); pre++) { if (dp[f[pre][sufi][__builtin_popcount(pre & prei)]] < dp[i]) { f[pre][sufi][__builtin_popcount(pre & prei)] = i; } } } int p = max_element(dp + 1, dp + n + 1) - dp; cout << dp[p] << '\n'; vector<int> res; while (p) { res.pb(p); p = trace[p]; } reverse(res.begin(), res.end()); for (int x : res) cout << x << ' '; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(task".INP","r")) { freopen(task".INP","r",stdin); //freopen(task".OUT","w",stdout); } Input(); Solve(); }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:69:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         freopen(task".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...