(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 #241837

#TimeUsernameProblemLanguageResultExecution timeMemory
241837ChrisTLongest beautiful sequence (IZhO17_subsequence)C++17
100 / 100
4681 ms93688 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; using pib = pair<int,bool>; using ll = long long; using ld = long double; #define all(x) (x).begin(),(x).end() #ifdef fread_unlocked #define fread fread_unlocked #define fwrite fwrite_unlocked #endif #define mp make_pair #define lc ind<<1 #define rc ind<<1|1 const int MN = 1e5+5, MOD = 1e9+7, BASE = 31, MASK = (1 << 10) - 1; pii idk[1 << 10][1 << 10][11]; int a[MN], k[MN], dp[MN], from[MN]; int main () { int n; scanf ("%d",&n); for (int i = 1; i <= n; i++) scanf ("%d",&a[i]); for (int i = 1; i <= n; i++) scanf ("%d",&k[i]); int ret = 0, wot = 0; for (int i = 1; i <= n; i++) { dp[i] = 1; from[i] = -1; for (int m1 = 0; m1 < (1 << 10); m1++) { int need = k[i] - __builtin_popcount((a[i]>>10)&m1); if (need < 0 || need > 10) continue; pii &go = idk[m1][a[i]&MASK][need]; if (go.first + 1 > dp[i]) { dp[i] = go.first + 1; from[i] = go.second; } } for (int m2 = 0; m2 < (1 << 10); m2++) { pii &go = idk[a[i]>>10][m2][__builtin_popcount(a[i]&m2)]; if (dp[i] > go.first) { go.first = dp[i]; go.second = i; } } if (dp[i] > ret) { ret = dp[i]; wot = i; } } vector<int> print; do { print.push_back(wot); } while (~(wot = from[wot])); reverse(all(print)); printf ("%d\n",ret); for (int i : print) printf ("%d ",i); printf ("\n"); return 0; }

Compilation message (stderr)

subsequence.cpp: In function 'int main()':
subsequence.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf ("%d",&n);
  ~~~~~~^~~~~~~~~
subsequence.cpp:21:37: 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:22:37: 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",&k[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...