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

#TimeUsernameProblemLanguageResultExecution timeMemory
665481AstraytLongest beautiful sequence (IZhO17_subsequence)C++17
100 / 100
2723 ms48232 KiB
//君の手を握ってしまったら //孤独を知らないこの街には //もう二度と帰ってくることはできないのでしょう //君が手を差し伸べた 光で影が生まれる //歌って聞かせて この話の続き //連れて行って見たことない星まで //さユリ - 花の塔 #include <bits/stdc++.h> using namespace std; typedef long long ll; //#define int ll #define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define pii pair<int,int> #define pb push_back #define ff first #define ss second #define mp make_pair #define maxn 200005 #define mod 1000000007 int tmp[(1<<10) + 1][(1<<10) + 1][11]; void solve(){ int n; cin >> n; vector<int> a(n + 1, 0), k(n + 1), cnt((1<<10) + 1, 0); vector<pii> dp(n + 1, mp(0, 0)); for(int i = 0; i <= (1<<10); ++i) { int x = i; while(x) cnt[i] += (x & 1), x >>= 1; } for(int i = 1; i <= n; ++i) cin >> a[i]; for(int i = 1; i <= n; ++i) cin >> k[i]; for(int i = 1; i <= n; ++i){ dp[i] = mp(1, i); for(int j = 0; j <= (1<<10); ++j){ int req = k[i] - cnt[j & (a[i] >> 10)]; if(req < 0 || req > 10) continue; int t = tmp[a[i] % 1024][j][req]; dp[i] = max(dp[i], mp(1 + dp[t].ff, t)); } for(int j = 0; j <= (1<<10); ++j){ int &p = tmp[j][(a[i] >> 10)][cnt[j & a[i]]]; if(p == 0) p = i; else if(dp[p].ff < dp[i].ff) p = i; } } int cur = (max_element(dp.begin(), dp.end()) - dp.begin()); cout << dp[cur].ff << '\n'; vector<int> ans; while(cur != dp[cur].ss){ ans.pb(cur); cur = dp[cur].ss; } ans.pb(cur); reverse(ans.begin(), ans.end()); for(int x:ans) cout << x << ' '; } signed main(){ starburst int t = 1; //cin >> t; while(t--) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...