# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1052491 | coolsentenceidontremember | Longest beautiful sequence (IZhO17_subsequence) | C++17 | 1735 ms | 97068 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-loops")
#define ll long long
#define ld long double
#define ff first
#define ss second
#define db double
#define time_begin() auto begin = chrono::high_resolution_clock::now()
#define time_end() auto end = chrono::high_resolution_clock::now(); auto elapsed = chrono::duration_cast<chrono::nanoseconds>(end-begin); auto sec = elapsed.count() * 1e-9; cerr << "\n\nExecution time: " << sec << " seconds";
#define check_time() cerr << "\nStatus : "; if (sec>1) cerr << "Time Limit Exceeded 1!!!1!111"; else cerr << "You good brother"
using namespace std;
void setIO(string s = ""){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
if (!s.empty()){
freopen((s+".in").c_str(), "r", stdin);
freopen((s+".out").c_str(), "w", stdout);
}
}
const int split = 10;
const int N = 1e5;
struct state{
int len;
int end;
} dp[1<<split][1<<split][split+1];
int bc[1<<split][1<<split];
int a[N], k[N], trace[N];
int main(){
for (int i = 0; i < (1<<split); i++) for (int j = 0; j < (1<<split); j++) bc[i][j] = __builtin_popcount(i&j);
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 0; i < n; i++) cin >> k[i];
iota(trace, trace+n, 0);
int ans = 1, best = 0;
for (int i = 0; i < n; i++){
int l = a[i]>>split, r = a[i]%(1<<split);
int lbs = 1;
for (int l_prev = 0; l_prev < (1<<split); l_prev++){
int bit = k[i] - bc[l_prev][l];
if (bit < 0 || bit > split) continue;
int comp = dp[l_prev][r][bit].len + 1;
if (comp > lbs){
lbs = comp;
trace[i] = dp[l_prev][r][bit].end;
}
}
if (lbs > ans){
ans = lbs;
best = i;
}
for (int spread = 0; spread < (1<<split); spread++){
state &s = dp[l][spread][bc[r][spread]];
if (lbs > s.len){
s.len = lbs;
s.end = i;
}
}
}
cout << ans << '\n';
vector<int> lbs;
while (trace[best]!=best){
lbs.push_back(best);
best = trace[best];
}
lbs.push_back(best);
reverse(lbs.begin(), lbs.end());
for (const int &i : lbs) cout << i+1 << ' ';
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |