# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1097891 |
2024-10-08T14:25:07 Z |
khongphaifu |
Drvca (COCI19_drvca) |
C++14 |
|
1000 ms |
5584 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pb push_back
#define ll long long
#define el "\n"
#define alla(a,n) a+1,a+n+1
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define fu(i,a,b) for(ll i=a;i<=b;i++)
#define fud(i,a,b) for(ll i=a;i>=b;i--)
const ll MOD=1e9+7 ;//1234567891;
const ll inf=1e18;
const ll base = 311;
const ll N=1e6+5;
const ll N1=1e3+5;
template <class T> bool mini(T &x, T y){return (x > y ? x = y, 1 : 0);}
template <class T> bool maxi(T &x, T y){return (x < y ? x = y, 1 : 0);}
template <class T> void add(T &x, ll y){x += y; if(x >= MOD) x -= MOD;}
template <class T> void sub(T &x, T y){x -= y; if(x < 0) x += MOD;}
/*v*/
int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1},
dy[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll n;
ll h[N];
signed main(void)
{
#define TASK "test"
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);srand(time(0));
if(fopen(TASK".inp","r"))
{
freopen(TASK".inp" ,"r",stdin) ; freopen(TASK".out" ,"w",stdout);
}
cin>>n;
fu(i,1,n) cin>>h[i];
sort(alla(h,n));
// fu(i,1,n)
// {
// vector<ll> b;
// ll d1=-1;
// ll check=0;
// fu(j,1,n)
// {
// if(i==j) continue;
// b.pb(h[j]);
// if(b.size()==2) d1=b[1]-b[0];
// else if(b.size()>2)
// {
// if(b[b.size()-1]-b[b.size()-2]!=d1)
// {
// check=1;
// break;
// }
// }
// }
// if(check) continue;
// cout<<1<<el<<h[i]<<el;
// cout<<b.size()<<el;
// for(auto it:b) cout<<it<<" ";
// return 0;
// }
fu(i,2,n)
{
// chon 1
ll d=h[i]-h[1],ptd=h[i];
vector<ll> a,b;
a.pb(h[1]);a.pb(h[i]);
ll ok=1;
ll d1=-1;
ll check=0;
// b.pb(h[2]);
fu(j,2,i-1)
{
b.pb(h[j]);
if(b.size()==2) d1=b[1]-b[0];
else if(b.size()>2)
{
if(b[b.size()-1]-b[b.size()-2]!=d1)
{
ok=0;break;
}
}
}
if(!ok)
{
cout<<-1;return 0;
}
fu(j,i+1,n)
{
if(h[j]-ptd==d) a.pb(h[j]),ptd=h[j];
else
{
b.pb(h[j]);
if(b.size()==2) d1=b[1]-b[0];
else if(b.size()>2)
{
if(b[b.size()-1]-b[b.size()-2]!=d1)
{
check=1;break;
}
}
}
}
if(check) continue;
if(b.size()==0)
{
cout<<a.size()-1<<el;
fu(luatbeo,0,a.size()-2) cout<<a[luatbeo]<<" ";
cout<<el;
cout<<1<<el;
cout<<a[a.size()-1]<<" ";
return 0;
}
cout<<a.size()<<el;
for(auto it:a) cout<<it<<" ";
cout<<el<<b.size()<<el;
for(auto it:b) cout<<it<<" ";
return 0;
}
cout<<-1;
return 0;
}
Compilation message
drvca.cpp: In function 'int main()':
drvca.cpp:14:32: 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]
14 | #define fu(i,a,b) for(ll i=a;i<=b;i++)
......
116 | fu(luatbeo,0,a.size()-2) cout<<a[luatbeo]<<" ";
| ~~~~~~~~~~~~~~~~~~~~
drvca.cpp:116:13: note: in expansion of macro 'fu'
116 | fu(luatbeo,0,a.size()-2) cout<<a[luatbeo]<<" ";
| ^~
drvca.cpp:39:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | freopen(TASK".inp" ,"r",stdin) ; freopen(TASK".out" ,"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
drvca.cpp:39:49: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
39 | freopen(TASK".inp" ,"r",stdin) ; freopen(TASK".out" ,"w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
5584 KB |
Output is correct |
2 |
Correct |
20 ms |
3932 KB |
Output is correct |
3 |
Correct |
20 ms |
4300 KB |
Output is correct |
4 |
Correct |
20 ms |
5460 KB |
Output is correct |
5 |
Correct |
21 ms |
4044 KB |
Output is correct |
6 |
Correct |
24 ms |
3924 KB |
Output is correct |
7 |
Correct |
21 ms |
4044 KB |
Output is correct |
8 |
Correct |
20 ms |
5468 KB |
Output is correct |
9 |
Execution timed out |
1046 ms |
3032 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
344 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |