Submission #1089247

#TimeUsernameProblemLanguageResultExecution timeMemory
1089247vjudge1Kpart (eJOI21_kpart)C++17
30 / 100
2066 ms1228 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define ll long long #define F first #define S second #define ull unsigned long long #define db double #define ldb long double #define pb push_back #define pf push_front #define ppb pop_back #define ppf pop_front #define yes cout<<"YES\n" #define no cout<<"NO\n" #define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> #define all(x) x.begin(), x.end() const int mod = 1e9 + 7; const int N = 1000001; using namespace std; using namespace __gnu_pbds; ll n, m, k, p[N], f[N], a, b, dp[N], ans[N], cnt[N]; vector <ll> v, q; signed main (){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll tt; cin >> tt; while (tt--){ cin >> n; for (int i = 1; i <= n; i++){ cin >> p[i]; ans[i] = 1; } ans[1] = 0; for (int i = 1; i <= n; i++){ dp[0] = 1; a = 0; cnt[0] = 1; cnt[p[i]] = 1; q.clear(); q.pb(p[i]); q.pb(0); dp[p[i]] = 1; a += p[i]; for (int y = i + 1; y <= n; y++){ a += p[y]; v.clear(); for (int j = 0; j < q.size(); j++){ if (cnt[q[j] + p[y]] == 0)v.pb (q[j] + p[y]), cnt[q[j] + p[y]] = 1; dp[q[j] + p[y]] = 1; } for (auto j: v){ q.pb(j); } if (a % 2 == 1 || dp[a / 2] == 0){ ans[y - i + 1] = 0; } } for (auto y: q){ dp[y] = 0; cnt[y] = 0; } } v.clear(); for (int i = 1; i <= n; i++){ if (ans[i]){ v.pb (i); } } cout << v.size() << ' '; for (auto i: v){ cout << i << ' '; } cout << '\n'; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:54:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |     for (int j = 0; j < q.size(); j++){
      |                     ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...