QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#183125 | #5475. Make a Loop | real_sigma_team | Compile Error | / | / | C++20 | 2.5kb | 2023-09-19 03:36:59 | 2023-09-19 03:37:00 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
const int N = 101;
const int R = 1e4 + 1;
int dp[N][N * R], r[N];
void solve() {
dp[0][0] = 1;
int n;
cin >> n;
if (n & 1) {
cout << "No\n";
return;
}
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> r[i];
sum += r[i];
}
if (sum & 1) {
cout << "No\n";
return;
}
int need = sum / 2;
sum = 0;
for (int i = 0; i < n; i++) {
int ri = r[i];
for (int j = i; j >= 0; j--) {
for (int l = 0; l <= sum && l + ri <= need; l++) {
dp[j + 1][l + ri] += dp[j][l];
dp[j + 1][l + ri] = min(dp[j + 1][l + ri], 2);
}
}
sum += ri;
}
bool ok = 0;
for (int i = 2; i < n; i += 2) {
if (dp[i][need] == 2) {
ok = true;
}
}
cout << (ok ? "Yes" : "No") << '\n';
}
int main() {
#ifndef LOCAL
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#else
freopen("input.txt", "r", stdin);
#endif
solve();
return 0;
}#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using ll = long long;
const int N = 101;
const int R = 1e4 + 1;
int dp[N][N * R], r[N];
void solve() {
dp[0][0] = 1;
int n;
cin >> n;
if (n & 1) {
cout << "No\n";
return;
}
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> r[i];
sum += r[i];
}
if (sum & 1) {
cout << "No\n";
return;
}
int need = sum / 2;
sum = 0;
for (int i = 0; i < n; i++) {
int ri = r[i];
for (int j = i; j >= 0; j--) {
for (int l = 0; l <= sum && l + ri <= need; l++) {
dp[j + 1][l + ri] += dp[j][l];
dp[j + 1][l + ri] = min(dp[j + 1][l + ri], 2);
}
}
sum += ri;
}
bool ok = 0;
for (int i = 2; i < n; i += 2) {
if (dp[i][need] == 2) {
ok = true;
}
}
cout << (ok ? "Yes" : "No") << '\n';
}
int main() {
#ifndef LOCAL
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#else
freopen("input.txt", "r", stdin);
#endif
solve();
return 0;
}
詳細信息
answer.code:70:2: error: stray ‘#’ in program 70 | }#include<bits/stdc++.h> | ^ answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:11: error: ‘bits’ was not declared in this scope 70 | }#include<bits/stdc++.h> | ^~~~ answer.code:70:16: error: ‘stdc’ was not declared in this scope; did you mean ‘std’? 70 | }#include<bits/stdc++.h> | ^~~~ | std answer.code:70:3: error: ‘include’ does not name a type 70 | }#include<bits/stdc++.h> | ^~~~~~~ answer.code:79:11: error: redefinition of ‘const int N’ 79 | const int N = 101; | ^ answer.code:10:11: note: ‘const int N’ previously defined here 10 | const int N = 101; | ^ answer.code:80:11: error: redefinition of ‘const int R’ 80 | const int R = 1e4 + 1; | ^ answer.code:11:11: note: ‘const int R’ previously defined here 11 | const int R = 1e4 + 1; | ^ answer.code:82:5: error: redefinition of ‘int dp [101][1010101]’ 82 | int dp[N][N * R], r[N]; | ^~ answer.code:13:5: note: ‘int dp [101][1010101]’ previously declared here 13 | int dp[N][N * R], r[N]; | ^~ answer.code:82:19: error: redefinition of ‘int r [101]’ 82 | int dp[N][N * R], r[N]; | ^ answer.code:13:19: note: ‘int r [101]’ previously declared here 13 | int dp[N][N * R], r[N]; | ^ answer.code:84:6: error: redefinition of ‘void solve()’ 84 | void solve() { | ^~~~~ answer.code:15:6: note: ‘void solve()’ previously defined here 15 | void solve() { | ^~~~~ answer.code:130:5: error: redefinition of ‘int main()’ 130 | int main() { | ^~~~ answer.code:61:5: note: ‘int main()’ previously defined here 61 | int main() { | ^~~~