Submission #910260

# Submission time Handle Problem Language Result Execution time Memory
910260 2024-01-18T03:17:48 Z vjudge1 Bootfall (IZhO17_bootfall) C++17
0 / 100
1000 ms 420 KB
/*
   (( '-""``""-' ))
     )-__-_.._-__-(
   / --- (o _ o) --- \
   \ .-* ( .0. ) *-. /
   _'-. ,_ '=' _, .-'_
  / ;#'#'# - #'#'#; \
 \_)) -----'#'----- ((_/
      # --------- #
      '# ------- #'
  /..-'# ------- #'-.\
  _\...-\'# -- #'/-.../_
  ((____)- '#' -(____))
    art by - Vinni01 / luchi abi
 
    cout << fixed << setprecision(6) << x;
    freopen ( "sum.in", "r", stdin )
*/
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <unordered_map>
using namespace std ;
#define ll long long
#define dd double
#define ff first
#define ss second
#define pb push_back 
#define pf push_front
#define UseOFF ios_base::sync_with_stdio(0);cin.tie(0), cout.tie(0);
#define sz size
#define ins insert
#define new jweijofdg
const ll N = 2e6 + 11 ;
ll tt = 1 ;
map < ll, ll > cnt ;
ll mx = 0 ;
map < ll, ll > mp ;
ll a[ N ] ;
vector < pair < ll, ll > > v1, v3 ;
vector < ll > v2 ;
set < ll > st ;
void solve()
{
	ll n ;
	cin >> n ;
	ll pos = 0 ;
	ll sum = 0 ;
	for( int i = 0 ; i < n ; i++ )
	{
		cin >> a[ i ] ;
		sum += a[ i ] ;
	}
	set < ll > st ;
	bool b = 0 ;
	for( int k = 1 ; k <= sum ; k++ )
	{
		ll cnt = 0 ;
		for( int l = -1 ; l < n ; l++ )
		{
			ll prev ;
			if( l >= 0 ) prev = a[ l ] ;
			if( l >= 0 ) a[ l ] = 0 ;
			for( int i = 1 ; i < ( 1 << n ) ; i++ )
			{
				ll sum1 = 0, sum2 = 0 ;
				for( int j = 0 ; j < n ; j++ )
				{
					if( ( i >> j ) & 1 )
					{
						sum1 += a[ j ] ;
					}
					else sum2 += a[ j ] ;
				}
				ll d = abs( sum1 - sum2 ) ;
				if( l == -1 )
				{
					if( d == 0 )
					{
						b = 1 ;
					}
				}
				if( k == d )
				{
					//cout << k << " || " << sum1 << " " << sum2 << " " << cnt + 1 << " || " << l << '\n' ;
					cnt++ ;
					break ;
				}
			}
			if( l >= 0 ) a[ l ] = prev ;
		}
		if( cnt == n )
		{
			st.ins( k ) ;
		}
	}
	if( b == 0 ) st.clear() ;
	cout << st.sz() << '\n' ;
	for( auto to : st )
	{
		cout << to << " " ;
	}
}
signed main()
{
	while( tt-- )
	{
		solve() ;
	}
}

Compilation message

bootfall.cpp: In function 'void solve()':
bootfall.cpp:69:5: warning: unused variable 'pos' [-Wunused-variable]
   69 |  ll pos = 0 ;
      |     ^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1049 ms 420 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1049 ms 420 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1049 ms 420 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1049 ms 420 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1049 ms 420 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Execution timed out 1049 ms 420 KB Time limit exceeded
6 Halted 0 ms 0 KB -