Submission #839655

#TimeUsernameProblemLanguageResultExecution timeMemory
839655alishejhfKpart (eJOI21_kpart)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #define ent '\n' #define fi first #define se second #define sz(x) (int)x.size() #define pb push_back #define all(x) x.begin(),x.end() using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int N = 1e3 + 10; const int mod = 1e9 + 7; const int inf = (int)(1e9 + 7); const ll INF = (ll)(2e18 + 7); const ld eps = (ld)(1e-12); const int dx[] = { -1,0,1,0,1,1,-1,-1 }, dy[] = { 0,1,0,-1,1,-1,1,-1 }; mt19937 mrand(random_device{}()); int rnd(int x) { return mrand() % x; } int n,a[N],cnt[N]; bitset<50001> dp; void solve(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; cnt[i]=0; } for(int i=1;i<=n;i++){ ll sum=0; dp.reset(); dp[0]=1; for(int j=i;j<=n;j++){ sum+=a[j]; dp|=(dp<<a[j]); if(sum&1) continue; if((sum>>1)>5e4){ break; } if(dp[sum>>1]){ ++cnt[j-i+1]; } } } for(int i=1;i<=n;i++){ if(cnt[i]==n-i+1){ ans.pb(i); } } cout<<sz(ans)<<' '; for(auto it:ans){ cout<<it<<' '; } cout<<ent; return; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); srand(time(0)); //freopen(".in", "r", stdin); //freopen(".out","w",stdout); int ttt=1; cin>>ttt; for(int i=1;i<=ttt;i++){ //cout<<"NEWCASE"<<ent; solve(); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:50:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |             ans.pb(i);
      |             ^~~
      |             abs
Main.cpp:53:14: error: 'ans' was not declared in this scope; did you mean 'abs'?
   53 |     cout<<sz(ans)<<' ';
      |              ^~~
Main.cpp:6:20: note: in definition of macro 'sz'
    6 | #define sz(x) (int)x.size()
      |                    ^