# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
443076 |
2021-07-09T15:31:29 Z |
Karliver |
Drvca (COCI19_drvca) |
C++14 |
|
78 ms |
11584 KB |
#include <bits/stdc++.h>
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(20) << (x)
#define all(v) (v).begin(), (v).end()
using namespace std;
#define forn(i,n) for (int i = 0; i < (n); ++i)
#define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
using ll = long long;
int mod = (ll)1e9 + 7;
#define PI acos(-1)
typedef pair<int, int> pairs;
const int INF = 1e9 + 1;
const int N = 2e5 + 100;
const double eps = 1e-7;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template <typename XPAX>
void ckma(XPAX &x, XPAX y) {
x = (x < y ? y : x);
}
template <typename XPAX>
void ckmi(XPAX &x, XPAX y) {
x = (x > y ? y : x);
}
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
void solve() {
int n;
cin >> n;
V<int>a (n);
forn(i, n) cin >> a[i];
sort(all(a));
map<int, int> mp;
for(auto t : a)
mp[t]++;
if(n < 4) {
cout << 1 << '\n' << a[0] << '\n';
cout << n - 1 << '\n';
for(int i = 1;i < n;++i)cout << a[i] << ' ' ;
exit(0);
}
auto ck = [&](int f, int s) {
V<int> one{f, s};
auto sp = mp;
int d = s - f;
sp[f]--;
sp[s]--;
s += d;
while(sp[s]) {
one.push_back(s);
sp[s]--;
s += d;
}
V<int> two;
for(auto c : sp) {
while(c.second--)
two.push_back(c.first);
}
if(one.size() == n) {
two.push_back(one.back());
one.pop_back();
}
bool ok = (two.size() > 0);
if(two.size() > 1) {
d = two[1] - two[0];
for(int i = 2;i < two.size();++i) {
if(two[i] - two[i - 1] != d)
ok = 0;
}
}
if(ok) {
cout << one.size() << '\n';
for(auto c : one)
cout << c << ' ';
cout << '\n';
cout << two.size() << '\n';
for(auto c : two)
cout << c << ' ';
exit(0);
}
};
for(int i = 0;i < 3;++i) {
for(int j = i + 1;j < 3;++j) {
ck(a[i], a[j]);
}
}
cout << -1 << '\n';
}
void test_case() {
int t;
cin >> t;
forn(p, t) {
//cout << "Case #" << p + 1 << ": ";
solve();
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
solve();
}
Compilation message
drvca.cpp: In lambda function:
drvca.cpp:98:18: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
98 | if(one.size() == n) {
| ~~~~~~~~~~~^~~~
drvca.cpp:107:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
107 | for(int i = 2;i < two.size();++i) {
| ~~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
63 ms |
11584 KB |
Output is correct |
2 |
Correct |
64 ms |
11580 KB |
Output is correct |
3 |
Correct |
63 ms |
11556 KB |
Output is correct |
4 |
Correct |
62 ms |
11584 KB |
Output is correct |
5 |
Correct |
64 ms |
11496 KB |
Output is correct |
6 |
Correct |
62 ms |
11584 KB |
Output is correct |
7 |
Correct |
65 ms |
11536 KB |
Output is correct |
8 |
Correct |
64 ms |
11516 KB |
Output is correct |
9 |
Incorrect |
78 ms |
10040 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
0 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
0 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |