# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580545 | myvaluska | Kpart (eJOI21_kpart) | C++14 | 2084 ms | 1072 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// arc172.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<int>v(n);
for (int i = 0; i < n; i++)
{
cin >> v[i];
}
vector<vector<int>>ka(n, vector<int>(n,-1));///index,dlzka
for (int i = 0; i < n; i++)
{
int sum = 0;
vector<int>dp(50029, -1);
dp[0] = 1;
vector<int>dasa;///ide sa robit skareda optimalizacia:)))
dasa.push_back(0);
for (int j = i; j < n; j++)
{
int d = j - i + 1;
sum += v[j];
int x = dasa.size() - 1;
for (int k=x;k>=0;k--)
{
if (dp[dasa[k]+v[j]]==-1&&dasa[k]+v[j]<=dp.size())
{
dp[dasa[k]+v[j]] = 1;
dasa.push_back(dasa[k]+v[j]);
}
}
/*for (int i2 = 0; i2 <20; i2++)
{
cout << dp[i2] << ' ';
}*/
///cout << endl;
if (sum % 2 == 0 && dp[sum / 2] == 1)
{
ka[i][d - 1] = 1;
///cout << "da sa " << i << ' ' << d - 1 << endl;
}
}
}
vector<int>vys;
for (int i = 1; i < n + 1; i++)
{
int flag = 0;
for (int j = 0; j < n; j++)
{
if (ka[j][i - 1] == -1&&n-j>=i)
{
flag = 1;
}
}
if (flag == 0)
{
vys.push_back(i);
}
}
cout << vys.size() << ' ';
for (int i = 0; i < vys.size(); i++)
{
cout << vys[i] << " ";
}
cout << "\n";
}
return 0;
///std::cout << "Hello World!\n";
}
// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu
// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Compilation message (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... |