이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
#define bit(x,y) ((x >> y) & 1)
const ll mod = 1000000007;
const ll N = 1e5 + 5;
const ll inf = LLONG_MAX/4;
ll a[N],k[N];
ll n;
ll maxv[12][(1 << 10) + 5][(1 << 10) + 5];
ll d[N],v[N];
vector<ll> siu[11][(1 << 10) + 5];
ll cnt[N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cin >> n;
ll i,j;
for(i = 0;i < (1 << 10);i++)
{
for(j = 0;j < 10;j++)
{
cnt[i] += bit(i,j);
}
}
for(i = 0;i < (1 << 10);i++)
{
for(j = 0;j < (1 << 10);j++)
{
siu[cnt[i & j]][i].push_back(j);
}
}
for(i = 1;i <= n;i++) cin >> a[i];
for(i = 1;i <= n;i++) cin >> k[i];
for(i = 1;i <= n;i++)
{
ll x = a[i];
ll px = x & ((1 << 10) - 1);
ll sx = x >> 10;
ll cm = 0;
for(j = 0;j <= 10;j++)
{
for(auto y : siu[k[i] - j][sx])
{
if(cm < d[maxv[j][px][y]])
{
cm = d[maxv[j][px][y]];
v[i] = maxv[j][px][y];
}
}
}
cm++;
for(j = 0;j < (1 << 10);j++)
{
ll c = cnt[px & j];
if(d[maxv[c][j][sx]] < cm)
{
maxv[c][j][sx] = i;
}
}
d[i] = cm;
}
ll mp,ans = 0;
for(i = 1;i <= n;i++)
{
if(ans < d[i])
{
mp = i;
ans = d[i];
}
}
cout << ans << "\n";
vector<ll> tmp;
while(ans--)
{
tmp.push_back(mp);
mp = v[mp];
}
reverse(tmp.begin(),tmp.end());
for(auto hahasus : tmp) cout << hahasus << " ";
}
# | 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... |