# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
566243 | Rifal | Bootfall (IZhO17_bootfall) | C++14 | 1090 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <fstream>
#define endl '\n'
#define mod 32768
#define INF 100000000000000
//#define ll long long
//#define cin fin
//#define cout fout
using namespace std;
//ofstream fout("convention.out");
//ifstream fin("convention.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n;
cin >> n;
int arr[n];
int cnt[5000] = {};
set<int> sul;
bool check = false;
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
for(int j = 1; j < (1<<(n)); j++)
{
long long sum1 = 0, sum2 = 0;
for(int q = 0; q < n; q++)
{
if((j&(1<<q)) > 0)
{
sum1 += arr[q];
}
else
{
sum2 += arr[q];
}
}
if(sum1 == sum2)
{
check = true;
}
}
if(!check)
{
cout << 0 << endl;
return 0;
}
for(int i = 0; i < n; i++)
{
vector<int> v, ans;
bool ccc[5000] = {};
for(int j = 0; j < n; j++)
{
if(j == i)
{
continue;
}
v.push_back(arr[j]);
}
for(int j = 1; j < (1<<(n-1)); j++)
{
long long sum1 = 0, sum2 = 0;
for(int q = 0; q < n-1; q++)
{
if((j&(1<<q)) > 0)
{
sum1 += v[q];
}
else
{
sum2 += v[q];
}
}
if(ccc[abs(sum1-sum2)] == 0 && abs(sum1-sum2) != 0)
{
ccc[abs(sum1-sum2)] = 1;
ans.push_back(abs(sum1-sum2));
}
}
for(int j = 0; j < ans.size(); j++)
{
cnt[ans[j]]++;
if(cnt[ans[j]] >= n)
sul.insert(ans[j]);
}
}
cout << sul.size() << endl;
for(auto i : sul)
{
cout << i << ' ';
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |