(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.

제출 #36180

#제출 시각아이디문제언어결과실행 시간메모리
36180UncleGrandpa925Longest beautiful sequence (IZhO17_subsequence)C++14
100 / 100
4549 ms48776 KiB
/*input 4 1 2 3 4 10 0 1 0 5 5 3 5 3 5 10 1 20 1 20 */ #include <bits/stdc++.h> using namespace std; #define sp ' ' #define endl '\n' #define fi first #define se second #define mp make_pair #define N 100005 #define M 1024 #define bit(x,y) ((x>>y)&1LL) int n; int a[N], b[N], cnt[M]; int dp[N], par[N]; int g[M][M][11]; vector<int> order; signed main() { // #ifdef in1code // freopen("1test.inp", "r", stdin); // #endif scanf("%d", &n); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); for (int i = 1; i <= n; i++) scanf("%d", &b[i]); for (int i = 0; i < M; i++) cnt[i] = __builtin_popcount(i); memset(g, 0, sizeof(g)); pair<int, int> ans = mp(1, 1); for (int i = 1; i <= n; i ++) { dp[i] = 1; int prefix = a[i] >> 10; int suffix = a[i] - (prefix << 10); for (int mask = 0; mask < M; mask++) { int left = b[i] - cnt[mask & prefix]; if (left < 0 || left > 10) continue; int y = g[mask][suffix][left]; if (dp[y] + 1 > dp[i]) { dp[i] = dp[y] + 1; par[i] = y; } } if (dp[i] > ans.fi) ans = mp(dp[i], i); for (int mask = 0; mask < M; mask ++) { int x = mask & suffix; int &y = g[prefix][mask][cnt[x]]; if (dp[y] < dp[i]) y = i; } } while (ans.fi > 0) { order.push_back(ans.se); ans.se = par[ans.se]; ans.fi--; } reverse(order.begin(), order.end()); printf("%lu\n", order.size()); for (int i = 0; i < order.size(); i++) printf("%d ", order[i]); }

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

subsequence.cpp: In function 'int main()':
subsequence.cpp:62:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < order.size(); i++) printf("%d ", order[i]);
                    ^
subsequence.cpp:30:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &n);
                 ^
subsequence.cpp:31:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
                                                 ^
subsequence.cpp:32:49: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
                                                 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...