Submission #1270213

#TimeUsernameProblemLanguageResultExecution timeMemory
1270213tvdanDrvca (COCI19_drvca)C++20
0 / 110
1093 ms2372 KiB
//ojou kawayo no.1 #include <bits/stdc++.h> using namespace std; #define tsk "drvca" #define pb push_back #define pf push_front //dm define endl #define fi first #define se second #define Ningen_sama signed #define tachi main() #define __builtin_popcount __builtin_popcountll #define el cout<<'\n' #define all(a) a.begin(),a.end() #define invAll(a) a.rbegin(),a.rend() #define sz(a) ((int)a.size()) #define BIT(x, k) (1ll&(x >> k)) #define len(s) (int)s.size() #define mem(a,x) memset(a,x,sizeof(a)) #define debug(x) cout << #x << " = " << x << '\n' #define execute cerr << "Time elapsed: " << (1.0 * clock() / CLOCKS_PER_SEC) << "s" #define FOR(i, l, r) for(int i = (l), _r = (r); i <= _r; ++i) #define FORD(i, l, r) for(int i = (l), _r = (r); i >= _r; --i) #define REP(i, n) for(int i = 0, _n = (n); i < _n; ++i) //#define int long long template<class T> bool maximize(T& u, T v){if(u >= v) return false;return u = v, true;} template<class T> bool minimize(T& u, T v){if(u <= v) return false;return u = v, true;} using pii = pair<int, int>; using ll = long long; using vi = vector<int>; using vpii = vector<pair<int, int>>; #define inf32 0x3f3f3f3f #define inf64 0x3f3f3f3f3f3f3f3f const int maxn = 1e6+5; const int N = 5e3 + 5; const int base = 31; const ll mod = 1e9 + 7; const ll need = 67108863; const int vc = 2e9 + 1; const ll INF18 = 4557430888798830399; const ll LOG = 20; const double eps = 1e-9; const int BLOCK = 447; const int dx[4] = {1, 0, -1, 0}; const int dy[4] = {0, -1, 0, 1}; mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count()); #define rand rd inline long long Rand(long long L, long long R) { if(L>R) return 0; return L + rd() % (R - L + 1); } inline ll add(ll x, ll y){x+=y;if(x>=mod) x-=mod;if(x<0) x+=mod;return x;} inline ll mult(ll x, ll y){return 1LL * x * y % mod;} int n; int a[maxn]; inline void init(){ } inline void input(){ cin >> n; FOR(i, 1, n){ cin >> a[i]; } } inline void solve(){ vector<int> v1, v2; sort(a + 1, a + 1 + n); int diff; bool check = true; FOR(i, 2, n){ v1.clear(); v2.clear(); v1.push_back(a[1]); v1.push_back(a[i]); check = true; diff = a[i] - a[1]; if(i != 2){ FOR(j, 2, i - 1){ v2.push_back(a[j]); if(sz(v2) > 2 && v2[sz(v2) - 1] - v2[sz(v2) - 2] != v2[sz(v2) - 2] - v2[sz(v2) - 3]){ check = false; break; } } } if(!check) continue; // debug(i); int posi = i, j = i + 1; while(j <= n){ if(a[j] - a[posi] != diff){ // debug(j); // debug(posi); // debug(a[j]); // debug(a[posi]); // debug(diff); // if(sz(v2)) cout << v2.back() << " "; // if(sz(v2) > 1) cout << v2[sz(v2) - 2]; el; v2.push_back(a[j]); if(sz(v2) > 2 && v2[sz(v2) - 1] - v2[sz(v2) - 2] != v2[sz(v2) - 2] - v2[sz(v2) - 3]){ check = false; break; } } else{ posi = j; v1.push_back(a[j]); } j++; // if(!check) break; } // cout << sz(v1); el; // for(int v : v1) cout << v << " "; el; // cout << sz(v2); el; // for(int v : v2) cout << v << " "; el; // cout << check; el; if(!check) continue; if(sz(v1) + sz(v2) == n){ if(sz(v2) == 0){ v2.push_back(v1.back()); v1.pop_back(); } cout << sz(v1); el; for(int v : v1) cout << v << " "; el; cout << sz(v2); el; for(int v : v2) cout << v << " "; el; return; } //el; } cout << -1; } Ningen_sama tachi{ //konnakiri~~ if(fopen(tsk".inp","r")){ freopen(tsk".inp","r",stdin); freopen(tsk".out","w",stdout); } ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int Yodayo = 1; //cin >> Yodayo; //init(); while(Yodayo--){ input(); solve(); } //execute; } //otsunakiri~~

Compilation message (stderr)

drvca.cpp: In function 'int main()':
drvca.cpp:149:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  149 |         freopen(tsk".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
drvca.cpp:150:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  150 |         freopen(tsk".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...