# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
831753 |
2023-08-20T13:19:46 Z |
Chal1shkan |
Drvca (COCI19_drvca) |
C++14 |
|
139 ms |
13376 KB |
# include <bits/stdc++.h>
# define mkp make_pair
# define ff first
# define ss second
# define pll pair <ll, ll>
# define pii pair <int, int>
# define vec vector
# define pb push_back
# define pf push_front
# define ppb pop_back
# define ppf pop_front
# define all(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
# define sz(x) ((int)(x).size())
# define lb lower_bound
# define ub upper_bound
# define br break
# define rt return
# define cn continue
# define nl "\n"
# define off exit(0)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll MAXN = 1e5 + 25;
const ll MAXL = 18 + 0;
const ll INF = 1e18 + 0;
const ll inf = 2e9 + 0;
const ll MOD = 1e9 + 7;
const ll mod = 998244353;
const ld PI = acos( (ld) -1 );
const ll P = 67 + 0 + 0;
int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
using namespace std;
void open (string fname = "")
{
if (fname.size())
{
freopen((fname + ".in").c_str(), "r", stdin);
freopen((fname + ".out").c_str(), "w", stdout);
}
}
void qataima ()
{
ios::sync_with_stdio(false);
cin.tie(0);
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
}
ll n, a[MAXN];
void solve (ll ps1, ll ps2)
{
ll d = a[ps2] - a[ps1];
multiset <ll> s;
multiset <ll> st;
for (ll i = 1; i <= n; ++i)
{
if (i != ps1 && i != ps2)
{
s.insert(a[i]);
}
}
if (sz(s) > 1)
{
auto lastt = s.end();
--lastt;
auto itt = s.begin();
while (itt != lastt)
{
itt++;
ll x = *itt;
itt--;
ll y = *itt;
st.insert(x - y);
itt++;
}
}
vec <ll> x = {a[ps1], a[ps2]}, y;
ll cnt = 2;
while (!s.empty())
{
if (*st.begin() == *st.rbegin())
{
br;
}
else
{
ll next = a[ps1] + d * cnt;
if (s.count(next))
{
auto it = s.find(next);
ll num1 = -1, num2 = -1;
if (it != s.begin())
{
it--;
num1 = *it;
st.erase(st.find(next - num1));
it++;
}
auto lastt = s.end();
--lastt;
if (it != lastt)
{
it++;
num2 = *it;
st.erase(st.find(num2 - next));
it--;
}
if (num1 != - 1 && num2 != -1)
{
st.insert(num2 - num1);
}
s.erase(it);
x.pb(next);
++cnt;
}
else
{
br;
}
}
}
for (ll num : s)
{
y.pb(num);
}
if (sz(x) == n)
{
cout << 1 << nl;
cout << x[0] << nl;
cout << sz(x) - 1 << nl;
for (ll i = 1; i < sz(x); ++i)
{
cout << x[i] << ' ';
}
cout << nl;
off;
}
if (sz(x) > 0 && sz(y) > 0)
{
if (sz(y) > 1)
{
for (ll i = 2; i < sz(y); ++i)
{
if (y[i] - y[i - 1] == y[1] - y[0])
{
cn;
}
rt;
}
}
cout << sz(x) << nl;
for (ll i = 0; i < sz(x); ++i)
{
cout << x[i] << ' ';
}
cout << nl;
cout << sz(y) << nl;
for (ll i = 0; i < sz(y); ++i)
{
cout << y[i] << ' ';
}
cout << nl;
off;
}
}
void ma1n ()
{
cin >> n;
for (ll i = 1; i <= n; ++i)
{
cin >> a[i];
}
sort(a + 1, a + n + 1);
solve(1, 2);
solve(2, 3);
solve(1, 3);
cout << -1 << nl;
}
int main (/* You Vs You */)
{
qataima ();
open ();
int zxc = 1;
// cin >> zxc;
while (zxc--)
{
ma1n ();
}
return 0;
}
Compilation message
drvca.cpp: In function 'void open(std::string)':
drvca.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
48 | freopen((fname + ".in").c_str(), "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drvca.cpp:49:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
49 | freopen((fname + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
13232 KB |
Output is correct |
2 |
Correct |
57 ms |
12440 KB |
Output is correct |
3 |
Correct |
73 ms |
12440 KB |
Output is correct |
4 |
Correct |
53 ms |
12364 KB |
Output is correct |
5 |
Correct |
69 ms |
13248 KB |
Output is correct |
6 |
Correct |
56 ms |
12436 KB |
Output is correct |
7 |
Correct |
69 ms |
13100 KB |
Output is correct |
8 |
Correct |
69 ms |
12448 KB |
Output is correct |
9 |
Correct |
56 ms |
11820 KB |
Output is correct |
10 |
Correct |
69 ms |
12364 KB |
Output is correct |
11 |
Correct |
43 ms |
13376 KB |
Output is correct |
12 |
Correct |
1 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
332 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
0 ms |
340 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
1 ms |
336 KB |
Output is correct |
16 |
Correct |
1 ms |
340 KB |
Output is correct |
17 |
Correct |
0 ms |
328 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
332 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
0 ms |
340 KB |
Output is correct |
27 |
Correct |
1 ms |
336 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
29 |
Correct |
1 ms |
340 KB |
Output is correct |
30 |
Correct |
0 ms |
212 KB |
Output is correct |
31 |
Correct |
75 ms |
13232 KB |
Output is correct |
32 |
Correct |
57 ms |
12440 KB |
Output is correct |
33 |
Correct |
73 ms |
12440 KB |
Output is correct |
34 |
Correct |
53 ms |
12364 KB |
Output is correct |
35 |
Correct |
69 ms |
13248 KB |
Output is correct |
36 |
Correct |
56 ms |
12436 KB |
Output is correct |
37 |
Correct |
69 ms |
13100 KB |
Output is correct |
38 |
Correct |
69 ms |
12448 KB |
Output is correct |
39 |
Correct |
56 ms |
11820 KB |
Output is correct |
40 |
Correct |
69 ms |
12364 KB |
Output is correct |
41 |
Correct |
43 ms |
13376 KB |
Output is correct |
42 |
Correct |
1 ms |
336 KB |
Output is correct |
43 |
Correct |
78 ms |
12380 KB |
Output is correct |
44 |
Correct |
139 ms |
12992 KB |
Output is correct |
45 |
Correct |
59 ms |
12352 KB |
Output is correct |
46 |
Correct |
54 ms |
12352 KB |
Output is correct |
47 |
Correct |
123 ms |
11468 KB |
Output is correct |
48 |
Correct |
50 ms |
12444 KB |
Output is correct |
49 |
Correct |
65 ms |
12392 KB |
Output is correct |
50 |
Correct |
103 ms |
13272 KB |
Output is correct |
51 |
Correct |
52 ms |
12444 KB |
Output is correct |
52 |
Correct |
57 ms |
12364 KB |
Output is correct |
53 |
Correct |
124 ms |
11360 KB |
Output is correct |
54 |
Correct |
57 ms |
12592 KB |
Output is correct |
55 |
Correct |
60 ms |
12452 KB |
Output is correct |
56 |
Correct |
65 ms |
12448 KB |
Output is correct |
57 |
Correct |
52 ms |
13288 KB |
Output is correct |
58 |
Correct |
0 ms |
212 KB |
Output is correct |