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

Submission #572669

#TimeUsernameProblemLanguageResultExecution timeMemory
572669YouAreMyGalaxyLongest beautiful sequence (IZhO17_subsequence)C++17
100 / 100
2414 ms52280 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" #define Log2(x) 31 - __builtin_clz(x) using namespace std; const int N = 1e5; int dp[1 << 10][1 << 10][11], f[N + 1], a[N + 1], b[N + 1], n, cbit[1 << 20]; void read() { cin >> n; for (int i = 1; i <= n; ++ i) { cin >> a[i]; } for (int i = 1; i <= n; ++ i) { cin >> b[i]; } } void Traceback(int i, int nxt) { if (i == 0) { return ; } if (f[i] + 1 == f[nxt] && cbit[a[i] & a[nxt]] == b[nxt]) { Traceback(i - 1, i); cout << i << ' '; } else { Traceback(i - 1, nxt); } } void solve() { for (int i = 1; i < (1 << 20); ++ i) { cbit[i] = __builtin_popcount(i); } for (int i = 1; i <= n; ++ i) { int pre = a[i] >> 10, suf = a[i] & ((1 << 10) - 1); f[i] = 1; for (int j = 0; j < (1 << 10); ++ j) { int k = cbit[pre & j]; if (k > b[i] || b[i] - k > 10) { continue; } f[i] = max(f[i], dp[j][suf][b[i] - k] + 1); } for (int j = 0; j < (1 << 10); ++ j) { int k = cbit[suf & j]; dp[pre][j][k] = max(dp[pre][j][k], f[i]); } } int root = max_element(f + 1, f + n + 1) - f; cout << f[root] << '\n'; Traceback(root - 1, root); cout << root; } 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); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case #" << __ << ":" << '\n'; read(); solve(); } }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:73:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |         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...