# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1107383 |
2024-11-01T07:28:31 Z |
vjudge1 |
Kpart (eJOI21_kpart) |
C++17 |
|
9 ms |
352 KB |
#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast, unroll-loops")
// #pragma GCC target("avx2,fma")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse4a,abm,mmx,avx,popcnt,tune=native")
// #pragma GCC optimize("inline")
// #pragma GCC optimize("-fgcse,-fgcse-lm")
// #pragma GCC optimize("-ftree-pre,-ftree-vrp")
// #pragma GCC optimize("-ffast-math")
// #pragma GCC optimize("-fipa-sra")
// #pragma GCC optimize("-fpeephole2")
// #pragma GCC optimize("-fsched-spec")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,popcnt,tune=native")
// #pragma GCC optimize("unroll-loops")
#define int long long
using ll = int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vb = vector<bool>;
using vpii = vector<pii>;
using vs = vector<string>;
#define cupsize \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr); \
cout.tie(nullptr);
#define pb push_back
#define st first
#define nd second
#define all(x) x.begin() + 1, x.end()
#define sz(x) (ll) x.size()
#define watch(x) (cout << #x << " == " << x << '\n')
const int maxn = 2e5 + 7;
const int maxn2 = 1e5 + 7;
const int mod = 1e9 + 7;
const int mod2 = (119 << 23) + 1; // 998244353
const int inf = 1e18;
const int iinf = 1e9;
const double eps = 1e-7;
const int block = 350;
void mtests(auto x)
{
int tests;
cin >> tests;
while (tests--)
{
x();
}
}
template <typename T>
void readv(vector<T> &v, int from = 0)
{
for (size_t i = from; i < v.size(); ++i)
{
cin >> v[i];
}
}
template <typename T>
void printv(vector<T> &v, int from = 0)
{
for (size_t i = from; i < v.size(); ++i)
{
cout << v[i] << ' ';
}
}
void precalc()
{
}
// int n, m;
// int a[maxn2];
// int b[maxn2];
// void solve()
// {
// cin >> n >> m;
// for (int i = 1; i <= n; ++i)
// {
// cin >> a[i];
// }
// for (int i = 1; i <= m; ++i)
// {
// cin >> b[i];
// }
// if (n == 1)
// {
// for (int mask = 0; mask < (1 << m); ++mask)
// {
// int sum = 0;
// for (int i = 0; i < m; ++i)
// {
// if ((1 << i) & mask)
// {
// sum += b[i + 1];
// }
// }
// if (sum == a[1])
// {
// cout << "YES";
// return;
// }
// }
// cout << "NO";
// }
// }
// void solve()
// {
// int n;
// cin >> n;
// string s;
// cin >> s;
// bool mark = true;
// int cntG = 0;
// int cntR = 0;
// for (int i = 0; i < n; ++i)
// {
// if (mark && s[i] == 'Y')
// {
// mark = false;
// }
// if (s[i] == 'R')
// {
// cntR++;
// }
// else
// {
// cntG++;
// }
// }
// if (mark)
// {
// if (cntG != cntR - 1 && cntR != cntG - 1)
// {
// cout << "-1";
// return;
// }
// }
// }
bool eq(vector<int> a, int k)
{
for (int i = 1; i + k <= a.size() - 1; ++i)
{
int sum = 0;
vector<int> qqq;
for (int j = i; j <= i + k - 1; ++j)
{
sum += a[j];
qqq.pb(a[j]);
}
if (sum % 2 == 1)
{
return false;
}
sort(qqq.begin(), qqq.end());
int qweqw = sum / 2;
if (qqq[qqq.size() - 1] > qweqw)
{
return false;
}
else
{
return true;
}
}
return false;
}
void solveq()
{
int n;
cin >> n;
vector<int> a(n + 1);
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
vector<int> answers;
for (int k = 1; k <= n; ++k)
{
if (eq(a, k))
{
answers.pb(k);
}
}
cout << answers.size() << ' ';
printv(answers, 0);
cout << '\n';
}
int32_t main()
{
cupsize;
precalc();
mtests(solveq);
// solve();
}
Compilation message
Main.cpp:49:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
49 | void mtests(auto x)
| ^~~~
Main.cpp: In function 'bool eq(std::vector<long long int>, long long int)':
Main.cpp:156:27: 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]
156 | for (int i = 1; i + k <= a.size() - 1; ++i)
| ~~~~~~^~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |