Submission #1085647

#TimeUsernameProblemLanguageResultExecution timeMemory
1085647serifefedartarDrvca (COCI19_drvca)C++17
0 / 110
19 ms2660 KiB
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
#define f first
#define s second
#define LOGN 21
const ll MOD = 1e9 + 7;
const ll MAXN = 2e5 + 100;
 
vector<int> h;
 
int main() {
    fast;
    int N;
    cin >> N;
 
    h = vector<int>(N+1, 0);
    for (int i = 1; i <= N; i++)
        cin >> h[i];
    sort(h.begin(), h.end());
 	
  	if (N == 2) {
      cout << "1\n";
      cout << h[1] << "\n";
      cout << "1\n";
      cout << h[2] << "\n";
      exit(0);
    }
  
    for (int i = 1; i <= 2; i++) {
        for (int j = i+1; j <= 3; j++) {
 
            vector<int> sequence, other_sequence;
            for (int k = 1; k <= 3; k++) {
                if (i != k && j != k)
                    other_sequence.push_back(h[k]);
            }
            sequence.push_back(h[i]);
            sequence.push_back(h[j]);
 
            for (int i = 4; i <= N; i++) {
                if (h[i] == sequence.back() * 2 - sequence.end()[-2])
                    sequence.push_back(h[i]);
                else
                    other_sequence.push_back(h[i]);
            }
 
            set<int> diff;
            for (int i = 1; i < other_sequence.size(); i++)
                diff.insert(other_sequence[i] - other_sequence[i-1]);
 
            if (diff.size() <= 1) {
                if (other_sequence.size() == 0) {
                    other_sequence.push_back(sequence.back());
                    sequence.pop_back();
                }
 
                cout << sequence.size() << "\n";
                for (auto u : sequence)
                    cout << u << " ";
                cout << "\n";
                cout << other_sequence.size() << "\n";
                for (auto u : other_sequence)
                    cout << u << " ";
                cout << "\n";
                exit(0);
            }
        }
    }
    cout << "-1\n";
}

Compilation message (stderr)

drvca.cpp: In function 'int main()':
drvca.cpp:51:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |             for (int i = 1; i < other_sequence.size(); i++)
      |                             ~~^~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...