이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define it int
#define ld long double
#define endl '\n'
#define TIME 1.0*clock()/CLOCKS_PER_SEC
using namespace std;
mt19937 gen(chrono::system_clock::now().time_since_epoch().count());
const int M = 1e9 + 7;
const int N = 1e5 + 7;
it n, x[N], k[N], kol[(1<<10)], dp[(1<<10)][(1<<10)][11], pr[(1<<10)][(1<<10)][11], ans = 0, pos = 0;
main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
#ifdef LOCAL
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
vector<it> p(N, 0), res(N, 1);
cin >> n;
for (it i = 1; i <= n; i++)
cin >> x[i];
for (it i = 1; i <= n; i++)
cin >> k[i];
for (size_t i = 1; i <= n; i++){
it a = (x[i]>>10);
it b = x[i] - (a<<10);
for (size_t j = 0; j < 1024; j++){
it need = k[i] - __builtin_popcount(b&j);
if (need >= 0 && need <= 10 && dp[a][j][need] + 1 > res[i])
res[i] = dp[a][j][need] + 1, p[i] = pr[a][j][need];
}
for (size_t j = 0; j < 1024; j++){
it cur = __builtin_popcount(a&j);
if (dp[j][b][cur] < res[i])
dp[j][b][cur] = res[i], pr[j][b][cur] = i;
}
if (res[i] > ans)
ans = res[i], pos = i;
}
vector<it> path;
while (pos){
path.pb(pos);
pos = p[pos];
}
reverse(path.begin(), path.end());
cout << path.size() << endl;
for (auto itt : path) cout << itt << ' ';
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
subsequence.cpp:21:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main() {
^
subsequence.cpp: In function 'int main()':
subsequence.cpp:35:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (size_t i = 1; i <= n; i++){
~~^~~~
# | 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... |