Submission #1107393

# Submission time Handle Problem Language Result Execution time Memory
1107393 2024-11-01T07:35:15 Z vjudge1 Kpart (eJOI21_kpart) C++17
0 / 100
2000 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define nn "\n";
#define pb push_back
#define all(v) (v).begin() , (v).end()
const int N = 2e4+ 4;
int n , T , q , m ;
signed main(){
    ios_base::sync_with_stdio(0) , cin.tie(0);
    cin>> T;
    while(T--){
        cin>> n ;
        int a[n+1];
        set<int>st;
        for(int i=1 ; i <= n; i++){
            cin>> a[i];
        }
        map<int , int >us;
        for(int i =1 ; i < n ; i++){
            for(int j = i+1 ; j <= n;  j++){
                      vector<int>v;
                for(int u = i ; u <= j ; u++){
                    v.pb(a[u]);
                }
                for(int mi =0 ; mi < ( 1 << v.size()) -1 ; mi++){
                        int f =0 , s =0 ;
                    for(int mj =0 ; mj < v.size(); mj++){
                        if((mi >> mj )&1)f+=v[mj];
                        else s+=v[mj];
                    }
                    if(f == s ){
                        us[v.size()]++;
                        break;
                    }
                }
            }
        }
        vector<int>way;
        for(int i =1 ;i <= n ; i++){
            if(us[i]== n - i + 1 ){
                way.pb(i);
            }
        }
        cout << way.size()<< ' ';
        for(auto it:way)cout <<it << ' ';
        cout << nn
    }
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:28:40: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |                     for(int mj =0 ; mj < v.size(); mj++){
      |                                     ~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 2061 ms 336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2047 ms 336 KB Time limit exceeded
2 Halted 0 ms 0 KB -