Submission #1097891

#TimeUsernameProblemLanguageResultExecution timeMemory
1097891khongphaifuDrvca (COCI19_drvca)C++14
0 / 110
1046 ms5584 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...