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

#TimeUsernameProblemLanguageResultExecution timeMemory
692254HuyLongest beautiful sequence (IZhO17_subsequence)C++17
0 / 100
1 ms212 KiB
#include<bits/stdc++.h> //#define int long long #define pii pair<int,int> #define fi first #define se second #pragma GCC tarGet ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #pragma GCC optimize("Ofast") #pragma GCC tarGet("avx,avx2,fma") using namespace std; using ll = long long; const int mod = 1e9+7; const int maxN = 1e5+5; const int N = 3e5; const ll infty = 1e16; void InputFile() { freopen("ATHM.inp","r",stdin); freopen("ATHM.out","w",stdout); //freopen("test.out","r",stdin); } int n; int a[maxN]; int k[maxN]; int cbit[1001]; int dp[maxN]; void Read() { cin >> n; for(int i = 1;i <= n;i++) cin >> a[i]; for(int i = 1;i <= n;i++) cin >> k[i]; } void Sub1() { for(int i = 1;i <= n;i++) { dp[i] = 1; for(int j = 1;j < i;j++) { int x = (a[j] & a[i]); if(__builtin_popcount(x) == k[i]) { dp[i] = max(dp[i],dp[j] + 1); } } } cout << *max_element(dp + 1,dp + n + 1); } void Sub3() { for(int i = 0;i <= 1000;i++) cbit[i] = __builtin_popcount(i); for(int i = 1;i <= n;i++) { //dp[a[i]] = max(dp[a[i]],1); for(int j = 0;j <= 1000;j++) { if(cbit[a[i]&j] == k[i]) { dp[a[i]] = max(dp[a[i]],dp[j] + 1); } } dp[a[i]] = max(dp[a[i]],1); } cout << *max_element(dp,dp + 1000 + 1); } void Solve() { if(n <= 5000) Sub1(); else Sub3(); //Sub3(); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); //InputFile(); //int sub_type; //cin >> sub_type; //Sieve(); //Prepare(); int test; //cin >> test; test = 1; while(test--) //for(int prc = 1; prc <= test; prc++) { Read(); Solve(); //Debug(); } }

Compilation message (stderr)

subsequence.cpp:6: warning: ignoring '#pragma GCC tarGet' [-Wunknown-pragmas]
    6 | #pragma GCC tarGet ("avx2")
      | 
subsequence.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    7 | #pragma GCC optimization ("O3")
      | 
subsequence.cpp:8: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    8 | #pragma GCC optimization ("unroll-loops")
      | 
subsequence.cpp:10: warning: ignoring '#pragma GCC tarGet' [-Wunknown-pragmas]
   10 | #pragma GCC tarGet("avx,avx2,fma")
      | 
subsequence.cpp: In function 'void InputFile()':
subsequence.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen("ATHM.inp","r",stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
subsequence.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen("ATHM.out","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...