답안 #580530

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580530 2022-06-21T11:54:35 Z myvaluska Kpart (eJOI21_kpart) C++14
10 / 100
2000 ms 752 KB
// 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>
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    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;
            for (int j = i; j < n; j++)
            {
                int d = j - i + 1;
                sum += v[j];
                for (int k = dp.size() - 1; k >= 0; k--)
                {
                    if (k - v[j] >= 0 && dp[k - v[j]] == 1)
                    {
                        dp[k] = 1;
                    }
                }
                /*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

Main.cpp: In function 'int main()':
Main.cpp:76:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |         for (int i = 0; i < vys.size(); i++)
      |                         ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 184 ms 524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1355 ms 528 KB Output is correct
2 Execution timed out 2079 ms 552 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2054 ms 752 KB Time limit exceeded
2 Halted 0 ms 0 KB -